Class: PaylerAPI::Response
- Inherits:
-
Object
- Object
- PaylerAPI::Response
- Defined in:
- lib/payler_api/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #duplicate_order_id? ⇒ Boolean
- #error? ⇒ Boolean
- #error_code ⇒ Object
- #error_message ⇒ Object (also: #message)
-
#initialize(httparty_response) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean (also: #success?)
- #three_ds? ⇒ Boolean
- #three_ds_attributes ⇒ Object
Constructor Details
#initialize(httparty_response) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 |
# File 'lib/payler_api/response.rb', line 7 def initialize httparty_response @data = httparty_response.parsed_response #rescue #@data = { 'error' => { 'code' => 0, 'message' => 'unknown' } } end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/payler_api/response.rb', line 5 def data @data end |
Instance Method Details
#duplicate_order_id? ⇒ Boolean
40 41 42 |
# File 'lib/payler_api/response.rb', line 40 def duplicate_order_id? error? && error_code == 3 end |
#error? ⇒ Boolean
22 23 24 |
# File 'lib/payler_api/response.rb', line 22 def error? data.has_key? 'error' end |
#error_code ⇒ Object
36 37 38 |
# File 'lib/payler_api/response.rb', line 36 def error_code data['error']['code'] if error? end |
#error_message ⇒ Object Also known as: message
44 45 46 |
# File 'lib/payler_api/response.rb', line 44 def data['error']['message'] if error? end |
#ok? ⇒ Boolean Also known as: success?
13 14 15 |
# File 'lib/payler_api/response.rb', line 13 def ok? data['order_id'] && !error? end |
#three_ds? ⇒ Boolean
18 19 20 |
# File 'lib/payler_api/response.rb', line 18 def three_ds? data['auth_type'] == 1 end |
#three_ds_attributes ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/payler_api/response.rb', line 26 def three_ds_attributes if three_ds? { url: data['acs_url'], pa_req: data['pareq'], md: data['md'] } else nil end end |