Class: DashamailTransactional::Response
- Inherits:
-
Object
- Object
- DashamailTransactional::Response
- Defined in:
- lib/dashamail/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #data ⇒ Object
- #http_code ⇒ Object
-
#initialize(answer) ⇒ Response
constructor
A new instance of Response.
- #raw ⇒ Object
- #success? ⇒ Boolean
- #text ⇒ Object
- #transaction_id ⇒ Object
Constructor Details
#initialize(answer) ⇒ Response
Returns a new instance of Response.
5 6 7 8 |
# File 'lib/dashamail/response.rb', line 5 def initialize(answer) @answer = answer @body = JSON.parse(@answer.body)['response'] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
30 31 32 |
# File 'lib/dashamail/response.rb', line 30 def body @body end |
Instance Method Details
#data ⇒ Object
26 27 28 |
# File 'lib/dashamail/response.rb', line 26 def data @body['data'] end |
#http_code ⇒ Object
14 15 16 |
# File 'lib/dashamail/response.rb', line 14 def http_code @answer.code end |
#raw ⇒ Object
32 33 34 |
# File 'lib/dashamail/response.rb', line 32 def raw @answer end |
#success? ⇒ Boolean
10 11 12 |
# File 'lib/dashamail/response.rb', line 10 def success? @body.dig('msg', 'err_code').to_i.zero? end |
#text ⇒ Object
18 19 20 |
# File 'lib/dashamail/response.rb', line 18 def text @body.dig('msg', 'text') end |
#transaction_id ⇒ Object
22 23 24 |
# File 'lib/dashamail/response.rb', line 22 def transaction_id @body.dig('data', 'transaction_id') end |