Class: ApiEntreprise::Commons::Response
- Inherits:
-
Object
- Object
- ApiEntreprise::Commons::Response
- Defined in:
- lib/api_entreprise/commons/response.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#rate_limit ⇒ Object
readonly
Returns the value of attribute rate_limit.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(raw:, http_status:, headers:, rate_limit: nil) ⇒ Response
constructor
A new instance of Response.
- #links ⇒ Object
- #meta ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(raw:, http_status:, headers:, rate_limit: nil) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 14 |
# File 'lib/api_entreprise/commons/response.rb', line 9 def initialize(raw:, http_status:, headers:, rate_limit: nil) @raw = raw.is_a?(Hash) ? raw : {} @http_status = http_status @headers = headers || {} @rate_limit = rate_limit end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/api_entreprise/commons/response.rb', line 7 def headers @headers end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
7 8 9 |
# File 'lib/api_entreprise/commons/response.rb', line 7 def http_status @http_status end |
#rate_limit ⇒ Object (readonly)
Returns the value of attribute rate_limit.
7 8 9 |
# File 'lib/api_entreprise/commons/response.rb', line 7 def rate_limit @rate_limit end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
7 8 9 |
# File 'lib/api_entreprise/commons/response.rb', line 7 def raw @raw end |
Instance Method Details
#data ⇒ Object
16 17 18 |
# File 'lib/api_entreprise/commons/response.rb', line 16 def data raw['data'] end |
#links ⇒ Object
20 21 22 |
# File 'lib/api_entreprise/commons/response.rb', line 20 def links raw['links'] || {} end |
#meta ⇒ Object
24 25 26 |
# File 'lib/api_entreprise/commons/response.rb', line 24 def raw['meta'] || {} end |
#success? ⇒ Boolean
28 29 30 |
# File 'lib/api_entreprise/commons/response.rb', line 28 def success? http_status.to_i.between?(200, 299) end |