Class: SlidePay::Response
- Inherits:
-
String
- Object
- String
- SlidePay::Response
- Defined in:
- lib/slidepay/response.rb
Instance Attribute Summary collapse
-
#custom ⇒ Object
Returns the value of attribute custom.
-
#data ⇒ Object
Returns the value of attribute data.
-
#data_md5 ⇒ Object
Returns the value of attribute data_md5.
-
#endpoint ⇒ Object
response metadata fields.
-
#id ⇒ Object
Returns the value of attribute id.
-
#method ⇒ Object
Returns the value of attribute method.
-
#milliseconds ⇒ Object
Returns the value of attribute milliseconds.
-
#obj ⇒ Object
Returns the value of attribute obj.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#success ⇒ Object
Returns the value of attribute success.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Instance Method Summary collapse
-
#error ⇒ Object
error fields.
- #error_code ⇒ Object
- #error_text ⇒ Object
-
#initialize(response_json = nil) ⇒ Response
constructor
A new instance of Response.
- #parse_object_from_json ⇒ Object
- #was_successful? ⇒ Boolean
Constructor Details
#initialize(response_json = nil) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 |
# File 'lib/slidepay/response.rb', line 7 def initialize(response_json=nil) if response_json replace response_json parse_object_from_json end end |
Instance Attribute Details
#custom ⇒ Object
Returns the value of attribute custom.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def custom @custom end |
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def data @data end |
#data_md5 ⇒ Object
Returns the value of attribute data_md5.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def data_md5 @data_md5 end |
#endpoint ⇒ Object
response metadata fields
35 36 37 |
# File 'lib/slidepay/response.rb', line 35 def endpoint @endpoint end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def id @id end |
#method ⇒ Object
Returns the value of attribute method.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def method @method end |
#milliseconds ⇒ Object
Returns the value of attribute milliseconds.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def milliseconds @milliseconds end |
#obj ⇒ Object
Returns the value of attribute obj.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def obj @obj end |
#operation ⇒ Object
Returns the value of attribute operation.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def operation @operation end |
#success ⇒ Object
Returns the value of attribute success.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def success @success end |
#timezone ⇒ Object
Returns the value of attribute timezone.
4 5 6 |
# File 'lib/slidepay/response.rb', line 4 def timezone @timezone end |
Instance Method Details
#error ⇒ Object
error fields
40 41 42 43 44 45 46 |
# File 'lib/slidepay/response.rb', line 40 def error if was_successful? == false @data else nil end end |
#error_code ⇒ Object
48 49 50 51 52 |
# File 'lib/slidepay/response.rb', line 48 def error_code if error @data['error_code'] end end |
#error_text ⇒ Object
54 55 56 57 58 |
# File 'lib/slidepay/response.rb', line 54 def error_text if error @data['error_text'] end end |
#parse_object_from_json ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/slidepay/response.rb', line 14 def parse_object_from_json object = MultiJson.decode(self) @success = object['success'] @custom = object['custom'] @operation = object['operation'] @endpoint = object['endpoint'] @timezone = object['timezone'] @method = object['method'] @obj = object['obj'] @id = object['id'] @milliseconds = object['milliseconds'] @data = object['data'] @data_md5 = object['data_md5'] end |
#was_successful? ⇒ Boolean
30 31 32 |
# File 'lib/slidepay/response.rb', line 30 def was_successful? @success == true end |