Class: HttpClientGenerator::Request
- Inherits:
-
Object
- Object
- HttpClientGenerator::Request
- Defined in:
- lib/http_client_generator/request.rb
Constant Summary collapse
- CONTENT_TYPES =
%i[json text].freeze
- DEFAULT_HEADERS_BY_CONTENT_TYPE =
{ json: { accept: 'application/json', content_type: 'application/json' }, text: { content_type: 'text/plain' }, }.freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
-
#response_body ⇒ Object
Returns the value of attribute response_body.
-
#url ⇒ Object
Returns the value of attribute url.
-
#verb ⇒ Object
Returns the value of attribute verb.
Instance Method Summary collapse
- #current_headers ⇒ Object
-
#initialize(verb:, content_type:, url:, body:, rest_args:) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(verb:, content_type:, url:, body:, rest_args:) ⇒ Request
Returns a new instance of Request.
20 21 22 23 24 25 26 27 |
# File 'lib/http_client_generator/request.rb', line 20 def initialize(verb:, content_type:, url:, body:, rest_args:) @verb = verb @content_type = content_type @url = url @rest_args = rest_args @body = body @headers = {} end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
18 19 20 |
# File 'lib/http_client_generator/request.rb', line 18 def body @body end |
#content_type ⇒ Object
Returns the value of attribute content_type.
18 19 20 |
# File 'lib/http_client_generator/request.rb', line 18 def content_type @content_type end |
#headers ⇒ Object
Returns the value of attribute headers.
18 19 20 |
# File 'lib/http_client_generator/request.rb', line 18 def headers @headers end |
#request_id ⇒ Object
Returns the value of attribute request_id.
18 19 20 |
# File 'lib/http_client_generator/request.rb', line 18 def request_id @request_id end |
#response_body ⇒ Object
Returns the value of attribute response_body.
18 19 20 |
# File 'lib/http_client_generator/request.rb', line 18 def response_body @response_body end |
#url ⇒ Object
Returns the value of attribute url.
18 19 20 |
# File 'lib/http_client_generator/request.rb', line 18 def url @url end |
#verb ⇒ Object
Returns the value of attribute verb.
18 19 20 |
# File 'lib/http_client_generator/request.rb', line 18 def verb @verb end |
Instance Method Details
#current_headers ⇒ Object
29 30 31 |
# File 'lib/http_client_generator/request.rb', line 29 def current_headers default_headers.merge(headers) end |