peddler 2.1.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -41
  3. data/lib/mws.rb +2 -1
  4. data/lib/mws/easy_ship.rb +3 -0
  5. data/lib/mws/easy_ship/client.rb +93 -0
  6. data/lib/mws/fulfillment_outbound_shipment/client.rb +1 -1
  7. data/lib/mws/orders/client.rb +6 -6
  8. data/lib/mws/shipment_invoicing.rb +3 -0
  9. data/lib/mws/shipment_invoicing/client.rb +74 -0
  10. data/lib/peddler/client.rb +11 -10
  11. data/lib/peddler/content.rb +2 -2
  12. data/lib/peddler/errors/builder.rb +7 -2
  13. data/lib/peddler/errors/class_generator.rb +1 -1
  14. data/lib/peddler/errors/error.rb +6 -2
  15. data/lib/peddler/errors/parser.rb +1 -1
  16. data/lib/peddler/flat_file_parser.rb +5 -3
  17. data/lib/peddler/marketplace.rb +23 -19
  18. data/lib/peddler/mws.rb +2 -2
  19. data/lib/peddler/operation.rb +17 -11
  20. data/lib/peddler/parser.rb +1 -1
  21. data/lib/peddler/structured_list.rb +1 -1
  22. data/lib/peddler/vcr_matcher.rb +7 -7
  23. data/lib/peddler/version.rb +1 -1
  24. data/lib/peddler/xml_parser.rb +1 -1
  25. data/lib/peddler/xml_response_parser.rb +1 -1
  26. metadata +11 -146
  27. data/lib/mws/off_amazon_payments/client.rb +0 -362
  28. data/test/credentials.rb +0 -23
  29. data/test/helper.rb +0 -15
  30. data/test/integration/internals/test_errors.rb +0 -17
  31. data/test/integration/internals/test_multibyte_queries.rb +0 -17
  32. data/test/integration/internals/test_mws_headers.rb +0 -21
  33. data/test/integration/internals/test_string_encodings.rb +0 -38
  34. data/test/integration/test_feeds.rb +0 -37
  35. data/test/integration/test_fulfillment_inbound_shipment.rb +0 -35
  36. data/test/integration/test_fulfillment_inventory.rb +0 -20
  37. data/test/integration/test_fulfillment_outbound_shipment.rb +0 -13
  38. data/test/integration/test_merchant_fulfillment.rb +0 -69
  39. data/test/integration/test_off_amazon_payments.rb +0 -13
  40. data/test/integration/test_orders.rb +0 -30
  41. data/test/integration/test_products.rb +0 -97
  42. data/test/integration/test_recommendations.rb +0 -20
  43. data/test/integration/test_reports.rb +0 -51
  44. data/test/integration/test_sellers.rb +0 -13
  45. data/test/integration/test_subscriptions.rb +0 -27
  46. data/test/integration_helper.rb +0 -53
  47. data/test/mws.yml +0 -36
  48. data/test/mws.yml.example +0 -32
  49. data/test/null_client.rb +0 -25
  50. data/test/recorder.rb +0 -39
  51. data/test/unit/mws/test_feeds_client.rb +0 -103
  52. data/test/unit/mws/test_finances_client.rb +0 -74
  53. data/test/unit/mws/test_fulfillment_inbound_shipment_client.rb +0 -426
  54. data/test/unit/mws/test_fulfillment_inventory_client.rb +0 -48
  55. data/test/unit/mws/test_fulfillment_outbound_shipment_client.rb +0 -202
  56. data/test/unit/mws/test_merchant_fulfillment_client.rb +0 -109
  57. data/test/unit/mws/test_off_amazon_payments_client.rb +0 -286
  58. data/test/unit/mws/test_orders_client.rb +0 -111
  59. data/test/unit/mws/test_products_client.rb +0 -248
  60. data/test/unit/mws/test_recommendations_client.rb +0 -62
  61. data/test/unit/mws/test_reports_client.rb +0 -209
  62. data/test/unit/mws/test_sellers_client.rb +0 -47
  63. data/test/unit/mws/test_subscriptions_client.rb +0 -182
  64. data/test/unit/peddler/errors/test_builder.rb +0 -65
  65. data/test/unit/peddler/errors/test_class_generator.rb +0 -18
  66. data/test/unit/peddler/errors/test_error.rb +0 -33
  67. data/test/unit/peddler/errors/test_parser.rb +0 -44
  68. data/test/unit/peddler/test_client.rb +0 -203
  69. data/test/unit/peddler/test_flat_file_parser.rb +0 -111
  70. data/test/unit/peddler/test_headers.rb +0 -103
  71. data/test/unit/peddler/test_marketplace.rb +0 -47
  72. data/test/unit/peddler/test_operation.rb +0 -87
  73. data/test/unit/peddler/test_parser.rb +0 -36
  74. data/test/unit/peddler/test_structured_list.rb +0 -39
  75. data/test/unit/peddler/test_vcr_matcher.rb +0 -55
  76. data/test/unit/peddler/test_xml_parser.rb +0 -37
  77. data/test/unit/peddler/test_xml_response_parser.rb +0 -39
  78. data/test/unit/test_mws.rb +0 -11
  79. data/test/vcr_cassettes/CartInformation.yml +0 -433
  80. data/test/vcr_cassettes/CustomerInformation.yml +0 -433
  81. data/test/vcr_cassettes/Errors.yml +0 -444
  82. data/test/vcr_cassettes/Feeds.yml +0 -9957
  83. data/test/vcr_cassettes/FulfillmentInboundShipment.yml +0 -6166
  84. data/test/vcr_cassettes/FulfillmentInventory.yml +0 -850
  85. data/test/vcr_cassettes/FulfillmentOutboundShipment.yml +0 -433
  86. data/test/vcr_cassettes/MWSHeaders.yml +0 -2964
  87. data/test/vcr_cassettes/MerchantFulfillment.yml +0 -753
  88. data/test/vcr_cassettes/MultibyteQueries.yml +0 -437
  89. data/test/vcr_cassettes/OffAmazonPayments.yml +0 -433
  90. data/test/vcr_cassettes/Orders.yml +0 -4740
  91. data/test/vcr_cassettes/PeddlerVCRMatcher.yml +0 -41
  92. data/test/vcr_cassettes/Products.yml +0 -7139
  93. data/test/vcr_cassettes/Recommendations.yml +0 -3145
  94. data/test/vcr_cassettes/Reports.yml +0 -5549
  95. data/test/vcr_cassettes/Sellers.yml +0 -433
  96. data/test/vcr_cassettes/Subscriptions.yml +0 -1529
@@ -1,362 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'peddler/client'
4
-
5
- module MWS
6
- module OffAmazonPayments
7
- # The Off-Amazon Payments API helps you to process payments for purchases
8
- # made by buyers on your website using the Login and Pay with Amazon
9
- # service. This API enables you to programmatically retrieve shipping and
10
- # payment information provided by the buyer from their Amazon account. It
11
- # allows you to authorize, capture, and refund payments, enabling a variety
12
- # of payments scenarios.
13
- #
14
- # @note The Off-Amazon Payments API section is only applicable to payments
15
- # made through the Login and Pay with Amazon service offered by Amazon
16
- # Payments. You cannot use this API section to process payments for Amazon
17
- # Marketplace, Amazon Webstore, or Checkout by Amazon.
18
- class Client < ::Peddler::Client
19
- self.version = '2013-01-01'
20
- self.path = "/OffAmazonPayments/#{version}/"
21
-
22
- # Switches the client to the sandbox environment
23
- #
24
- # @see https://payments.amazon.com/help/Checkout-by-Amazon/Using-the-Checkout-by-Amazon-Sandbox/Overview-of-the-Sandbox
25
- # @return [self]
26
- def sandbox
27
- self.path = "/OffAmazonPayments_Sandbox/#{version}/"
28
- self
29
- end
30
-
31
- # Reserves a specified amount against the payment method(s) stored in the
32
- # order reference
33
- #
34
- # @see https://payments.amazon.com/documentation/apireference/201752010
35
- # @param [String] amazon_order_reference_id
36
- # @param [String] authorization_reference_id
37
- # @param [Struct, Hash] authorization_amount
38
- # @param [Hash] opts
39
- # @option opts [String] :seller_authorization_note
40
- # @option opts [Integer] :transaction_timeout
41
- # @option opts [Boolean] :capture_now
42
- # @option opts [String] :soft_descriptor
43
- # @return [Peddler::XMLParser]
44
- def authorize(amazon_order_reference_id, authorization_reference_id,
45
- authorization_amount, opts = {})
46
- operation('Authorize')
47
- .add(opts)
48
- .add('AmazonOrderReferenceId' => amazon_order_reference_id,
49
- 'AuthorizationReferenceId' => authorization_reference_id,
50
- 'AuthorizationAmount' => authorization_amount)
51
-
52
- run
53
- end
54
-
55
- # Cancels a previously confirmed order reference
56
- #
57
- # @see https://payments.amazon.com/documentation/apireference/201751990
58
- # @param [String] amazon_order_reference_id
59
- # @param [Hash] opts
60
- # @option opts [String] cancelation_reason
61
- # @return [Peddler::XMLParser]
62
- def cancel_order_reference(amazon_order_reference_id, opts = {})
63
- operation('CancelOrderReference')
64
- .add(opts)
65
- .add('AmazonOrderReferenceId' => amazon_order_reference_id)
66
-
67
- run
68
- end
69
-
70
- # Captures funds from an authorized payment instrument
71
- #
72
- # @see https://payments.amazon.com/documentation/apireference/201752040
73
- # @param [String] amazon_authorization_id
74
- # @param [String] capture_reference_id
75
- # @param [Struct, Hash] capture_amount
76
- # @param [Hash] opts
77
- # @option opts [String] :seller_capture_note
78
- # @option opts [String] :soft_descriptor
79
- # @return [Peddler::XMLParser]
80
- def capture(amazon_authorization_id, capture_reference_id, capture_amount,
81
- opts = {})
82
- operation('Capture')
83
- .add(opts)
84
- .add('AmazonAuthorizationId' => amazon_authorization_id,
85
- 'CaptureReferenceId' => capture_reference_id,
86
- 'CaptureAmount' => capture_amount)
87
-
88
- run
89
- end
90
-
91
- # Closes an authorization
92
- #
93
- # @see https://payments.amazon.com/documentation/apireference/201752070
94
- # @param [String] amazon_authorization_id
95
- # @param [Hash] opts
96
- # @option opts [String] closure_reason
97
- # @return [Peddler::XMLParser]
98
- def close_authorization(amazon_authorization_id, opts = {})
99
- operation('CloseAuthorization')
100
- .add(opts)
101
- .add('AmazonAuthorizationId' => amazon_authorization_id)
102
-
103
- run
104
- end
105
-
106
- # Confirms that an order reference has been fulfilled (fully or partially)
107
- # and that you do not expect to create any new authorizations on this
108
- # order reference
109
- #
110
- # @see https://payments.amazon.com/documentation/apireference/201752000
111
- # @param [String] amazon_order_reference_id
112
- # @param [Hash] opts
113
- # @option opts [String] closure_reason
114
- # @return [Peddler::XMLParser]
115
- def close_order_reference(amazon_order_reference_id, opts = {})
116
- operation('CloseOrderReference')
117
- .add(opts)
118
- .add('AmazonOrderReferenceId' => amazon_order_reference_id)
119
-
120
- run
121
- end
122
-
123
- # Confirms that the order reference is free of constraints and all
124
- # required information has been set on the order reference
125
- #
126
- # @see https://payments.amazon.com/documentation/apireference/201751980
127
- # @param [String] amazon_order_reference_id
128
- # @return [Peddler::XMLParser]
129
- def confirm_order_reference(amazon_order_reference_id)
130
- operation('ConfirmOrderReference')
131
- .add('AmazonOrderReferenceId' => amazon_order_reference_id)
132
-
133
- run
134
- end
135
-
136
- # Creates an order reference for the given object
137
- #
138
- # @see https://payments.amazon.com/documentation/apireference/201751670
139
- # @param [String] id
140
- # @param [String] id_type
141
- # @param [Hash] opts
142
- # @option opts [Boolean] :inherit_shipping_address
143
- # @option opts [Boolean] :confirm_now
144
- # @option opts [Struct, Hash] :order_reference_attributes
145
- # @return [Peddler::XMLParser]
146
- def create_order_reference_for_id(id, id_type, opts = {})
147
- operation('CreateOrderReferenceForId')
148
- .add(opts)
149
- .add('Id' => id, 'IdType' => id_type)
150
-
151
- run
152
- end
153
-
154
- # Returns the status of a particular authorization and the total amount
155
- # captured on the authorization
156
- #
157
- # @see https://payments.amazon.com/documentation/apireference/201752030
158
- # @param [String] amazon_authorization_id
159
- # @return [Peddler::XMLParser]
160
- def get_authorization_details(amazon_authorization_id)
161
- operation('GetAuthorizationDetails')
162
- .add('AmazonAuthorizationId' => amazon_authorization_id)
163
-
164
- run
165
- end
166
-
167
- # Returns the status of a particular capture and the total amount refunded
168
- # on the capture
169
- #
170
- # @see https://payments.amazon.com/documentation/apireference/201752060
171
- # @param [String] amazon_capture_id
172
- # @return [Peddler::XMLParser]
173
- def get_capture_details(amazon_capture_id)
174
- operation('GetCaptureDetails')
175
- .add('AmazonCaptureId' => amazon_capture_id)
176
-
177
- run
178
- end
179
-
180
- # Returns details about the Order Reference object and its current state
181
- #
182
- # @see https://payments.amazon.com/documentation/apireference/201751970
183
- # @param [String] amazon_order_reference_id
184
- # @param [Hash] opts
185
- # @option opts [String] address_consent_token
186
- # @return [Peddler::XMLParser]
187
- def get_order_reference_details(amazon_order_reference_id, opts = {})
188
- operation('GetOrderReferenceDetails')
189
- .add(opts)
190
- .add('AmazonOrderReferenceId' => amazon_order_reference_id)
191
-
192
- run
193
- end
194
-
195
- # Returns the status of a particular refund
196
- #
197
- # @see https://payments.amazon.com/documentation/apireference/201752100
198
- # @param [String] amazon_refund_id
199
- # @return [Peddler::XMLParser]
200
- def get_refund_details(amazon_refund_id)
201
- operation('GetRefundDetails')
202
- .add('AmazonRefundId' => amazon_refund_id)
203
-
204
- run
205
- end
206
-
207
- # Gets the operational status of the API
208
- #
209
- # @see https://payments.amazon.com/documentation/apireference/201752110
210
- # @return [Peddler::XMLParser]
211
- def get_service_status
212
- operation('GetServiceStatus')
213
- run
214
- end
215
-
216
- # Refunds a previously captured amount
217
- #
218
- # @see https://payments.amazon.com/documentation/apireference/201752080
219
- # @param [String] amazon_capture_id
220
- # @param [String] refund_reference_id
221
- # @param [Struct, Hash] refund_amount
222
- # @param [Hash] opts
223
- # @option opts [String] :seller_refund_note
224
- # @option opts [String] :soft_descriptor
225
- # @return [Peddler::XMLParser]
226
- def refund(amazon_capture_id, refund_reference_id, refund_amount,
227
- opts = {})
228
- operation('Refund')
229
- .add(opts)
230
- .add('AmazonCaptureId' => amazon_capture_id,
231
- 'RefundReferenceId' => refund_reference_id,
232
- 'RefundAmount' => refund_amount)
233
-
234
- run
235
- end
236
-
237
- # Sets order reference details such as the order total and a description
238
- # for the order
239
- #
240
- # @see https://payments.amazon.com/documentation/apireference/201751960
241
- # @param [String] amazon_order_reference_id
242
- # @param [Struct, Hash] order_total
243
- # @param [Hash] opts
244
- # @option opts [String] :platform_id
245
- # @option opts [String] :seller_note
246
- # @option opts [Struct, Hash] :seller_order_attributes
247
- # @return [Peddler::XMLParser]
248
- def set_order_reference_details(amazon_order_reference_id, order_total,
249
- opts = {})
250
- order_reference_attributes = opts.update('OrderTotal' => order_total)
251
- operation('SetOrderReferenceDetails')
252
- .add('AmazonOrderReferenceId' => amazon_order_reference_id,
253
- 'OrderReferenceAttributes' => order_reference_attributes)
254
-
255
- run
256
- end
257
-
258
- # Reserves a specified amount against the payment method(s) stored in the
259
- # billing agreement
260
- #
261
- # @see https://payments.amazon.com/documentation/apireference/201751940
262
- # @param [String] amazon_billing_agreement_id
263
- # @param [String] authorization_reference_id
264
- # @param [Hash, Struct] authorization_amount
265
- # @param [Hash] opts
266
- # @option opts [String] :seller_authorization_note
267
- # @option opts [Integer] :transaction_timeout
268
- # @option opts [Boolean] :capture_now
269
- # @option opts [String] :soft_descriptor
270
- # @option opts [String] :seller_note
271
- # @option opts [String] :platform_id
272
- # @option opts [Hash, Struct] :seller_order_attributes
273
- # @option opts [Boolean] :inherit_shipping_address
274
- # @return [Peddler::XMLParser]
275
- def authorize_on_billing_agreement(amazon_billing_agreement_id,
276
- authorization_reference_id,
277
- authorization_amount, opts = {})
278
- operation('AuthorizeOnBillingAgreement')
279
- .add(opts)
280
- .add('AmazonBillingAgreementId' => amazon_billing_agreement_id,
281
- 'AuthorizationReferenceId' => authorization_reference_id,
282
- 'AuthorizationAmount' => authorization_amount)
283
-
284
- run
285
- end
286
-
287
- # Confirms that you want to terminate the billing agreement with the buyer
288
- # and that you do not expect to create any new order references or
289
- # authorizations on this billing agreement
290
- #
291
- # @see https://payments.amazon.com/documentation/apireference/201751950
292
- # @param [String] amazon_billing_agreement_id
293
- # @param [Hash] opts
294
- # @option opts [String] :closure_reason
295
- # @return [Peddler::XMLParser]
296
- def close_billing_agreement(amazon_billing_agreement_id, opts = {})
297
- operation('CloseBillingAgreement')
298
- .add(opts)
299
- .add('AmazonBillingAgreementId' => amazon_billing_agreement_id)
300
-
301
- run
302
- end
303
-
304
- # Confirms that the billing agreement is free of constraints and all
305
- # required information has been set on the billing agreement
306
- #
307
- # @see https://payments.amazon.com/documentation/apireference/201751710
308
- # @param [String] amazon_billing_agreement_id
309
- # @return [Peddler::XMLParser]
310
- def confirm_billing_agreement(amazon_billing_agreement_id)
311
- operation('ConfirmBillingAgreement')
312
- .add('AmazonBillingAgreementId' => amazon_billing_agreement_id)
313
-
314
- run
315
- end
316
-
317
- # Returns details about the Billing Agreement object and its current state
318
- #
319
- # @see https://payments.amazon.com/documentation/apireference/201751690
320
- # @param [String] amazon_billing_agreement_id
321
- # @param [Hash] opts
322
- # @option opts [String] :address_consent_token
323
- # @return [Peddler::XMLParser]
324
- def get_billing_agreement_details(amazon_billing_agreement_id, opts = {})
325
- operation('GetBillingAgreementDetails')
326
- .add(opts)
327
- .add('AmazonBillingAgreementId' => amazon_billing_agreement_id)
328
-
329
- run
330
- end
331
-
332
- # Sets billing agreement details such as a description of the agreement
333
- # and other information about the seller
334
- #
335
- # @see https://payments.amazon.com/documentation/apireference/201751700
336
- # @param [String] amazon_billing_agreement_id
337
- # @param [Struct, Hash] billing_agreement_attributes
338
- # @return [Peddler::XMLParser]
339
- def set_billing_agreement_details(amazon_billing_agreement_id,
340
- billing_agreement_attributes)
341
- operation('SetBillingAgreementDetails')
342
- .add('AmazonBillingAgreementId' => amazon_billing_agreement_id,
343
- 'BillingAgreementAttributes' => billing_agreement_attributes)
344
-
345
- run
346
- end
347
-
348
- # Validates the status of the BillingAgreement object and the payment
349
- # method associated with it
350
- #
351
- # @see https://payments.amazon.com/documentation/apireference/201751720
352
- # @param [String] amazon_billing_agreement_id
353
- # @return [Peddler::XMLParser]
354
- def validate_billing_agreement(amazon_billing_agreement_id)
355
- operation('ValidateBillingAgreement')
356
- .add('AmazonBillingAgreementId' => amazon_billing_agreement_id)
357
-
358
- run
359
- end
360
- end
361
- end
362
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'forwardable'
4
- require 'yaml'
5
-
6
- module Credentials
7
- class <<self
8
- extend Forwardable
9
- include Enumerable
10
-
11
- attr_reader :all
12
-
13
- def_delegators :all, :each
14
- end
15
-
16
- %w[mws.yml mws.yml.example].each do |path|
17
- file = File.expand_path("../#{path}", __FILE__)
18
- if File.exist?(file)
19
- @all = YAML.load_file(file)
20
- break
21
- end
22
- end
23
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Keep SimpleCov at top.
4
- require 'simplecov'
5
- SimpleCov.start do
6
- add_filter '/test/'
7
- end
8
-
9
- require 'minitest/autorun'
10
- require 'minitest/focus'
11
- begin
12
- require 'pry'
13
- rescue LoadError
14
- nil
15
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'integration_helper'
4
- require 'mws/orders'
5
-
6
- class TestErrors < IntegrationTest
7
- use 'Orders'
8
-
9
- def test_invalid_key
10
- clients.each do |client|
11
- assert_raises Peddler::Errors::InvalidAccessKeyId do
12
- client.aws_access_key_id = 'foo'
13
- client.get_order('bar')
14
- end
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'integration_helper'
4
- require 'mws/products'
5
-
6
- class TestMultibyteQueries < IntegrationTest
7
- use 'Products'
8
-
9
- def test_posting_multibyte_queries_properly
10
- ret = clients.map do |client|
11
- res = client.list_matching_products(client.marketplace.id, 'félix guattari machinic eros')
12
- res.body.force_encoding 'UTF-8' if defined? Ox # Ox workaround
13
- res.parse
14
- end
15
- assert ret.map(&:to_s).join.include?('Félix')
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'integration_helper'
4
- require 'mws/products'
5
-
6
- class TestMWSHeaders < IntegrationTest
7
- use 'Products'
8
-
9
- def test_parsing_headers
10
- clients.each do |client|
11
- res = client.get_lowest_priced_offers_for_asin(client.marketplace.id,
12
- '1780935374', 'New')
13
- refute_nil res.mws_quota_max
14
- refute_nil res.mws_quota_remaining
15
- refute_nil res.mws_quota_resets_on
16
- refute_nil res.mws_request_id
17
- refute_nil res.mws_timestamp
18
- refute_nil res.mws_response_context
19
- end
20
- end
21
- end