Class: CommandTower::Clients::Transport::Request
- Inherits:
-
Data
- Object
- Data
- CommandTower::Clients::Transport::Request
- Defined in:
- app/services/command_tower/clients/transport/request.rb
Constant Summary collapse
- SUPPORTED_METHODS =
%i[get post put patch delete].freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
- .build(method:, url:, headers: {}, body: nil, query: {}, timeout: nil) ⇒ Object
- .validate_method!(method) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body
6 7 8 |
# File 'app/services/command_tower/clients/transport/request.rb', line 6 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers
6 7 8 |
# File 'app/services/command_tower/clients/transport/request.rb', line 6 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method
6 7 8 |
# File 'app/services/command_tower/clients/transport/request.rb', line 6 def method @method end |
#query ⇒ Object (readonly)
Returns the value of attribute query
6 7 8 |
# File 'app/services/command_tower/clients/transport/request.rb', line 6 def query @query end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout
6 7 8 |
# File 'app/services/command_tower/clients/transport/request.rb', line 6 def timeout @timeout end |
#url ⇒ Object (readonly)
Returns the value of attribute url
6 7 8 |
# File 'app/services/command_tower/clients/transport/request.rb', line 6 def url @url end |
Class Method Details
.build(method:, url:, headers: {}, body: nil, query: {}, timeout: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/services/command_tower/clients/transport/request.rb', line 9 def self.build(method:, url:, headers: {}, body: nil, query: {}, timeout: nil) new( method: normalize_and_validate_method(method), url: url.to_s, headers: normalize_headers(headers), body: body, query: normalize_query(query), timeout: timeout ) end |
.validate_method!(method) ⇒ Object
20 21 22 |
# File 'app/services/command_tower/clients/transport/request.rb', line 20 def self.validate_method!(method) normalize_and_validate_method(method) end |
Instance Method Details
#merge_headers(extra) ⇒ Object
44 45 46 |
# File 'app/services/command_tower/clients/transport/request.rb', line 44 def merge_headers(extra) with(headers: headers.merge(self.class.send(:normalize_headers, extra))) end |