Class: Zapi::ZapiResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response:) ⇒ ZapiResponse

Returns a new instance of ZapiResponse.



5
6
7
# File 'lib/zapi_response.rb', line 5

def initialize raw_response:
  @raw_response = raw_response
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



3
4
5
# File 'lib/zapi_response.rb', line 3

def raw_response
  @raw_response
end

Instance Method Details

#_responseObject



29
30
31
# File 'lib/zapi_response.rb', line 29

def _response
  raw_hash.try(:[], 'response')
end

#api_versionObject



17
18
19
# File 'lib/zapi_response.rb', line 17

def api_version
  _response.try(:[],'zapiVersion')
end

#dataObject



25
26
27
# File 'lib/zapi_response.rb', line 25

def data
   _response.try(:[],'methodResponse')
end

#method_nameObject



21
22
23
# File 'lib/zapi_response.rb', line 21

def method_name
  data.try(:[],'methodName')
end

#raw_hashObject



13
14
15
# File 'lib/zapi_response.rb', line 13

def raw_hash
  Hash.from_xml(raw_xml).with_indifferent_access
end

#raw_xmlObject



9
10
11
# File 'lib/zapi_response.rb', line 9

def raw_xml
  raw_response.body
end