amazon_mws_products 0.0.2 → 0.0.3
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 +3 -1
- data/lib/amazon_mws_products/get_matching_products.rb +3 -3
- data/lib/amazon_mws_products/list_matching_products.rb +4 -4
- data/lib/amazon_mws_products/version.rb +1 -1
- data/spec/amazon_mws_products/get_matching_products_spec.rb +5 -1
- data/spec/amazon_mws_products/list_matching_products_spec.rb +11 -2
- metadata +1 -1
data/README.md
CHANGED
@@ -29,7 +29,9 @@ account = OpenStruct.new(seller_id: "your mws seller id",
|
|
29
29
|
marketplace_id: "the marketplace id",
|
30
30
|
secret_access_key: "your secret access key")
|
31
31
|
|
32
|
-
client = AmazonMwsProducts::ListMatchingProducts.new(account,
|
32
|
+
client = AmazonMwsProducts::ListMatchingProducts.new(account: account,
|
33
|
+
query: "star wars",
|
34
|
+
query_context_id: "Toys")
|
33
35
|
response = client.execute # response body will be a Nokogiri::XML::Document
|
34
36
|
puts response.body.to_xml
|
35
37
|
```
|
@@ -2,9 +2,9 @@ module AmazonMwsProducts
|
|
2
2
|
class GetMatchingProducts
|
3
3
|
attr_reader :account, :asins
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@account = account
|
7
|
-
@asins
|
5
|
+
def initialize(options)
|
6
|
+
@account = options.fetch(:account)
|
7
|
+
@asins = options.fetch(:asins)
|
8
8
|
end
|
9
9
|
|
10
10
|
def execute
|
@@ -2,10 +2,10 @@ module AmazonMwsProducts
|
|
2
2
|
class ListMatchingProducts
|
3
3
|
attr_reader :account, :query, :query_context_id
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@account
|
7
|
-
@query
|
8
|
-
@query_context_id = query_context_id
|
5
|
+
def initialize(options)
|
6
|
+
@account = options.fetch(:account)
|
7
|
+
@query = options.fetch(:query)
|
8
|
+
@query_context_id = options[:query_context_id]
|
9
9
|
end
|
10
10
|
|
11
11
|
def execute
|
@@ -11,7 +11,11 @@ module AmazonMwsProducts
|
|
11
11
|
|
12
12
|
let(:asins) {%w{B002QYOP72 B009AWSLFK B008BV6XA6}}
|
13
13
|
|
14
|
-
|
14
|
+
let(:options) {{
|
15
|
+
account: account,
|
16
|
+
asins: asins
|
17
|
+
}}
|
18
|
+
subject { GetMatchingProducts.new(options) }
|
15
19
|
|
16
20
|
before(:each) do
|
17
21
|
stub_request(:get, %r{^https://mws.amazonservices.com/Products/2011-10-01}).
|
@@ -10,8 +10,12 @@ module AmazonMwsProducts
|
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:query) { "harry potter dvd" }
|
13
|
+
let(:options) {{
|
14
|
+
account: account,
|
15
|
+
query: query
|
16
|
+
}}
|
13
17
|
|
14
|
-
subject { ListMatchingProducts.new(
|
18
|
+
subject { ListMatchingProducts.new(options) }
|
15
19
|
|
16
20
|
before(:each) do
|
17
21
|
stub_request(:get, %r{^https://mws.amazonservices.com/Products/2011-10-01}).
|
@@ -39,7 +43,12 @@ module AmazonMwsProducts
|
|
39
43
|
end
|
40
44
|
|
41
45
|
context "query context id included in request" do
|
42
|
-
|
46
|
+
let(:options) {{
|
47
|
+
account: account,
|
48
|
+
query: query,
|
49
|
+
query_context_id: "Toys"
|
50
|
+
}}
|
51
|
+
|
43
52
|
it "adds the proper query parameter" do
|
44
53
|
subject.execute
|
45
54
|
|