peddler 0.7.9 → 0.7.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fa0b5d3d2a19f2c2466f3b81f8b3af63c30efe9
4
- data.tar.gz: f934d8b778d1c56c5c7533f9c5d59ebf0cf06550
3
+ metadata.gz: ea0fdd1ff90c94773f752bd53dbf254e10bd6f1f
4
+ data.tar.gz: 9246c675af95a2f4def757766ac4ef58704c6988
5
5
  SHA512:
6
- metadata.gz: a6ca2e943bc525e08b7e8195bdd12e5b65075dbb30bad789328e8a92fc18d59f0df035538459a091b7069a9da5e9ecb27ccdc8d910208c7ab4b26405dcdad427
7
- data.tar.gz: e3f5068c70c530a2f198cdfbe571ccb7c6b119125aed38b9b132f78da568891cb2ee1bfa5867254640a0747d831b9c50438cda2132d67f51d8a221d26d73388a
6
+ metadata.gz: 280944799765cc755270f75c55b25637b2ca33ac88feb42aa87d18382349b3cb08423ff60bb835c133588158becc8030a3a0fdcffb62a2d1ae3c396b3023f1b7
7
+ data.tar.gz: eae4ebbcf5207c81ad78d343cf66741f088869a5d2153177885dd930042c1f536b72d9620c67afc721152d06f9070359f04aecccf5a17d0c89b77b88f3e9eea0
data/README.md CHANGED
@@ -30,17 +30,6 @@ client = MWS.orders(
30
30
  )
31
31
  ```
32
32
 
33
- Or you can set them via `Client#configure`:
34
-
35
- ```ruby
36
- client.configure do |c|
37
- c.marketplace_id = 'A1F83G8C2ARO7P'
38
- c.merchant_id = 'A2A9WNXCU02UZW'
39
- c.aws_access_key_id = 'AKIVICHZMZ2JRSSLC27W'
40
- c.aws_secret_access_key = 'rOMa3ydPBTJ3AD0bxERTOX0Fv0fAC6Q0s6/czMZO'
41
- end
42
- ```
43
-
44
33
  Alternatively, use environment variables if you only have a single set of credentials:
45
34
 
46
35
  ```sh
@@ -86,8 +75,6 @@ The MWS Fulfillment Inventory API can help you stay up-to-date on the availabili
86
75
 
87
76
  ### Fulfillment Outbound Shipment
88
77
 
89
- **Partially implemented**
90
-
91
78
  The MWS Fulfillment Outbound Shipment API enables you to fulfill orders placed through channels other than Amazon's retail web site, using your inventory in the Amazon Fulfillment Network. You can request previews of potential fulfillment orders that return estimated shipping fees and shipping dates based on shipping speed. You can get detailed item-level, shipment-level, and order-level information for any existing fulfillment order that you specify. You can also request lists of existing fulfillment orders based on when they were fulfilled and by the fulfillment method associated with them.
92
79
 
93
80
  Support for creating and cancelling fulfillment orders has been implemented, but the rest of the API is not supported yet.
@@ -98,6 +85,12 @@ Support for creating and cancelling fulfillment orders has been implemented, but
98
85
 
99
86
  The MWS Off-Amazon Payments API helps you to process payments for purchases made by buyers on your website using the Login and Pay with Amazon service. This API enables you to programmatically retrieve shipping and payment information provided by the buyer from their Amazon account. It allows you to authorize, capture, and refund payments, enabling a variety of payments scenarios.
100
87
 
88
+ You can switch the client to the sandbox environment:
89
+
90
+ ```ruby
91
+ client = MWS.off_amazon_payments.sandbox
92
+ ```
93
+
101
94
  [Read more](http://rubydoc.info/github/hakanensari/peddler/MWS/OffAmazonPayments)
102
95
 
103
96
  ### Orders
@@ -10,14 +10,29 @@ module MWS
10
10
  # and order-level information for any existing fulfillment order that you
11
11
  # specify. You can also request lists of existing fulfillment orders based on
12
12
  # when they were fulfilled and by the fulfillment method associated with them.
13
- #
14
- # @todo Not implemented
15
13
  class FulfillmentOutboundShipment < ::Peddler::Client
16
14
  path '/FulfillmentOutboundShipment/2010-10-01'
17
15
 
18
16
  # Lists fulfillment order previews
19
- def get_fulfillment_preview
20
- raise NotImplementedError
17
+ #
18
+ # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_GetFulfillmentPreview.html
19
+ # @param address [Struct, Hash]
20
+ # @param items [Array<Struct, Hash>]
21
+ # @param opts [Hash]
22
+ # @option opts Array[String] :shipping_speed_categories
23
+ # @option opts Boolean :include_cod_fulfillment_preview
24
+ # @return [Peddler::XMLParser]
25
+ def get_fulfillment_preview(address, items, opts = {})
26
+ if opts.has_key?(:include_cod_fulfillment_preview)
27
+ opts['IncludeCODFulfillmentPreview'] = opts.delete(:include_cod_fulfillment_preview)
28
+ end
29
+
30
+ operation('GetFulfillmentPreview')
31
+ .add(opts.merge('Address' => address, 'Items' => items))
32
+ .structure!('Items', 'member')
33
+ .structure!('ShippingSpeedCategories')
34
+
35
+ run
21
36
  end
22
37
 
23
38
  # Requests that Amazon ship items from the seller's Amazon Fulfillment
@@ -30,15 +45,12 @@ module MWS
30
45
  # @param displayable_order_comment [String]
31
46
  # @param shipping_speed_category [String]
32
47
  # @param destination_address [Struct, Hash]
33
- # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_Datatypes.html#Address
34
48
  # @params items [Array<Struct, Hash>]
35
- # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_Datatypes.html#CreateFulfillmentOrderItem
36
49
  # @param opts [Hash]
37
50
  # @option opts [String] :fulfillment_action
38
51
  # @option opts [String] :fulfillment_policy
39
52
  # @option opts [Array<String>] :notification_email_list
40
53
  # @option opts [Struct, Hash] :cod_settings
41
- # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_Datatypes.html#CODSettings
42
54
  # @return [Peddler::XMLParser]
43
55
  def create_fulfillment_order(seller_fulfillment_order_id, displayable_order_id, displayable_order_date_time, displayable_order_comment, shipping_speed_category, destination_address, items, opts = {})
44
56
  if opts.has_key?(:cod_settings)
@@ -65,23 +77,64 @@ module MWS
65
77
 
66
78
  # Updates and/or requests shipment for a fulfillment order with an order
67
79
  # hold on it
68
- def update_fulfillment_order
69
- raise NotImplementedError
80
+ #
81
+ # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_UpdateFulfillmentOrder.html
82
+ # @param seller_fulfillment_order_id [String]
83
+ # @param opts [Hash]
84
+ # @option opts [String] :fulfillment_action
85
+ # @option opts [String] :displayable_order_id
86
+ # @option opts [String, #iso8601] :displayable_order_date_time
87
+ # @option opts [String] :displayable_order_comment
88
+ # @option opts [String] :shipping_speed_category
89
+ # @option opts [Struct, Hash] :destination_address
90
+ # @option opts [String] :fulfillment_policy
91
+ # @option opts [Array<String>] :notification_email_list
92
+ # @option opts [Array<Struct, Hash>] :items
93
+ # @return [Peddler::XMLParser]
94
+ def update_fulfillment_order(seller_fulfillment_order_id, opts = {})
95
+ operation('UpdateFulfillmentOrder')
96
+ .add(opts.merge('SellerFulfillmentOrderId' => seller_fulfillment_order_id))
97
+ .structure!('NotificationEmailList', 'member')
98
+ .structure!('Items', 'member')
99
+
100
+ run
70
101
  end
71
102
 
72
103
  # Gets a fulfillment order
73
- def get_fulfillment_order
74
- raise NotImplementedError
104
+ #
105
+ # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_GetFulfillmentOrder.html
106
+ # @param seller_fulfillment_order_id [String]
107
+ # @return [Peddler::XMLParser]
108
+ def get_fulfillment_order(seller_fulfillment_order_id)
109
+ operation('GetFulfillmentOrder')
110
+ .add('SellerFulfillmentOrderId' => seller_fulfillment_order_id)
111
+
112
+ run
75
113
  end
76
114
 
77
115
  # Returns a list of fulfillment orders fulfilled on or after a date
78
- def list_all_fulfillment_orders
79
- raise NotImplementedError
116
+ #
117
+ # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_ListAllFulfillmentOrders.html
118
+ # @param opts [Hash]
119
+ # @option opts [String, #iso8601] :query_start_date_time
120
+ # @return [Peddler::XMLParser]
121
+ def list_all_fulfillment_orders(query_start_date_time = nil)
122
+ opts = query_start_date_time ? { 'QueryStartDateTime' => query_start_date_time } : {}
123
+ operation('ListAllFulfillmentOrders').add(opts)
124
+
125
+ run
80
126
  end
81
127
 
82
128
  # Returns the next page of fulfillment orders
83
- def list_all_fulfillment_orders_by_next_token
84
- raise NotImplementedError
129
+ #
130
+ # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_ListAllFulfillmentOrdersByNextToken.html
131
+ # @param next_token [String]
132
+ # @return [Peddler::XMLParser]
133
+ def list_all_fulfillment_orders_by_next_token(next_token)
134
+ operation('ListAllFulfillmentOrdersByNextToken')
135
+ .add('NextToken' => next_token)
136
+
137
+ run
85
138
  end
86
139
 
87
140
  # Returns delivery tracking information for a package in an outbound
@@ -15,6 +15,143 @@ module MWS
15
15
  class OffAmazonPayments < ::Peddler::Client
16
16
  path '/OffAmazonPayments/2013-01-01/'
17
17
 
18
+ # Switches the client to the sandbox environment
19
+ #
20
+ # @see https://payments.amazon.com/help/Checkout-by-Amazon/Using-the-Checkout-by-Amazon-Sandbox/Overview-of-the-Sandbox
21
+ # @return [self]
22
+ def sandbox
23
+ self.path = '/OffAmazonPayments_Sandbox/2013-01-01/'
24
+ self
25
+ end
26
+
27
+ # Creates an order reference for the given object
28
+ #
29
+ # @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CreateOrderReferenceForId.html
30
+ # @param id [String]
31
+ # @param id_type [String]
32
+ # @param opts [Hash]
33
+ # @option opts [Boolean] :inherit_shipping_address
34
+ # @option opts [Boolean] :confirm_now
35
+ # @return [Peddler::XMLParser]
36
+ def create_order_reference_for_id(id, id_type, opts = {})
37
+ operation('CreateOrderReferenceForId')
38
+ .add(opts.merge(
39
+ 'Id' => id,
40
+ 'IdType' => id_type
41
+ ))
42
+
43
+ run
44
+ end
45
+
46
+ # Returns details about the Billing Agreement object and its current state
47
+ #
48
+ # @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetBillingAgreementDetails.html
49
+ # @param amazon_billing_agreement_id [String]
50
+ # @param opts [Hash]
51
+ # @option opts [String] :address_consent_token
52
+ # @return [Peddler::XMLParser]
53
+ def get_billing_agreement_details(amazon_billing_agreement_id, opts = {})
54
+ operation('GetBillingAgreementDetails')
55
+ .add(opts.merge(
56
+ 'AmazonBillingAgreementId' => amazon_billing_agreement_id
57
+ ))
58
+
59
+ run
60
+ end
61
+
62
+ # Sets billing agreement details such as a description of the agreement and
63
+ # other information about the seller
64
+ #
65
+ # @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetBillingAgreementDetails.html
66
+ # @param amazon_billing_agreement_id [String]
67
+ # @param billing_agreement_attributes [Struct, Hash]
68
+ # @return [Peddler::XMLParser]
69
+ def set_billing_agreement_details(amazon_billing_agreement_id, billing_agreement_attributes)
70
+ operation('SetBillingAgreementDetails')
71
+ .add(
72
+ 'AmazonBillingAgreementId' => amazon_billing_agreement_id,
73
+ 'BillingAgreementAttributes' => billing_agreement_attributes
74
+ )
75
+
76
+ run
77
+ end
78
+
79
+ # Confirms that the billing agreement is free of constraints and all
80
+ # required information has been set on the billing agreement
81
+ #
82
+ # @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmBillingAgreement.html
83
+ # @param amazon_billing_agreement_id [String]
84
+ # @return [Peddler::XMLParser]
85
+ def confirm_billing_agreement(amazon_billing_agreement_id)
86
+ operation('ConfirmBillingAgreement')
87
+ .add(
88
+ 'AmazonBillingAgreementId' => amazon_billing_agreement_id
89
+ )
90
+
91
+ run
92
+ end
93
+
94
+ # Validates the status of the BillingAgreement object and the payment method
95
+ # associated with it
96
+ #
97
+ # @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ValidateBillingAgreement.html
98
+ # @param amazon_billing_agreement_id [String]
99
+ # @return [Peddler::XMLParser]
100
+ def validate_billing_agreement(amazon_billing_agreement_id)
101
+ operation('ValidateBillingAgreement')
102
+ .add(
103
+ 'AmazonBillingAgreementId' => amazon_billing_agreement_id
104
+ )
105
+
106
+ run
107
+ end
108
+
109
+ # Reserves a specified amount against the payment method(s) stored in the
110
+ # billing agreement
111
+ #
112
+ # @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_AuthorizeOnBillingAgreement.html
113
+ # @param amazon_billing_agreement_id [String]
114
+ # @param authorization_reference_id [String]
115
+ # @param authorization_amount [Hash, Struct]
116
+ # @param opts [Hash]
117
+ # @option opts [String] :seller_authorization_note
118
+ # @option opts [Integer] :transaction_timeout
119
+ # @option opts [Boolean] :capture_now
120
+ # @option opts [String] :soft_descriptor
121
+ # @option opts [String] :seller_note
122
+ # @option opts [String] :platform_id
123
+ # @option opts [Hash, Struct] :seller_order_attributes
124
+ # @option opts [Boolean] :inherit_shipping_address
125
+ # @return [Peddler::XMLParser]
126
+ def authorize_on_billing_agreement(amazon_billing_agreement_id, authorization_reference_id, authorization_amount, opts = {})
127
+ operation('AuthorizeOnBillingAgreement')
128
+ .add(opts.merge(
129
+ 'AmazonBillingAgreementId' => amazon_billing_agreement_id,
130
+ 'AuthorizationReferenceId' => authorization_reference_id,
131
+ 'AuthorizationAmount' => authorization_amount
132
+ ))
133
+
134
+ run
135
+ end
136
+
137
+ # Confirms that you want to terminate the billing agreement with the buyer
138
+ # and that you do not expect to create any new order references or
139
+ # authorizations on this billing agreement
140
+ #
141
+ # @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseBillingAgreement.html
142
+ # @param amazon_billing_agreement_id [String]
143
+ # @param opts [Hash]
144
+ # @option opts [String] :closure_reason
145
+ # @return [Peddler::XMLParser]
146
+ def close_billing_agreement(amazon_billing_agreement_id, opts = {})
147
+ operation('CloseBillingAgreement')
148
+ .add(opts.merge(
149
+ 'AmazonBillingAgreementId' => amazon_billing_agreement_id
150
+ ))
151
+
152
+ run
153
+ end
154
+
18
155
  # Sets order reference details such as the order total and a description for
19
156
  # the order
20
157
  #
@@ -22,6 +22,7 @@ module Peddler
22
22
  'ATVPDKIKX0DER' => 'mws.amazonservices.com'
23
23
  }
24
24
 
25
+ attr_accessor :path
25
26
  attr_writer :merchant_id, :marketplace_id
26
27
  attr_reader :body
27
28
 
@@ -42,7 +43,7 @@ module Peddler
42
43
  end
43
44
 
44
45
  def aws_endpoint
45
- "https://#{host}#{self.class.path}"
46
+ "https://#{host}#{self.path || self.class.path}"
46
47
  end
47
48
 
48
49
  def marketplace_id
@@ -1,3 +1,3 @@
1
1
  module Peddler
2
- VERSION = '0.7.9'
2
+ VERSION = '0.7.10'
3
3
  end
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+ require 'mws/products'
3
+
4
+ class MWSOffAmazonPaymentsTest < MiniTest::Test
5
+ def test_sandbox
6
+ client = MWS::OffAmazonPayments.new(marketplace_id: 'A1F83G8C2ARO7P').sandbox
7
+ assert_includes client.aws_endpoint, 'OffAmazonPayments_Sandbox'
8
+ end
9
+ end
@@ -33,6 +33,13 @@ class PeddlerClientTest < MiniTest::Test
33
33
  assert @client.aws_endpoint.match(%r{/Foo$})
34
34
  end
35
35
 
36
+ def test_instance_path_overrides_class_path
37
+ @klass.path('/Foo')
38
+
39
+ @client.path = '/Foo/Bar'
40
+ assert @client.aws_endpoint.match(%r{/Foo/Bar$})
41
+ end
42
+
36
43
  def test_default_path
37
44
  assert_equal '/', @klass.path
38
45
  end
@@ -16,6 +16,13 @@ class PeddlerStructuredListTest < MiniTest::Test
16
16
  assert_equal exp, @list.build(%w(foo bar))
17
17
  end
18
18
 
19
+ def test_handles_single_key
20
+ list = Peddler::StructuredList.new('Foo')
21
+ exp = { 'Foo.1' => 'bar' }
22
+
23
+ assert_equal exp, list.build('bar')
24
+ end
25
+
19
26
  def test_handles_more_than_two_keys
20
27
  list = Peddler::StructuredList.new('QueryList', 'Query', '1', 'FilterOptions', 'FilterOption')
21
28
  exp = { 'QueryList.Query.1.FilterOptions.FilterOption.1' => 'foo' }
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.7.9
4
+ version: 0.7.10
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-05-15 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jeff
@@ -170,6 +170,7 @@ files:
170
170
  - test/integration_helper.rb
171
171
  - test/mws.yml
172
172
  - test/mws.yml.example
173
+ - test/unit/mws/test_off_amazon_payments.rb
173
174
  - test/unit/mws/test_products.rb
174
175
  - test/unit/peddler/test_client.rb
175
176
  - test/unit/peddler/test_flat_file_parser.rb
@@ -192,7 +193,8 @@ files:
192
193
  - test/vcr_cassettes/Sellers.yml
193
194
  - test/vcr_cassettes/Subscriptions.yml
194
195
  homepage: http://github.com/hakanensari/peddler
195
- licenses: []
196
+ licenses:
197
+ - MIT
196
198
  metadata: {}
197
199
  post_install_message:
198
200
  rdoc_options: []
@@ -232,6 +234,7 @@ test_files:
232
234
  - test/integration_helper.rb
233
235
  - test/mws.yml
234
236
  - test/mws.yml.example
237
+ - test/unit/mws/test_off_amazon_payments.rb
235
238
  - test/unit/mws/test_products.rb
236
239
  - test/unit/peddler/test_client.rb
237
240
  - test/unit/peddler/test_flat_file_parser.rb