Class: Dolibarr::Api::Response

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/dolibarr-api/response.rb', line 9

def data
  @data
end

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/dolibarr-api/response.rb', line 9

def headers
  @headers
end

#statusObject (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

#deconstructObject



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_hObject



19
20
21
# File 'lib/dolibarr-api/response.rb', line 19

def to_h
  data.respond_to?(:to_hash) ? data.to_hash : data
end