mws-rb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +73 -0
- data/Guardfile +8 -0
- data/LICENSE +20 -0
- data/README.markdown +90 -0
- data/Rakefile +1 -0
- data/lib/mws-rb.rb +50 -0
- data/lib/mws-rb/api/base.rb +48 -0
- data/lib/mws-rb/api/feeds.rb +29 -0
- data/lib/mws-rb/api/feeds/envelope.rb +61 -0
- data/lib/mws-rb/api/feeds/xsd/AdditionalProductInformation.xsd +23 -0
- data/lib/mws-rb/api/feeds/xsd/Amazon.xsd +94 -0
- data/lib/mws-rb/api/feeds/xsd/Arts.xsd +144 -0
- data/lib/mws-rb/api/feeds/xsd/AutoAccessory.xsd +1714 -0
- data/lib/mws-rb/api/feeds/xsd/Baby.xsd +206 -0
- data/lib/mws-rb/api/feeds/xsd/Beauty.xsd +170 -0
- data/lib/mws-rb/api/feeds/xsd/Books.xsd +135 -0
- data/lib/mws-rb/api/feeds/xsd/CE.xsd +2878 -0
- data/lib/mws-rb/api/feeds/xsd/CameraPhoto.xsd +2612 -0
- data/lib/mws-rb/api/feeds/xsd/ClothingAccessories.xsd +128 -0
- data/lib/mws-rb/api/feeds/xsd/Computers.xsd +2347 -0
- data/lib/mws-rb/api/feeds/xsd/EUCompliance.xsd +24 -0
- data/lib/mws-rb/api/feeds/xsd/EntertainmentCollectibles.xsd +99 -0
- data/lib/mws-rb/api/feeds/xsd/FBA.xsd +28 -0
- data/lib/mws-rb/api/feeds/xsd/FoodAndBeverages.xsd +1000 -0
- data/lib/mws-rb/api/feeds/xsd/FoodServiceAndJanSan.xsd +216 -0
- data/lib/mws-rb/api/feeds/xsd/FulfillmentCenter.xsd +57 -0
- data/lib/mws-rb/api/feeds/xsd/GiftCards.xsd +97 -0
- data/lib/mws-rb/api/feeds/xsd/Gourmet.xsd +85 -0
- data/lib/mws-rb/api/feeds/xsd/Health.xsd +335 -0
- data/lib/mws-rb/api/feeds/xsd/Home.xsd +1362 -0
- data/lib/mws-rb/api/feeds/xsd/HomeImprovement.xsd +1065 -0
- data/lib/mws-rb/api/feeds/xsd/Industrial.xsd +315 -0
- data/lib/mws-rb/api/feeds/xsd/Inventory.xsd +49 -0
- data/lib/mws-rb/api/feeds/xsd/Jewelry.xsd +916 -0
- data/lib/mws-rb/api/feeds/xsd/LabSupplies.xsd +178 -0
- data/lib/mws-rb/api/feeds/xsd/LargeAppliances.xsd +646 -0
- data/lib/mws-rb/api/feeds/xsd/Lighting.xsd +243 -0
- data/lib/mws-rb/api/feeds/xsd/Listings.xsd +32 -0
- data/lib/mws-rb/api/feeds/xsd/Luggage.xsd +93 -0
- data/lib/mws-rb/api/feeds/xsd/MechanicalFasteners.xsd +172 -0
- data/lib/mws-rb/api/feeds/xsd/Miscellaneous.xsd +157 -0
- data/lib/mws-rb/api/feeds/xsd/Motorcycles.xsd +348 -0
- data/lib/mws-rb/api/feeds/xsd/Music.xsd +251 -0
- data/lib/mws-rb/api/feeds/xsd/MusicalInstruments.xsd +853 -0
- data/lib/mws-rb/api/feeds/xsd/Office.xsd +586 -0
- data/lib/mws-rb/api/feeds/xsd/OrderAcknowledgement.xsd +55 -0
- data/lib/mws-rb/api/feeds/xsd/OrderAdjustment.xsd +175 -0
- data/lib/mws-rb/api/feeds/xsd/OrderFulfillment.xsd +57 -0
- data/lib/mws-rb/api/feeds/xsd/Override.xsd +48 -0
- data/lib/mws-rb/api/feeds/xsd/PetSupplies.xsd +197 -0
- data/lib/mws-rb/api/feeds/xsd/PowerTransmission.xsd +87 -0
- data/lib/mws-rb/api/feeds/xsd/Price.xsd +59 -0
- data/lib/mws-rb/api/feeds/xsd/ProcessingReport.xsd +87 -0
- data/lib/mws-rb/api/feeds/xsd/Product.xsd +399 -0
- data/lib/mws-rb/api/feeds/xsd/ProductClothing.xsd +285 -0
- data/lib/mws-rb/api/feeds/xsd/ProductImage.xsd +39 -0
- data/lib/mws-rb/api/feeds/xsd/RawMaterials.xsd +125 -0
- data/lib/mws-rb/api/feeds/xsd/Relationship.xsd +47 -0
- data/lib/mws-rb/api/feeds/xsd/SWVG.xsd +345 -0
- data/lib/mws-rb/api/feeds/xsd/SettlementReport.xsd +158 -0
- data/lib/mws-rb/api/feeds/xsd/Shoes.xsd +213 -0
- data/lib/mws-rb/api/feeds/xsd/Sports.xsd +772 -0
- data/lib/mws-rb/api/feeds/xsd/SportsMemorabilia.xsd +55 -0
- data/lib/mws-rb/api/feeds/xsd/TiresAndWheels.xsd +159 -0
- data/lib/mws-rb/api/feeds/xsd/Tools.xsd +82 -0
- data/lib/mws-rb/api/feeds/xsd/Toys.xsd +272 -0
- data/lib/mws-rb/api/feeds/xsd/ToysBaby.xsd +335 -0
- data/lib/mws-rb/api/feeds/xsd/Video.xsd +406 -0
- data/lib/mws-rb/api/feeds/xsd/WineAndAlcohol.xsd +181 -0
- data/lib/mws-rb/api/feeds/xsd/Wireless.xsd +128 -0
- data/lib/mws-rb/api/feeds/xsd/amzn-base.xsd +4350 -0
- data/lib/mws-rb/api/feeds/xsd/amzn-envelope.xsd +98 -0
- data/lib/mws-rb/api/feeds/xsd/amzn-header.xsd +45 -0
- data/lib/mws-rb/api/fulfillment_inbound_shipment.rb +15 -0
- data/lib/mws-rb/api/fulfillment_inventory.rb +13 -0
- data/lib/mws-rb/api/fulfillment_outbound_shipment.rb +11 -0
- data/lib/mws-rb/api/orders.rb +15 -0
- data/lib/mws-rb/api/products.rb +18 -0
- data/lib/mws-rb/api/recommendations.rb +13 -0
- data/lib/mws-rb/api/reports.rb +16 -0
- data/lib/mws-rb/api/sellers.rb +14 -0
- data/lib/mws-rb/connection.rb +53 -0
- data/lib/mws-rb/query.rb +94 -0
- data/lib/mws-rb/version.rb +3 -0
- data/mws-rb.gemspec +28 -0
- data/spec/mws-rb/api/base_spec.rb +51 -0
- data/spec/mws-rb/api/feeds/envelope_spec.rb +29 -0
- data/spec/mws-rb/api/feeds_spec.rb +23 -0
- data/spec/mws-rb/api/fulfillment_inbound_shipment_spec.rb +23 -0
- data/spec/mws-rb/api/fulfillment_inventory_spec.rb +23 -0
- data/spec/mws-rb/api/fulfillment_outbound_shipment_spec.rb +23 -0
- data/spec/mws-rb/api/orders_spec.rb +24 -0
- data/spec/mws-rb/api/products_spec.rb +24 -0
- data/spec/mws-rb/api/recommendations_spec.rb +24 -0
- data/spec/mws-rb/api/reports_spec.rb +24 -0
- data/spec/mws-rb/api/sellers_spec.rb +28 -0
- data/spec/mws-rb/connection_spec.rb +58 -0
- data/spec/mws-rb/mws_spec.rb +11 -0
- data/spec/mws-rb/query_spec.rb +110 -0
- data/spec/spec_helper.rb +7 -0
- metadata +260 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
tmp
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mws-rb (0.0.1)
|
5
|
+
activesupport (~> 3.0)
|
6
|
+
builder
|
7
|
+
httparty (~> 0)
|
8
|
+
nokogiri (~> 1)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (3.2.17)
|
14
|
+
i18n (~> 0.6, >= 0.6.4)
|
15
|
+
multi_json (~> 1.0)
|
16
|
+
builder (3.2.2)
|
17
|
+
coderay (1.0.9)
|
18
|
+
diff-lcs (1.2.4)
|
19
|
+
ffi (1.9.0)
|
20
|
+
formatador (0.2.4)
|
21
|
+
guard (1.8.3)
|
22
|
+
formatador (>= 0.2.4)
|
23
|
+
listen (~> 1.3)
|
24
|
+
lumberjack (>= 1.0.2)
|
25
|
+
pry (>= 0.9.10)
|
26
|
+
thor (>= 0.14.6)
|
27
|
+
guard-rspec (3.0.3)
|
28
|
+
guard (>= 1.8)
|
29
|
+
rspec (~> 2.13)
|
30
|
+
httparty (0.13.1)
|
31
|
+
json (~> 1.8)
|
32
|
+
multi_xml (>= 0.5.2)
|
33
|
+
i18n (0.6.9)
|
34
|
+
json (1.8.1)
|
35
|
+
listen (1.3.1)
|
36
|
+
rb-fsevent (>= 0.9.3)
|
37
|
+
rb-inotify (>= 0.9)
|
38
|
+
rb-kqueue (>= 0.2)
|
39
|
+
lumberjack (1.0.4)
|
40
|
+
method_source (0.8.2)
|
41
|
+
mini_portile (0.5.3)
|
42
|
+
multi_json (1.9.3)
|
43
|
+
multi_xml (0.5.5)
|
44
|
+
nokogiri (1.6.1)
|
45
|
+
mini_portile (~> 0.5.0)
|
46
|
+
pry (0.9.12.2)
|
47
|
+
coderay (~> 1.0.5)
|
48
|
+
method_source (~> 0.8)
|
49
|
+
slop (~> 3.4)
|
50
|
+
rb-fsevent (0.9.3)
|
51
|
+
rb-inotify (0.9.2)
|
52
|
+
ffi (>= 0.5.0)
|
53
|
+
rb-kqueue (0.2.0)
|
54
|
+
ffi (>= 0.5.0)
|
55
|
+
rspec (2.14.1)
|
56
|
+
rspec-core (~> 2.14.0)
|
57
|
+
rspec-expectations (~> 2.14.0)
|
58
|
+
rspec-mocks (~> 2.14.0)
|
59
|
+
rspec-core (2.14.5)
|
60
|
+
rspec-expectations (2.14.2)
|
61
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
62
|
+
rspec-mocks (2.14.3)
|
63
|
+
slop (3.4.6)
|
64
|
+
thor (0.18.1)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
ruby
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
guard
|
71
|
+
guard-rspec
|
72
|
+
mws-rb!
|
73
|
+
rspec
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
opyright (c) 2013 Jhimy Fernandes Villar
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
mws-rb
|
2
|
+
========
|
3
|
+
|
4
|
+
This gem is a complete wrapper for Amazon.com's Marketplace Web Service (MWS) API. It was extracted from http://veeqo.com
|
5
|
+
|
6
|
+
#### Installation
|
7
|
+
|
8
|
+
Using with a Gemfile:
|
9
|
+
|
10
|
+
gem 'mws-rb'
|
11
|
+
bundle install
|
12
|
+
|
13
|
+
Using in a simple ruby file:
|
14
|
+
|
15
|
+
gem install mws-rb
|
16
|
+
require 'mws-rb'
|
17
|
+
|
18
|
+
#### Initialization
|
19
|
+
|
20
|
+
mws_api = MWS.new(
|
21
|
+
host: "mws-eu.amazonservices.com",
|
22
|
+
aws_access_key_id: "Your access key id",
|
23
|
+
aws_secret_access_key: "Your secret access key",
|
24
|
+
seller_id: "Your seller/merchant id"
|
25
|
+
)
|
26
|
+
|
27
|
+
#### Using
|
28
|
+
|
29
|
+
To access the apis you can use:
|
30
|
+
mws_api._api_name_._action_to_calll(params={})
|
31
|
+
|
32
|
+
Let's say we want to retrieve a list of orders using MWS orders api:
|
33
|
+
|
34
|
+
mws_api.orders.list_orders(
|
35
|
+
"MarketplaceId.Id.1" => "marketplace id",
|
36
|
+
created_after: Time.new(2013, 1, 1)
|
37
|
+
)
|
38
|
+
|
39
|
+
Here is a list of all available APIS:
|
40
|
+
|
41
|
+
mws_api.feeds
|
42
|
+
mws_api.orders
|
43
|
+
mws_api.reports
|
44
|
+
mws_api.products
|
45
|
+
mws_api.sellers
|
46
|
+
mws_api.recommendations
|
47
|
+
mws_api.fulfillment_inventory
|
48
|
+
mws_api.fulfillment_inbound_shipment
|
49
|
+
mws_api.fulfillment_outbound_shipment
|
50
|
+
|
51
|
+
#### API docs/actions/params
|
52
|
+
|
53
|
+
You can check on the MWS documentation section all actions and params needed:
|
54
|
+
|
55
|
+
- http://docs.developer.amazonservices.com/en_US/feeds/index.html
|
56
|
+
- http://docs.developer.amazonservices.com/en_US/reports/index.html
|
57
|
+
- http://docs.developer.amazonservices.com/en_US/fba_inbound/index.html
|
58
|
+
- http://docs.developer.amazonservices.com/en_US/fba_inventory/index.html
|
59
|
+
- http://docs.developer.amazonservices.com/en_US/fba_outbound/index.html
|
60
|
+
- http://docs.developer.amazonservices.com/en_US/orders/index.html
|
61
|
+
- http://docs.developer.amazonservices.com/en_US/products/index.html
|
62
|
+
- http://docs.developer.amazonservices.com/en_US/recommendations/index.html
|
63
|
+
- http://docs.developer.amazonservices.com/en_US/sellers/index.html
|
64
|
+
|
65
|
+
## TODO
|
66
|
+
|
67
|
+
- Complete documentation.
|
68
|
+
|
69
|
+
## LICENSE
|
70
|
+
|
71
|
+
Copyright (c) Jhimy Fernandes Villar
|
72
|
+
|
73
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
74
|
+
a copy of this software and associated documentation files (the
|
75
|
+
"Software"), to deal in the Software without restriction, including
|
76
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
77
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
78
|
+
permit persons to whom the Software is furnished to do so, subject to
|
79
|
+
the following conditions:
|
80
|
+
|
81
|
+
The above copyright notice and this permission notice shall be
|
82
|
+
included in all copies or substantial portions of the Software.
|
83
|
+
|
84
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
87
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
88
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
89
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
90
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/mws-rb.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'base64'
|
3
|
+
require 'openssl'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
require 'builder'
|
6
|
+
require 'nokogiri'
|
7
|
+
|
8
|
+
require_relative 'mws-rb/query'
|
9
|
+
require_relative 'mws-rb/connection'
|
10
|
+
require_relative 'mws-rb/api/base'
|
11
|
+
require_relative 'mws-rb/api/orders'
|
12
|
+
require_relative 'mws-rb/api/reports'
|
13
|
+
require_relative 'mws-rb/api/products'
|
14
|
+
require_relative 'mws-rb/api/sellers'
|
15
|
+
require_relative 'mws-rb/api/recommendations'
|
16
|
+
require_relative 'mws-rb/api/fulfillment_inventory'
|
17
|
+
require_relative 'mws-rb/api/fulfillment_inbound_shipment'
|
18
|
+
require_relative 'mws-rb/api/fulfillment_outbound_shipment'
|
19
|
+
require_relative 'mws-rb/api/feeds'
|
20
|
+
require_relative 'mws-rb/api/feeds/envelope'
|
21
|
+
|
22
|
+
module MWS
|
23
|
+
@@aws_access_key_id = nil
|
24
|
+
@@aws_secret_access_key = nil
|
25
|
+
|
26
|
+
def self.aws_access_key_id=(key_id)
|
27
|
+
@@aws_access_key_id = key_id
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.aws_access_key_id
|
31
|
+
@@aws_access_key_id
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.aws_secret_access_key=(secret_key)
|
35
|
+
@@aws_secret_access_key = secret_key
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.aws_secret_access_key
|
39
|
+
@@aws_secret_access_key
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.new(options={})
|
43
|
+
@connection = MWS::Connection.new(options)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Allow using using a global key and secret
|
47
|
+
def self.config
|
48
|
+
yield self
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module MWS
|
2
|
+
module API
|
3
|
+
class Base
|
4
|
+
attr_reader :connection, :uri, :version, :verb
|
5
|
+
|
6
|
+
def initialize(connection)
|
7
|
+
@verb ||= :get
|
8
|
+
@connection = connection
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(action, params={})
|
12
|
+
@verb = params.delete(:verb) || @verb
|
13
|
+
|
14
|
+
#extract request_params for feeds api requests
|
15
|
+
request_params = params[:request_params] || {}
|
16
|
+
params = params.except(:request_params)
|
17
|
+
|
18
|
+
query = Query.new({
|
19
|
+
verb: @verb,
|
20
|
+
uri: @uri,
|
21
|
+
host: @connection.host,
|
22
|
+
|
23
|
+
aws_access_key_id: @connection.aws_access_key_id,
|
24
|
+
aws_secret_access_key: @connection.aws_secret_access_key,
|
25
|
+
seller_id: @connection.seller_id,
|
26
|
+
action: action.to_s.camelize,
|
27
|
+
version: @version,
|
28
|
+
params: params
|
29
|
+
})
|
30
|
+
|
31
|
+
case @verb.to_s.upcase
|
32
|
+
when "GET"
|
33
|
+
HTTParty.get(query.request_uri)
|
34
|
+
when "POST"
|
35
|
+
HTTParty.post(query.request_uri, request_params)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def method_missing(name, *args)
|
40
|
+
if self.class::Actions.include?(name)
|
41
|
+
self.call(name, *args)
|
42
|
+
else
|
43
|
+
super
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module MWS
|
2
|
+
module API
|
3
|
+
class Feeds < Base
|
4
|
+
Actions = [:get_feed_submission_list, :get_feed_submission_list_by_next_token,
|
5
|
+
:get_feed_submission_count, :cancel_feed_submissions, :get_feed_submission_result ]
|
6
|
+
|
7
|
+
def initialize(connection)
|
8
|
+
@uri = "/"
|
9
|
+
@version = "2009-01-01"
|
10
|
+
@verb = :post
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def submit_feed(params={})
|
15
|
+
xml_envelope = Envelope.new(params.merge!(merchant_id: self.connection.seller_id))
|
16
|
+
params = params.except(:merchant_id, :message_type, :message, :skip_schema_validation)
|
17
|
+
call(:submit_feed, params.merge!(
|
18
|
+
request_params: {
|
19
|
+
format: "xml",
|
20
|
+
headers: {
|
21
|
+
"Content-MD5" => xml_envelope.md5
|
22
|
+
},
|
23
|
+
body: xml_envelope.to_s
|
24
|
+
}
|
25
|
+
))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class MWS::API::Feeds::Envelope
|
2
|
+
def initialize(params={})
|
3
|
+
@envelope = build_envelope(params)
|
4
|
+
validate! unless params[:skip_schema_validation] == true
|
5
|
+
end
|
6
|
+
|
7
|
+
def valid?
|
8
|
+
self.errors.count == 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate!
|
12
|
+
unless valid?
|
13
|
+
raise "Invalid XML:\n" + self.errors.join("\n")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def md5
|
18
|
+
Digest::MD5.base64digest(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_str
|
22
|
+
to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
result = @envelope.target!
|
27
|
+
result.gsub!('<Items type="array">', "")
|
28
|
+
result.gsub!('</Items>', "")
|
29
|
+
result.gsub!('<Inventories type="array">', "")
|
30
|
+
result.gsub!('</Inventories>', "")
|
31
|
+
result
|
32
|
+
end
|
33
|
+
|
34
|
+
def xsd
|
35
|
+
Nokogiri::XML::Schema(File.open(File.join(File.dirname(__FILE__),"xsd/amzn-envelope.xsd")))
|
36
|
+
end
|
37
|
+
|
38
|
+
def errors
|
39
|
+
@errors ||= xsd.validate(Nokogiri::XML(self))
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def build_envelope(params={})
|
44
|
+
xml = Builder::XmlMarkup.new
|
45
|
+
xml.instruct!
|
46
|
+
|
47
|
+
xml.AmazonEnvelope do
|
48
|
+
xml.Header do
|
49
|
+
xml.DocumentVersion "1.01"
|
50
|
+
xml.MerchantIdentifier params[:merchant_id]
|
51
|
+
end
|
52
|
+
|
53
|
+
xml.MessageType params[:message_type].to_s.camelize
|
54
|
+
xml.PurgeAndReplace params[:purge_and_replace] || false
|
55
|
+
|
56
|
+
xml << params[:message].to_xml(skip_instruct: true, root: "Message") if params[:message]
|
57
|
+
xml << {"Messages" => params[:messages]}.to_xml(skip_instruct: true) if params[:messages]
|
58
|
+
end
|
59
|
+
xml
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Revision="$Revision: #1 $" -->
|
3
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
4
|
+
<!--
|
5
|
+
$Date: 2012/09/11/ $
|
6
|
+
AMAZON.COM CONFIDENTIAL. This document and the information contained in it are
|
7
|
+
confidential and proprietary information of Amazon.com and may not be reproduced,
|
8
|
+
distributed or used, in whole or in part, for any purpose other than as necessary
|
9
|
+
to list products for sale on the www.amazon.com web site pursuant to an agreement
|
10
|
+
with Amazon.com.
|
11
|
+
-->
|
12
|
+
<xsd:include schemaLocation="amzn-base.xsd"/>
|
13
|
+
<xsd:element name="AdditionalProductInformation">
|
14
|
+
<xsd:complexType>
|
15
|
+
<xsd:sequence>
|
16
|
+
<xsd:element name="MaterialFabric" type="HundredString" minOccurs="0" maxOccurs="3"/>
|
17
|
+
<xsd:element name="ImportDesignation" type="HundredString" minOccurs="0"/>
|
18
|
+
<xsd:element name="CountryAsLabeled" type="CountryOfOriginType" minOccurs="0"/>
|
19
|
+
<xsd:element name="FurDescription" type="HundredString" minOccurs="0"/>
|
20
|
+
</xsd:sequence>
|
21
|
+
</xsd:complexType>
|
22
|
+
</xsd:element>
|
23
|
+
</xsd:schema>
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
3
|
+
<xsd:annotation>
|
4
|
+
<xsd:documentation>
|
5
|
+
$Date: 2006/11/10 22:51:27 $
|
6
|
+
AMAZON.COM CONFIDENTIAL.This document and the information contained in it are
|
7
|
+
confidential and proprietary information of Amazon.com and may not be reproduced,distributed or used, in whole or in part, for any purpose other than as necessary to list products for sale on the www.amazon.com web site pursuant to an agreement with Amazon.com.
|
8
|
+
</xsd:documentation>
|
9
|
+
</xsd:annotation>
|
10
|
+
<xsd:include schemaLocation="amzn-base.xsd"/>
|
11
|
+
|
12
|
+
<xsd:element name="Amazon-Vendor-Only">
|
13
|
+
<xsd:complexType>
|
14
|
+
<xsd:sequence>
|
15
|
+
<xsd:element name="Cost" type="CurrencyAmount"/>
|
16
|
+
</xsd:sequence>
|
17
|
+
</xsd:complexType>
|
18
|
+
</xsd:element>
|
19
|
+
<xsd:annotation>
|
20
|
+
<xsd:documentation>
|
21
|
+
If you are using the Amazon-Only structure, please also include and populate the Amazon-Vendor-Only structure.
|
22
|
+
</xsd:documentation>
|
23
|
+
</xsd:annotation>
|
24
|
+
|
25
|
+
<xsd:element name="Amazon-Only">
|
26
|
+
<xsd:complexType>
|
27
|
+
<xsd:sequence>
|
28
|
+
<xsd:element name="Tier" type="xsd:positiveInteger"/>
|
29
|
+
<xsd:element name="PurchasingCategory" type="StringNotNull"/>
|
30
|
+
<xsd:element name="PurchasingSubCategory" type="StringNotNull"/>
|
31
|
+
<xsd:element name="PackagingType" type="StringNotNull"/>
|
32
|
+
<xsd:element name="UnderlyingAvailability">
|
33
|
+
<xsd:simpleType>
|
34
|
+
<xsd:restriction base="xsd:string">
|
35
|
+
<xsd:enumeration value="backordered"/>
|
36
|
+
<xsd:enumeration value="manufacturer-out-of-stock"/>
|
37
|
+
<xsd:enumeration value="pre-ordered"/>
|
38
|
+
<xsd:enumeration value="2-3-days"/>
|
39
|
+
<xsd:enumeration value="1-2-weeks"/>
|
40
|
+
<xsd:enumeration value="4-6-weeks"/>
|
41
|
+
</xsd:restriction>
|
42
|
+
</xsd:simpleType>
|
43
|
+
</xsd:element>
|
44
|
+
<xsd:element name="ReplenishmentCategory">
|
45
|
+
<xsd:simpleType>
|
46
|
+
<xsd:restriction base="xsd:string">
|
47
|
+
<xsd:enumeration value="basic-replenishment"/>
|
48
|
+
<xsd:enumeration value="limited-replenishment"/>
|
49
|
+
<xsd:enumeration value="manufacturer-out-of-stock"/>
|
50
|
+
<xsd:enumeration value="new-product"/>
|
51
|
+
<xsd:enumeration value="non-replenishable"/>
|
52
|
+
<xsd:enumeration value="non-stockupable"/>
|
53
|
+
<xsd:enumeration value="obsolete"/>
|
54
|
+
<xsd:enumeration value="planned-replenishment"/>
|
55
|
+
</xsd:restriction>
|
56
|
+
</xsd:simpleType>
|
57
|
+
</xsd:element>
|
58
|
+
<xsd:element name="DropShipStatus">
|
59
|
+
<xsd:simpleType>
|
60
|
+
<xsd:restriction base="xsd:string">
|
61
|
+
<xsd:enumeration value="drop-ship-disabled"/>
|
62
|
+
<xsd:enumeration value="drop-ship-disabled-by-buyer"/>
|
63
|
+
<xsd:enumeration value="drop-ship-enabled"/>
|
64
|
+
<xsd:enumeration value="drop-ship-enabled-no-auto-pricing"/>
|
65
|
+
<xsd:enumeration value="drop-ship-only"/>
|
66
|
+
</xsd:restriction>
|
67
|
+
</xsd:simpleType>
|
68
|
+
</xsd:element>
|
69
|
+
<xsd:element name="OutOfStockWebsiteMessage">
|
70
|
+
<xsd:simpleType>
|
71
|
+
<xsd:restriction base="xsd:string">
|
72
|
+
<xsd:enumeration value="email-me-when-available"/>
|
73
|
+
<xsd:enumeration value="out-of-stock"/>
|
74
|
+
<xsd:enumeration value="pre-order-ute"/>
|
75
|
+
<xsd:enumeration value="underlying-availability"/>
|
76
|
+
</xsd:restriction>
|
77
|
+
</xsd:simpleType>
|
78
|
+
</xsd:element>
|
79
|
+
</xsd:sequence>
|
80
|
+
</xsd:complexType>
|
81
|
+
</xsd:element>
|
82
|
+
</xsd:schema>
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|