Class: CloudPayments::Client::Response
- Inherits:
-
Object
- Object
- CloudPayments::Client::Response
- Defined in:
- lib/cloud_payments/client/response.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#origin_body ⇒ Object
readonly
Returns the value of attribute origin_body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(status, body, headers = {}) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(status, body, headers = {}) ⇒ Response
Returns a new instance of Response.
7 8 9 10 |
# File 'lib/cloud_payments/client/response.rb', line 7 def initialize(status, body, headers = {}) @status, @origin_body, @headers = status, body, headers @origin_body = body.dup.force_encoding('UTF-8') if body.respond_to?(:force_encoding) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/cloud_payments/client/response.rb', line 5 def headers @headers end |
#origin_body ⇒ Object (readonly)
Returns the value of attribute origin_body.
5 6 7 |
# File 'lib/cloud_payments/client/response.rb', line 5 def origin_body @origin_body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/cloud_payments/client/response.rb', line 5 def status @status end |
Instance Method Details
#body ⇒ Object
12 13 14 |
# File 'lib/cloud_payments/client/response.rb', line 12 def body @body ||= headers && headers['content-type'] =~ /json/ ? serializer.load(origin_body) : origin_body end |