amazon_mws_products 0.0.1 → 0.0.2

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 CHANGED
@@ -4,8 +4,6 @@ A client for the AmazonMWS Products API as defined by:
4
4
 
5
5
  https://images-na.ssl-images-amazon.com/images/G/01/mwsportal/doc/en_US/products/MWSProductsApiReference._V388666043_.pdf
6
6
 
7
- TODO: Write a gem description
8
-
9
7
  ## Installation
10
8
 
11
9
  Add this line to your application's Gemfile:
@@ -22,7 +20,19 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ```ruby
24
+ require 'amazon_mws_products'
25
+ require 'ostruct'
26
+
27
+ account = OpenStruct.new(seller_id: "your mws seller id",
28
+ aws_access_key_id: "your mws access key",
29
+ marketplace_id: "the marketplace id",
30
+ secret_access_key: "your secret access key")
31
+
32
+ client = AmazonMwsProducts::ListMatchingProducts.new(account, "harry potter dvd")
33
+ response = client.execute # response body will be a Nokogiri::XML::Document
34
+ puts response.body.to_xml
35
+ ```
26
36
 
27
37
  ## Contributing
28
38
 
data/TODO.md ADDED
@@ -0,0 +1,3 @@
1
+ * Create an actual Account class
2
+ * Probably create a configuration block syntax
3
+ * Add ability for users to configure Faraday options
@@ -1,14 +1,17 @@
1
1
  module AmazonMwsProducts
2
2
  class ListMatchingProducts
3
- attr_reader :account, :query
3
+ attr_reader :account, :query, :query_context_id
4
4
 
5
- def initialize(account, query)
5
+ def initialize(account, query, query_context_id = nil)
6
6
  @account = account
7
7
  @query = query
8
+ @query_context_id = query_context_id
8
9
  end
9
10
 
10
11
  def execute
11
- client.get("Query" => URI.encode(query))
12
+ params = { "Query" => URI.encode(query) }
13
+ params["QueryContextId"] = query_context_id if query_context_id
14
+ client.get(params)
12
15
  end
13
16
 
14
17
  def client
@@ -1,3 +1,3 @@
1
1
  module AmazonMwsProducts
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -38,6 +38,19 @@ module AmazonMwsProducts
38
38
  end
39
39
  end
40
40
 
41
+ context "query context id included in request" do
42
+ subject { ListMatchingProducts.new(account, query, "Toys") }
43
+ it "adds the proper query parameter" do
44
+ subject.execute
45
+
46
+ a_request(:get, "https://mws.amazonservices.com/Products/2011-10-01").
47
+ with(:query => hash_including(
48
+ "Query" => "harry%20potter%20dvd",
49
+ "QueryContextId" => "Toys"
50
+ )).should have_been_made.once
51
+ end
52
+ end
53
+
41
54
  it "signs the request" do
42
55
  Timecop.freeze(DateTime.new(2012, 3, 14, 15, 9, 26, Rational(-7,24))) do
43
56
  subject.execute
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: amazon_mws_products
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Donald Plummer
@@ -172,6 +172,7 @@ files:
172
172
  - LICENSE.txt
173
173
  - README.md
174
174
  - Rakefile
175
+ - TODO.md
175
176
  - amazon_mws_products.gemspec
176
177
  - examples/list_matching_products.rb
177
178
  - lib/amazon_mws_products.rb