Class: Proxima::Request
- Inherits:
-
Object
- Object
- Proxima::Request
- Defined in:
- lib/proxima/request.rb
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.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(api, method, path, opts = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(api, method, path, opts = {}) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/proxima/request.rb', line 11 def initialize(api, method, path, opts = {}) @api = api @method = method.to_s.upcase headers = opts[:headers] || {} @body = if opts[:json] headers[:content_type] = 'application/json' opts[:json].to_json elsif opts[:body] opts[:body] end headers = @api.headers.merge headers @headers = headers.map{ |name, val| [to_header(name), val.to_s] }.to_h query_str = opts[:query] ? "?#{opts[:query].to_query}" : '' @uri = URI.join(@api.base_uri, path, query_str) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/proxima/request.rb', line 9 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/proxima/request.rb', line 8 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
6 7 8 |
# File 'lib/proxima/request.rb', line 6 def method @method end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/proxima/request.rb', line 5 def response @response end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
7 8 9 |
# File 'lib/proxima/request.rb', line 7 def uri @uri end |