Class: Boletoman::Services::Itau::Boleto::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/boletoman/services/itau/boleto/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Response

Returns a new instance of Response.



8
9
10
11
# File 'lib/boletoman/services/itau/boleto/response.rb', line 8

def initialize(raw)
  @status = raw.status
  @body = JSON.parse(raw.body)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/boletoman/services/itau/boleto/response.rb', line 6

def body
  @body
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/boletoman/services/itau/boleto/response.rb', line 6

def status
  @status
end

Instance Method Details

#barcodeObject



17
18
19
# File 'lib/boletoman/services/itau/boleto/response.rb', line 17

def barcode
  body['codigo_barras']
end

#error?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/boletoman/services/itau/boleto/response.rb', line 13

def error?
  status >= 400
end

#lineObject



21
22
23
# File 'lib/boletoman/services/itau/boleto/response.rb', line 21

def line
  body['numero_linha_digitavel']
end

#nosso_numeroObject



25
26
27
# File 'lib/boletoman/services/itau/boleto/response.rb', line 25

def nosso_numero
  body['nosso_numero'][0..-2] # remove the verificator digit
end