Class: ReveAI::Response
- Inherits:
-
Object
- Object
- ReveAI::Response
- Defined in:
- lib/reve_ai/response.rb
Overview
Base response wrapper for API responses.
Provides access to HTTP status, headers, and parsed response body.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Hash
readonly
Parsed response body.
-
#headers ⇒ Hash
readonly
Response headers.
-
#status ⇒ Integer
readonly
HTTP status code.
Instance Method Summary collapse
-
#initialize(status:, headers:, body:) ⇒ Response
constructor
Creates a new response wrapper.
-
#request_id ⇒ String?
Returns the request ID for this response.
-
#success? ⇒ Boolean
Checks if the response indicates success (2xx status).
Constructor Details
#initialize(status:, headers:, body:) ⇒ Response
Creates a new response wrapper.
24 25 26 27 28 |
# File 'lib/reve_ai/response.rb', line 24 def initialize(status:, headers:, body:) @status = status @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Hash (readonly)
Returns Parsed response body.
17 18 19 |
# File 'lib/reve_ai/response.rb', line 17 def body @body end |
#headers ⇒ Hash (readonly)
Returns Response headers.
14 15 16 |
# File 'lib/reve_ai/response.rb', line 14 def headers @headers end |
#status ⇒ Integer (readonly)
Returns HTTP status code.
11 12 13 |
# File 'lib/reve_ai/response.rb', line 11 def status @status end |
Instance Method Details
#request_id ⇒ String?
Returns the request ID for this response.
Useful for debugging and support requests.
42 43 44 |
# File 'lib/reve_ai/response.rb', line 42 def request_id body[:request_id] || headers["x-reve-request-id"] end |
#success? ⇒ Boolean
Checks if the response indicates success (2xx status).
33 34 35 |
# File 'lib/reve_ai/response.rb', line 33 def success? status >= 200 && status < 300 end |