Class: CoreLibrary::ApiResponse
- Inherits:
-
Object
- Object
- CoreLibrary::ApiResponse
- Defined in:
- lib/apimatic-core/http/response/api_response.rb
Overview
The class to hold the complete HTTP response.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#raw_body ⇒ Object
readonly
Returns the value of attribute raw_body.
-
#reason_phrase ⇒ Object
readonly
Returns the value of attribute reason_phrase.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Returns true if status_code is between 400-600.
-
#initialize(http_response, data: nil, errors: nil) ⇒ ApiResponse
constructor
The constructor.
-
#success? ⇒ Boolean
Returns true if status_code is between 200-300.
Constructor Details
#initialize(http_response, data: nil, errors: nil) ⇒ ApiResponse
The constructor
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 13 def initialize(http_response, data: nil, errors: nil) @status_code = http_response.status_code @reason_phrase = http_response.reason_phrase @headers = http_response.headers @raw_body = http_response.raw_body @request = http_response.request @data = data @errors = errors end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 5 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 5 def errors @errors end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 5 def headers @headers end |
#raw_body ⇒ Object (readonly)
Returns the value of attribute raw_body.
5 6 7 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 5 def raw_body @raw_body end |
#reason_phrase ⇒ Object (readonly)
Returns the value of attribute reason_phrase.
5 6 7 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 5 def reason_phrase @reason_phrase end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
5 6 7 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 5 def request @request end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
5 6 7 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 5 def status_code @status_code end |
Instance Method Details
#error? ⇒ Boolean
Returns true if status_code is between 400-600
31 32 33 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 31 def error? status_code >= 400 && status_code < 600 end |
#success? ⇒ Boolean
Returns true if status_code is between 200-300
26 27 28 |
# File 'lib/apimatic-core/http/response/api_response.rb', line 26 def success? status_code >= 200 && status_code < 300 end |