Class: Cloudquery::Request
- Inherits:
-
Object
- Object
- Cloudquery::Request
- Defined in:
- lib/cloudquery.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#host ⇒ Object
Returns the value of attribute host.
-
#method ⇒ Object
Returns the value of attribute method.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #request_uri(account = @account, secret = @secret) ⇒ Object
- #url(account = @account, secret = @secret) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cloudquery.rb', line 35 def initialize(={}) @method = [:method] || 'POST' @headers = [:headers] || {} @scheme = [:scheme] || SCHEME @host = [:host] || HOST @port = [:port] || (@scheme == 'https' ? URI::HTTPS::DEFAULT_PORT : URI::HTTP::DEFAULT_PORT) @path = [:path] || PATH @params = [:params] || {} if ['PUT', 'DELETE'].include?(@method) @params['_method'] = @method @method = 'POST' end @body = [:body] @account = [:account] @secret = [:secret] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
33 34 35 |
# File 'lib/cloudquery.rb', line 33 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
33 34 35 |
# File 'lib/cloudquery.rb', line 33 def headers @headers end |
#host ⇒ Object
Returns the value of attribute host.
33 34 35 |
# File 'lib/cloudquery.rb', line 33 def host @host end |
#method ⇒ Object
Returns the value of attribute method.
33 34 35 |
# File 'lib/cloudquery.rb', line 33 def method @method end |
#params ⇒ Object
Returns the value of attribute params.
33 34 35 |
# File 'lib/cloudquery.rb', line 33 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
33 34 35 |
# File 'lib/cloudquery.rb', line 33 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
33 34 35 |
# File 'lib/cloudquery.rb', line 33 def port @port end |
#scheme ⇒ Object
Returns the value of attribute scheme.
33 34 35 |
# File 'lib/cloudquery.rb', line 33 def scheme @scheme end |
Instance Method Details
#request_uri(account = @account, secret = @secret) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cloudquery.rb', line 53 def request_uri(account=@account, secret=@secret) query = query_str(signature_params(account)) uri = if query.empty? @path.dup else "#{@path}?#{query}" end uri = append_signature(uri, secret) if secret uri end |
#url(account = @account, secret = @secret) ⇒ Object
64 65 66 |
# File 'lib/cloudquery.rb', line 64 def url(account=@account, secret=@secret) base_uri.merge(request_uri(account, secret)).to_s end |