Class: ConvertSdk::HttpClient::Response
- Inherits:
-
Struct
- Object
- Struct
- ConvertSdk::HttpClient::Response
- Defined in:
- lib/convert_sdk/http_client.rb
Overview
An immutable result of a single HTTP request.
status is the HTTP status integer (or FAILURE_STATUS on a transport
failure); body is the parsed JSON object (or nil); headers is the
response header hash; #success? is a strict 2xx predicate.
Declared as an explicit class < Struct.new(...) subclass (NOT the
Struct.new do...end block form): this is the only shape Steep can
statically resolve #success? and the keyword constructor against, the
same reason the frozen value objects (BucketedVariation/BucketedFeature)
use it.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize ⇒ void
constructor
Builds the struct then freezes it (immutable value object).
-
#success? ⇒ Boolean
True iff
statusis in the 2xx range.
Constructor Details
#initialize ⇒ void
Returns builds the struct then freezes it (immutable value object).
71 72 73 74 |
# File 'lib/convert_sdk/http_client.rb', line 71 def initialize(**) super freeze end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
69 70 71 |
# File 'lib/convert_sdk/http_client.rb', line 69 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
69 70 71 |
# File 'lib/convert_sdk/http_client.rb', line 69 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status
69 70 71 |
# File 'lib/convert_sdk/http_client.rb', line 69 def status @status end |
Instance Method Details
#success? ⇒ Boolean
Returns true iff status is in the 2xx range.
77 78 79 |
# File 'lib/convert_sdk/http_client.rb', line 77 def success? status.between?(200, 299) end |