Class: Inttegro::TransportResponse
- Inherits:
-
Object
- Object
- Inttegro::TransportResponse
- Extended by:
- T::Sig
- Defined in:
- lib/inttegro/transport_response.rb
Overview
Normalizes Net::HTTP and custom adapter responses at the SDK boundary. Adapter objects are deliberately accepted as Object and validated here so unknown values cannot flow unchecked through the rest of the SDK.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(response) ⇒ TransportResponse
constructor
A new instance of TransportResponse.
Constructor Details
#initialize(response) ⇒ TransportResponse
Returns a new instance of TransportResponse.
22 23 24 25 26 27 |
# File 'lib/inttegro/transport_response.rb', line 22 def initialize(response) @code = T.let(read_string(response, :code), String) @body = T.let(read_string(response, :body), String) @message = T.let(read_string(response, :message), String) @headers = T.let(normalize_headers(read_headers(response)), Types::ResponseHeaders) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
16 17 18 |
# File 'lib/inttegro/transport_response.rb', line 16 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
16 17 18 |
# File 'lib/inttegro/transport_response.rb', line 16 def code @code end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
19 20 21 |
# File 'lib/inttegro/transport_response.rb', line 19 def headers @headers end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
16 17 18 |
# File 'lib/inttegro/transport_response.rb', line 16 def @message end |
Instance Method Details
#[](name) ⇒ Object
30 31 32 33 |
# File 'lib/inttegro/transport_response.rb', line 30 def [](name) pair = @headers.find { |key, _values| key.casecmp?(name) } pair&.last&.first end |