Class: Nasp::InstructionQuery

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/nasp/instruction_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#paymentObject (readonly)

Returns the value of attribute payment.



6
7
8
# File 'lib/nasp/instruction_query.rb', line 6

def payment
  @payment
end

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/nasp/instruction_query.rb', line 6

def response
  @response
end

#tokenObject (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_callObject



17
18
19
20
21
22
# 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_emailObject



32
33
34
# File 'lib/nasp/instruction_query.rb', line 32

def buyer_email
  result["Pagador"]["Email"]
end

#buyer_nameObject



28
29
30
# File 'lib/nasp/instruction_query.rb', line 28

def buyer_name
  result["Pagador"]["Nome"]
end

#dateObject



36
37
38
# File 'lib/nasp/instruction_query.rb', line 36

def date
  DateTime.parse(@payment["Data"])
end

#escrow_end_dateObject



40
41
42
# File 'lib/nasp/instruction_query.rb', line 40

def escrow_end_date
  DateTime.parse(@payment["DataCredito"])
end

#fee_amountObject



48
49
50
# File 'lib/nasp/instruction_query.rb', line 48

def fee_amount
  @payment["TaxaMoIP"]["__content__"]
end

#gross_amountObject



44
45
46
# File 'lib/nasp/instruction_query.rb', line 44

def gross_amount
  @payment["TotalPago"]["__content__"]
end

#idObject



68
69
70
# File 'lib/nasp/instruction_query.rb', line 68

def id
  @payment["CodigoMoIP"]
end

#net_amountObject



52
53
54
# File 'lib/nasp/instruction_query.rb', line 52

def net_amount
  @payment["ValorLiquido"]["__content__"]
end

#payment_flagObject



60
61
62
# File 'lib/nasp/instruction_query.rb', line 60

def payment_flag
  @payment["InstituicaoPagamento"]
end

#payment_typeObject



56
57
58
# File 'lib/nasp/instruction_query.rb', line 56

def payment_type
  @payment["FormaPagamento"]
end

#resultObject



24
25
26
# File 'lib/nasp/instruction_query.rb', line 24

def result
  @response["ConsultarTokenResponse"]["RespostaConsultar"]["Autorizacao"]
end

#statusObject



64
65
66
# File 'lib/nasp/instruction_query.rb', line 64

def status
  @payment["Status"]["Tipo"]
end