peddler 0.8.0 → 0.9.0
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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +15 -14
- data/lib/mws/cart_information/client.rb +72 -0
- data/lib/mws/cart_information.rb +1 -69
- data/lib/mws/customer_information/client.rb +79 -0
- data/lib/mws/customer_information.rb +1 -77
- data/lib/mws/feeds/client.rb +112 -0
- data/lib/mws/feeds.rb +1 -110
- data/lib/mws/fulfillment_inbound_shipment/client.rb +233 -0
- data/lib/mws/fulfillment_inbound_shipment.rb +1 -231
- data/lib/mws/fulfillment_inventory/client.rb +53 -0
- data/lib/mws/fulfillment_inventory.rb +1 -51
- data/lib/mws/fulfillment_outbound_shipment/client.rb +171 -0
- data/lib/mws/fulfillment_outbound_shipment.rb +1 -168
- data/lib/mws/off_amazon_payments/client.rb +362 -0
- data/lib/mws/off_amazon_payments.rb +1 -360
- data/lib/mws/orders/client.rb +102 -0
- data/lib/mws/orders.rb +1 -98
- data/lib/mws/products/client.rb +234 -0
- data/lib/mws/products.rb +1 -232
- data/lib/mws/recommendations/client.rb +71 -0
- data/lib/mws/recommendations.rb +1 -66
- data/lib/mws/reports/client.rb +220 -0
- data/lib/mws/reports.rb +1 -220
- data/lib/mws/sellers/client.rb +42 -0
- data/lib/mws/sellers.rb +1 -40
- data/lib/mws/subscriptions/client.rb +177 -0
- data/lib/mws/subscriptions.rb +1 -169
- data/lib/mws.rb +2 -2
- data/lib/peddler/client.rb +3 -3
- data/lib/peddler/flat_file_parser.rb +3 -3
- data/lib/peddler/operation.rb +2 -3
- data/lib/peddler/structured_list.rb +1 -3
- data/lib/peddler/version.rb +1 -1
- data/lib/peddler/xml_parser.rb +1 -1
- data/test/integration/test_cart_information.rb +2 -2
- data/test/integration/test_customer_information.rb +2 -2
- data/test/integration/test_feeds.rb +2 -2
- data/test/integration/test_fulfillment_inbound_shipment.rb +2 -2
- data/test/integration/test_fulfillment_inventory.rb +3 -7
- data/test/integration/test_fulfillment_outbound_shipment.rb +2 -49
- data/test/integration/test_off_amazon_payments.rb +2 -2
- data/test/integration/test_orders.rb +2 -13
- data/test/integration/test_products.rb +2 -2
- data/test/integration/test_recommendations.rb +2 -11
- data/test/integration/test_reports.rb +2 -3
- data/test/integration/test_sellers.rb +2 -9
- data/test/integration/test_subscriptions.rb +2 -2
- data/test/integration_test_helper.rb +49 -0
- data/test/mws.yml +16 -0
- data/test/mws.yml.bak +16 -0
- data/test/test_helper.rb +7 -0
- data/test/unit/mws/test_off_amazon_payments_client.rb +9 -0
- data/test/unit/mws/test_products_client.rb +9 -0
- data/test/unit/peddler/test_client.rb +2 -2
- data/test/unit/peddler/test_flat_file_parser.rb +2 -2
- data/test/unit/peddler/test_operation.rb +2 -2
- data/test/unit/peddler/test_parser.rb +2 -2
- data/test/unit/peddler/test_structured_list.rb +2 -2
- data/test/unit/peddler/test_xml_parser.rb +2 -2
- data/test/unit/test_mws.rb +3 -3
- data/test/vcr_cassettes/CartInformation.yml +37 -725
- data/test/vcr_cassettes/CustomerInformation.yml +37 -728
- data/test/vcr_cassettes/Feeds.yml +100 -528
- data/test/vcr_cassettes/FulfillmentInboundShipment.yml +39 -728
- data/test/vcr_cassettes/FulfillmentInventory.yml +96 -997
- data/test/vcr_cassettes/FulfillmentOutboundShipment.yml +39 -725
- data/test/vcr_cassettes/OffAmazonPayments.yml +36 -727
- data/test/vcr_cassettes/Orders.yml +38 -29855
- data/test/vcr_cassettes/Products.yml +1300 -3871
- data/test/vcr_cassettes/Recommendations.yml +8934 -15590
- data/test/vcr_cassettes/Reports.yml +288 -1326
- data/test/vcr_cassettes/Sellers.yml +38 -1178
- data/test/vcr_cassettes/Subscriptions.yml +244 -1066
- metadata +27 -98
- data/test/helper.rb +0 -3
- data/test/integration_helper.rb +0 -49
- data/test/mws.yml.1 +0 -32
- data/test/mws.yml.example +0 -4
- data/test/unit/mws/test_off_amazon_payments.rb +0 -9
- data/test/unit/mws/test_products.rb +0 -9
@@ -0,0 +1,362 @@
|
|
1
|
+
require 'peddler/client'
|
2
|
+
|
3
|
+
module MWS
|
4
|
+
module OffAmazonPayments
|
5
|
+
# The Off-Amazon Payments API helps you to process payments for purchases
|
6
|
+
# made by buyers on your website using the Login and Pay with Amazon
|
7
|
+
# service. This API enables you to programmatically retrieve shipping and
|
8
|
+
# payment information provided by the buyer from their Amazon account. It
|
9
|
+
# allows you to authorize, capture, and refund payments, enabling a variety
|
10
|
+
# of payments scenarios.
|
11
|
+
#
|
12
|
+
# @note The Off-Amazon Payments API section is only applicable to payments
|
13
|
+
# made through the Login and Pay with Amazon service offered by Amazon
|
14
|
+
# Payments. You cannot use this API section to process payments for Amazon
|
15
|
+
# Marketplace, Amazon Webstore, or Checkout by Amazon.
|
16
|
+
class Client < ::Peddler::Client
|
17
|
+
path '/OffAmazonPayments/2013-01-01/'
|
18
|
+
|
19
|
+
# Switches the client to the sandbox environment
|
20
|
+
#
|
21
|
+
# @see https://payments.amazon.com/help/Checkout-by-Amazon/Using-the-Checkout-by-Amazon-Sandbox/Overview-of-the-Sandbox
|
22
|
+
# @return [self]
|
23
|
+
def sandbox
|
24
|
+
self.path = '/OffAmazonPayments_Sandbox/2013-01-01/'
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
# Creates an order reference for the given object
|
29
|
+
#
|
30
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CreateOrderReferenceForId.html
|
31
|
+
# @param id [String]
|
32
|
+
# @param id_type [String]
|
33
|
+
# @param opts [Hash]
|
34
|
+
# @option opts [Boolean] :inherit_shipping_address
|
35
|
+
# @option opts [Boolean] :confirm_now
|
36
|
+
# @return [Peddler::XMLParser]
|
37
|
+
def create_order_reference_for_id(id, id_type, opts = {})
|
38
|
+
operation('CreateOrderReferenceForId')
|
39
|
+
.add(opts.merge(
|
40
|
+
'Id' => id,
|
41
|
+
'IdType' => id_type
|
42
|
+
))
|
43
|
+
|
44
|
+
run
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns details about the Billing Agreement object and its current state
|
48
|
+
#
|
49
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetBillingAgreementDetails.html
|
50
|
+
# @param amazon_billing_agreement_id [String]
|
51
|
+
# @param opts [Hash]
|
52
|
+
# @option opts [String] :address_consent_token
|
53
|
+
# @return [Peddler::XMLParser]
|
54
|
+
def get_billing_agreement_details(amazon_billing_agreement_id, opts = {})
|
55
|
+
operation('GetBillingAgreementDetails')
|
56
|
+
.add(opts.merge(
|
57
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id
|
58
|
+
))
|
59
|
+
|
60
|
+
run
|
61
|
+
end
|
62
|
+
|
63
|
+
# Sets billing agreement details such as a description of the agreement
|
64
|
+
# and other information about the seller
|
65
|
+
#
|
66
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetBillingAgreementDetails.html
|
67
|
+
# @param amazon_billing_agreement_id [String]
|
68
|
+
# @param billing_agreement_attributes [Struct, Hash]
|
69
|
+
# @return [Peddler::XMLParser]
|
70
|
+
def set_billing_agreement_details(amazon_billing_agreement_id, billing_agreement_attributes)
|
71
|
+
operation('SetBillingAgreementDetails')
|
72
|
+
.add(
|
73
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id,
|
74
|
+
'BillingAgreementAttributes' => billing_agreement_attributes
|
75
|
+
)
|
76
|
+
|
77
|
+
run
|
78
|
+
end
|
79
|
+
|
80
|
+
# Confirms that the billing agreement is free of constraints and all
|
81
|
+
# required information has been set on the billing agreement
|
82
|
+
#
|
83
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmBillingAgreement.html
|
84
|
+
# @param amazon_billing_agreement_id [String]
|
85
|
+
# @return [Peddler::XMLParser]
|
86
|
+
def confirm_billing_agreement(amazon_billing_agreement_id)
|
87
|
+
operation('ConfirmBillingAgreement')
|
88
|
+
.add(
|
89
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id
|
90
|
+
)
|
91
|
+
|
92
|
+
run
|
93
|
+
end
|
94
|
+
|
95
|
+
# Validates the status of the BillingAgreement object and the payment
|
96
|
+
# method associated with it
|
97
|
+
#
|
98
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ValidateBillingAgreement.html
|
99
|
+
# @param amazon_billing_agreement_id [String]
|
100
|
+
# @return [Peddler::XMLParser]
|
101
|
+
def validate_billing_agreement(amazon_billing_agreement_id)
|
102
|
+
operation('ValidateBillingAgreement')
|
103
|
+
.add(
|
104
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id
|
105
|
+
)
|
106
|
+
|
107
|
+
run
|
108
|
+
end
|
109
|
+
|
110
|
+
# Reserves a specified amount against the payment method(s) stored in the
|
111
|
+
# billing agreement
|
112
|
+
#
|
113
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_AuthorizeOnBillingAgreement.html
|
114
|
+
# @param amazon_billing_agreement_id [String]
|
115
|
+
# @param authorization_reference_id [String]
|
116
|
+
# @param authorization_amount [Hash, Struct]
|
117
|
+
# @param opts [Hash]
|
118
|
+
# @option opts [String] :seller_authorization_note
|
119
|
+
# @option opts [Integer] :transaction_timeout
|
120
|
+
# @option opts [Boolean] :capture_now
|
121
|
+
# @option opts [String] :soft_descriptor
|
122
|
+
# @option opts [String] :seller_note
|
123
|
+
# @option opts [String] :platform_id
|
124
|
+
# @option opts [Hash, Struct] :seller_order_attributes
|
125
|
+
# @option opts [Boolean] :inherit_shipping_address
|
126
|
+
# @return [Peddler::XMLParser]
|
127
|
+
def authorize_on_billing_agreement(amazon_billing_agreement_id, authorization_reference_id, authorization_amount, opts = {})
|
128
|
+
operation('AuthorizeOnBillingAgreement')
|
129
|
+
.add(opts.merge(
|
130
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id,
|
131
|
+
'AuthorizationReferenceId' => authorization_reference_id,
|
132
|
+
'AuthorizationAmount' => authorization_amount
|
133
|
+
))
|
134
|
+
|
135
|
+
run
|
136
|
+
end
|
137
|
+
|
138
|
+
# Confirms that you want to terminate the billing agreement with the buyer
|
139
|
+
# and that you do not expect to create any new order references or
|
140
|
+
# authorizations on this billing agreement
|
141
|
+
#
|
142
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseBillingAgreement.html
|
143
|
+
# @param amazon_billing_agreement_id [String]
|
144
|
+
# @param opts [Hash]
|
145
|
+
# @option opts [String] :closure_reason
|
146
|
+
# @return [Peddler::XMLParser]
|
147
|
+
def close_billing_agreement(amazon_billing_agreement_id, opts = {})
|
148
|
+
operation('CloseBillingAgreement')
|
149
|
+
.add(opts.merge(
|
150
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id
|
151
|
+
))
|
152
|
+
|
153
|
+
run
|
154
|
+
end
|
155
|
+
|
156
|
+
# Sets order reference details such as the order total and a description
|
157
|
+
# for the order
|
158
|
+
#
|
159
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetOrderReferenceDetails.html
|
160
|
+
# @param amazon_order_reference_id [String]
|
161
|
+
# @param order_total [Struct, Hash]
|
162
|
+
# @param opts [Hash]
|
163
|
+
# @option opts [String] :platform_id
|
164
|
+
# @option opts [String] :seller_note
|
165
|
+
# @option opts [Struct, Hash] :seller_order_attributes
|
166
|
+
# @return [Peddler::XMLParser]
|
167
|
+
def set_order_reference_details(amazon_order_reference_id, order_total, opts = {})
|
168
|
+
operation('SetOrderReferenceDetails')
|
169
|
+
.add(
|
170
|
+
'AmazonOrderReferenceId' => amazon_order_reference_id,
|
171
|
+
'OrderReferenceAttributes' => opts.merge('OrderTotal' => order_total)
|
172
|
+
)
|
173
|
+
|
174
|
+
run
|
175
|
+
end
|
176
|
+
|
177
|
+
# Returns details about the Order Reference object and its current state
|
178
|
+
#
|
179
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetOrderReferenceDetails.html
|
180
|
+
# @param amazon_order_reference_id [String]
|
181
|
+
# @param opts [Hash]
|
182
|
+
# @option opts [String] address_consent_token
|
183
|
+
# @return [Peddler::XMLParser]
|
184
|
+
def get_order_reference_details(amazon_order_reference_id, opts = {})
|
185
|
+
operation('GetOrderReferenceDetails')
|
186
|
+
.add(opts.merge('AmazonOrderReferenceId' => amazon_order_reference_id))
|
187
|
+
|
188
|
+
run
|
189
|
+
end
|
190
|
+
|
191
|
+
# Confirms that the order reference is free of constraints and all required
|
192
|
+
# information has been set on the order reference
|
193
|
+
#
|
194
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmOrderReference.html
|
195
|
+
# @param amazon_order_reference_id [String]
|
196
|
+
# @return [Peddler::XMLParser]
|
197
|
+
def confirm_order_reference(amazon_order_reference_id)
|
198
|
+
operation('ConfirmOrderReference')
|
199
|
+
.add('AmazonOrderReferenceId' => amazon_order_reference_id)
|
200
|
+
|
201
|
+
run
|
202
|
+
end
|
203
|
+
|
204
|
+
# Cancels a previously confirmed order reference
|
205
|
+
#
|
206
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CancelOrderReference.html
|
207
|
+
# @param amazon_order_reference_id [String]
|
208
|
+
# @param opts [Hash]
|
209
|
+
# @option opts [String] cancelation_reason
|
210
|
+
# @return [Peddler::XMLParser]
|
211
|
+
def cancel_order_reference(amazon_order_reference_id, opts = {})
|
212
|
+
operation('CancelOrderReference')
|
213
|
+
.add(opts.merge('AmazonOrderReferenceId' => amazon_order_reference_id))
|
214
|
+
|
215
|
+
run
|
216
|
+
end
|
217
|
+
|
218
|
+
# Confirms that an order reference has been fulfilled (fully or partially)
|
219
|
+
# and that you do not expect to create any new authorizations on this
|
220
|
+
# order reference
|
221
|
+
#
|
222
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
|
223
|
+
# @param amazon_order_reference_id [String]
|
224
|
+
# @param opts [Hash]
|
225
|
+
# @option opts [String] closure_reason
|
226
|
+
# @return [Peddler::XMLParser]
|
227
|
+
def close_order_reference(amazon_order_reference_id, opts = {})
|
228
|
+
operation('CloseOrderReference')
|
229
|
+
.add(opts.merge('AmazonOrderReferenceId' => amazon_order_reference_id))
|
230
|
+
|
231
|
+
run
|
232
|
+
end
|
233
|
+
|
234
|
+
# Reserves a specified amount against the payment method(s) stored in the
|
235
|
+
# order reference
|
236
|
+
#
|
237
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Authorize.html
|
238
|
+
# @param amazon_order_reference_id [String]
|
239
|
+
# @param authorization_reference_id [String]
|
240
|
+
# @param authorization_amount [Struct, Hash]
|
241
|
+
# @param opts [Hash]
|
242
|
+
# @option opts [String] :seller_authorization_note
|
243
|
+
# @option opts [Integer] :transaction_timeout
|
244
|
+
# @option opts [Boolean] :capture_now
|
245
|
+
# @option opts [String] :soft_descriptor
|
246
|
+
# @return [Peddler::XMLParser]
|
247
|
+
def authorize(amazon_order_reference_id, authorization_reference_id, authorization_amount, opts = {})
|
248
|
+
operation('Authorize')
|
249
|
+
.add(opts.merge(
|
250
|
+
'AmazonOrderReferenceId' => amazon_order_reference_id,
|
251
|
+
'AuthorizationReferenceId' => authorization_reference_id,
|
252
|
+
'AuthorizationAmount' => authorization_amount
|
253
|
+
))
|
254
|
+
|
255
|
+
run
|
256
|
+
end
|
257
|
+
|
258
|
+
# Returns the status of a particular authorization and the total amount
|
259
|
+
# captured on the authorization
|
260
|
+
#
|
261
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetAuthorizationDetails.html
|
262
|
+
# @param amazon_authorization_id [String]
|
263
|
+
# @return [Peddler::XMLParser]
|
264
|
+
def get_authorization_details(amazon_authorization_id)
|
265
|
+
operation('GetAuthorizationDetails')
|
266
|
+
.add('AmazonAuthorizationId' => amazon_authorization_id)
|
267
|
+
|
268
|
+
run
|
269
|
+
end
|
270
|
+
|
271
|
+
# Captures funds from an authorized payment instrument
|
272
|
+
#
|
273
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Capture.html
|
274
|
+
# @param amazon_authorization_id [String]
|
275
|
+
# @param capture_reference_id [String]
|
276
|
+
# @param capture_amount [Struct, Hash]
|
277
|
+
# @param opts [Hash]
|
278
|
+
# @option opts [String] :seller_capture_note
|
279
|
+
# @option opts [String] :soft_descriptor
|
280
|
+
# @return [Peddler::XMLParser]
|
281
|
+
def capture(amazon_authorization_id, capture_reference_id, capture_amount, opts = {})
|
282
|
+
operation('Capture')
|
283
|
+
.add(opts.merge(
|
284
|
+
'AmazonAuthorizationId' => amazon_authorization_id,
|
285
|
+
'CaptureReferenceId' => capture_reference_id,
|
286
|
+
'CaptureAmount' => capture_amount
|
287
|
+
))
|
288
|
+
|
289
|
+
run
|
290
|
+
end
|
291
|
+
|
292
|
+
# Returns the status of a particular capture and the total amount refunded
|
293
|
+
# on the capture
|
294
|
+
#
|
295
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetCaptureDetails.html
|
296
|
+
# @param amazon_capture_id [String]
|
297
|
+
# @return [Peddler::XMLParser]
|
298
|
+
def get_capture_details(amazon_capture_id)
|
299
|
+
operation('GetAuthorizationDetails')
|
300
|
+
.add('AmazonCaptureId' => amazon_capture_id)
|
301
|
+
|
302
|
+
run
|
303
|
+
end
|
304
|
+
|
305
|
+
# Closes an authorization
|
306
|
+
#
|
307
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseAuthorization.html
|
308
|
+
# @param amazon_authorization_id [String]
|
309
|
+
# @param opts [Hash]
|
310
|
+
# @option opts [String] closure_reason
|
311
|
+
# @return [Peddler::XMLParser]
|
312
|
+
def close_authorization(amazon_authorization_id, opts = {})
|
313
|
+
operation('CloseAuthorization')
|
314
|
+
.add(opts.merge('AmazonAuthorizationId' => amazon_authorization_id))
|
315
|
+
|
316
|
+
run
|
317
|
+
end
|
318
|
+
|
319
|
+
# Refunds a previously captured amount
|
320
|
+
#
|
321
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Refund.html
|
322
|
+
# @param amazon_capture_id [String]
|
323
|
+
# @param refund_reference_id [String]
|
324
|
+
# @param refund_amount [Struct, Hash]
|
325
|
+
# @param opts [Hash]
|
326
|
+
# @option opts [String] :seller_refund_note
|
327
|
+
# @option opts [String] :soft_descriptor
|
328
|
+
# @return [Peddler::XMLParser]
|
329
|
+
def refund(amazon_capture_id, refund_reference_id, refund_amount, opts = {})
|
330
|
+
operation('Refund')
|
331
|
+
.add(opts.merge(
|
332
|
+
'AmazonCaptureId' => amazon_capture_id,
|
333
|
+
'RefundReferenceId' => refund_reference_id,
|
334
|
+
'RefundAmount' => refund_amount
|
335
|
+
))
|
336
|
+
|
337
|
+
run
|
338
|
+
end
|
339
|
+
|
340
|
+
# Returns the status of a particular refund
|
341
|
+
#
|
342
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetRefundDetails.html
|
343
|
+
# @param amazon_refund_id [String]
|
344
|
+
# @return [Peddler::XMLParser]
|
345
|
+
def get_refund_details(amazon_refund_id)
|
346
|
+
operation('GetRefundDetails')
|
347
|
+
.add('AmazonRefundId' => amazon_refund_id)
|
348
|
+
|
349
|
+
run
|
350
|
+
end
|
351
|
+
|
352
|
+
# Gets the operational status of the API
|
353
|
+
#
|
354
|
+
# @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetServiceStatus.html
|
355
|
+
# @return [Peddler::XMLParser]
|
356
|
+
def get_service_status
|
357
|
+
operation('GetServiceStatus')
|
358
|
+
run
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|