vacuum 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -113
- data/lib/vacuum/request.rb +66 -0
- data/lib/vacuum/version.rb +1 -1
- data/lib/vacuum.rb +5 -38
- data/test/request_test.rb +18 -0
- metadata +24 -96
- data/lib/vacuum/endpoint/base.rb +0 -58
- data/lib/vacuum/endpoint/mws.rb +0 -59
- data/lib/vacuum/endpoint/product_advertising.rb +0 -34
- data/lib/vacuum/mws.rb +0 -8
- data/lib/vacuum/product_advertising.rb +0 -7
- data/lib/vacuum/request/base.rb +0 -109
- data/lib/vacuum/request/mws.rb +0 -24
- data/lib/vacuum/request/product_advertising.rb +0 -101
- data/lib/vacuum/request/signature/authentication.rb +0 -32
- data/lib/vacuum/request/signature/builder.rb +0 -70
- data/lib/vacuum/request/utils.rb +0 -24
- data/lib/vacuum/response/base.rb +0 -57
- data/lib/vacuum/response/mws.rb +0 -7
- data/lib/vacuum/response/product_advertising.rb +0 -19
- data/lib/vacuum/response/utils.rb +0 -48
- data/spec/fixtures/product_advertising +0 -1
- data/spec/spec_helper.rb +0 -15
- data/spec/support/shared_examples/endpoint.rb +0 -43
- data/spec/support/shared_examples/request.rb +0 -142
- data/spec/support/shared_examples/response.rb +0 -51
- data/spec/vacuum/endpoint/base_spec.rb +0 -19
- data/spec/vacuum/endpoint/mws_spec.rb +0 -47
- data/spec/vacuum/endpoint/product_advertising_spec.rb +0 -25
- data/spec/vacuum/request/base_spec.rb +0 -22
- data/spec/vacuum/request/mws_spec.rb +0 -26
- data/spec/vacuum/request/product_advertising_spec.rb +0 -118
- data/spec/vacuum/request/signature/authentication_spec.rb +0 -30
- data/spec/vacuum/request/signature/builder_spec.rb +0 -76
- data/spec/vacuum/request/utils_spec.rb +0 -23
- data/spec/vacuum/response/base_spec.rb +0 -38
- data/spec/vacuum/response/product_advertising_spec.rb +0 -57
- data/spec/vacuum/response/utils_spec.rb +0 -42
data/README.md
CHANGED
@@ -1,126 +1,24 @@
|
|
1
1
|
# Vacuum
|
2
2
|
|
3
|
-
[![travis]
|
3
|
+
[![travis][1]][2]
|
4
4
|
|
5
|
-
Vacuum is a thin Ruby wrapper to
|
5
|
+
Vacuum is a thin Ruby wrapper to the [Amazon Product Advertising API][3].
|
6
6
|
|
7
|
-
![vacuum]
|
8
|
-
|
9
|
-
## Installation
|
10
|
-
|
11
|
-
```sh
|
12
|
-
gem install vacuum
|
13
|
-
```
|
14
|
-
|
15
|
-
## Amazon Product Advertising API
|
16
|
-
|
17
|
-
Vacuum knows the [Amazon Product Advertising API] [5] inside out.
|
18
|
-
|
19
|
-
Set up a request:
|
7
|
+
![vacuum][4]
|
20
8
|
|
21
9
|
```ruby
|
22
|
-
|
10
|
+
request = Vacuum.new
|
23
11
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
config.tag 'tag'
|
28
|
-
end
|
29
|
-
```
|
30
|
-
|
31
|
-
Build and run a search:
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
req.build operation: 'ItemSearch',
|
35
|
-
search_index: 'Books',
|
36
|
-
keywords: 'Deleuze'
|
37
|
-
res = req.get
|
38
|
-
|
39
|
-
res.valid? or raise res.code
|
12
|
+
request.configure key: 'foo',
|
13
|
+
secret: 'secret',
|
14
|
+
tag: 'foo-bar'
|
40
15
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
Or run the same search less verbosely:
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
res = req.search :books, 'Deleuze'
|
48
|
-
p res.body
|
49
|
-
```
|
50
|
-
|
51
|
-
The response wraps a [Nokogiri] [6] document:
|
52
|
-
|
53
|
-
```ruby
|
54
|
-
res.xml
|
55
|
-
```
|
56
|
-
|
57
|
-
And lets you drop down to any node:
|
58
|
-
|
59
|
-
```ruby
|
60
|
-
res.find('Item') do |item|
|
61
|
-
p item
|
62
|
-
end
|
16
|
+
request.get query: { 'Operation' => 'ItemSearch',
|
17
|
+
'SearchIndex' => 'Books',
|
18
|
+
'Keywords' => 'Architecture' }
|
63
19
|
```
|
64
20
|
|
65
|
-
Browse more examples [here] [7].
|
66
|
-
|
67
|
-
## Amazon Marketplace Web Services API
|
68
|
-
|
69
|
-
The wrapper to the [Amazon Marketplace Web Services API] [8] is a
|
70
|
-
work-in-progress.
|
71
|
-
|
72
|
-
Set up a request to the Products API:
|
73
|
-
|
74
|
-
```ruby
|
75
|
-
req = Vacuum.new(:mws_products) do |config|
|
76
|
-
config.locale 'US'
|
77
|
-
config.key 'key'
|
78
|
-
config.secret 'secret'
|
79
|
-
config.marketplace 'marketplace'
|
80
|
-
config.seller 'seller'
|
81
|
-
end
|
82
|
-
```
|
83
|
-
|
84
|
-
Get the lowest offers for a single ASIN:
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
req.build 'Action' => 'GetLowestOfferListingsForASIN',
|
88
|
-
'ASINList.ASIN.1' => '0231081596'
|
89
|
-
offers = req.get.find 'GetLowestOfferListingsForASINResult'
|
90
|
-
```
|
91
|
-
|
92
|
-
I will at some point throw in some syntactic sugar for common operations.
|
93
|
-
|
94
|
-
## Other AWS APIs
|
95
|
-
|
96
|
-
Vacuum should work with all AWS libraries, including EC2, S3, IAM, SimpleDB,
|
97
|
-
SQS, SNS, SES, and ELB. Most of these already have popular Ruby
|
98
|
-
implementations. If you need to implement one using Vacuum, please fork and
|
99
|
-
send a pull request when done.
|
100
|
-
|
101
|
-
## HTTP Client Adapters
|
102
|
-
|
103
|
-
You can use any of the alternative adapters [Faraday] [9] supports:
|
104
|
-
|
105
|
-
```ruby
|
106
|
-
req.connection do |builder|
|
107
|
-
builder.adapter :em_synchrony
|
108
|
-
end
|
109
|
-
```
|
110
|
-
|
111
|
-
## Addendum
|
112
|
-
|
113
|
-
![vacuums] [10]
|
114
|
-
|
115
|
-
> Workers queuing to crawl AWS.
|
116
|
-
|
117
21
|
[1]: https://secure.travis-ci.org/hakanensari/vacuum.png
|
118
22
|
[2]: http://travis-ci.org/hakanensari/vacuum
|
119
|
-
[3]:
|
23
|
+
[3]: https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html
|
120
24
|
[4]: http://f.cl.ly/items/2k2X0e2u0G3k1c260D2u/vacuum.png
|
121
|
-
[5]: https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html
|
122
|
-
[6]: http://nokogiri.org/
|
123
|
-
[7]: https://github.com/hakanensari/vacuum/blob/master/examples/product_advertising/
|
124
|
-
[8]: https://developer.amazonservices.com/gp/mws/docs.html
|
125
|
-
[9]: https://github.com/technoweenie/faraday
|
126
|
-
[10]: http://f.cl.ly/items/1Q3W372A0H3M0w2H1e0W/hoover.jpeg
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'jeff'
|
2
|
+
|
3
|
+
module Vacuum
|
4
|
+
# An Amazon Product Advertising API request.
|
5
|
+
class Request
|
6
|
+
include Jeff
|
7
|
+
|
8
|
+
BadLocale = Class.new ArgumentError
|
9
|
+
MissingTag = Class.new ArgumentError
|
10
|
+
|
11
|
+
# A list of Amazon Product Advertising API hosts.
|
12
|
+
HOSTS = {
|
13
|
+
'CA' => 'ecs.amazonaws.ca',
|
14
|
+
'CN' => 'webservices.amazon.cn',
|
15
|
+
'DE' => 'ecs.amazonaws.de',
|
16
|
+
'ES' => 'webservices.amazon.es',
|
17
|
+
'FR' => 'ecs.amazonaws.fr',
|
18
|
+
'IT' => 'webservices.amazon.it',
|
19
|
+
'JP' => 'ecs.amazonaws.jp',
|
20
|
+
'UK' => 'ecs.amazonaws.co.uk',
|
21
|
+
'US' => 'ecs.amazonaws.com'
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
params 'AssociateTag' => -> { tag },
|
25
|
+
'Service' => 'AWSECommerceService',
|
26
|
+
'Version' => '2011-08-01'
|
27
|
+
|
28
|
+
# Creates a new request for given locale and credentials.
|
29
|
+
#
|
30
|
+
# locale - The String Product Advertising API locale (default: US).
|
31
|
+
#
|
32
|
+
# Raises a Bad Locale error if locale is not valid.
|
33
|
+
def initialize(locale = nil)
|
34
|
+
host = HOSTS[locale || 'US'] or raise BadLocale
|
35
|
+
self.endpoint = "http://#{host}/onca/xml"
|
36
|
+
end
|
37
|
+
|
38
|
+
# Configures the Amazon Product Advertising API request.
|
39
|
+
#
|
40
|
+
# credentials - The Hash credentials of the API endpoint.
|
41
|
+
# :key - The String Amazon Web Services (AWS) key.
|
42
|
+
# :secret - The String AWS secret.
|
43
|
+
# :tag - The String Associate Tag.
|
44
|
+
#
|
45
|
+
# Yields self.
|
46
|
+
#
|
47
|
+
# Returns nothing.
|
48
|
+
def configure(credentials, &blk)
|
49
|
+
if block_given?
|
50
|
+
yield self
|
51
|
+
else
|
52
|
+
credentials.each { |key, val| self.send "#{key}=", val }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Gets the String Associate Tag.
|
57
|
+
#
|
58
|
+
# Raises a Missing Tag error if Associate Tag is missing.
|
59
|
+
def tag
|
60
|
+
@tag or raise MissingTag
|
61
|
+
end
|
62
|
+
|
63
|
+
# Sets the String Associate Tag.
|
64
|
+
attr_writer :tag
|
65
|
+
end
|
66
|
+
end
|
data/lib/vacuum/version.rb
CHANGED
data/lib/vacuum.rb
CHANGED
@@ -1,46 +1,13 @@
|
|
1
|
-
# Standard library dependencies.
|
2
|
-
require 'base64'
|
3
1
|
require 'forwardable'
|
4
|
-
require 'openssl'
|
5
|
-
require 'time'
|
6
2
|
|
7
|
-
|
8
|
-
require 'addressable/uri'
|
9
|
-
require 'faraday'
|
10
|
-
require 'nokogiri'
|
11
|
-
|
12
|
-
# Internal dependencies.
|
13
|
-
require 'vacuum/endpoint/base'
|
14
|
-
require 'vacuum/request/base'
|
15
|
-
require 'vacuum/request/signature/authentication'
|
16
|
-
require 'vacuum/request/signature/builder'
|
17
|
-
require 'vacuum/request/utils'
|
18
|
-
require 'vacuum/response/base'
|
19
|
-
require 'vacuum/response/utils'
|
3
|
+
require 'vacuum/request'
|
20
4
|
require 'vacuum/version'
|
21
5
|
|
22
|
-
# Vacuum is a Ruby wrapper to
|
6
|
+
# Vacuum is a Ruby wrapper to the Amazon Product Advertising API.
|
23
7
|
module Vacuum
|
24
|
-
BadLocale = Class.new ArgumentError
|
25
|
-
BadResponse = Class.new StandardError
|
26
|
-
MissingKey = Class.new ArgumentError
|
27
|
-
MissingSecret = Class.new ArgumentError
|
28
|
-
|
29
8
|
class << self
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
require 'vacuum/mws'
|
34
|
-
Request::MWS.new do |config|
|
35
|
-
config.api = api.slice(4, api.size).to_sym
|
36
|
-
blk.call config
|
37
|
-
end
|
38
|
-
when :product_advertising
|
39
|
-
require 'vacuum/product_advertising'
|
40
|
-
Request::ProductAdvertising.new &blk
|
41
|
-
else
|
42
|
-
raise NotImplementedError
|
43
|
-
end
|
44
|
-
end
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def_delegator 'Vacuum::Request', :new
|
45
12
|
end
|
46
13
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../lib/vacuum'
|
3
|
+
|
4
|
+
module Vacuum
|
5
|
+
describe Request do
|
6
|
+
it 'requires a valid locale' do
|
7
|
+
-> { Request.new('foo') }.must_raise Request::BadLocale
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'requires an Associate Tag' do
|
11
|
+
-> { Request.new('US').tag }.must_raise Request::MissingTag
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'defaults to the US endpoint' do
|
15
|
+
Request.new.endpoint.must_equal 'http://ecs.amazonaws.com/onca/xml'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vacuum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,110 +9,53 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
15
|
+
name: jeff
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
-
type: :
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: *70295025564860
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rspec
|
27
|
-
requirement: &70295025564460 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '2.9'
|
33
|
-
type: :development
|
21
|
+
version: 0.4.0
|
22
|
+
type: :runtime
|
34
23
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: addressable
|
38
|
-
requirement: &70295025563720 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
26
|
requirements:
|
41
27
|
- - ~>
|
42
28
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
type: :runtime
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: *70295025563720
|
29
|
+
version: 0.4.0
|
47
30
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement:
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
50
33
|
none: false
|
51
34
|
requirements:
|
52
|
-
- -
|
35
|
+
- - ! '>='
|
53
36
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
55
|
-
type: :
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
56
39
|
prerelease: false
|
57
|
-
version_requirements:
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: nokogiri
|
60
|
-
requirement: &70295025562560 !ruby/object:Gem::Requirement
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
41
|
none: false
|
62
42
|
requirements:
|
63
|
-
- -
|
43
|
+
- - ! '>='
|
64
44
|
- !ruby/object:Gem::Version
|
65
|
-
version: '
|
66
|
-
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *70295025562560
|
69
|
-
description: ! 'Vacuum is a wrapper to various Amazon Web Services (AWS) APIs, including
|
70
|
-
|
71
|
-
Product Advertising and Marketplace Web Services (MWS).
|
72
|
-
|
73
|
-
'
|
45
|
+
version: '0'
|
46
|
+
description: A wrapper to the Amazon Product Advertising API
|
74
47
|
email:
|
75
48
|
- hakan.ensari@papercavalier.com
|
76
49
|
executables: []
|
77
50
|
extensions: []
|
78
51
|
extra_rdoc_files: []
|
79
52
|
files:
|
80
|
-
- lib/vacuum/
|
81
|
-
- lib/vacuum/endpoint/mws.rb
|
82
|
-
- lib/vacuum/endpoint/product_advertising.rb
|
83
|
-
- lib/vacuum/mws.rb
|
84
|
-
- lib/vacuum/product_advertising.rb
|
85
|
-
- lib/vacuum/request/base.rb
|
86
|
-
- lib/vacuum/request/mws.rb
|
87
|
-
- lib/vacuum/request/product_advertising.rb
|
88
|
-
- lib/vacuum/request/signature/authentication.rb
|
89
|
-
- lib/vacuum/request/signature/builder.rb
|
90
|
-
- lib/vacuum/request/utils.rb
|
91
|
-
- lib/vacuum/response/base.rb
|
92
|
-
- lib/vacuum/response/mws.rb
|
93
|
-
- lib/vacuum/response/product_advertising.rb
|
94
|
-
- lib/vacuum/response/utils.rb
|
53
|
+
- lib/vacuum/request.rb
|
95
54
|
- lib/vacuum/version.rb
|
96
55
|
- lib/vacuum.rb
|
97
56
|
- LICENSE
|
98
57
|
- README.md
|
99
|
-
-
|
100
|
-
- spec/spec_helper.rb
|
101
|
-
- spec/support/shared_examples/endpoint.rb
|
102
|
-
- spec/support/shared_examples/request.rb
|
103
|
-
- spec/support/shared_examples/response.rb
|
104
|
-
- spec/vacuum/endpoint/base_spec.rb
|
105
|
-
- spec/vacuum/endpoint/mws_spec.rb
|
106
|
-
- spec/vacuum/endpoint/product_advertising_spec.rb
|
107
|
-
- spec/vacuum/request/base_spec.rb
|
108
|
-
- spec/vacuum/request/mws_spec.rb
|
109
|
-
- spec/vacuum/request/product_advertising_spec.rb
|
110
|
-
- spec/vacuum/request/signature/authentication_spec.rb
|
111
|
-
- spec/vacuum/request/signature/builder_spec.rb
|
112
|
-
- spec/vacuum/request/utils_spec.rb
|
113
|
-
- spec/vacuum/response/base_spec.rb
|
114
|
-
- spec/vacuum/response/product_advertising_spec.rb
|
115
|
-
- spec/vacuum/response/utils_spec.rb
|
58
|
+
- test/request_test.rb
|
116
59
|
homepage: https://github.com/hakanensari/vacuum
|
117
60
|
licenses: []
|
118
61
|
post_install_message:
|
@@ -124,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
67
|
requirements:
|
125
68
|
- - ! '>='
|
126
69
|
- !ruby/object:Gem::Version
|
127
|
-
version: '
|
70
|
+
version: '1.9'
|
128
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
72
|
none: false
|
130
73
|
requirements:
|
@@ -133,25 +76,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
76
|
version: '0'
|
134
77
|
requirements: []
|
135
78
|
rubyforge_project:
|
136
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.23
|
137
80
|
signing_key:
|
138
81
|
specification_version: 3
|
139
|
-
summary:
|
82
|
+
summary: Amazon Product Advertising in Ruby
|
140
83
|
test_files:
|
141
|
-
-
|
142
|
-
|
143
|
-
- spec/support/shared_examples/endpoint.rb
|
144
|
-
- spec/support/shared_examples/request.rb
|
145
|
-
- spec/support/shared_examples/response.rb
|
146
|
-
- spec/vacuum/endpoint/base_spec.rb
|
147
|
-
- spec/vacuum/endpoint/mws_spec.rb
|
148
|
-
- spec/vacuum/endpoint/product_advertising_spec.rb
|
149
|
-
- spec/vacuum/request/base_spec.rb
|
150
|
-
- spec/vacuum/request/mws_spec.rb
|
151
|
-
- spec/vacuum/request/product_advertising_spec.rb
|
152
|
-
- spec/vacuum/request/signature/authentication_spec.rb
|
153
|
-
- spec/vacuum/request/signature/builder_spec.rb
|
154
|
-
- spec/vacuum/request/utils_spec.rb
|
155
|
-
- spec/vacuum/response/base_spec.rb
|
156
|
-
- spec/vacuum/response/product_advertising_spec.rb
|
157
|
-
- spec/vacuum/response/utils_spec.rb
|
84
|
+
- test/request_test.rb
|
85
|
+
has_rdoc:
|
data/lib/vacuum/endpoint/base.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Endpoint
|
3
|
-
# An Amazon Web Services (AWS) API endpoint.
|
4
|
-
class Base
|
5
|
-
LOCALES = %w(CA CN DE ES FR IT JP UK US)
|
6
|
-
|
7
|
-
# Raises a Not Implemented Error.
|
8
|
-
#
|
9
|
-
# When implemented, this should return a String AWS API host.
|
10
|
-
def host
|
11
|
-
raise NotImplementedError
|
12
|
-
end
|
13
|
-
|
14
|
-
# Returns the String AWS access key ID.
|
15
|
-
#
|
16
|
-
# Raises a Missing Key error if key is missing.
|
17
|
-
def key
|
18
|
-
@key or raise MissingKey
|
19
|
-
end
|
20
|
-
|
21
|
-
# Sets the String AWS access key ID.
|
22
|
-
attr_writer :key
|
23
|
-
|
24
|
-
# Returns the String AWS API locale (default: US).
|
25
|
-
#
|
26
|
-
# Raises a Bad Locale error if locale is not valid.
|
27
|
-
def locale
|
28
|
-
@locale ||= 'US'
|
29
|
-
LOCALES.include? @locale or raise BadLocale
|
30
|
-
|
31
|
-
@locale
|
32
|
-
end
|
33
|
-
|
34
|
-
# Sets the String AWS API locale.
|
35
|
-
attr_writer :locale
|
36
|
-
|
37
|
-
# Returns the String AWS access secret key.
|
38
|
-
#
|
39
|
-
# Raises a Missing Secret error if secret is missing.
|
40
|
-
def secret
|
41
|
-
@secret or raise MissingSecret
|
42
|
-
end
|
43
|
-
|
44
|
-
# Sets the String AWS access secret key.
|
45
|
-
attr_writer :secret
|
46
|
-
|
47
|
-
# Returns a String user agent for the AWS API request.
|
48
|
-
def user_agent
|
49
|
-
engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
50
|
-
language = [engine, RUBY_VERSION, "p#{RUBY_PATCHLEVEL}"].join ' '
|
51
|
-
hostname = `hostname`.chomp
|
52
|
-
version = Vacuum::VERSION
|
53
|
-
|
54
|
-
"Vacuum/#{version} (Language=#{language}; Host=#{hostname})"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/lib/vacuum/endpoint/mws.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Endpoint
|
3
|
-
# A Marketplace Web Services (MWS) API endpoint.
|
4
|
-
class MWS < Base
|
5
|
-
# A list of MWS API hosts.
|
6
|
-
HOSTS = {
|
7
|
-
'CA' => 'mws.amazonservices.ca',
|
8
|
-
'CN' => 'mws.amazonservices.com.cn',
|
9
|
-
'DE' => 'mws-eu.amazonservices.com',
|
10
|
-
'ES' => 'mws-eu.amazonservices.com',
|
11
|
-
'FR' => 'mws-eu.amazonservices.com',
|
12
|
-
'IT' => 'mws-eu.amazonservices.com',
|
13
|
-
'JP' => 'mws.amazonservices.jp',
|
14
|
-
'UK' => 'mws-eu.amazonservices.com',
|
15
|
-
'US' => 'mws.amazonservices.com'
|
16
|
-
}
|
17
|
-
|
18
|
-
# Internal: Gets/Sets the Symbol MWS API type.
|
19
|
-
attr_accessor :api
|
20
|
-
|
21
|
-
# Returns a String MWS API host.
|
22
|
-
def host
|
23
|
-
HOSTS[locale]
|
24
|
-
end
|
25
|
-
|
26
|
-
# Sets the String marketplace ID.
|
27
|
-
#
|
28
|
-
# Raises a Missing Marketplace error if marketplace ID is missing.
|
29
|
-
def marketplace
|
30
|
-
@marketplace or raise MissingMarketplace
|
31
|
-
end
|
32
|
-
|
33
|
-
# Sets the String marketplace ID tag.
|
34
|
-
attr_writer :marketplace
|
35
|
-
|
36
|
-
# Returns a String MWS API URL path.
|
37
|
-
#
|
38
|
-
# Raises a Not Implemented Error if API is not implemented.
|
39
|
-
def path
|
40
|
-
case api
|
41
|
-
when :products
|
42
|
-
'/Products/2011-10-01'
|
43
|
-
else
|
44
|
-
raise NotImplementedError
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Sets the String seller ID.
|
49
|
-
#
|
50
|
-
# Raises a Missing Seller error if seller ID is missing.
|
51
|
-
def seller
|
52
|
-
@seller or raise MissingSeller
|
53
|
-
end
|
54
|
-
|
55
|
-
# Sets the String seller ID tag.
|
56
|
-
attr_writer :seller
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Vacuum
|
2
|
-
module Endpoint
|
3
|
-
# A Product Advertising API endpoint.
|
4
|
-
class ProductAdvertising < Base
|
5
|
-
# A list of Product Advertising API hosts.
|
6
|
-
HOSTS = {
|
7
|
-
'CA' => 'ecs.amazonaws.ca',
|
8
|
-
'CN' => 'webservices.amazon.cn',
|
9
|
-
'DE' => 'ecs.amazonaws.de',
|
10
|
-
'ES' => 'webservices.amazon.es',
|
11
|
-
'FR' => 'ecs.amazonaws.fr',
|
12
|
-
'IT' => 'webservices.amazon.it',
|
13
|
-
'JP' => 'ecs.amazonaws.jp',
|
14
|
-
'UK' => 'ecs.amazonaws.co.uk',
|
15
|
-
'US' => 'ecs.amazonaws.com'
|
16
|
-
}
|
17
|
-
|
18
|
-
# Returns a String Product Advertising API host.
|
19
|
-
def host
|
20
|
-
HOSTS[locale]
|
21
|
-
end
|
22
|
-
|
23
|
-
# Sets the String Associate tag.
|
24
|
-
#
|
25
|
-
# Raises a Missing Tag error if tag is missing.
|
26
|
-
def tag
|
27
|
-
@tag or raise MissingTag
|
28
|
-
end
|
29
|
-
|
30
|
-
# Sets the String Associate tag.
|
31
|
-
attr_writer :tag
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/vacuum/mws.rb
DELETED