Class: ZeroClick::Sellers::Response
- Inherits:
-
Object
- Object
- ZeroClick::Sellers::Response
- Defined in:
- lib/zeroclick/sellers/contracts.rb
Overview
A framework-neutral response the caller is expected to return as-is.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status:, body:, headers: {}) ⇒ Response
constructor
A new instance of Response.
- #json_body ⇒ Object
Constructor Details
#initialize(status:, body:, headers: {}) ⇒ Response
Returns a new instance of Response.
64 65 66 67 68 69 |
# File 'lib/zeroclick/sellers/contracts.rb', line 64 def initialize(status:, body:, headers: {}) @status = status @body = body @headers = headers.freeze freeze end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
62 63 64 |
# File 'lib/zeroclick/sellers/contracts.rb', line 62 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
62 63 64 |
# File 'lib/zeroclick/sellers/contracts.rb', line 62 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
62 63 64 |
# File 'lib/zeroclick/sellers/contracts.rb', line 62 def status @status end |
Class Method Details
.json(payload, status: 200, headers: {}) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/zeroclick/sellers/contracts.rb', line 71 def self.json(payload, status: 200, headers: {}) new( status: status, # Compact separators, matching the other SDKs byte for byte. body: JSON.generate(payload), headers: { "content-type" => "application/json" }.merge(headers) ) end |
Instance Method Details
#json_body ⇒ Object
80 81 82 |
# File 'lib/zeroclick/sellers/contracts.rb', line 80 def json_body JSON.parse(@body) end |