Class: RollbarApi::Request
- Inherits:
-
Object
- Object
- RollbarApi::Request
- Defined in:
- lib/rollbar-api/request.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(method:, path:, params:) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(method:, path:, params:) ⇒ Request
Returns a new instance of Request.
4 5 6 7 8 9 |
# File 'lib/rollbar-api/request.rb', line 4 def initialize(method:, path:, params:) @method = method path = "/#{path}" unless path.start_with?("/") @path = path @params = params end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/rollbar-api/request.rb', line 3 def method @method end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/rollbar-api/request.rb', line 3 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/rollbar-api/request.rb', line 3 def path @path end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rollbar-api/request.rb', line 11 def execute connection.send(method) do |request| if method == :get request.url("#{path}?#{params.to_param}") else request.url(path) request.body = body_to_json(params) if params.present? end request.headers.merge!({ "Accept" => "application/json", "Content-Type" => "application/json", }) request end end |