Class: Barthes::Client::Ace

Inherits:
HTTParty show all
Defined in:
lib/barthes/client/ace.rb

Direct Known Subclasses

AceJson4, AceQuery2, AceQuery3, AceQuery4

Constant Summary collapse

OPTION_KEYS =
%w(
  authorization_key
  signature_method
  authorization_prefix
  service
  region
  host
  nonce
  access_key_id_key
  path
  use_ssl
  endpoint
  response_format
  http_method
  access_key_id
  secret_access_key
  timeout
  headers
)

Instance Method Summary collapse

Methods inherited from HTTParty

#compare, #extract, #set_proxy, #xpath

Constructor Details

#initialize(env) ⇒ Ace



34
35
36
37
38
39
40
41
42
43
# File 'lib/barthes/client/ace.rb', line 34

def initialize(env)
  # TODO: validate existence of required options
  @options = env.slice(*OPTION_KEYS).symbolize_keys
  @options[:http_method] = @options[:http_method].downcase.to_sym if @options[:http_method]
  if env['client'] && env['client']['user']
    @user = env['client']['user']
    @options[:access_key_id] = env["#{@user}.access_key_id"]
    @options[:secret_access_key] = env["#{@user}.secret_access_key"]
  end
end

Instance Method Details

#action(params) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/barthes/client/ace.rb', line 45

def action(params)
  params = params.dup
  action = params.delete('Action')
  params ||= {}
  response = @client.action(action, params)
  response
end