Class: Plz::Commands::Request
- Inherits:
-
Object
- Object
- Plz::Commands::Request
- Defined in:
- lib/plz/commands/request.rb
Instance Method Summary collapse
-
#call ⇒ Object
Sends an HTTP request and logs out the response.
-
#initialize(headers: nil, params: nil, method: nil, base_url: nil, path: nil, options: nil) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(headers: nil, params: nil, method: nil, base_url: nil, path: nil, options: nil) ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 15 16 17 |
# File 'lib/plz/commands/request.rb', line 10 def initialize(headers: nil, params: nil, method: nil, base_url: nil, path: nil, options: nil) @headers = headers @params = params @method = method @base_url = base_url @path = path @options = end |
Instance Method Details
#call ⇒ Object
Sends an HTTP request and logs out the response
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/plz/commands/request.rb', line 20 def call response = client.send(@method.downcase, @path, @params, @headers) print ResponseRenderer.call( status: response.status, headers: response.headers, body: response.body, response_header: flag_to_show_response_header, response_body: flag_to_show_response_body, color: flag_to_color_response, ) rescue Faraday::ConnectionFailed => exception puts exception end |