Class: FriendlyShipping::Response
- Inherits:
-
Object
- Object
- FriendlyShipping::Response
- Defined in:
- lib/friendly_shipping/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
(also: #code)
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ 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.
10 11 12 13 14 |
# File 'lib/friendly_shipping/response.rb', line 10 def initialize(status:, body:, headers:) @status = status @body = body @headers = headers || {} end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/friendly_shipping/response.rb', line 5 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/friendly_shipping/response.rb', line 5 def headers @headers end |
#status ⇒ Object (readonly) Also known as: code
Returns the value of attribute status.
5 6 7 |
# File 'lib/friendly_shipping/response.rb', line 5 def status @status end |
Class Method Details
.new_from_rest_client_response(response) ⇒ FriendlyShipping::Response
20 21 22 |
# File 'lib/friendly_shipping/response.rb', line 20 def self.new_from_rest_client_response(response) new(status: response&.code, body: response&.body, headers: response&.headers) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
25 26 27 28 |
# File 'lib/friendly_shipping/response.rb', line 25 def ==(other) other.class == self.class && other.attributes == attributes end |
#hash ⇒ Object
32 33 34 |
# File 'lib/friendly_shipping/response.rb', line 32 def hash attributes.hash end |