class Nasp::InstructionQuery
Attributes
payment[R]
response[R]
token[R]
Public Class Methods
new(token)
click to toggle source
# File lib/nasp/instruction_query.rb, line 9 def initialize(token) @token = token @auth = { username: Nasp.token, password: Nasp.key } end
Public Instance Methods
api_call()
click to toggle source
# File lib/nasp/instruction_query.rb, line 17 def api_call options = {:basic_auth => @auth} url = "/ws/alpha/ConsultarInstrucao/#{@token}" @response = self.class.get(url, options) @payment = last_payment end
buyer_email()
click to toggle source
# File lib/nasp/instruction_query.rb, line 32 def buyer_email result["Pagador"]["Email"] end
buyer_name()
click to toggle source
# File lib/nasp/instruction_query.rb, line 28 def buyer_name result["Pagador"]["Nome"] end
date()
click to toggle source
# File lib/nasp/instruction_query.rb, line 36 def date DateTime.parse(@payment["Data"]) end
escrow_end_date()
click to toggle source
# File lib/nasp/instruction_query.rb, line 40 def escrow_end_date DateTime.parse(@payment["DataCredito"]) end
fee_amount()
click to toggle source
# File lib/nasp/instruction_query.rb, line 48 def fee_amount @payment["TaxaMoIP"]["__content__"] end
gross_amount()
click to toggle source
# File lib/nasp/instruction_query.rb, line 44 def gross_amount @payment["TotalPago"]["__content__"] end
id()
click to toggle source
# File lib/nasp/instruction_query.rb, line 68 def id @payment["CodigoMoIP"] end
net_amount()
click to toggle source
# File lib/nasp/instruction_query.rb, line 52 def net_amount @payment["ValorLiquido"]["__content__"] end
payment_flag()
click to toggle source
# File lib/nasp/instruction_query.rb, line 60 def payment_flag @payment["InstituicaoPagamento"] end
payment_type()
click to toggle source
# File lib/nasp/instruction_query.rb, line 56 def payment_type @payment["FormaPagamento"] end
result()
click to toggle source
# File lib/nasp/instruction_query.rb, line 24 def result @response["ConsultarTokenResponse"]["RespostaConsultar"]["Autorizacao"] end
status()
click to toggle source
# File lib/nasp/instruction_query.rb, line 64 def status @payment["Status"]["Tipo"] end
Private Instance Methods
last_payment()
click to toggle source
# File lib/nasp/instruction_query.rb, line 73 def last_payment payment = result["Pagamento"] if payment.kind_of?(Hash) @payment = payment else @payment = payment.first payment.each do |r| payment_date = DateTime.parse(r["Data"]) @payment = r if payment_date > self.date end end @payment end