Class: ProcessOut::Response
- Inherits:
-
Object
- Object
- ProcessOut::Response
- Defined in:
- lib/processout/networking/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
-
#code ⇒ Object
Code returns the error code contained in the response, if any.
-
#initialize(resp) ⇒ Response
constructor
A new instance of Response.
-
#message ⇒ Object
Message returns the error message contained in the response, if any.
-
#success ⇒ Object
Success returns whether or not the response returned a successful message.
Constructor Details
#initialize(resp) ⇒ Response
Returns a new instance of Response.
14 15 16 17 18 19 |
# File 'lib/processout/networking/response.rb', line 14 def initialize(resp) @resp = resp @status = resp.code.to_i @body = JSON.parse(resp.body) self.check end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
12 13 14 |
# File 'lib/processout/networking/response.rb', line 12 def body @body end |
Instance Method Details
#code ⇒ Object
Code returns the error code contained in the response, if any
30 31 32 33 34 35 |
# File 'lib/processout/networking/response.rb', line 30 def code if @body.include? "error_type" return @body["error_type"] end "" end |
#message ⇒ Object
Message returns the error message contained in the response, if any
38 39 40 41 42 43 |
# File 'lib/processout/networking/response.rb', line 38 def if @body.include? "message" return @body["message"] end "" end |
#success ⇒ Object
Success returns whether or not the response returned a successful message
22 23 24 25 26 27 |
# File 'lib/processout/networking/response.rb', line 22 def success if @body.include? "success" return @body["success"] end false end |