Class: DevSuite::RequestBuilder::Builder::Http
- Defined in:
- lib/dev_suite/request_builder/builder/http.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#http_method ⇒ Object
readonly
Returns the value of attribute http_method.
Attributes inherited from Base
Instance Method Summary collapse
- #build_command ⇒ Object
-
#initialize(url:, http_method: "GET", headers: {}, body: nil, tool:) ⇒ Http
constructor
A new instance of Http.
Constructor Details
#initialize(url:, http_method: "GET", headers: {}, body: nil, tool:) ⇒ Http
Returns a new instance of Http.
9 10 11 12 13 |
# File 'lib/dev_suite/request_builder/builder/http.rb', line 9 def initialize(url:, http_method: "GET", headers: {}, body: nil, tool:) super(url: url, headers: headers, tool: tool) @http_method = http_method.upcase @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/dev_suite/request_builder/builder/http.rb', line 7 def body @body end |
#http_method ⇒ Object (readonly)
Returns the value of attribute http_method.
7 8 9 |
# File 'lib/dev_suite/request_builder/builder/http.rb', line 7 def http_method @http_method end |
Instance Method Details
#build_command ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/dev_suite/request_builder/builder/http.rb', line 15 def build_command case tool when :curl Tool::Curl.new.build_command(http_method: http_method, url: url, headers: headers, body: format_body(body)) else raise ArgumentError, "Unknown tool: #{tool}" end end |