peddler 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +14 -57
- data/lib/peddler.rb +1 -6
- data/lib/peddler/apis.rb +45 -0
- data/lib/peddler/service.rb +34 -65
- data/lib/peddler/version.rb +1 -1
- data/test/service_test.rb +21 -0
- data/test/test_helper.rb +3 -0
- metadata +32 -22
- data/lib/peddler/feeds.rb +0 -7
- data/lib/peddler/fulfillment_inbound_shipment.rb +0 -11
- data/lib/peddler/fulfillment_inventory.rb +0 -10
- data/lib/peddler/fulfillment_outbound_shipment.rb +0 -10
- data/lib/peddler/orders.rb +0 -9
- data/lib/peddler/products.rb +0 -11
- data/lib/peddler/reports.rb +0 -7
- data/lib/peddler/sellers.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc50fce63ad3d1352ca442c1d29dcabb2f5ba5d
|
4
|
+
data.tar.gz: 72703e47d8dd0f04c1c96d5c754c3d8217183599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d48814cee3986c8d9168bdf1a60ca128a5c1edcd81207c611b31286f1539343628ca0f99a94b29fd334491893f3016c9936595fe085dee781ad39cb27352a69
|
7
|
+
data.tar.gz: c8bee181bbb23d6906e15206a845535e09f1c99b7aab3954d63dcb4ddcffd35da712e8f5b2055f7613122f7a5faf2fce5bcc1f36d41547a7e40479adb7c1e5da
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,65 +1,22 @@
|
|
1
1
|
# Peddler
|
2
2
|
|
3
|
-
|
3
|
+
![Peddler][1]
|
4
4
|
|
5
|
-
|
5
|
+
Peddler provides a light-weight wrapper around the [Amazon Marketplace Web
|
6
|
+
Service (MWS) APIs][2].
|
6
7
|
|
7
|
-
|
8
|
+
## Usage
|
8
9
|
|
9
10
|
```ruby
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
client = Peddler::Products.new('US', 'aws_key', 'aws_secret, 'seller_id')
|
12
|
+
params = {
|
13
|
+
'Marketplace' => client.marketplace_id('US'),
|
14
|
+
'Action' => 'ListMatchingProducts',
|
15
|
+
'Query' => 'Architecture'
|
16
|
+
}
|
17
|
+
|
18
|
+
res = client.get(query: params)
|
17
19
|
```
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
The Feeds API lets you upload inventory and order data to Amazon.
|
22
|
-
|
23
|
-
## Fulfillment Inbound Shipment
|
24
|
-
|
25
|
-
With the Fulfillment Inbound Shipment API, you can create and update inbound
|
26
|
-
shipments of inventory in the Amazon Fulfillment Network. You can also request
|
27
|
-
lists of inbound shipments or inbound shipment items based on criteria that you
|
28
|
-
specify.
|
29
|
-
|
30
|
-
## Fulfillment Inventory
|
31
|
-
|
32
|
-
The Fulfillment Inventory API lets you see what is available in your inventory.
|
33
|
-
It's a real-time reporting mechanism that returns your current or
|
34
|
-
recently-changed inventory supply in the Amazon fulfillment network.
|
35
|
-
|
36
|
-
## Fulfillment Outbound Shipment
|
37
|
-
|
38
|
-
The Fulfillment Outbound Shipment API is designed to help you integrate
|
39
|
-
Fulfillment by Amazon with any payment processing application or inventory
|
40
|
-
management system currently in use.
|
41
|
-
|
42
|
-
## Orders
|
43
|
-
|
44
|
-
The Orders API helps you build simple applications that retrieve only the order
|
45
|
-
information that you need.
|
46
|
-
|
47
|
-
## Products
|
48
|
-
|
49
|
-
The Products API helps you get information to match your products to existing
|
50
|
-
product listings on Amazon Marketplace websites and to make sourcing and
|
51
|
-
pricing decisions for listing those products on Amazon Marketplace websites.
|
52
|
-
|
53
|
-
## Reports
|
54
|
-
|
55
|
-
The Reports API lets you request reports about your inventory and orders.
|
56
|
-
|
57
|
-
## Sellers
|
58
|
-
|
59
|
-
The Sellers API lets sellers retrieve information about their seller account,
|
60
|
-
such as the marketplaces they participate in.
|
61
|
-
|
62
|
-
[1]: https://secure.travis-ci.org/papercavalier/peddler.png
|
63
|
-
[2]: http://travis-ci.org/papercavalier/peddler
|
64
|
-
[3]: http://f.cl.ly/items/0W3V0A1Z110Q0x461b3H/mussels.jpeg
|
65
|
-
[4]: https://developer.amazonservices.com/gp/mws/docs.html
|
21
|
+
[1]: http://f.cl.ly/items/0W3V0A1Z110Q0x461b3H/mussels.jpeg
|
22
|
+
[2]: https://developer.amazonservices.com/gp/mws/docs.html
|
data/lib/peddler.rb
CHANGED
data/lib/peddler/apis.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'peddler/service'
|
2
|
+
|
3
|
+
module Peddler
|
4
|
+
class Feeds < Service
|
5
|
+
end
|
6
|
+
|
7
|
+
class FulfillmentInboundShipment < Service
|
8
|
+
path 'FulfillmentInboundShipment/2010-10-01'
|
9
|
+
end
|
10
|
+
|
11
|
+
class FulfillmentInventory < Service
|
12
|
+
path 'FulfillmentInventory/2010-10-01'
|
13
|
+
end
|
14
|
+
|
15
|
+
class FulfillmentOutboundShipment < Service
|
16
|
+
path 'FulfillmentOutboundShipment/2010-10-01'
|
17
|
+
end
|
18
|
+
|
19
|
+
class OffAmazonPayments < Service
|
20
|
+
path 'OffAmazonPayments/2013-01-01/'
|
21
|
+
end
|
22
|
+
|
23
|
+
class Orders < Service
|
24
|
+
path 'Orders/2011-01-01'
|
25
|
+
end
|
26
|
+
|
27
|
+
class Products < Service
|
28
|
+
path 'Products/2011-10-01'
|
29
|
+
end
|
30
|
+
|
31
|
+
class Recommendations < Service
|
32
|
+
path 'Recommendations/2013-04-01'
|
33
|
+
end
|
34
|
+
|
35
|
+
class Reports < Service
|
36
|
+
end
|
37
|
+
|
38
|
+
class Sellers < Service
|
39
|
+
path 'Sellers/2011-07-01'
|
40
|
+
end
|
41
|
+
|
42
|
+
class Subscriptions < Service
|
43
|
+
path 'Subscriptions/2013-07-01'
|
44
|
+
end
|
45
|
+
end
|
data/lib/peddler/service.rb
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
require 'jeff'
|
2
2
|
|
3
3
|
module Peddler
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
|
4
|
+
# Service is an abstract wrapper around a Marketplace Web Services (MWS)
|
5
|
+
# endpoint.
|
6
|
+
#
|
7
|
+
# The initializer takes four arguments:
|
8
|
+
#
|
9
|
+
# country - The String ISO 3166-1 two-letter country code of
|
10
|
+
# the base marketplace of the seller.
|
11
|
+
# aws_access_key_id - The String AWS access key id.
|
12
|
+
# aws_secret_access_key - The String AWS secret access key.
|
13
|
+
# seller_id - The String MWS merchant id.
|
14
|
+
#
|
15
|
+
# These arguments are optional and can be set individually later.
|
16
|
+
Service = Struct.new(:country, :aws_access_key_id, :aws_secret_access_key, :seller_id) do
|
9
17
|
include Jeff
|
10
18
|
|
11
|
-
class << self
|
12
|
-
# Gets/Sets the path of the MWS endpoint.
|
13
|
-
#
|
14
|
-
# path - A String path (optional).
|
15
|
-
def path(path = nil)
|
16
|
-
@path = path if path
|
17
|
-
@path
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
params 'SellerId' => -> { seller }
|
22
|
-
|
23
19
|
# A list of MWS hosts.
|
24
20
|
HOSTS = {
|
25
21
|
'CA' => 'mws.amazonservices.ca',
|
@@ -27,80 +23,53 @@ module Peddler
|
|
27
23
|
'DE' => 'mws-eu.amazonservices.com',
|
28
24
|
'ES' => 'mws-eu.amazonservices.com',
|
29
25
|
'FR' => 'mws-eu.amazonservices.com',
|
26
|
+
'GB' => 'mws-eu.amazonservices.com',
|
30
27
|
'IN' => 'mws.amazonservices.in',
|
31
28
|
'IT' => 'mws-eu.amazonservices.com',
|
32
29
|
'JP' => 'mws.amazonservices.jp',
|
33
|
-
'UK' => 'mws-eu.amazonservices.com',
|
34
30
|
'US' => 'mws.amazonservices.com'
|
35
31
|
}
|
36
32
|
|
37
|
-
# A list of
|
38
|
-
|
33
|
+
# A list of marketplace ids.
|
34
|
+
MARKETPLACE_IDS = {
|
39
35
|
'CA' => 'A2EUQ1WTGCTBG2',
|
40
|
-
'CN' =>
|
36
|
+
'CN' => 'AAHKV2X7AFYLW',
|
41
37
|
'DE' => 'A1PA6795UKMFR9',
|
42
38
|
'ES' => 'A1RKKUPIHCS9HS',
|
43
39
|
'FR' => 'A13V1IB3VIYZZH',
|
44
|
-
'
|
40
|
+
'GB' => 'A1F83G8C2ARO7P',
|
41
|
+
'IN' => 'A21TJRUUN4KGV',
|
45
42
|
'IT' => 'APJ6JRA9NG5V4',
|
46
43
|
'JP' => 'A1VC38T7YXB528',
|
47
|
-
'UK' => 'A1F83G8C2ARO7P',
|
48
44
|
'US' => 'ATVPDKIKX0DER'
|
49
45
|
}
|
50
46
|
|
51
|
-
|
52
|
-
base.params(params)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Create a new service endpoint for given locale.
|
47
|
+
# Gets/Sets the path of the MWS endpoint.
|
56
48
|
#
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
def initialize(locale)
|
61
|
-
@host = HOSTS[@locale = locale] or raise BadLocale
|
49
|
+
# path - A String path (default: nil).
|
50
|
+
def self.path(path = nil)
|
51
|
+
path ? @path = path : @path
|
62
52
|
end
|
63
53
|
|
64
|
-
#
|
65
|
-
|
66
|
-
|
67
|
-
# :key - The String Amazon Web Services (AWS) key.
|
68
|
-
# :secret - The String AWS secret.
|
69
|
-
# :seller - The String MWS Seller Id.
|
70
|
-
#
|
71
|
-
# Returns nothing.
|
72
|
-
def configure(credentials)
|
73
|
-
credentials.each { |key, val| self.send("#{key}=", val) }
|
54
|
+
# So that subclasses can continue adding their params.
|
55
|
+
def self.inherited(base)
|
56
|
+
base.params(params)
|
74
57
|
end
|
75
58
|
|
59
|
+
params('SellerId' => -> { seller_id })
|
60
|
+
|
76
61
|
# Returns the String MWS endpoint.
|
77
62
|
def endpoint
|
78
|
-
"https://#{
|
63
|
+
"https://#{HOSTS.fetch(country)}/#{self.class.path}"
|
79
64
|
end
|
80
65
|
|
81
|
-
#
|
66
|
+
# Get the marketplace id for a given country.
|
82
67
|
#
|
83
|
-
#
|
84
|
-
# endpoint).
|
85
|
-
def marketplace(locale = nil)
|
86
|
-
MARKETPLACES[locale || @locale] or raise BadLocale
|
87
|
-
end
|
88
|
-
|
89
|
-
# Gets the String MWS seller id.
|
68
|
+
# country - A String ISO 3166-1 two-letter country code.
|
90
69
|
#
|
91
|
-
#
|
92
|
-
def
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
# Sets the String MWS seller id.
|
97
|
-
attr_writer :seller
|
98
|
-
|
99
|
-
# Gets the String service status.
|
100
|
-
def status
|
101
|
-
get(query: { 'Action' => 'GetServiceStatus' })
|
102
|
-
.body
|
103
|
-
.match(/GREEN_?I?|YELLOW|RED/)[0]
|
70
|
+
# Returns a String marketplace id.
|
71
|
+
def marketplace_id(country)
|
72
|
+
MARKETPLACE_IDS.fetch(country)
|
104
73
|
end
|
105
74
|
end
|
106
75
|
end
|
data/lib/peddler/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class ServiceTest < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@klass = Class.new(Peddler::Service)
|
6
|
+
@service = @klass.new('US', 'key', 'secret', 'seller_id')
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_configures_path
|
10
|
+
@klass.path('Foo')
|
11
|
+
assert @service.endpoint.match(/Foo$/)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_has_user_agent
|
15
|
+
refute @service.connection.data[:headers].empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_gets_marketplace_ids
|
19
|
+
refute_equal @service.marketplace_id('US'), @service.marketplace_id('GB')
|
20
|
+
end
|
21
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,18 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peddler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
8
|
-
- Ezekiel Templin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: jeff
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
17
30
|
requirements:
|
18
31
|
- - '>='
|
@@ -26,39 +39,34 @@ dependencies:
|
|
26
39
|
- !ruby/object:Gem::Version
|
27
40
|
version: '0'
|
28
41
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
42
|
+
name: rake
|
30
43
|
requirement: !ruby/object:Gem::Requirement
|
31
44
|
requirements:
|
32
|
-
- -
|
45
|
+
- - '>='
|
33
46
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0
|
35
|
-
type: :
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
36
49
|
prerelease: false
|
37
50
|
version_requirements: !ruby/object:Gem::Requirement
|
38
51
|
requirements:
|
39
|
-
- -
|
52
|
+
- - '>='
|
40
53
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0
|
42
|
-
description: A wrapper to the Amazon Marketplace Web Service (MWS) API
|
54
|
+
version: '0'
|
55
|
+
description: A light-weight wrapper to the Amazon Marketplace Web Service (MWS) API
|
43
56
|
email:
|
44
|
-
-
|
57
|
+
- hakan.ensari@papercavalier.com
|
45
58
|
executables: []
|
46
59
|
extensions: []
|
47
60
|
extra_rdoc_files: []
|
48
61
|
files:
|
49
|
-
- lib/peddler/
|
50
|
-
- lib/peddler/fulfillment_inbound_shipment.rb
|
51
|
-
- lib/peddler/fulfillment_inventory.rb
|
52
|
-
- lib/peddler/fulfillment_outbound_shipment.rb
|
53
|
-
- lib/peddler/orders.rb
|
54
|
-
- lib/peddler/products.rb
|
55
|
-
- lib/peddler/reports.rb
|
56
|
-
- lib/peddler/sellers.rb
|
62
|
+
- lib/peddler/apis.rb
|
57
63
|
- lib/peddler/service.rb
|
58
64
|
- lib/peddler/version.rb
|
59
65
|
- lib/peddler.rb
|
60
66
|
- LICENSE
|
61
67
|
- README.md
|
68
|
+
- test/service_test.rb
|
69
|
+
- test/test_helper.rb
|
62
70
|
homepage: http://github.com/papercavalier/peddler
|
63
71
|
licenses: []
|
64
72
|
metadata: {}
|
@@ -78,8 +86,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
86
|
version: '0'
|
79
87
|
requirements: []
|
80
88
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.0.
|
89
|
+
rubygems_version: 2.0.5
|
82
90
|
signing_key:
|
83
91
|
specification_version: 4
|
84
92
|
summary: Wraps the Amazon Marketplace Web Service API
|
85
|
-
test_files:
|
93
|
+
test_files:
|
94
|
+
- test/service_test.rb
|
95
|
+
- test/test_helper.rb
|
data/lib/peddler/feeds.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'peddler/service'
|
2
|
-
|
3
|
-
# With the Fulfillment Inbound Shipment API, you can create and update inbound
|
4
|
-
# shipments of inventory in the Amazon Fulfillment Network. You can also
|
5
|
-
# request lists of inbound shipments or inbound shipment items based on
|
6
|
-
# criteria that you specify.
|
7
|
-
module Peddler
|
8
|
-
class FulfillmentInboundShipment < Service
|
9
|
-
path 'FulfillmentInboundShipment/2010-10-01'
|
10
|
-
end
|
11
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'peddler/service'
|
2
|
-
|
3
|
-
module Peddler
|
4
|
-
# The Fulfillment Inventory API lets you see what is available in your
|
5
|
-
# inventory. It's a real-time reporting mechanism that returns your current
|
6
|
-
# or recently-changed inventory supply in the Amazon fulfillment network.
|
7
|
-
class FulfillmentInventory < Service
|
8
|
-
path 'FulfillmentInventory/2010-10-01'
|
9
|
-
end
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'peddler/service'
|
2
|
-
|
3
|
-
module Peddler
|
4
|
-
# The Fulfillment Outbound Shipment API is designed to help you integrate
|
5
|
-
# Fulfillment by Amazon with any payment processing application or inventory
|
6
|
-
# management system currently in use.
|
7
|
-
class FulfillmentOutboundShipment < Service
|
8
|
-
path 'FulfillmentOutboundShipment/2010-10-01'
|
9
|
-
end
|
10
|
-
end
|
data/lib/peddler/orders.rb
DELETED
data/lib/peddler/products.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'peddler/service'
|
2
|
-
|
3
|
-
module Peddler
|
4
|
-
# The Products API helps you get information to match your products to
|
5
|
-
# existing product listings on Amazon Marketplace websites and to make
|
6
|
-
# sourcing and pricing decisions for listing those products on Amazon
|
7
|
-
# Marketplace websites.
|
8
|
-
class Products < Service
|
9
|
-
path 'Products/2011-10-01'
|
10
|
-
end
|
11
|
-
end
|
data/lib/peddler/reports.rb
DELETED
data/lib/peddler/sellers.rb
DELETED