Class: ApiBucket::Amazon::Client

Inherits:
Object
  • Object
show all
Includes:
Http
Defined in:
lib/api_bucket/amazon/client.rb,
lib/api_bucket/amazon/client/http.rb

Defined Under Namespace

Modules: Http

Constant Summary collapse

REQUEST_URL =
'http://ecs.amazonaws.jp/onca/xml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Http

#camelize, #prepare_query, #send_request, #sign_request, #url_encode

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/api_bucket/amazon/client.rb', line 26

def initialize(options={})
  options = ApiBucket::Amazon.options.merge(options)
  self.version             = '2011-08-01'
  self.service             = 'AWSECommerceService'
  self.a_w_s_access_key_id = options[:a_w_s_access_key_id]
  self.a_w_s_secret_key    = options[:a_w_s_secret_key]
  self.associate_tag       = options[:associate_tag]
  self.country             = 'ja'
  self.count               = 20
  self.item_page           = 1
end

Instance Attribute Details

#a_w_s_access_key_idObject

Returns the value of attribute a_w_s_access_key_id.



5
6
7
# File 'lib/api_bucket/amazon/client.rb', line 5

def a_w_s_access_key_id
  @a_w_s_access_key_id
end

#a_w_s_secret_keyObject

Returns the value of attribute a_w_s_secret_key.



5
6
7
# File 'lib/api_bucket/amazon/client.rb', line 5

def a_w_s_secret_key
  @a_w_s_secret_key
end

#associate_tagObject

Returns the value of attribute associate_tag.



5
6
7
# File 'lib/api_bucket/amazon/client.rb', line 5

def associate_tag
  @associate_tag
end

#countObject

Returns the value of attribute count.



6
7
8
# File 'lib/api_bucket/amazon/client.rb', line 6

def count
  @count
end

#countryObject

Returns the value of attribute country.



6
7
8
# File 'lib/api_bucket/amazon/client.rb', line 6

def country
  @country
end

#item_pageObject

Returns the value of attribute item_page.



6
7
8
# File 'lib/api_bucket/amazon/client.rb', line 6

def item_page
  @item_page
end

#serviceObject

Returns the value of attribute service.



5
6
7
# File 'lib/api_bucket/amazon/client.rb', line 5

def service
  @service
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/api_bucket/amazon/client.rb', line 5

def version
  @version
end

Instance Method Details

#categoriesObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/api_bucket/amazon/client.rb', line 10

def categories
  {
    ALL:            'All',
    DVD:            'DVD / BD',
    Books:          'Books',
    ForeignBooks:   'ForeignBooks',
    VideoGames:     'VideoGames',
    Music:          'Music',
    Software:       'Software',
    Electronics:    'Electronics',
    Watches:        'Watches',
    KindleStore:    'KindleStore',
    Grocery:        'Grocery',
  }
end

#lookup(id, params = {}) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/api_bucket/amazon/client.rb', line 57

def lookup(id, params={})
  options = {
    a_w_s_access_key_id: self.a_w_s_access_key_id,
    a_w_s_secret_key:    self.a_w_s_secret_key,
    associate_tag:       self.associate_tag,

    operation:      'ItemLookup',
    response_group:  'Large,EditorialReview,ItemAttributes',
    item_id:          id,
    timestamp:       Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
  }
  options.merge!(params)

  ApiBucket::Amazon::Response.new(send_request(options))
end

#search(keywords, params = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/api_bucket/amazon/client.rb', line 38

def search(keywords, params={})
  options = {
    a_w_s_access_key_id: self.a_w_s_access_key_id,
    a_w_s_secret_key:    self.a_w_s_secret_key,
    associate_tag:       self.associate_tag,

    operation:       'ItemSearch',
    response_group:  'Large,EditorialReview,ItemAttributes',
    item_page:       @page,
    count:           @limit,
    search_index:    'All',
    keywords:        keywords,
    timestamp:       Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
  }
  options.merge!(params)

  ApiBucket::Amazon::Response.new(send_request(options))
end