Class: AceClient::Xml3
Instance Attribute Summary
Attributes inherited from Base3
Attributes inherited from Base
#access_key_id, #endpoint, #http_method, #http_proxy, #last_response, #last_response_time, #secret_access_key, #use_ssl, #user_agent
Instance Method Summary collapse
- #action(method, path, params = {}) ⇒ Object
- #create_request(method, path, params = {}) ⇒ Object
- #dryrun(method, path, params = {}) ⇒ 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 Method Details
#action(method, path, params = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/ace-client/xml3.rb', line 11 def action(method, path, params={}) record_response do create_request(method, path, params).perform end end |
#create_request(method, path, params = {}) ⇒ Object
21 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 55 56 57 |
# File 'lib/ace-client/xml3.rb', line 21 def create_request(method, path, params={}) @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 http_method_class = case method when :get; Net::HTTP::Get when :post; Net::HTTP::Post when :delete; Net::HTTP::Delete end if !params.empty? builder = Builder::XmlMarkup.new [:body] = builder.tag!(params.keys.first) do |b| params[params.keys.first].each do |k, v| b.tag!(k, v) end end end @path = File.join('/', @version, path) @before_request.call(@params) if @before_request HTTParty::Request.new(http_method_class, endpoint_url + @path, ) end |
#dryrun(method, path, params = {}) ⇒ Object
17 18 19 |
# File 'lib/ace-client/xml3.rb', line 17 def dryrun(method, path, params={}) create_request(method, path, params) end |