peddler 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -11
- data/lib/mws/fulfillment_outbound_shipment/client.rb +1 -1
- data/lib/mws/reports/client.rb +1 -1
- data/lib/peddler/client.rb +17 -5
- data/lib/peddler/version.rb +1 -1
- data/test/unit/peddler/test_client.rb +20 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7ac83135cc31198b41fceb4be3028d9944e702a
|
4
|
+
data.tar.gz: 5a48846777e07c4eb00cd068a81ca08586074a25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff2c5463b8af1784df36c2040f1f149b8c80d9c0dc4f57ec2a1ed3a9550c72d3e9a9725a3c09061458ef33abb0bce0b7be30ad6bbbcddaf7c1c5a11a9a3c58a7
|
7
|
+
data.tar.gz: 9148086d4d91c67a83be7a999da65dd492b6db60d08c704ce58286fff11f7a25e73cbddd477b25957a42f329b15b4459c1e3df11590f39239554268d34ff9b0d
|
data/README.md
CHANGED
@@ -11,33 +11,40 @@ To use Amazon MWS, you must have an eligible seller account.
|
|
11
11
|
|
12
12
|
![Peddler](http://f.cl.ly/items/231z2m0r1Q2o2q1n0w1N/peddler.jpg)
|
13
13
|
|
14
|
-
##
|
14
|
+
## Scope
|
15
15
|
|
16
|
-
|
16
|
+
**Peddler** maps one on one to the MWS APIs and their various operations. It treats required request parameters as ordinary arguments and optional ones as keyword arguments. It parses XML responses with [**MultiXml**](https://github.com/sferik/multi_xml), which helps cast the result nodes into Ruby Hashes. Tab-delimited files are handled with Standard Library's [**CSV**](https://github.com/ruby/ruby/blob/trunk/lib/csv.rb).
|
17
|
+
|
18
|
+
Further abstraction is not in the scope of this project. See [**MWS Orders**](https://github.com/hakanensari/mws-orders) for a richer interface to the same-named API, built on **Peddler**.
|
19
|
+
|
20
|
+
## Quick Start
|
17
21
|
|
18
22
|
```ruby
|
19
23
|
require 'peddler'
|
24
|
+
|
20
25
|
client = MWS.orders
|
26
|
+
parser = client.list_orders(created_after: 1.month.ago)
|
27
|
+
parser.parse
|
21
28
|
```
|
22
29
|
|
23
30
|
You can set up credentials when instantiating:
|
24
31
|
|
25
32
|
```ruby
|
26
33
|
client = MWS.orders(
|
27
|
-
marketplace_id:
|
28
|
-
merchant_id:
|
29
|
-
aws_access_key_id:
|
30
|
-
aws_secret_access_key:
|
34
|
+
marketplace_id: "YOUR_MARKETPLACE_ID",
|
35
|
+
merchant_id: "YOUR_MERCHANT_ID",
|
36
|
+
aws_access_key_id: "YOUR_AWS_ACCESS_KEY_ID",
|
37
|
+
aws_secret_access_key: "YOUR_AWS_SECRET_ACCESS_KEY"
|
31
38
|
)
|
32
39
|
```
|
33
40
|
|
34
|
-
Alternatively, use environment variables if you only have a single set of credentials:
|
41
|
+
Alternatively, you can use environment variables if you only have a single set of credentials:
|
35
42
|
|
36
43
|
```sh
|
37
|
-
export MWS_MARKETPLACE_ID=
|
38
|
-
export MWS_MERCHANT_ID=
|
39
|
-
export AWS_ACCESS_KEY_ID=
|
40
|
-
export AWS_SECRET_ACCESS_KEY=
|
44
|
+
export MWS_MARKETPLACE_ID=YOUR_MARKETPLACE_ID
|
45
|
+
export MWS_MERCHANT_ID=YOUR_MERCHANT_ID
|
46
|
+
export AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY_ID
|
47
|
+
export AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY
|
41
48
|
```
|
42
49
|
|
43
50
|
## Usage
|
@@ -142,7 +142,7 @@ module MWS
|
|
142
142
|
# Returns delivery tracking information for a package in an outbound
|
143
143
|
# shipment for a Multi-Channel Fulfillment order
|
144
144
|
def get_package_tracking_details
|
145
|
-
|
145
|
+
raise NotImplementedError
|
146
146
|
end
|
147
147
|
|
148
148
|
# Requests that Amazon stop attempting to fulfill an existing fulfillment
|
data/lib/mws/reports/client.rb
CHANGED
@@ -186,7 +186,7 @@ module MWS
|
|
186
186
|
# @see http://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportScheduleListByNextToken.html
|
187
187
|
# @raise [NotImplementedError]
|
188
188
|
def get_report_schedule_list_by_next_token(*)
|
189
|
-
|
189
|
+
raise NotImplementedError
|
190
190
|
end
|
191
191
|
|
192
192
|
# Count scheduled reports
|
data/lib/peddler/client.rb
CHANGED
@@ -23,13 +23,21 @@ module Peddler
|
|
23
23
|
}
|
24
24
|
|
25
25
|
attr_accessor :path
|
26
|
-
attr_writer :merchant_id, :marketplace_id
|
26
|
+
attr_writer :merchant_id, :marketplace_id
|
27
27
|
attr_reader :body
|
28
28
|
|
29
29
|
alias_method :configure, :tap
|
30
30
|
|
31
31
|
params('SellerId' => -> { merchant_id })
|
32
32
|
|
33
|
+
def self.parser
|
34
|
+
@parser ||= Parser
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.parser=(parser)
|
38
|
+
@parser = parser
|
39
|
+
end
|
40
|
+
|
33
41
|
def self.path(path = nil)
|
34
42
|
path ? @path = path : @path ||= '/'
|
35
43
|
end
|
@@ -54,8 +62,8 @@ module Peddler
|
|
54
62
|
@merchant_id ||= ENV['MWS_MERCHANT_ID']
|
55
63
|
end
|
56
64
|
|
57
|
-
def
|
58
|
-
@
|
65
|
+
def defaults
|
66
|
+
@defaults ||= { expects: 200 }
|
59
67
|
end
|
60
68
|
|
61
69
|
def headers
|
@@ -72,7 +80,7 @@ module Peddler
|
|
72
80
|
end
|
73
81
|
|
74
82
|
def run(&blk)
|
75
|
-
opts =
|
83
|
+
opts = defaults.merge(query: operation, headers: headers)
|
76
84
|
opts.store(:body, body) if body
|
77
85
|
opts.store(:response_block, blk) if block_given?
|
78
86
|
res = post(opts)
|
@@ -103,11 +111,15 @@ module Peddler
|
|
103
111
|
end
|
104
112
|
|
105
113
|
def host
|
106
|
-
HOSTS.fetch(marketplace_id) {
|
114
|
+
HOSTS.fetch(marketplace_id) { raise BadMarketplaceId }
|
107
115
|
end
|
108
116
|
|
109
117
|
def extract_options(args)
|
110
118
|
args.last.is_a?(Hash) ? args.pop : {}
|
111
119
|
end
|
120
|
+
|
121
|
+
def parser
|
122
|
+
self.class.parser
|
123
|
+
end
|
112
124
|
end
|
113
125
|
end
|
data/lib/peddler/version.rb
CHANGED
@@ -13,14 +13,12 @@ class TestPeddlerClient < MiniTest::Test
|
|
13
13
|
Excon.stub({}, body: @body, status: 200)
|
14
14
|
|
15
15
|
@klass = Class.new(Peddler::Client)
|
16
|
+
@klass.parser = Parser
|
16
17
|
@client = @klass.new
|
17
|
-
|
18
18
|
@client.aws_access_key_id = 'key'
|
19
19
|
@client.aws_secret_access_key = 'secret'
|
20
20
|
@client.merchant_id = 'seller'
|
21
21
|
@client.marketplace_id = 'ATVPDKIKX0DER' # US
|
22
|
-
@client.parser = Parser
|
23
|
-
|
24
22
|
@client.operation('Foo')
|
25
23
|
end
|
26
24
|
|
@@ -116,4 +114,23 @@ class TestPeddlerClient < MiniTest::Test
|
|
116
114
|
|
117
115
|
assert_equal @body, chunks
|
118
116
|
end
|
117
|
+
|
118
|
+
def test_request_preserves_user_agent
|
119
|
+
instrumentor = Class.new
|
120
|
+
class << instrumentor
|
121
|
+
attr_accessor :events
|
122
|
+
|
123
|
+
def instrument(name, params = {})
|
124
|
+
events.update(name => params)
|
125
|
+
yield if block_given?
|
126
|
+
end
|
127
|
+
end
|
128
|
+
instrumentor.events = {}
|
129
|
+
|
130
|
+
@client.defaults.update(instrumentor: instrumentor)
|
131
|
+
@client.run
|
132
|
+
headers = instrumentor.events['excon.request'][:headers]
|
133
|
+
|
134
|
+
assert headers.has_key?('User-Agent')
|
135
|
+
end
|
119
136
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peddler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeff
|