Class: DashamailTransactional::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/dashamail/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



30
31
32
# File 'lib/dashamail/response.rb', line 30

def body
  @body
end

Instance Method Details

#dataObject



26
27
28
# File 'lib/dashamail/response.rb', line 26

def data
  @body['data']
end

#http_codeObject



14
15
16
# File 'lib/dashamail/response.rb', line 14

def http_code
  @answer.code
end

#rawObject



32
33
34
# File 'lib/dashamail/response.rb', line 32

def raw
  @answer
end

#success?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/dashamail/response.rb', line 10

def success?
  @body.dig('msg', 'err_code').to_i.zero?
end

#textObject



18
19
20
# File 'lib/dashamail/response.rb', line 18

def text
  @body.dig('msg', 'text')
end

#transaction_idObject



22
23
24
# File 'lib/dashamail/response.rb', line 22

def transaction_id
  @body.dig('data', 'transaction_id')
end