peddler 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -6
  3. data/lib/peddler/api.rb +28 -13
  4. data/lib/peddler/{api → apis}/amazon_warehousing_and_distribution_2024_05_09.rb +5 -5
  5. data/lib/peddler/{api → apis}/aplus_content_2020_11_01.rb +12 -12
  6. data/lib/peddler/{api → apis}/application_integrations_2024_04_01.rb +5 -5
  7. data/lib/peddler/{api → apis}/application_management_2023_11_30.rb +3 -3
  8. data/lib/peddler/{api → apis}/catalog_items_2020_12_01.rb +4 -4
  9. data/lib/peddler/{api → apis}/catalog_items_2022_04_01.rb +5 -5
  10. data/lib/peddler/{api → apis}/catalog_items_v0.rb +5 -5
  11. data/lib/peddler/{api → apis}/data_kiosk_2023_11_15.rb +7 -7
  12. data/lib/peddler/{api → apis}/easy_ship_2022_03_23.rb +20 -21
  13. data/lib/peddler/{api → apis}/fba_inbound_eligibility_v1.rb +3 -3
  14. data/lib/peddler/{api → apis}/fba_inventory_v1.rb +6 -6
  15. data/lib/peddler/{api → apis}/feeds_2021_06_30.rb +12 -9
  16. data/lib/peddler/{api → apis}/finances_2024_06_19.rb +3 -3
  17. data/lib/peddler/apis/finances_v0.rb +135 -0
  18. data/lib/peddler/{api → apis}/fulfillment_inbound_2024_03_20.rb +84 -54
  19. data/lib/peddler/{api → apis}/fulfillment_inbound_v0.rb +27 -20
  20. data/lib/peddler/{api → apis}/fulfillment_outbound_2020_07_01.rb +16 -16
  21. data/lib/peddler/{api → apis}/invoices_2024_06_19.rb +9 -9
  22. data/lib/peddler/{api → apis}/listings_items_2020_09_01.rb +5 -5
  23. data/lib/peddler/{api → apis}/listings_items_2021_08_01.rb +7 -41
  24. data/lib/peddler/{api → apis}/listings_restrictions_2021_08_01.rb +3 -3
  25. data/lib/peddler/{api → apis}/merchant_fulfillment_v0.rb +14 -14
  26. data/lib/peddler/{api → apis}/messaging_v1.rb +15 -15
  27. data/lib/peddler/{api → apis}/notifications_v1.rb +10 -10
  28. data/lib/peddler/{api → apis}/orders_v0.rb +13 -13
  29. data/lib/peddler/{api → apis}/product_fees_v0.rb +5 -5
  30. data/lib/peddler/{api → apis}/product_pricing_2022_05_01.rb +8 -8
  31. data/lib/peddler/{api → apis}/product_pricing_v0.rb +8 -8
  32. data/lib/peddler/{api → apis}/product_type_definitions_2020_09_01.rb +4 -4
  33. data/lib/peddler/{api → apis}/replenishment_2022_11_07.rb +5 -5
  34. data/lib/peddler/{api → apis}/reports_2021_06_30.rb +12 -12
  35. data/lib/peddler/{api → apis}/sales_v1.rb +3 -3
  36. data/lib/peddler/{api → apis}/sellers_v1.rb +4 -4
  37. data/lib/peddler/{api → apis}/services_v1.rb +19 -19
  38. data/lib/peddler/{api → apis}/shipment_invoicing_v0.rb +5 -5
  39. data/lib/peddler/{api → apis}/shipping_v1.rb +11 -11
  40. data/lib/peddler/{api → apis}/shipping_v2.rb +19 -19
  41. data/lib/peddler/{api → apis}/solicitations_v1.rb +4 -4
  42. data/lib/peddler/{api → apis}/supply_sources_2020_07_01.rb +8 -8
  43. data/lib/peddler/{api → apis}/tokens_2021_03_01.rb +3 -3
  44. data/lib/peddler/{api → apis}/uploads_2020_11_01.rb +3 -3
  45. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_inventory_v1.rb +4 -4
  46. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_orders_2021_12_28.rb +5 -5
  47. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_orders_v1.rb +6 -6
  48. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_payments_v1.rb +4 -4
  49. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb +9 -9
  50. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_shipping_2021_12_28.rb +17 -17
  51. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_shipping_v1.rb +30 -30
  52. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_transactions_2021_12_28.rb +4 -4
  53. data/lib/peddler/{api → apis}/vendor_direct_fulfillment_transactions_v1.rb +4 -4
  54. data/lib/peddler/{api → apis}/vendor_invoices_v1.rb +4 -4
  55. data/lib/peddler/{api → apis}/vendor_orders_v1.rb +7 -7
  56. data/lib/peddler/{api → apis}/vendor_shipments_v1.rb +6 -6
  57. data/lib/peddler/{api → apis}/vendor_transaction_status_v1.rb +3 -3
  58. data/lib/peddler/endpoint.rb +2 -2
  59. data/lib/peddler/error.rb +21 -12
  60. data/lib/peddler/helpers/feeds_2021_06_30.rb +26 -0
  61. data/lib/peddler/json_feed_document.rb +31 -0
  62. data/lib/peddler/marketplace.rb +46 -2
  63. data/lib/peddler/response.rb +46 -0
  64. data/lib/peddler/version.rb +1 -1
  65. data/lib/peddler.rb +54 -55
  66. metadata +59 -56
  67. data/lib/peddler/api/finances_v0.rb +0 -148
@@ -5,11 +5,11 @@ require "peddler/api"
5
5
  module Peddler
6
6
  class << self
7
7
  def vendor_direct_fulfillment_shipping_2021_12_28(...)
8
- API::VendorDirectFulfillmentShipping20211228.new(...)
8
+ APIs::VendorDirectFulfillmentShipping20211228.new(...)
9
9
  end
10
10
  end
11
11
 
12
- class API
12
+ module APIs
13
13
  # Selling Partner API for Direct Fulfillment Shipping
14
14
  #
15
15
  # The Selling Partner API for Direct Fulfillment Shipping provides programmatic access to a direct fulfillment
@@ -31,7 +31,7 @@ module Peddler
31
31
  # @param next_token [String] Used for pagination when there are more ship labels than the specified result size
32
32
  # limit. The token value is returned in the previous API call.
33
33
  # @param rate_limit [Float] Requests per second
34
- # @return [Hash] The API response
34
+ # @return [Peddler::Response] The API response
35
35
  def get_shipping_labels(created_after, created_before, ship_from_party_id: nil, limit: nil, sort_order: "ASC",
36
36
  next_token: nil, rate_limit: 10.0)
37
37
  path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels"
@@ -50,9 +50,9 @@ module Peddler
50
50
  # Creates a shipping label for a purchase order and returns a transactionId for reference.
51
51
  #
52
52
  # @note This operation can make a dynamic sandbox call.
53
- # @param body [Hash] Request body that contains the shipping labels data.
53
+ # @param body [Hash] Request body containing the shipping labels data.
54
54
  # @param rate_limit [Float] Requests per second
55
- # @return [Hash] The API response
55
+ # @return [Peddler::Response] The API response
56
56
  def submit_shipping_label_request(body, rate_limit: 10.0)
57
57
  path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels"
58
58
 
@@ -62,10 +62,10 @@ module Peddler
62
62
  # Returns a shipping label for the purchaseOrderNumber that you specify.
63
63
  #
64
64
  # @note This operation can make a dynamic sandbox call.
65
- # @param purchase_order_number [String] The purchase order number for which you want to return the shipping label.
66
- # Should be the same `purchaseOrderNumber` as received in the order.
65
+ # @param purchase_order_number [String] The purchase order number for which you want to return the shipping label
66
+ # and should be the same purchaseOrderNumber as received in the order.
67
67
  # @param rate_limit [Float] Requests per second
68
- # @return [Hash] The API response
68
+ # @return [Peddler::Response] The API response
69
69
  def get_shipping_label(purchase_order_number, rate_limit: 10.0)
70
70
  path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/#{purchase_order_number}"
71
71
 
@@ -77,9 +77,9 @@ module Peddler
77
77
  # @note This operation can make a dynamic sandbox call.
78
78
  # @param purchase_order_number [String] The purchase order number for which you want to return the shipping
79
79
  # labels. It should be the same purchaseOrderNumber as received in the order.
80
- # @param body [Hash] The request payload that contains parameters for creating shipping labels.
80
+ # @param body [Hash] The request payload containing parameters for creating shipping labels.
81
81
  # @param rate_limit [Float] Requests per second
82
- # @return [Hash] The API response
82
+ # @return [Peddler::Response] The API response
83
83
  def create_shipping_labels(purchase_order_number, body, rate_limit: 10.0)
84
84
  path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/#{purchase_order_number}"
85
85
 
@@ -91,7 +91,7 @@ module Peddler
91
91
  # @note This operation can make a dynamic sandbox call.
92
92
  # @param body [Hash] Request body containing the shipment confirmations data.
93
93
  # @param rate_limit [Float] Requests per second
94
- # @return [Hash] The API response
94
+ # @return [Peddler::Response] The API response
95
95
  def submit_shipment_confirmations(body, rate_limit: 10.0)
96
96
  path = "/vendor/directFulfillment/shipping/2021-12-28/shipmentConfirmations"
97
97
 
@@ -103,9 +103,9 @@ module Peddler
103
103
  # order, when the package is outside of Amazon Network visibility.
104
104
  #
105
105
  # @note This operation can make a dynamic sandbox call.
106
- # @param body [Hash] Request body that contains the shipment status update data.
106
+ # @param body [Hash] Request body containing the shipment status update data.
107
107
  # @param rate_limit [Float] Requests per second
108
- # @return [Hash] The API response
108
+ # @return [Peddler::Response] The API response
109
109
  def submit_shipment_status_updates(body, rate_limit: 10.0)
110
110
  path = "/vendor/directFulfillment/shipping/2021-12-28/shipmentStatusUpdates"
111
111
 
@@ -128,7 +128,7 @@ module Peddler
128
128
  # @param next_token [String] Used for pagination when there are more orders than the specified result size limit.
129
129
  # The token value is returned in the previous API call.
130
130
  # @param rate_limit [Float] Requests per second
131
- # @return [Hash] The API response
131
+ # @return [Peddler::Response] The API response
132
132
  def get_customer_invoices(created_after, created_before, ship_from_party_id: nil, limit: nil, sort_order: nil,
133
133
  next_token: nil, rate_limit: 10.0)
134
134
  path = "/vendor/directFulfillment/shipping/2021-12-28/customerInvoices"
@@ -149,7 +149,7 @@ module Peddler
149
149
  # @note This operation can make a dynamic sandbox call.
150
150
  # @param purchase_order_number [String] Purchase order number of the shipment for which to return the invoice.
151
151
  # @param rate_limit [Float] Requests per second
152
- # @return [Hash] The API response
152
+ # @return [Peddler::Response] The API response
153
153
  def get_customer_invoice(purchase_order_number, rate_limit: 10.0)
154
154
  path = "/vendor/directFulfillment/shipping/2021-12-28/customerInvoices/#{purchase_order_number}"
155
155
 
@@ -171,7 +171,7 @@ module Peddler
171
171
  # @param next_token [String] Used for pagination when there are more packing slips than the specified result size
172
172
  # limit. The token value is returned in the previous API call.
173
173
  # @param rate_limit [Float] Requests per second
174
- # @return [Hash] The API response
174
+ # @return [Peddler::Response] The API response
175
175
  def get_packing_slips(created_after, created_before, ship_from_party_id: nil, limit: nil, sort_order: "ASC",
176
176
  next_token: nil, rate_limit: 10.0)
177
177
  path = "/vendor/directFulfillment/shipping/2021-12-28/packingSlips"
@@ -192,7 +192,7 @@ module Peddler
192
192
  # @note This operation can make a dynamic sandbox call.
193
193
  # @param purchase_order_number [String] The purchaseOrderNumber for the packing slip you want.
194
194
  # @param rate_limit [Float] Requests per second
195
- # @return [Hash] The API response
195
+ # @return [Peddler::Response] The API response
196
196
  def get_packing_slip(purchase_order_number, rate_limit: 10.0)
197
197
  path = "/vendor/directFulfillment/shipping/2021-12-28/packingSlips/#{purchase_order_number}"
198
198
 
@@ -5,33 +5,33 @@ require "peddler/api"
5
5
  module Peddler
6
6
  class << self
7
7
  def vendor_direct_fulfillment_shipping_v1(...)
8
- API::VendorDirectFulfillmentShippingV1.new(...)
8
+ APIs::VendorDirectFulfillmentShippingV1.new(...)
9
9
  end
10
10
  end
11
11
 
12
- class API
12
+ module APIs
13
13
  # Selling Partner API for Direct Fulfillment Shipping
14
14
  #
15
15
  # The Selling Partner API for Direct Fulfillment Shipping provides programmatic access to a direct fulfillment
16
16
  # vendor's shipping data.
17
17
  class VendorDirectFulfillmentShippingV1 < API
18
18
  # Returns a list of shipping labels created during the time frame that you specify. You define that time frame
19
- # using the `createdAfter` and `createdBefore` parameters. You must use both of these parameters. The date range
20
- # to search must not be more than 7 days.
19
+ # using the createdAfter and createdBefore parameters. You must use both of these parameters. The date range to
20
+ # search must not be more than 7 days.
21
21
  #
22
22
  # @note This operation can make a static sandbox call.
23
- # @param ship_from_party_id [String] The vendor `warehouseId` for order fulfillment. If not specified, the result
23
+ # @param ship_from_party_id [String] The vendor warehouseId for order fulfillment. If not specified, the result
24
24
  # will contain orders for all warehouses.
25
25
  # @param limit [Integer] The limit to the number of records returned.
26
26
  # @param created_after [String] Shipping labels that became available after this date and time will be included in
27
- # the result. Must be in {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date/time format.
27
+ # the result. Must be in ISO-8601 date/time format.
28
28
  # @param created_before [String] Shipping labels that became available before this date and time will be included
29
- # in the result. Must be in {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date/time format.
29
+ # in the result. Must be in ISO-8601 date/time format.
30
30
  # @param sort_order [String] Sort ASC or DESC by order creation date.
31
31
  # @param next_token [String] Used for pagination when there are more ship labels than the specified result size
32
32
  # limit. The token value is returned in the previous API call.
33
33
  # @param rate_limit [Float] Requests per second
34
- # @return [Hash] The API response
34
+ # @return [Peddler::Response] The API response
35
35
  def get_shipping_labels(created_after, created_before, ship_from_party_id: nil, limit: nil, sort_order: "ASC",
36
36
  next_token: nil, rate_limit: 10.0)
37
37
  path = "/vendor/directFulfillment/shipping/v1/shippingLabels"
@@ -47,25 +47,25 @@ module Peddler
47
47
  meter(rate_limit).get(path, params:)
48
48
  end
49
49
 
50
- # Creates a shipping label for a purchase order and returns a `transactionId` for reference.
50
+ # Creates a shipping label for a purchase order and returns a transactionId for reference.
51
51
  #
52
52
  # @note This operation can make a static sandbox call.
53
53
  # @param body [Hash] Request body containing one or more shipping labels data.
54
54
  # @param rate_limit [Float] Requests per second
55
- # @return [Hash] The API response
55
+ # @return [Peddler::Response] The API response
56
56
  def submit_shipping_label_request(body, rate_limit: 10.0)
57
57
  path = "/vendor/directFulfillment/shipping/v1/shippingLabels"
58
58
 
59
59
  meter(rate_limit).post(path, body:)
60
60
  end
61
61
 
62
- # Returns a shipping label for the `purchaseOrderNumber` that you specify.
62
+ # Returns a shipping label for the purchaseOrderNumber that you specify.
63
63
  #
64
64
  # @note This operation can make a static sandbox call.
65
65
  # @param purchase_order_number [String] The purchase order number for which you want to return the shipping label.
66
- # It should be the same `purchaseOrderNumber` as received in the order.
66
+ # It should be the same purchaseOrderNumber as received in the order.
67
67
  # @param rate_limit [Float] Requests per second
68
- # @return [Hash] The API response
68
+ # @return [Peddler::Response] The API response
69
69
  def get_shipping_label(purchase_order_number, rate_limit: 10.0)
70
70
  path = "/vendor/directFulfillment/shipping/v1/shippingLabels/#{purchase_order_number}"
71
71
 
@@ -77,7 +77,7 @@ module Peddler
77
77
  # @note This operation can make a static sandbox call.
78
78
  # @param body [Hash] Request body containing the shipment confirmations data.
79
79
  # @param rate_limit [Float] Requests per second
80
- # @return [Hash] The API response
80
+ # @return [Peddler::Response] The API response
81
81
  def submit_shipment_confirmations(body, rate_limit: 10.0)
82
82
  path = "/vendor/directFulfillment/shipping/v1/shipmentConfirmations"
83
83
 
@@ -91,7 +91,7 @@ module Peddler
91
91
  # @note This operation can make a static sandbox call.
92
92
  # @param body [Hash] Request body containing the shipment status update data.
93
93
  # @param rate_limit [Float] Requests per second
94
- # @return [Hash] The API response
94
+ # @return [Peddler::Response] The API response
95
95
  def submit_shipment_status_updates(body, rate_limit: 10.0)
96
96
  path = "/vendor/directFulfillment/shipping/v1/shipmentStatusUpdates"
97
97
 
@@ -99,22 +99,22 @@ module Peddler
99
99
  end
100
100
 
101
101
  # Returns a list of customer invoices created during a time frame that you specify. You define the time frame
102
- # using the `createdAfter` and `createdBefore` parameters. You must use both of these parameters. The date range
103
- # to search must be no more than 7 days.
102
+ # using the createdAfter and createdBefore parameters. You must use both of these parameters. The date range to
103
+ # search must be no more than 7 days.
104
104
  #
105
105
  # @note This operation can make a static sandbox call.
106
- # @param ship_from_party_id [String] The vendor `warehouseId` for order fulfillment. If not specified, the result
106
+ # @param ship_from_party_id [String] The vendor warehouseId for order fulfillment. If not specified, the result
107
107
  # will contain orders for all warehouses.
108
108
  # @param limit [Integer] The limit to the number of records returned
109
109
  # @param created_after [String] Orders that became available after this date and time will be included in the
110
- # result. Must be in {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date/time format.
110
+ # result. Must be in ISO-8601 date/time format.
111
111
  # @param created_before [String] Orders that became available before this date and time will be included in the
112
- # result. Must be in {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date/time format.
112
+ # result. Must be in ISO-8601 date/time format.
113
113
  # @param sort_order [String] Sort ASC or DESC by order creation date.
114
114
  # @param next_token [String] Used for pagination when there are more orders than the specified result size limit.
115
115
  # The token value is returned in the previous API call.
116
116
  # @param rate_limit [Float] Requests per second
117
- # @return [Hash] The API response
117
+ # @return [Peddler::Response] The API response
118
118
  def get_customer_invoices(created_after, created_before, ship_from_party_id: nil, limit: nil, sort_order: nil,
119
119
  next_token: nil, rate_limit: 10.0)
120
120
  path = "/vendor/directFulfillment/shipping/v1/customerInvoices"
@@ -130,12 +130,12 @@ module Peddler
130
130
  meter(rate_limit).get(path, params:)
131
131
  end
132
132
 
133
- # Returns a customer invoice based on the `purchaseOrderNumber` that you specify.
133
+ # Returns a customer invoice based on the purchaseOrderNumber that you specify.
134
134
  #
135
135
  # @note This operation can make a static sandbox call.
136
136
  # @param purchase_order_number [String] Purchase order number of the shipment for which to return the invoice.
137
137
  # @param rate_limit [Float] Requests per second
138
- # @return [Hash] The API response
138
+ # @return [Peddler::Response] The API response
139
139
  def get_customer_invoice(purchase_order_number, rate_limit: 10.0)
140
140
  path = "/vendor/directFulfillment/shipping/v1/customerInvoices/#{purchase_order_number}"
141
141
 
@@ -146,18 +146,18 @@ module Peddler
146
146
  # must not be more than 7 days.
147
147
  #
148
148
  # @note This operation can make a static sandbox call.
149
- # @param ship_from_party_id [String] The vendor `warehouseId` for order fulfillment. If not specified the result
149
+ # @param ship_from_party_id [String] The vendor warehouseId for order fulfillment. If not specified the result
150
150
  # will contain orders for all warehouses.
151
151
  # @param limit [Integer] The limit to the number of records returned
152
152
  # @param created_after [String] Packing slips that became available after this date and time will be included in
153
- # the result. Must be in {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date/time format.
153
+ # the result. Must be in ISO-8601 date/time format.
154
154
  # @param created_before [String] Packing slips that became available before this date and time will be included in
155
- # the result. Must be in {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date/time format.
155
+ # the result. Must be in ISO-8601 date/time format.
156
156
  # @param sort_order [String] Sort ASC or DESC by packing slip creation date.
157
157
  # @param next_token [String] Used for pagination when there are more packing slips than the specified result size
158
158
  # limit. The token value is returned in the previous API call.
159
159
  # @param rate_limit [Float] Requests per second
160
- # @return [Hash] The API response
160
+ # @return [Peddler::Response] The API response
161
161
  def get_packing_slips(created_after, created_before, ship_from_party_id: nil, limit: nil, sort_order: "ASC",
162
162
  next_token: nil, rate_limit: 10.0)
163
163
  path = "/vendor/directFulfillment/shipping/v1/packingSlips"
@@ -173,12 +173,12 @@ module Peddler
173
173
  meter(rate_limit).get(path, params:)
174
174
  end
175
175
 
176
- # Returns a packing slip based on the `purchaseOrderNumber` that you specify.
176
+ # Returns a packing slip based on the purchaseOrderNumber that you specify.
177
177
  #
178
178
  # @note This operation can make a static sandbox call.
179
- # @param purchase_order_number [String] The `purchaseOrderNumber` for the packing slip you want.
179
+ # @param purchase_order_number [String] The purchaseOrderNumber for the packing slip you want.
180
180
  # @param rate_limit [Float] Requests per second
181
- # @return [Hash] The API response
181
+ # @return [Peddler::Response] The API response
182
182
  def get_packing_slip(purchase_order_number, rate_limit: 10.0)
183
183
  path = "/vendor/directFulfillment/shipping/v1/packingSlips/#{purchase_order_number}"
184
184
 
@@ -5,23 +5,23 @@ require "peddler/api"
5
5
  module Peddler
6
6
  class << self
7
7
  def vendor_direct_fulfillment_transactions_2021_12_28(...)
8
- API::VendorDirectFulfillmentTransactions20211228.new(...)
8
+ APIs::VendorDirectFulfillmentTransactions20211228.new(...)
9
9
  end
10
10
  end
11
11
 
12
- class API
12
+ module APIs
13
13
  # Selling Partner API for Direct Fulfillment Transaction Status
14
14
  #
15
15
  # The Selling Partner API for Direct Fulfillment Transaction Status provides programmatic access to a direct
16
16
  # fulfillment vendor's transaction status.
17
17
  class VendorDirectFulfillmentTransactions20211228 < API
18
- # Returns the status of the transaction indicated by the specified `transactionId`.
18
+ # Returns the status of the transaction indicated by the specified transactionId.
19
19
  #
20
20
  # @note This operation can make a dynamic sandbox call.
21
21
  # @param transaction_id [String] Previously returned in the response to the POST request of a specific
22
22
  # transaction.
23
23
  # @param rate_limit [Float] Requests per second
24
- # @return [Hash] The API response
24
+ # @return [Peddler::Response] The API response
25
25
  def get_transaction_status(transaction_id, rate_limit: 10.0)
26
26
  path = "/vendor/directFulfillment/transactions/2021-12-28/transactions/#{transaction_id}"
27
27
 
@@ -5,23 +5,23 @@ require "peddler/api"
5
5
  module Peddler
6
6
  class << self
7
7
  def vendor_direct_fulfillment_transactions_v1(...)
8
- API::VendorDirectFulfillmentTransactionsV1.new(...)
8
+ APIs::VendorDirectFulfillmentTransactionsV1.new(...)
9
9
  end
10
10
  end
11
11
 
12
- class API
12
+ module APIs
13
13
  # Selling Partner API for Direct Fulfillment Transaction Status
14
14
  #
15
15
  # The Selling Partner API for Direct Fulfillment Transaction Status provides programmatic access to a direct
16
16
  # fulfillment vendor's transaction status.
17
17
  class VendorDirectFulfillmentTransactionsV1 < API
18
- # Returns the status of the transaction indicated by the specified `transactionId`.
18
+ # Returns the status of the transaction indicated by the specified transactionId.
19
19
  #
20
20
  # @note This operation can make a static sandbox call.
21
21
  # @param transaction_id [String] Previously returned in the response to the POST request of a specific
22
22
  # transaction.
23
23
  # @param rate_limit [Float] Requests per second
24
- # @return [Hash] The API response
24
+ # @return [Peddler::Response] The API response
25
25
  def get_transaction_status(transaction_id, rate_limit: 10.0)
26
26
  path = "/vendor/directFulfillment/transactions/v1/transactions/#{transaction_id}"
27
27
 
@@ -5,12 +5,12 @@ require "peddler/api"
5
5
  module Peddler
6
6
  class << self
7
7
  def vendor_invoices_v1(...)
8
- API::VendorInvoicesV1.new(...)
8
+ APIs::VendorInvoicesV1.new(...)
9
9
  end
10
10
  end
11
11
 
12
- class API
13
- # Selling Partner API for Retail Procurement Payments
12
+ module APIs
13
+ # Vendor Invoices v1
14
14
  #
15
15
  # The Selling Partner API for Retail Procurement Payments provides programmatic access to vendors payments data.
16
16
  class VendorInvoicesV1 < API
@@ -19,7 +19,7 @@ module Peddler
19
19
  # @note This operation can make a static sandbox call.
20
20
  # @param body [Hash] The request body containing the invoice data to submit.
21
21
  # @param rate_limit [Float] Requests per second
22
- # @return [Hash] The API response
22
+ # @return [Peddler::Response] The API response
23
23
  def submit_invoices(body, rate_limit: 10.0)
24
24
  path = "/vendor/payments/v1/invoices"
25
25
 
@@ -5,11 +5,11 @@ require "peddler/api"
5
5
  module Peddler
6
6
  class << self
7
7
  def vendor_orders_v1(...)
8
- API::VendorOrdersV1.new(...)
8
+ APIs::VendorOrdersV1.new(...)
9
9
  end
10
10
  end
11
11
 
12
- class API
12
+ module APIs
13
13
  # Selling Partner API for Retail Procurement Orders
14
14
  #
15
15
  # The Selling Partner API for Retail Procurement Orders provides programmatic access to vendor orders data.
@@ -47,7 +47,7 @@ module Peddler
47
47
  # purchase orders for all of the vendor codes that exist in the vendor group used to authorize the API client
48
48
  # application are returned.
49
49
  # @param rate_limit [Float] Requests per second
50
- # @return [Hash] The API response
50
+ # @return [Peddler::Response] The API response
51
51
  def get_purchase_orders(limit: nil, created_after: nil, created_before: nil, sort_order: nil, next_token: nil,
52
52
  include_details: nil, changed_after: nil, changed_before: nil, po_item_state: nil, is_po_changed: nil,
53
53
  purchase_order_state: nil, ordering_vendor_code: nil, rate_limit: 10.0)
@@ -76,7 +76,7 @@ module Peddler
76
76
  # @param purchase_order_number [String] The purchase order identifier for the order that you want. Formatting
77
77
  # Notes: 8-character alpha-numeric code.
78
78
  # @param rate_limit [Float] Requests per second
79
- # @return [Hash] The API response
79
+ # @return [Peddler::Response] The API response
80
80
  def get_purchase_order(purchase_order_number, rate_limit: 10.0)
81
81
  path = "/vendor/orders/v1/purchaseOrders/#{purchase_order_number}"
82
82
 
@@ -86,9 +86,9 @@ module Peddler
86
86
  # Submits acknowledgements for one or more purchase orders.
87
87
  #
88
88
  # @note This operation can make a static sandbox call.
89
- # @param body [Hash]
89
+ # @param body [Hash] Submits acknowledgements for one or more purchase orders from a vendor.
90
90
  # @param rate_limit [Float] Requests per second
91
- # @return [Hash] The API response
91
+ # @return [Peddler::Response] The API response
92
92
  def submit_acknowledgement(body, rate_limit: 10.0)
93
93
  path = "/vendor/orders/v1/acknowledgements"
94
94
 
@@ -130,7 +130,7 @@ module Peddler
130
130
  # If not included in filter, this will return purchase orders for all the buyer's warehouses used for vendor
131
131
  # group purchase orders.
132
132
  # @param rate_limit [Float] Requests per second
133
- # @return [Hash] The API response
133
+ # @return [Peddler::Response] The API response
134
134
  def get_purchase_orders_status(limit: nil, sort_order: nil, next_token: nil, created_after: nil,
135
135
  created_before: nil, updated_after: nil, updated_before: nil, purchase_order_number: nil,
136
136
  purchase_order_status: nil, item_confirmation_status: nil, item_receive_status: nil, ordering_vendor_code: nil,
@@ -5,12 +5,12 @@ require "peddler/api"
5
5
  module Peddler
6
6
  class << self
7
7
  def vendor_shipments_v1(...)
8
- API::VendorShipmentsV1.new(...)
8
+ APIs::VendorShipmentsV1.new(...)
9
9
  end
10
10
  end
11
11
 
12
- class API
13
- # Selling Partner API for Retail Procurement Shipments
12
+ module APIs
13
+ # Vendor Shipments v1
14
14
  #
15
15
  # The Selling Partner API for Retail Procurement Shipments provides programmatic access to retail shipping data for
16
16
  # vendors.
@@ -20,7 +20,7 @@ module Peddler
20
20
  # @note This operation can make a static sandbox call.
21
21
  # @param body [Hash] A request to submit shipment confirmation.
22
22
  # @param rate_limit [Float] Requests per second
23
- # @return [Hash] The API response
23
+ # @return [Peddler::Response] The API response
24
24
  def submit_shipment_confirmations(body, rate_limit: 10.0)
25
25
  path = "/vendor/shipping/v1/shipmentConfirmations"
26
26
 
@@ -31,7 +31,7 @@ module Peddler
31
31
  #
32
32
  # @param body [Hash] A request to submit shipment request.
33
33
  # @param rate_limit [Float] Requests per second
34
- # @return [Hash] The API response
34
+ # @return [Peddler::Response] The API response
35
35
  def submit_shipments(body, rate_limit: 10.0)
36
36
  cannot_sandbox!
37
37
 
@@ -87,7 +87,7 @@ module Peddler
87
87
  # @param seller_warehouse_code [String] Get Shipping Details based on vendor warehouse code. This value should be
88
88
  # same as 'sellingParty.partyId' in the Shipment.
89
89
  # @param rate_limit [Float] Requests per second
90
- # @return [Hash] The API response
90
+ # @return [Peddler::Response] The API response
91
91
  def get_shipment_details(limit: nil, sort_order: nil, next_token: nil, created_after: nil, created_before: nil,
92
92
  shipment_confirmed_before: nil, shipment_confirmed_after: nil, package_label_created_before: nil,
93
93
  package_label_created_after: nil, shipped_before: nil, shipped_after: nil, estimated_delivery_before: nil,
@@ -5,11 +5,11 @@ require "peddler/api"
5
5
  module Peddler
6
6
  class << self
7
7
  def vendor_transaction_status_v1(...)
8
- API::VendorTransactionStatusV1.new(...)
8
+ APIs::VendorTransactionStatusV1.new(...)
9
9
  end
10
10
  end
11
11
 
12
- class API
12
+ module APIs
13
13
  # Selling Partner API for Retail Procurement Transaction Status
14
14
  #
15
15
  # The Selling Partner API for Retail Procurement Transaction Status provides programmatic access to status
@@ -20,7 +20,7 @@ module Peddler
20
20
  # @param transaction_id [String] The GUID provided by Amazon in the 'transactionId' field in response to the post
21
21
  # request of a specific transaction.
22
22
  # @param rate_limit [Float] Requests per second
23
- # @return [Hash] The API response
23
+ # @return [Peddler::Response] The API response
24
24
  def get_transaction(transaction_id, rate_limit: 10.0)
25
25
  cannot_sandbox!
26
26
 
@@ -27,14 +27,14 @@ module Peddler
27
27
  raise ArgumentError, "#{aws_region} not found"
28
28
  end
29
29
 
30
- new(**values.merge(aws_region: aws_region))
30
+ new(**values, aws_region: aws_region)
31
31
  end
32
32
 
33
33
  def find_by_selling_region(selling_region)
34
34
  aws_region, values = ENDPOINTS.find { |_, v| v[:selling_region] == selling_region } ||
35
35
  raise(ArgumentError, "#{selling_region} not found")
36
36
 
37
- new(**values.merge(aws_region: aws_region))
37
+ new(**values, aws_region: aws_region)
38
38
  end
39
39
  end
40
40
 
data/lib/peddler/error.rb CHANGED
@@ -2,30 +2,39 @@
2
2
 
3
3
  module Peddler
4
4
  class Error < StandardError
5
- class InvalidInput < Error; end
6
- class NotFound < Error; end
7
- class QuotaExceeded < Error; end
8
- class Unauthorized < Error; end
9
-
10
- attr_reader :cause
5
+ attr_reader :response
11
6
 
12
7
  # @!visibility private
13
8
  class << self
14
9
  def build(response)
15
10
  error = JSON.parse(response).dig("errors").first
16
11
  class_name = error.dig("code")
17
- klass = const_get(class_name)
12
+ message = error.dig("message")
13
+ klass = if Errors.const_defined?(class_name)
14
+ Errors.const_get(class_name)
15
+ else
16
+ Errors.const_set(
17
+ class_name,
18
+ Class.new(Error),
19
+ )
20
+ end
18
21
 
19
- klass.new(error.dig("message"), response)
22
+ klass.new(message, response)
20
23
  rescue NameError
21
- const_set(class_name, Class.new(Error))
22
- retry
24
+ # Do nothing if code cannot be converted to a class name
23
25
  end
24
26
  end
25
27
 
26
- def initialize(msg = nil, cause = nil)
27
- @cause = cause
28
+ def initialize(msg = nil, response = nil)
29
+ @response = response
28
30
  super(msg)
29
31
  end
30
32
  end
33
+
34
+ module Errors
35
+ class InvalidInput < Error; end
36
+ class NotFound < Error; end
37
+ class QuotaExceeded < Error; end
38
+ class Unauthorized < Error; end
39
+ end
31
40
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peddler
4
+ module Helpers
5
+ module Feeds20210630
6
+ # Uploads feed_content to a signed upload_url previously provided by
7
+ # create_feed_document. The upload_url is signed, the Host and content-type
8
+ # headers must match the signing.
9
+ # @param upload_url [String] The signed url from the `create_feed_document` response.
10
+ # @param feed_content [String] The body of the content to upload.
11
+ # @param content_type [String] The content type of the upload,
12
+ # this must match the content-type requested in `create_feed_document`
13
+ # @return [HTTP::Response] The API response
14
+ def upload_feed_document(upload_url, feed_content, content_type)
15
+ response = HTTP.headers("content-type" => content_type).put(upload_url, body: feed_content)
16
+
17
+ if response.status.client_error?
18
+ error = Error.build(response)
19
+ raise error if error
20
+ end
21
+
22
+ response
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peddler
4
+ class JSONFeedDocument
5
+ CONTENT_TYPE = "application/json; charset=UTF-8"
6
+
7
+ def upload(content)
8
+ # While HTTPrb already sets the content-type, Amazon server seems to fail if we don't explicitly set it again
9
+ # here. A bit of a mystery; maybe it's the order of the headers that's screwing things up on their end?
10
+ HTTP.headers("Content-Type" => CONTENT_TYPE).put(url, json: content)
11
+ end
12
+
13
+ def initialize(api)
14
+ @api = api
15
+ end
16
+
17
+ def id
18
+ metadata.fetch("id")
19
+ end
20
+
21
+ def url
22
+ metadata.fetch("url")
23
+ end
24
+
25
+ private
26
+
27
+ def metadata
28
+ @metadata ||= @api.create_feed_document({ "contentType" => CONTENT_TYPE }).parse
29
+ end
30
+ end
31
+ end