mws-rb 0.0.1
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/.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
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<!-- Revision="$Revision: #6 $" -->
|
|
3
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
|
4
|
+
<!--
|
|
5
|
+
$Date: 2007/01/18 $
|
|
6
|
+
|
|
7
|
+
AMAZON.COM CONFIDENTIAL. This document and the information contained in it are
|
|
8
|
+
confidential and proprietary information of Amazon.com and may not be reproduced,
|
|
9
|
+
distributed or used, in whole or in part, for any purpose other than as necessary
|
|
10
|
+
to list products for sale on the www.amazon.com web site pursuant to an agreement
|
|
11
|
+
with Amazon.com.
|
|
12
|
+
-->
|
|
13
|
+
<xsd:include schemaLocation="amzn-base.xsd"/>
|
|
14
|
+
<xsd:include schemaLocation="amzn-header.xsd"/>
|
|
15
|
+
<xsd:include schemaLocation="FulfillmentCenter.xsd"/>
|
|
16
|
+
<xsd:include schemaLocation="Inventory.xsd"/>
|
|
17
|
+
<xsd:include schemaLocation="Listings.xsd"/>
|
|
18
|
+
<xsd:include schemaLocation="OrderAcknowledgement.xsd"/>
|
|
19
|
+
<xsd:include schemaLocation="OrderAdjustment.xsd"/>
|
|
20
|
+
<xsd:include schemaLocation="OrderFulfillment.xsd"/>
|
|
21
|
+
|
|
22
|
+
<xsd:include schemaLocation="Override.xsd"/>
|
|
23
|
+
<xsd:include schemaLocation="Price.xsd"/>
|
|
24
|
+
<xsd:include schemaLocation="ProcessingReport.xsd"/>
|
|
25
|
+
<xsd:include schemaLocation="ProductImage.xsd"/>
|
|
26
|
+
<xsd:include schemaLocation="Product.xsd"/>
|
|
27
|
+
<xsd:include schemaLocation="Relationship.xsd"/>
|
|
28
|
+
<xsd:include schemaLocation="SettlementReport.xsd"/>
|
|
29
|
+
<xsd:element name="AmazonEnvelope">
|
|
30
|
+
<xsd:complexType>
|
|
31
|
+
<xsd:sequence>
|
|
32
|
+
<xsd:element ref="Header"/>
|
|
33
|
+
<xsd:element name="MessageType">
|
|
34
|
+
<xsd:simpleType>
|
|
35
|
+
<xsd:restriction base="xsd:string">
|
|
36
|
+
<xsd:enumeration value="FulfillmentCenter"/>
|
|
37
|
+
<xsd:enumeration value="Inventory"/>
|
|
38
|
+
<xsd:enumeration value="Listings"/>
|
|
39
|
+
<xsd:enumeration value="OrderAcknowledgement"/>
|
|
40
|
+
<xsd:enumeration value="OrderAdjustment"/>
|
|
41
|
+
<xsd:enumeration value="OrderFulfillment"/>
|
|
42
|
+
<xsd:enumeration value="Override"/>
|
|
43
|
+
<xsd:enumeration value="Price"/>
|
|
44
|
+
<xsd:enumeration value="ProcessingReport"/>
|
|
45
|
+
<xsd:enumeration value="Product"/>
|
|
46
|
+
<xsd:enumeration value="ProductImage"/>
|
|
47
|
+
<xsd:enumeration value="Relationship"/>
|
|
48
|
+
<xsd:enumeration value="SettlementReport"/>
|
|
49
|
+
</xsd:restriction>
|
|
50
|
+
</xsd:simpleType>
|
|
51
|
+
</xsd:element>
|
|
52
|
+
<xsd:element ref="MarketplaceName" minOccurs="0">
|
|
53
|
+
<xsd:annotation>
|
|
54
|
+
<xsd:documentation>
|
|
55
|
+
The MarketplaceName is only supported for
|
|
56
|
+
Override feeds.
|
|
57
|
+
If included here, the MarketplaceName will
|
|
58
|
+
apply to all messages in the feed.
|
|
59
|
+
</xsd:documentation>
|
|
60
|
+
</xsd:annotation>
|
|
61
|
+
</xsd:element>
|
|
62
|
+
<xsd:element name="PurgeAndReplace" type="xsd:boolean" minOccurs="0"/>
|
|
63
|
+
<xsd:element name="EffectiveDate" type="xsd:dateTime" minOccurs="0"/>
|
|
64
|
+
<xsd:element name="Message" maxOccurs="unbounded">
|
|
65
|
+
<xsd:complexType>
|
|
66
|
+
<xsd:sequence>
|
|
67
|
+
<xsd:element name="MessageID" type="IDNumber"/>
|
|
68
|
+
<xsd:element name="OperationType" minOccurs="0">
|
|
69
|
+
<xsd:simpleType>
|
|
70
|
+
<xsd:restriction base="xsd:string">
|
|
71
|
+
<xsd:enumeration value="Update"/>
|
|
72
|
+
<xsd:enumeration value="Delete"/>
|
|
73
|
+
<xsd:enumeration value="PartialUpdate"/>
|
|
74
|
+
</xsd:restriction>
|
|
75
|
+
</xsd:simpleType>
|
|
76
|
+
</xsd:element>
|
|
77
|
+
<xsd:choice>
|
|
78
|
+
<xsd:element ref="FulfillmentCenter"/>
|
|
79
|
+
<xsd:element ref="Inventory"/>
|
|
80
|
+
<xsd:element ref="Listings"/>
|
|
81
|
+
<xsd:element ref="OrderAcknowledgement"/>
|
|
82
|
+
<xsd:element ref="OrderAdjustment"/>
|
|
83
|
+
<xsd:element ref="OrderFulfillment"/>
|
|
84
|
+
<xsd:element ref="Override"/>
|
|
85
|
+
<xsd:element ref="Price"/>
|
|
86
|
+
<xsd:element ref="ProcessingReport"/>
|
|
87
|
+
<xsd:element ref="Product"/>
|
|
88
|
+
<xsd:element ref="ProductImage"/>
|
|
89
|
+
<xsd:element ref="Relationship"/>
|
|
90
|
+
<xsd:element ref="SettlementReport"/>
|
|
91
|
+
</xsd:choice>
|
|
92
|
+
</xsd:sequence>
|
|
93
|
+
</xsd:complexType>
|
|
94
|
+
</xsd:element>
|
|
95
|
+
</xsd:sequence>
|
|
96
|
+
</xsd:complexType>
|
|
97
|
+
</xsd:element>
|
|
98
|
+
</xsd:schema>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<!-- "$Revision: #3 $" -->
|
|
3
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
|
4
|
+
|
|
5
|
+
<!--
|
|
6
|
+
$Date: 2005/04/01 $
|
|
7
|
+
|
|
8
|
+
AMAZON.COM CONFIDENTIAL. This document and the information contained in it are
|
|
9
|
+
confidential and proprietary information of Amazon.com and may not be reproduced,
|
|
10
|
+
distributed or used, in whole or in part, for any purpose other than as necessary
|
|
11
|
+
to list products for sale on the www.amazon.com web site pursuant to an agreement
|
|
12
|
+
with Amazon.com.
|
|
13
|
+
-->
|
|
14
|
+
|
|
15
|
+
<xsd:include schemaLocation="amzn-base.xsd"/>
|
|
16
|
+
|
|
17
|
+
<xsd:element name="Header">
|
|
18
|
+
<xsd:complexType>
|
|
19
|
+
<xsd:sequence>
|
|
20
|
+
|
|
21
|
+
<xsd:element name="DocumentVersion">
|
|
22
|
+
<xsd:simpleType>
|
|
23
|
+
<xsd:restriction base="xsd:string">
|
|
24
|
+
<xsd:pattern value="\d{1,2}\.\d{1,2}"/>
|
|
25
|
+
</xsd:restriction>
|
|
26
|
+
</xsd:simpleType>
|
|
27
|
+
</xsd:element>
|
|
28
|
+
|
|
29
|
+
<xsd:element name="MerchantIdentifier" type="String"/>
|
|
30
|
+
|
|
31
|
+
<xsd:element name="OverrideReleaseId" minOccurs="0">
|
|
32
|
+
<xsd:simpleType>
|
|
33
|
+
<xsd:restriction base="xsd:string">
|
|
34
|
+
<xsd:pattern value="\d{1,4}\.\d{1,4}"/>
|
|
35
|
+
</xsd:restriction>
|
|
36
|
+
</xsd:simpleType>
|
|
37
|
+
</xsd:element>
|
|
38
|
+
|
|
39
|
+
</xsd:sequence>
|
|
40
|
+
</xsd:complexType>
|
|
41
|
+
</xsd:element>
|
|
42
|
+
|
|
43
|
+
</xsd:schema>
|
|
44
|
+
|
|
45
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
module API
|
|
3
|
+
class FulfillmentInboundShipment < Base
|
|
4
|
+
Actions = [:create_inbound_shipment_plan, :create_inbound_shipment, :update_inbound_shipment,
|
|
5
|
+
:list_inbound_shipments, :list_inbound_shipments_by_next_token, :list_inbound_shipment_items,
|
|
6
|
+
:list_inbound_shipment_items_by_next_token, :get_service_status]
|
|
7
|
+
|
|
8
|
+
def initialize(connection)
|
|
9
|
+
@uri = "/FulfillmentInboundShipment/2010-10-01"
|
|
10
|
+
@version = "2010-10-01"
|
|
11
|
+
super
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
module API
|
|
3
|
+
class FulfillmentInventory < Base
|
|
4
|
+
Actions = [:list_inventory_supply, :list_inventory_supply_by_next_token, :get_service_status]
|
|
5
|
+
|
|
6
|
+
def initialize(connection)
|
|
7
|
+
@uri = "/FulfillmentInventory/2010-10-01"
|
|
8
|
+
@version = "2010-10-01"
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
module API
|
|
3
|
+
class Orders < Base
|
|
4
|
+
Actions = [:list_orders, :list_orders_by_next_token, :get_order, :list_order_items,
|
|
5
|
+
:list_order_items_by_next_token, :get_service_status]
|
|
6
|
+
|
|
7
|
+
def initialize(connection)
|
|
8
|
+
@uri = "/Orders/2011-01-01"
|
|
9
|
+
@version = "2011-01-01"
|
|
10
|
+
@verb = :post
|
|
11
|
+
super
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
module API
|
|
3
|
+
class Products < Base
|
|
4
|
+
Actions = [:list_matching_products, :get_matching_product, :get_matching_product_for_id,
|
|
5
|
+
:get_competitive_pricing_for_SKU, :get_competitive_pricing_for_ASIN,
|
|
6
|
+
:get_lowest_offer_listings_for_SKU, :get_lowest_offer_listings_for_ASIN,
|
|
7
|
+
:get_my_price_for_SKU, :get_my_price_for_ASIN,
|
|
8
|
+
:get_product_categories_for_SKU, :get_product_categories_for_ASIN,
|
|
9
|
+
:get_service_status]
|
|
10
|
+
|
|
11
|
+
def initialize(connection)
|
|
12
|
+
@uri = "/Products/2011-10-01"
|
|
13
|
+
@version = "2011-10-01"
|
|
14
|
+
super
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
module API
|
|
3
|
+
class Recommendations < Base
|
|
4
|
+
Actions = [:get_last_updated_time_for_recommendations_checks, :list_recommendations, :list_recommendations_by_next_token]
|
|
5
|
+
|
|
6
|
+
def initialize(connection)
|
|
7
|
+
@uri = "/Recommendations/2013-04-01"
|
|
8
|
+
@version = "2013-04-01"
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
module API
|
|
3
|
+
class Reports < Base
|
|
4
|
+
Actions = [:request_report, :get_report_request_list, :get_report_request_list_by_next_token,
|
|
5
|
+
:get_report_request_count, :cancel_report_requests, :get_report_list, :get_report_list_by_next_token,
|
|
6
|
+
:get_report_count, :get_report, :manage_report_schedule, :get_report_schedule_list,
|
|
7
|
+
:get_report_schedule_list_by_next_token, :get_report_schedule_count, :update_report_acknowledgements]
|
|
8
|
+
|
|
9
|
+
def initialize(connection)
|
|
10
|
+
@uri = "/"
|
|
11
|
+
@version = "2009-01-01"
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
module API
|
|
3
|
+
class Sellers < Base
|
|
4
|
+
Actions = [:list_marketplace_participations, :list_marketplace_participations_by_next_token, :get_service_status]
|
|
5
|
+
|
|
6
|
+
def initialize(connection)
|
|
7
|
+
@uri = "/Sellers/2011-07-01"
|
|
8
|
+
@version = "2011-07-01"
|
|
9
|
+
@verb = :post
|
|
10
|
+
super
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
class Connection
|
|
3
|
+
attr_reader :host, :aws_access_key_id, :aws_secret_access_key, :seller_id
|
|
4
|
+
|
|
5
|
+
def initialize(options={})
|
|
6
|
+
@host = options[:host] ||"mws.amazonservices.com"
|
|
7
|
+
@aws_access_key_id = options[:aws_access_key_id] || MWS.aws_access_key_id
|
|
8
|
+
@aws_secret_access_key = options[:aws_secret_access_key] || MWS.aws_secret_access_key
|
|
9
|
+
@seller_id = options[:seller_id]
|
|
10
|
+
|
|
11
|
+
if @aws_access_key_id.to_s.empty? || @aws_secret_access_key.to_s.empty? || @seller_id.to_s.empty?
|
|
12
|
+
raise(ArgumentError, "You must provide :aws_access_key_id, :aws_secret_access_key and :seller_id")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Map APIS
|
|
17
|
+
def feeds
|
|
18
|
+
@fees ||= MWS::API::Feeds.new(self)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def fulfillment_inbound_shipment
|
|
22
|
+
@fis ||= MWS::API::FulfillmentInboundShipment.new(self)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def fulfillment_inventory
|
|
26
|
+
@fi ||= MWS::API::FulfillmentInventory.new(self)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def fulfillment_outbound_shipment
|
|
30
|
+
@fos ||= MWS::API::FulfillmentOutboundShipment.new(self)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def orders
|
|
34
|
+
@orders ||= MWS::API::Orders.new(self)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def products
|
|
38
|
+
@products ||= MWS::API::Products.new(self)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def recommendations
|
|
42
|
+
@recommendations ||= MWS::API::Recommendations.new(self)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def reports
|
|
46
|
+
@reports ||= MWS::API::Reports.new(self)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def sellers
|
|
50
|
+
@sellers ||= MWS::API::Sellers.new(self)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
data/lib/mws-rb/query.rb
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
module MWS
|
|
2
|
+
class Query
|
|
3
|
+
attr_reader :verb, :uri, :host, :aws_access_key_id, :aws_secret_access_key, :action, :seller_id,
|
|
4
|
+
:signature_method, :signature_version, :timestamp, :version
|
|
5
|
+
|
|
6
|
+
def initialize(params={})
|
|
7
|
+
@verb = params[:verb] || "GET"
|
|
8
|
+
@uri = params[:uri] || "/"
|
|
9
|
+
@host = params[:host]
|
|
10
|
+
|
|
11
|
+
@aws_access_key_id = params[:aws_access_key_id]
|
|
12
|
+
@aws_secret_access_key = params[:aws_secret_access_key]
|
|
13
|
+
@action = params[:action]
|
|
14
|
+
@seller_id = params[:seller_id]
|
|
15
|
+
@signature_method = params[:signature_method] || "HmacSHA256"
|
|
16
|
+
@signature_version = params[:signature_version] || 2
|
|
17
|
+
@timestamp = params[:timestamp] || Time.now
|
|
18
|
+
@version = params[:version]
|
|
19
|
+
|
|
20
|
+
@params = params[:params]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def request_uri
|
|
24
|
+
"https://" << @host << @uri << '?' << build_query(signature)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def canonical
|
|
28
|
+
canonical = [@verb.to_s.upcase, @host.downcase, @uri, build_query].join("\n")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def signature
|
|
32
|
+
digest = OpenSSL::Digest::Digest.new('sha256')
|
|
33
|
+
Base64.encode64(OpenSSL::HMAC.digest(digest, aws_secret_access_key, canonical)).strip
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def build_query(signature=nil)
|
|
37
|
+
query = {
|
|
38
|
+
"AWSAccessKeyId" => @aws_access_key_id,
|
|
39
|
+
"Action" => @action,
|
|
40
|
+
"SellerId" => @seller_id,
|
|
41
|
+
"SignatureMethod" => @signature_method,
|
|
42
|
+
"SignatureVersion" => @signature_version,
|
|
43
|
+
"Timestamp" => @timestamp,
|
|
44
|
+
"Version" => @version
|
|
45
|
+
}
|
|
46
|
+
query["Signature"] = signature if signature
|
|
47
|
+
|
|
48
|
+
params = Helpers.camelize_keys(@params || {})
|
|
49
|
+
params = Helpers.make_structured_lists(params)
|
|
50
|
+
query.merge!(params)
|
|
51
|
+
|
|
52
|
+
# Sort hash in natural-byte order
|
|
53
|
+
Hash[Helpers.escape_date_time_params(query).sort].to_query
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
module Helpers
|
|
57
|
+
def self.escape_date_time_params(params={})
|
|
58
|
+
params.map do |key, value|
|
|
59
|
+
case value.class.name
|
|
60
|
+
when "Time", "Date", "DateTime"
|
|
61
|
+
{key => value.iso8601}
|
|
62
|
+
when "Hash"
|
|
63
|
+
{key => escape_date_time_params(value)}
|
|
64
|
+
else
|
|
65
|
+
{key => value}
|
|
66
|
+
end
|
|
67
|
+
end.reduce({}, :merge)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.camelize_keys(params={})
|
|
71
|
+
params.map do |key, value|
|
|
72
|
+
case value.class.name
|
|
73
|
+
when "Hash"
|
|
74
|
+
{key.to_s.camelize => camelize_keys(value)}
|
|
75
|
+
else
|
|
76
|
+
{key.to_s.camelize => value}
|
|
77
|
+
end
|
|
78
|
+
end.reduce({}, :merge)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.make_structured_lists(params={})
|
|
82
|
+
params.map do |key, value|
|
|
83
|
+
if key.to_s.end_with?("list")
|
|
84
|
+
value[:values].each_with_index.map do |item, index|
|
|
85
|
+
{"#{value[:label]}.#{index + 1}" => item}
|
|
86
|
+
end.reduce({}, :merge)
|
|
87
|
+
else
|
|
88
|
+
{key => value}
|
|
89
|
+
end
|
|
90
|
+
end.reduce({}, :merge)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
data/mws-rb.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "mws-rb/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "mws-rb"
|
|
7
|
+
s.version = MWS::VERSION
|
|
8
|
+
s.authors = ["Jhimy Fernandes Villar"]
|
|
9
|
+
s.email = ["stjhimy@gmail.com"]
|
|
10
|
+
s.homepage = "http://github.com/stjhimy/mws-rb"
|
|
11
|
+
s.summary = %q{Amazon MWS Gem}
|
|
12
|
+
s.description = %q{A complete wrapper for Amazon.com's Marketplace Web Service (MWS) API.}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "ruby-mws"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
s.add_development_dependency "rspec"
|
|
21
|
+
s.add_development_dependency "guard"
|
|
22
|
+
s.add_development_dependency "guard-rspec"
|
|
23
|
+
|
|
24
|
+
s.add_dependency 'httparty', '~> 0'
|
|
25
|
+
s.add_dependency 'nokogiri', '~> 1'
|
|
26
|
+
s.add_dependency 'activesupport', '~> 3.0'
|
|
27
|
+
s.add_dependency 'builder'
|
|
28
|
+
end
|