mws-connect 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.sublime-project +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +111 -0
- data/Rakefile +1 -0
- data/lib/mws.rb +34 -0
- data/lib/mws/apis.rb +6 -0
- data/lib/mws/apis/feeds.rb +20 -0
- data/lib/mws/apis/feeds/api.rb +103 -0
- data/lib/mws/apis/feeds/distance.rb +23 -0
- data/lib/mws/apis/feeds/feed.rb +114 -0
- data/lib/mws/apis/feeds/image_listing.rb +44 -0
- data/lib/mws/apis/feeds/inventory.rb +77 -0
- data/lib/mws/apis/feeds/measurement.rb +32 -0
- data/lib/mws/apis/feeds/money.rb +31 -0
- data/lib/mws/apis/feeds/price_listing.rb +48 -0
- data/lib/mws/apis/feeds/product.rb +173 -0
- data/lib/mws/apis/feeds/sale_price.rb +31 -0
- data/lib/mws/apis/feeds/shipping.rb +160 -0
- data/lib/mws/apis/feeds/submission_info.rb +45 -0
- data/lib/mws/apis/feeds/submission_result.rb +87 -0
- data/lib/mws/apis/feeds/transaction.rb +37 -0
- data/lib/mws/apis/feeds/weight.rb +19 -0
- data/lib/mws/apis/orders.rb +23 -0
- data/lib/mws/connection.rb +84 -0
- data/lib/mws/enum.rb +81 -0
- data/lib/mws/errors.rb +32 -0
- data/lib/mws/query.rb +45 -0
- data/lib/mws/serializer.rb +81 -0
- data/lib/mws/signer.rb +20 -0
- data/lib/mws/utils.rb +50 -0
- data/mws.gemspec +25 -0
- data/scripts/catalog-workflow +136 -0
- data/spec/mws/apis/feeds/api_spec.rb +229 -0
- data/spec/mws/apis/feeds/distance_spec.rb +43 -0
- data/spec/mws/apis/feeds/feed_spec.rb +92 -0
- data/spec/mws/apis/feeds/image_listing_spec.rb +109 -0
- data/spec/mws/apis/feeds/inventory_spec.rb +135 -0
- data/spec/mws/apis/feeds/measurement_spec.rb +84 -0
- data/spec/mws/apis/feeds/money_spec.rb +43 -0
- data/spec/mws/apis/feeds/price_listing_spec.rb +90 -0
- data/spec/mws/apis/feeds/product_spec.rb +264 -0
- data/spec/mws/apis/feeds/shipping_spec.rb +78 -0
- data/spec/mws/apis/feeds/submission_info_spec.rb +111 -0
- data/spec/mws/apis/feeds/submission_result_spec.rb +157 -0
- data/spec/mws/apis/feeds/transaction_spec.rb +64 -0
- data/spec/mws/apis/feeds/weight_spec.rb +43 -0
- data/spec/mws/apis/orders_spec.rb +9 -0
- data/spec/mws/connection_spec.rb +331 -0
- data/spec/mws/enum_spec.rb +166 -0
- data/spec/mws/query_spec.rb +104 -0
- data/spec/mws/serializer_spec.rb +187 -0
- data/spec/mws/signer_spec.rb +67 -0
- data/spec/mws/utils_spec.rb +147 -0
- data/spec/spec_helper.rb +10 -0
- metadata +220 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mws
|
4
|
+
|
5
|
+
class Signer
|
6
|
+
attr_reader :verb, :host, :path, :secret
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Signer do
|
10
|
+
|
11
|
+
let(:query) { 'AWSAccessKeyId=Q6K3SCWMLYAKIAJXAAYQ&LastUpdatedAfter=2012-10-12T11%3A11%3A54-05%3A00&MarketplaceIdList.Id.1=ATVPDKIKX0DER&MarketplaceIdList.Id.2=KIKX0DERATVPD&SellerId=J4UBGSWCA31UTJ&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-10-12T15%3A14%3A52-05%3A00' }
|
12
|
+
|
13
|
+
let(:signer) { Signer.new({}) }
|
14
|
+
|
15
|
+
it 'should default verb to POST' do
|
16
|
+
signer.verb.should == 'POST'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should default host to mws.amazonservices.com' do
|
20
|
+
signer.host.should == 'mws.amazonservices.com'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should default path to /' do
|
24
|
+
signer.path.should == '/'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should accept overrides to verb via the method or verb options' do
|
28
|
+
[ :method, :verb ].each do | key |
|
29
|
+
Signer.new({key => 'get'}).verb.should == 'GET'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should accept overrides to host via the host option' do
|
34
|
+
Signer.new(host: 'MWS.AmazonServices.DE').host.should == 'mws.amazonservices.de'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should accept overrides to path via the path option' do
|
38
|
+
Signer.new(path: '/Foo/Bar').path.should == '/Foo/Bar'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should accept secret values via the secret option' do
|
42
|
+
secret = '53kddzBej7O7I5Yx9drGrXEUbzq/NskSrW4m5ncq'
|
43
|
+
Signer.new(secret: secret).secret.should == secret
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should correctly calculate a signature for the provided query and secret' do
|
47
|
+
signer.signature(query, '53kddzBej7O7I5Yx9drGrXEUbzq/NskSrW4m5ncq').should == 'jsOaccLC2MUFSUh5Lz7DdSA1+2//98LnUNp/b8xFi+0='
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should correctly calculate a signature for the provided query and default secret' do
|
51
|
+
Signer.new(secret: '53kddzBej7O7I5Yx9drGrXEUbzq/NskSrW4m5ncq').signature(query).should == 'jsOaccLC2MUFSUh5Lz7DdSA1+2//98LnUNp/b8xFi+0='
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should correclty sign the provided query and secret' do
|
55
|
+
signature = URI.encode_www_form_component signer.signature(query, '53kddzBej7O7I5Yx9drGrXEUbzq/NskSrW4m5ncq')
|
56
|
+
signer.sign(query, '53kddzBej7O7I5Yx9drGrXEUbzq/NskSrW4m5ncq').should == "#{query}&Signature=#{signature}"
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should correctly sign the provided query and default secret' do
|
60
|
+
signer = Signer.new(secret: '53kddzBej7O7I5Yx9drGrXEUbzq/NskSrW4m5ncq')
|
61
|
+
signature = URI.encode_www_form_component signer.signature(query)
|
62
|
+
signer.sign(query).should == "#{query}&Signature=#{signature}"
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mws
|
4
|
+
|
5
|
+
module Foo
|
6
|
+
|
7
|
+
module Bar
|
8
|
+
|
9
|
+
class Baz
|
10
|
+
|
11
|
+
def initialize(quk)
|
12
|
+
@quk = quk
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
class Quk
|
18
|
+
|
19
|
+
def initialize(bar)
|
20
|
+
@bar = bar
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe Utils do
|
30
|
+
|
31
|
+
context '.camelize' do
|
32
|
+
|
33
|
+
it 'should properly camelize nil' do
|
34
|
+
Utils.camelize(nil).should be nil
|
35
|
+
Utils.camelize(nil, false).should be nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should properly camelize the empty string' do
|
39
|
+
Utils.camelize('').should == ''
|
40
|
+
Utils.camelize('', false) == ''
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should trim whitespace from the string' do
|
44
|
+
Utils.camelize(' ').should == ''
|
45
|
+
Utils.camelize(' ', false) == ''
|
46
|
+
Utils.camelize(' foo_bar_baz ').should == 'FooBarBaz'
|
47
|
+
Utils.camelize(' foo_bar_baz ', false).should == 'fooBarBaz'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should properly camelize single segment names' do
|
51
|
+
Utils.camelize('foo').should == 'Foo'
|
52
|
+
Utils.camelize('foo', false).should == 'foo'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should properly camelize multi-segment names' do
|
56
|
+
Utils.camelize('foo_bar_baz').should == 'FooBarBaz'
|
57
|
+
Utils.camelize('foo_bar_baz', false).should == 'fooBarBaz'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should properly camelize mixed case multi-segment names' do
|
61
|
+
Utils.camelize('fOO_BAR_BAZ').should == 'FooBarBaz'
|
62
|
+
Utils.camelize('fOO_BAR_BAZ', false).should == 'fooBarBaz'
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
context '.underscore' do
|
68
|
+
|
69
|
+
it 'should properly underscore nil' do
|
70
|
+
Utils.underscore(nil).should be nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should properly camelize the empty string' do
|
74
|
+
Utils.underscore('').should == ''
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should trim whitespace from the string' do
|
78
|
+
Utils.underscore(' ').should == ''
|
79
|
+
Utils.underscore(' FooBarBaz ').should == 'foo_bar_baz'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should properly underscore single-segment names' do
|
83
|
+
Utils.underscore('Foo').should == 'foo'
|
84
|
+
Utils.underscore('foo').should == 'foo'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should properly underscore multi-segment names' do
|
88
|
+
Utils.underscore('FooBarBaz').should == 'foo_bar_baz'
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context '.uri_escape' do
|
94
|
+
|
95
|
+
{
|
96
|
+
' ' => '20',
|
97
|
+
'"' => '22',
|
98
|
+
'#' => '23',
|
99
|
+
'$' => '24',
|
100
|
+
'%' => '25',
|
101
|
+
'&' => '26',
|
102
|
+
'+' => '2B',
|
103
|
+
',' => '2C',
|
104
|
+
'/' => '2F',
|
105
|
+
':' => '3A',
|
106
|
+
';' => '3B',
|
107
|
+
'<' => '3C',
|
108
|
+
'=' => '3D',
|
109
|
+
'>' => '3E',
|
110
|
+
'?' => '3F',
|
111
|
+
'@' => '40',
|
112
|
+
'[' => '5B',
|
113
|
+
'\\' => '5C',
|
114
|
+
']' => '5D',
|
115
|
+
'^' => '5E',
|
116
|
+
'{' => '7B',
|
117
|
+
'|' => '7C',
|
118
|
+
'}' => '7D'
|
119
|
+
}.each do | key, value |
|
120
|
+
it "should properly escape '#{key}' as '%#{value}'" do
|
121
|
+
Utils.uri_escape("foo#{key}bar").should == "foo%#{value}bar"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
context '.alias' do
|
128
|
+
|
129
|
+
before(:all) do
|
130
|
+
Utils.alias Mws, Mws::Foo::Bar, :Baz, :Quk
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'should create aliases of the specified constants' do
|
134
|
+
Mws::Baz.should == Mws::Foo::Bar::Baz
|
135
|
+
Mws::Quk.should == Mws::Foo::Bar::Quk
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should create constructor shortcuts' do
|
139
|
+
Mws::Baz('quk').should be_a Mws::Foo::Bar::Baz
|
140
|
+
Mws::Quk('baz').should be_a Mws::Foo::Bar::Quk
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mws-connect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sean M. Duncan
|
9
|
+
- John E. Bailey
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-11-21 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: simplecov
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: cucumber
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: activesupport
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: logging
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ~>
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.8.0
|
87
|
+
type: :runtime
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.8.0
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: nokogiri
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.5.5
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.5.5
|
111
|
+
description: The missing ruby client library for Amazon MWS
|
112
|
+
email:
|
113
|
+
- info@devmode.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .sublime-project
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/mws.rb
|
125
|
+
- lib/mws/apis.rb
|
126
|
+
- lib/mws/apis/feeds.rb
|
127
|
+
- lib/mws/apis/feeds/api.rb
|
128
|
+
- lib/mws/apis/feeds/distance.rb
|
129
|
+
- lib/mws/apis/feeds/feed.rb
|
130
|
+
- lib/mws/apis/feeds/image_listing.rb
|
131
|
+
- lib/mws/apis/feeds/inventory.rb
|
132
|
+
- lib/mws/apis/feeds/measurement.rb
|
133
|
+
- lib/mws/apis/feeds/money.rb
|
134
|
+
- lib/mws/apis/feeds/price_listing.rb
|
135
|
+
- lib/mws/apis/feeds/product.rb
|
136
|
+
- lib/mws/apis/feeds/sale_price.rb
|
137
|
+
- lib/mws/apis/feeds/shipping.rb
|
138
|
+
- lib/mws/apis/feeds/submission_info.rb
|
139
|
+
- lib/mws/apis/feeds/submission_result.rb
|
140
|
+
- lib/mws/apis/feeds/transaction.rb
|
141
|
+
- lib/mws/apis/feeds/weight.rb
|
142
|
+
- lib/mws/apis/orders.rb
|
143
|
+
- lib/mws/connection.rb
|
144
|
+
- lib/mws/enum.rb
|
145
|
+
- lib/mws/errors.rb
|
146
|
+
- lib/mws/query.rb
|
147
|
+
- lib/mws/serializer.rb
|
148
|
+
- lib/mws/signer.rb
|
149
|
+
- lib/mws/utils.rb
|
150
|
+
- mws.gemspec
|
151
|
+
- scripts/catalog-workflow
|
152
|
+
- spec/mws/apis/feeds/api_spec.rb
|
153
|
+
- spec/mws/apis/feeds/distance_spec.rb
|
154
|
+
- spec/mws/apis/feeds/feed_spec.rb
|
155
|
+
- spec/mws/apis/feeds/image_listing_spec.rb
|
156
|
+
- spec/mws/apis/feeds/inventory_spec.rb
|
157
|
+
- spec/mws/apis/feeds/measurement_spec.rb
|
158
|
+
- spec/mws/apis/feeds/money_spec.rb
|
159
|
+
- spec/mws/apis/feeds/price_listing_spec.rb
|
160
|
+
- spec/mws/apis/feeds/product_spec.rb
|
161
|
+
- spec/mws/apis/feeds/shipping_spec.rb
|
162
|
+
- spec/mws/apis/feeds/submission_info_spec.rb
|
163
|
+
- spec/mws/apis/feeds/submission_result_spec.rb
|
164
|
+
- spec/mws/apis/feeds/transaction_spec.rb
|
165
|
+
- spec/mws/apis/feeds/weight_spec.rb
|
166
|
+
- spec/mws/apis/orders_spec.rb
|
167
|
+
- spec/mws/connection_spec.rb
|
168
|
+
- spec/mws/enum_spec.rb
|
169
|
+
- spec/mws/query_spec.rb
|
170
|
+
- spec/mws/serializer_spec.rb
|
171
|
+
- spec/mws/signer_spec.rb
|
172
|
+
- spec/mws/utils_spec.rb
|
173
|
+
- spec/spec_helper.rb
|
174
|
+
homepage: http://github.com/devmode/mws
|
175
|
+
licenses: []
|
176
|
+
post_install_message:
|
177
|
+
rdoc_options: []
|
178
|
+
require_paths:
|
179
|
+
- lib
|
180
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
+
none: false
|
182
|
+
requirements:
|
183
|
+
- - ! '>='
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - ! '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 1.8.24
|
195
|
+
signing_key:
|
196
|
+
specification_version: 3
|
197
|
+
summary: The missing ruby client library for Amazon MWS
|
198
|
+
test_files:
|
199
|
+
- spec/mws/apis/feeds/api_spec.rb
|
200
|
+
- spec/mws/apis/feeds/distance_spec.rb
|
201
|
+
- spec/mws/apis/feeds/feed_spec.rb
|
202
|
+
- spec/mws/apis/feeds/image_listing_spec.rb
|
203
|
+
- spec/mws/apis/feeds/inventory_spec.rb
|
204
|
+
- spec/mws/apis/feeds/measurement_spec.rb
|
205
|
+
- spec/mws/apis/feeds/money_spec.rb
|
206
|
+
- spec/mws/apis/feeds/price_listing_spec.rb
|
207
|
+
- spec/mws/apis/feeds/product_spec.rb
|
208
|
+
- spec/mws/apis/feeds/shipping_spec.rb
|
209
|
+
- spec/mws/apis/feeds/submission_info_spec.rb
|
210
|
+
- spec/mws/apis/feeds/submission_result_spec.rb
|
211
|
+
- spec/mws/apis/feeds/transaction_spec.rb
|
212
|
+
- spec/mws/apis/feeds/weight_spec.rb
|
213
|
+
- spec/mws/apis/orders_spec.rb
|
214
|
+
- spec/mws/connection_spec.rb
|
215
|
+
- spec/mws/enum_spec.rb
|
216
|
+
- spec/mws/query_spec.rb
|
217
|
+
- spec/mws/serializer_spec.rb
|
218
|
+
- spec/mws/signer_spec.rb
|
219
|
+
- spec/mws/utils_spec.rb
|
220
|
+
- spec/spec_helper.rb
|