Class: Nasp::InstructionQuery
- Inherits:
-
Object
- Object
- Nasp::InstructionQuery
- Includes:
- HTTParty
- Defined in:
- lib/nasp/instruction_query.rb
Instance Attribute Summary collapse
-
#payment ⇒ Object
readonly
Returns the value of attribute payment.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #api_call ⇒ Object
- #buyer_email ⇒ Object
- #buyer_name ⇒ Object
- #date ⇒ Object
- #escrow_end_date ⇒ Object
- #fee_amount ⇒ Object
- #gross_amount ⇒ Object
- #id ⇒ Object
-
#initialize(token) ⇒ InstructionQuery
constructor
A new instance of InstructionQuery.
- #net_amount ⇒ Object
- #payment_flag ⇒ Object
- #payment_type ⇒ Object
- #result ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(token) ⇒ InstructionQuery
Returns a new instance of InstructionQuery.
9 10 11 12 13 14 15 |
# File 'lib/nasp/instruction_query.rb', line 9 def initialize(token) @token = token @auth = { username: Nasp.token, password: Nasp.key } end |
Instance Attribute Details
#payment ⇒ Object (readonly)
Returns the value of attribute payment.
6 7 8 |
# File 'lib/nasp/instruction_query.rb', line 6 def payment @payment end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/nasp/instruction_query.rb', line 6 def response @response end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/nasp/instruction_query.rb', line 6 def token @token end |
Instance Method Details
#api_call ⇒ Object
17 18 19 20 21 22 |
# File 'lib/nasp/instruction_query.rb', line 17 def api_call = {:basic_auth => @auth} url = "/ws/alpha/ConsultarInstrucao/#{@token}" @response = self.class.get(url, ) @payment = last_payment end |
#buyer_email ⇒ Object
32 33 34 |
# File 'lib/nasp/instruction_query.rb', line 32 def buyer_email result["Pagador"]["Email"] end |
#buyer_name ⇒ Object
28 29 30 |
# File 'lib/nasp/instruction_query.rb', line 28 def buyer_name result["Pagador"]["Nome"] end |
#date ⇒ Object
36 37 38 |
# File 'lib/nasp/instruction_query.rb', line 36 def date DateTime.parse(@payment["Data"]) end |
#escrow_end_date ⇒ Object
40 41 42 |
# File 'lib/nasp/instruction_query.rb', line 40 def escrow_end_date DateTime.parse(@payment["DataCredito"]) end |
#fee_amount ⇒ Object
48 49 50 |
# File 'lib/nasp/instruction_query.rb', line 48 def fee_amount @payment["TaxaMoIP"]["__content__"] end |
#gross_amount ⇒ Object
44 45 46 |
# File 'lib/nasp/instruction_query.rb', line 44 def gross_amount @payment["TotalPago"]["__content__"] end |
#id ⇒ Object
68 69 70 |
# File 'lib/nasp/instruction_query.rb', line 68 def id @payment["CodigoMoIP"] end |
#net_amount ⇒ Object
52 53 54 |
# File 'lib/nasp/instruction_query.rb', line 52 def net_amount @payment["ValorLiquido"]["__content__"] end |
#payment_flag ⇒ Object
60 61 62 |
# File 'lib/nasp/instruction_query.rb', line 60 def payment_flag @payment["InstituicaoPagamento"] end |
#payment_type ⇒ Object
56 57 58 |
# File 'lib/nasp/instruction_query.rb', line 56 def payment_type @payment["FormaPagamento"] end |
#result ⇒ Object
24 25 26 |
# File 'lib/nasp/instruction_query.rb', line 24 def result @response["ConsultarTokenResponse"]["RespostaConsultar"]["Autorizacao"] end |
#status ⇒ Object
64 65 66 |
# File 'lib/nasp/instruction_query.rb', line 64 def status @payment["Status"]["Tipo"] end |