Class: Dolibarr::Api::Response
- Inherits:
-
Object
- Object
- Dolibarr::Api::Response
- Extended by:
- Forwardable
- Defined in:
- lib/dolibarr-api/response.rb
Overview
Result of an operation. Delegates to data for ergonomic access while keeping
status/headers available. Replaces the _with_http_info twin methods.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #deconstruct ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
-
#initialize(data:, status:, headers:) ⇒ Response
constructor
A new instance of Response.
- #to_h ⇒ Object
Constructor Details
#initialize(data:, status:, headers:) ⇒ Response
Returns a new instance of Response.
11 12 13 14 15 |
# File 'lib/dolibarr-api/response.rb', line 11 def initialize(data:, status:, headers:) @data = data @status = status @headers = headers end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/dolibarr-api/response.rb', line 9 def data @data end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/dolibarr-api/response.rb', line 9 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/dolibarr-api/response.rb', line 9 def status @status end |
Instance Method Details
#deconstruct ⇒ Object
27 28 29 |
# File 'lib/dolibarr-api/response.rb', line 27 def deconstruct [data, status, headers] end |
#deconstruct_keys(_keys) ⇒ Object
23 24 25 |
# File 'lib/dolibarr-api/response.rb', line 23 def deconstruct_keys(_keys) { data: data, status: status, headers: headers } end |
#to_h ⇒ Object
19 20 21 |
# File 'lib/dolibarr-api/response.rb', line 19 def to_h data.respond_to?(:to_hash) ? data.to_hash : data end |