peddler 4.3.0 → 4.4.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/README.md +328 -109
- data/lib/peddler/api.rb +11 -0
- data/lib/peddler/apis/amazon_warehousing_and_distribution_2024_05_09.rb +7 -7
- data/lib/peddler/apis/aplus_content_2020_11_01.rb +10 -10
- data/lib/peddler/apis/application_integrations_2024_04_01.rb +1 -1
- data/lib/peddler/apis/catalog_items_2020_12_01.rb +8 -8
- data/lib/peddler/apis/catalog_items_2022_04_01.rb +9 -9
- data/lib/peddler/apis/data_kiosk_2023_11_15.rb +4 -4
- data/lib/peddler/apis/fba_inbound_eligibility_v1.rb +1 -1
- data/lib/peddler/apis/fba_inventory_v1.rb +3 -3
- data/lib/peddler/apis/feeds_2021_06_30.rb +6 -6
- data/lib/peddler/apis/finances_2024_06_01.rb +1 -1
- data/lib/peddler/apis/finances_v0.rb +2 -2
- data/lib/peddler/apis/fulfillment_inbound_2024_03_20.rb +40 -40
- data/lib/peddler/apis/fulfillment_inbound_v0.rb +8 -8
- data/lib/peddler/apis/fulfillment_outbound_2020_07_01.rb +7 -7
- data/lib/peddler/apis/invoices_2024_06_19.rb +4 -4
- data/lib/peddler/apis/listings_items_2020_09_01.rb +6 -6
- data/lib/peddler/apis/listings_items_2021_08_01.rb +20 -26
- data/lib/peddler/apis/listings_restrictions_2021_08_01.rb +1 -1
- data/lib/peddler/apis/merchant_fulfillment_v0.rb +2 -2
- data/lib/peddler/apis/messaging_v1.rb +26 -26
- data/lib/peddler/apis/notifications_v1.rb +6 -6
- data/lib/peddler/apis/orders_v0.rb +16 -16
- data/lib/peddler/apis/product_fees_v0.rb +2 -2
- data/lib/peddler/apis/product_pricing_v0.rb +6 -6
- data/lib/peddler/apis/product_type_definitions_2020_09_01.rb +4 -4
- data/lib/peddler/apis/reports_2021_06_30.rb +9 -9
- data/lib/peddler/apis/sales_v1.rb +7 -2
- data/lib/peddler/apis/seller_wallet_2024_03_01.rb +5 -5
- data/lib/peddler/apis/services_v1.rb +27 -27
- data/lib/peddler/apis/shipment_invoicing_v0.rb +3 -3
- data/lib/peddler/apis/shipping_v1.rb +5 -5
- data/lib/peddler/apis/shipping_v2.rb +6 -6
- data/lib/peddler/apis/solicitations_v1.rb +4 -4
- data/lib/peddler/apis/supply_sources_2020_07_01.rb +4 -4
- data/lib/peddler/apis/uploads_2020_11_01.rb +2 -2
- data/lib/peddler/apis/vendor_direct_fulfillment_inventory_v1.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_orders_2021_12_28.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_orders_v1.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_shipping_2021_12_28.rb +4 -4
- data/lib/peddler/apis/vendor_direct_fulfillment_shipping_v1.rb +3 -3
- data/lib/peddler/apis/vendor_direct_fulfillment_transactions_2021_12_28.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_transactions_v1.rb +1 -1
- data/lib/peddler/apis/vendor_orders_v1.rb +1 -1
- data/lib/peddler/apis/vendor_transaction_status_v1.rb +1 -1
- data/lib/peddler/error.rb +16 -4
- data/lib/peddler/token.rb +6 -11
- data/lib/peddler/version.rb +1 -1
- data/lib/peddler.rb +51 -0
- metadata +1 -3
- data/lib/peddler/parsers/openapi_parser_generator.rb +0 -550
- data/lib/peddler/parsers/smart_parser.rb +0 -199
@@ -68,7 +68,7 @@ module Peddler
|
|
68
68
|
# @param rate_limit [Float] Requests per second
|
69
69
|
# @return [Peddler::Response] The API response
|
70
70
|
def get_shipping_label(purchase_order_number, rate_limit: 10.0)
|
71
|
-
path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/#{purchase_order_number}"
|
71
|
+
path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/#{percent_encode(purchase_order_number)}"
|
72
72
|
|
73
73
|
meter(rate_limit).get(path)
|
74
74
|
end
|
@@ -82,7 +82,7 @@ module Peddler
|
|
82
82
|
# @param rate_limit [Float] Requests per second
|
83
83
|
# @return [Peddler::Response] The API response
|
84
84
|
def create_shipping_labels(purchase_order_number, body, rate_limit: 10.0)
|
85
|
-
path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/#{purchase_order_number}"
|
85
|
+
path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/#{percent_encode(purchase_order_number)}"
|
86
86
|
|
87
87
|
meter(rate_limit).post(path, body:)
|
88
88
|
end
|
@@ -152,7 +152,7 @@ module Peddler
|
|
152
152
|
# @param rate_limit [Float] Requests per second
|
153
153
|
# @return [Peddler::Response] The API response
|
154
154
|
def get_customer_invoice(purchase_order_number, rate_limit: 10.0)
|
155
|
-
path = "/vendor/directFulfillment/shipping/2021-12-28/customerInvoices/#{purchase_order_number}"
|
155
|
+
path = "/vendor/directFulfillment/shipping/2021-12-28/customerInvoices/#{percent_encode(purchase_order_number)}"
|
156
156
|
|
157
157
|
meter(rate_limit).get(path)
|
158
158
|
end
|
@@ -195,7 +195,7 @@ module Peddler
|
|
195
195
|
# @param rate_limit [Float] Requests per second
|
196
196
|
# @return [Peddler::Response] The API response
|
197
197
|
def get_packing_slip(purchase_order_number, rate_limit: 10.0)
|
198
|
-
path = "/vendor/directFulfillment/shipping/2021-12-28/packingSlips/#{purchase_order_number}"
|
198
|
+
path = "/vendor/directFulfillment/shipping/2021-12-28/packingSlips/#{percent_encode(purchase_order_number)}"
|
199
199
|
|
200
200
|
meter(rate_limit).get(path)
|
201
201
|
end
|
@@ -67,7 +67,7 @@ module Peddler
|
|
67
67
|
# @param rate_limit [Float] Requests per second
|
68
68
|
# @return [Peddler::Response] The API response
|
69
69
|
def get_shipping_label(purchase_order_number, rate_limit: 10.0)
|
70
|
-
path = "/vendor/directFulfillment/shipping/v1/shippingLabels/#{purchase_order_number}"
|
70
|
+
path = "/vendor/directFulfillment/shipping/v1/shippingLabels/#{percent_encode(purchase_order_number)}"
|
71
71
|
|
72
72
|
meter(rate_limit).get(path)
|
73
73
|
end
|
@@ -137,7 +137,7 @@ module Peddler
|
|
137
137
|
# @param rate_limit [Float] Requests per second
|
138
138
|
# @return [Peddler::Response] The API response
|
139
139
|
def get_customer_invoice(purchase_order_number, rate_limit: 10.0)
|
140
|
-
path = "/vendor/directFulfillment/shipping/v1/customerInvoices/#{purchase_order_number}"
|
140
|
+
path = "/vendor/directFulfillment/shipping/v1/customerInvoices/#{percent_encode(purchase_order_number)}"
|
141
141
|
|
142
142
|
meter(rate_limit).get(path)
|
143
143
|
end
|
@@ -180,7 +180,7 @@ module Peddler
|
|
180
180
|
# @param rate_limit [Float] Requests per second
|
181
181
|
# @return [Peddler::Response] The API response
|
182
182
|
def get_packing_slip(purchase_order_number, rate_limit: 10.0)
|
183
|
-
path = "/vendor/directFulfillment/shipping/v1/packingSlips/#{purchase_order_number}"
|
183
|
+
path = "/vendor/directFulfillment/shipping/v1/packingSlips/#{percent_encode(purchase_order_number)}"
|
184
184
|
|
185
185
|
meter(rate_limit).get(path)
|
186
186
|
end
|
@@ -23,7 +23,7 @@ module Peddler
|
|
23
23
|
# @param rate_limit [Float] Requests per second
|
24
24
|
# @return [Peddler::Response] The API response
|
25
25
|
def get_transaction_status(transaction_id, rate_limit: 10.0)
|
26
|
-
path = "/vendor/directFulfillment/transactions/2021-12-28/transactions/#{transaction_id}"
|
26
|
+
path = "/vendor/directFulfillment/transactions/2021-12-28/transactions/#{percent_encode(transaction_id)}"
|
27
27
|
|
28
28
|
meter(rate_limit).get(path)
|
29
29
|
end
|
@@ -23,7 +23,7 @@ module Peddler
|
|
23
23
|
# @param rate_limit [Float] Requests per second
|
24
24
|
# @return [Peddler::Response] The API response
|
25
25
|
def get_transaction_status(transaction_id, rate_limit: 10.0)
|
26
|
-
path = "/vendor/directFulfillment/transactions/v1/transactions/#{transaction_id}"
|
26
|
+
path = "/vendor/directFulfillment/transactions/v1/transactions/#{percent_encode(transaction_id)}"
|
27
27
|
|
28
28
|
meter(rate_limit).get(path)
|
29
29
|
end
|
@@ -78,7 +78,7 @@ module Peddler
|
|
78
78
|
# @param rate_limit [Float] Requests per second
|
79
79
|
# @return [Peddler::Response] The API response
|
80
80
|
def get_purchase_order(purchase_order_number, rate_limit: 10.0)
|
81
|
-
path = "/vendor/orders/v1/purchaseOrders/#{purchase_order_number}"
|
81
|
+
path = "/vendor/orders/v1/purchaseOrders/#{percent_encode(purchase_order_number)}"
|
82
82
|
|
83
83
|
meter(rate_limit).get(path)
|
84
84
|
end
|
@@ -24,7 +24,7 @@ module Peddler
|
|
24
24
|
def get_transaction(transaction_id, rate_limit: 10.0)
|
25
25
|
cannot_sandbox!
|
26
26
|
|
27
|
-
path = "/vendor/transactions/v1/transactions/#{transaction_id}"
|
27
|
+
path = "/vendor/transactions/v1/transactions/#{percent_encode(transaction_id)}"
|
28
28
|
|
29
29
|
meter(rate_limit).get(path)
|
30
30
|
end
|
data/lib/peddler/error.rb
CHANGED
@@ -7,9 +7,18 @@ module Peddler
|
|
7
7
|
# @!visibility private
|
8
8
|
class << self
|
9
9
|
def build(response)
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
payload = JSON.parse(response)
|
11
|
+
|
12
|
+
if payload.key?("error")
|
13
|
+
class_name = normalize_class_name(payload["error"])
|
14
|
+
message = payload["error_description"]
|
15
|
+
elsif payload.key?("errors")
|
16
|
+
class_name = normalize_class_name(payload.dig("errors", 0, "code"))
|
17
|
+
message = payload.dig("errors", 0, "message")
|
18
|
+
else
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
13
22
|
klass = if Errors.const_defined?(class_name)
|
14
23
|
Errors.const_get(class_name)
|
15
24
|
else
|
@@ -27,7 +36,7 @@ module Peddler
|
|
27
36
|
private
|
28
37
|
|
29
38
|
def normalize_class_name(code)
|
30
|
-
if code.match?(/\A[A-Z_]
|
39
|
+
if code.match?(/\A([a-z_]+|[A-Z_]+)\z/)
|
31
40
|
code.split("_").map(&:capitalize).join
|
32
41
|
else
|
33
42
|
code
|
@@ -42,9 +51,12 @@ module Peddler
|
|
42
51
|
end
|
43
52
|
|
44
53
|
module Errors
|
54
|
+
class InvalidGrant < Error; end
|
45
55
|
class InvalidInput < Error; end
|
56
|
+
class InvalidRequest < Error; end
|
46
57
|
class NotFound < Error; end
|
47
58
|
class QuotaExceeded < Error; end
|
48
59
|
class Unauthorized < Error; end
|
60
|
+
class UnsupportedGrantType < Error; end
|
49
61
|
end
|
50
62
|
end
|
data/lib/peddler/token.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require "http"
|
4
4
|
|
5
|
+
require "peddler/error"
|
6
|
+
|
5
7
|
module Peddler
|
6
8
|
# Requests refresh and access tokens that authorize your application to take actions on behalf of a selling partner.
|
7
9
|
#
|
@@ -9,14 +11,7 @@ module Peddler
|
|
9
11
|
#
|
10
12
|
# @see https://developer-docs.amazon.com/sp-api/docs/connecting-to-the-selling-partner-api
|
11
13
|
class Token
|
12
|
-
|
13
|
-
attr_reader :cause
|
14
|
-
|
15
|
-
def initialize(msg = nil, cause = nil)
|
16
|
-
@cause = cause
|
17
|
-
super(msg)
|
18
|
-
end
|
19
|
-
end
|
14
|
+
Error = Class.new(Peddler::Error)
|
20
15
|
|
21
16
|
URL = "https://api.amazon.com/auth/o2/token"
|
22
17
|
|
@@ -37,9 +32,9 @@ module Peddler
|
|
37
32
|
def request
|
38
33
|
response = HTTP.post(URL, form: params)
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
raise
|
35
|
+
if response.status.client_error?
|
36
|
+
error = Error.build(response)
|
37
|
+
raise error if error
|
43
38
|
end
|
44
39
|
|
45
40
|
response
|
data/lib/peddler/version.rb
CHANGED
data/lib/peddler.rb
CHANGED
@@ -58,3 +58,54 @@ require "peddler/apis/vendor_orders_v1"
|
|
58
58
|
require "peddler/apis/vendor_shipments_v1"
|
59
59
|
require "peddler/apis/vendor_transaction_status_v1"
|
60
60
|
require "peddler/token"
|
61
|
+
|
62
|
+
module Peddler
|
63
|
+
class << self
|
64
|
+
alias_method :amazon_warehousing_and_distribution, :amazon_warehousing_and_distribution_2024_05_09
|
65
|
+
alias_method :aplus_content, :aplus_content_2020_11_01
|
66
|
+
alias_method :application_integrations, :application_integrations_2024_04_01
|
67
|
+
alias_method :application_management, :application_management_2023_11_30
|
68
|
+
alias_method :catalog_items, :catalog_items_2022_04_01
|
69
|
+
alias_method :data_kiosk, :data_kiosk_2023_11_15
|
70
|
+
alias_method :easy_ship, :easy_ship_2022_03_23
|
71
|
+
alias_method :fba_inbound_eligibility, :fba_inbound_eligibility_v1
|
72
|
+
alias_method :fba_inventory, :fba_inventory_v1
|
73
|
+
alias_method :feeds, :feeds_2021_06_30
|
74
|
+
alias_method :finances, :finances_2024_06_19
|
75
|
+
alias_method :fulfillment_inbound, :fulfillment_inbound_2024_03_20
|
76
|
+
alias_method :fulfillment_outbound, :fulfillment_outbound_2020_07_01
|
77
|
+
alias_method :invoices, :invoices_2024_06_19
|
78
|
+
alias_method :listings_items, :listings_items_2021_08_01
|
79
|
+
alias_method :listings_restrictions, :listings_restrictions_2021_08_01
|
80
|
+
alias_method :merchant_fulfillment, :merchant_fulfillment_v0
|
81
|
+
alias_method :messaging, :messaging_v1
|
82
|
+
alias_method :notifications, :notifications_v1
|
83
|
+
alias_method :orders, :orders_v0
|
84
|
+
alias_method :product_fees, :product_fees_v0
|
85
|
+
alias_method :product_pricing, :product_pricing_2022_05_01
|
86
|
+
alias_method :product_type_definitions, :product_type_definitions_2020_09_01
|
87
|
+
alias_method :replenishment, :replenishment_2022_11_07
|
88
|
+
alias_method :reports, :reports_2021_06_30
|
89
|
+
alias_method :sales, :sales_v1
|
90
|
+
alias_method :seller_wallet, :seller_wallet_2024_03_01
|
91
|
+
alias_method :sellers, :sellers_v1
|
92
|
+
alias_method :services, :services_v1
|
93
|
+
alias_method :shipment_invoicing, :shipment_invoicing_v0
|
94
|
+
alias_method :shipping, :shipping_v2
|
95
|
+
alias_method :solicitations, :solicitations_v1
|
96
|
+
alias_method :supply_sources, :supply_sources_2020_07_01
|
97
|
+
alias_method :tokens, :tokens_2021_03_01
|
98
|
+
alias_method :uploads, :uploads_2020_11_01
|
99
|
+
alias_method :vehicles, :vehicles_2024_11_01
|
100
|
+
alias_method :vendor_direct_fulfillment_inventory, :vendor_direct_fulfillment_inventory_v1
|
101
|
+
alias_method :vendor_direct_fulfillment_orders, :vendor_direct_fulfillment_orders_2021_12_28
|
102
|
+
alias_method :vendor_direct_fulfillment_payments, :vendor_direct_fulfillment_payments_v1
|
103
|
+
alias_method :vendor_direct_fulfillment_sandbox_test_data, :vendor_direct_fulfillment_sandbox_test_data_2021_10_28
|
104
|
+
alias_method :vendor_direct_fulfillment_shipping, :vendor_direct_fulfillment_shipping_2021_12_28
|
105
|
+
alias_method :vendor_direct_fulfillment_transactions, :vendor_direct_fulfillment_transactions_2021_12_28
|
106
|
+
alias_method :vendor_invoices, :vendor_invoices_v1
|
107
|
+
alias_method :vendor_orders, :vendor_orders_v1
|
108
|
+
alias_method :vendor_shipments, :vendor_shipments_v1
|
109
|
+
alias_method :vendor_transaction_status, :vendor_transaction_status_v1
|
110
|
+
end
|
111
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peddler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
@@ -100,8 +100,6 @@ files:
|
|
100
100
|
- lib/peddler/error.rb
|
101
101
|
- lib/peddler/helpers/feeds_2021_06_30.rb
|
102
102
|
- lib/peddler/marketplace.rb
|
103
|
-
- lib/peddler/parsers/openapi_parser_generator.rb
|
104
|
-
- lib/peddler/parsers/smart_parser.rb
|
105
103
|
- lib/peddler/response.rb
|
106
104
|
- lib/peddler/token.rb
|
107
105
|
- lib/peddler/version.rb
|