Class: Barchart::Request
- Inherits:
-
Object
- Object
- Barchart::Request
- Defined in:
- lib/barchart/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(method:, path:, body: nil) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(method:, path:, body: nil) ⇒ Request
Returns a new instance of Request.
5 6 7 8 9 10 |
# File 'lib/barchart/request.rb', line 5 def initialize(method:, path:, body: nil) Barchart.configuration.validate! @method = method @path = path @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/barchart/request.rb', line 3 def body @body end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/barchart/request.rb', line 3 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/barchart/request.rb', line 3 def path @path end |
Instance Method Details
#execute ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/barchart/request.rb', line 19 def execute p url response = RestClient::Request.new({ url: url, method: method, headers: { 'Content-Type': 'application/json', 'Date': Time.now.utc.httpdate, }, payload: body_to_json, }).execute convert_hash_keys(JSON.parse(response)) end |