Class: Trustly::Data::JSONRPCResponse
- Inherits:
-
Response
- Object
- Trustly::Data
- Response
- Trustly::Data::JSONRPCResponse
- Defined in:
- lib/trustly/data/jsonrpc_response.rb
Instance Attribute Summary
Attributes inherited from Response
#response_body, #response_reason, #response_result, #response_status
Attributes inherited from Trustly::Data
Instance Method Summary collapse
- #get_data(name = nil) ⇒ Object
-
#initialize(http_response) ⇒ JSONRPCResponse
constructor
A new instance of JSONRPCResponse.
Methods inherited from Response
#error?, #error_code, #error_msg, #get_method, #get_result, #get_signature, #get_uuid, #success?
Methods inherited from Trustly::Data
#get, #get_from, #json, #pop, #set, #set_in, #vacumm
Constructor Details
#initialize(http_response) ⇒ JSONRPCResponse
Returns a new instance of JSONRPCResponse.
3 4 5 6 7 |
# File 'lib/trustly/data/jsonrpc_response.rb', line 3 def initialize(http_response) super(http_response) version = self.get("version") raise Trustly::Exception::JSONRPCVersionError, "JSON RPC Version is not supported" if version != '1.1' end |
Instance Method Details
#get_data(name = nil) ⇒ Object
9 10 11 12 13 |
# File 'lib/trustly/data/jsonrpc_response.rb', line 9 def get_data(name=nil) return self.response_result.try(:[],"data") if name.nil? return Trustly::Exception::DataError, "Data not found or key is null" if self.response_result.try(:[],"data").nil? || name.nil? return self.response_result["data"][name] end |