Class: AceClient::Query3
Instance Attribute Summary collapse
-
#http_method ⇒ Object
Returns the value of attribute http_method.
Attributes inherited from Base3
Attributes inherited from Base
#access_key_id, #endpoint, #http_proxy, #last_response, #last_response_time, #secret_access_key, #use_ssl, #user_agent
Instance Method Summary collapse
- #action(action, params = {}) ⇒ Object
- #dryrun(action, params = {}) ⇒ Object
- #execute(params = {}, dryrun = false) ⇒ Object
Methods inherited from Base3
#create_signature, #date, #initialize, #string_to_sign
Methods inherited from Base
#endpoint_url, #initialize, #record_response, #set_http_proxy
Constructor Details
This class inherits a constructor from AceClient::Base3
Instance Attribute Details
#http_method ⇒ Object
Returns the value of attribute http_method.
8 9 10 |
# File 'lib/ace-client/query3.rb', line 8 def http_method @http_method end |
Instance Method Details
#action(action, params = {}) ⇒ Object
12 13 14 15 |
# File 'lib/ace-client/query3.rb', line 12 def action(action, params={}) params.update('Action' => action) execute(params) end |
#dryrun(action, params = {}) ⇒ Object
17 18 19 20 |
# File 'lib/ace-client/query3.rb', line 17 def dryrun(action, params={}) params.update('Action' => action) execute(params, true) end |
#execute(params = {}, dryrun = false) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ace-client/query3.rb', line 22 def execute(params={}, dryrun=false) @params = params @params['Version'] = @version if @version @before_signature.call(@params) if @before_signature signature = create_signature = self.class..dup [:headers] = {} [:headers]['Date'] = date [:headers][@authorization_key] = "#{@authorization_prefix} #{@access_key_id_key}=#{access_key_id},Algorithm=#{signature_method},Signature=#{signature}" [:headers]['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8' [:headers]['User-Agent'] = @user_agent if @user_agent [:headers][@nonce_key] = @nonce if @nonce if http_method == :get [:query] = @params http_method_class = Net::HTTP::Get elsif http_method == :post [:body] = @params http_method_class = Net::HTTP::Post end @before_request.call(@params) if @before_request request = HTTParty::Request.new(http_method_class, endpoint_url + @path, ) if dryrun request else record_response { request.perform } end end |