peddler 2.4.5 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +406 -134
  3. data/lib/peddler/access_token.rb +76 -0
  4. data/lib/peddler/api/amazon_warehousing_and_distribution_2024_05_09.rb +80 -0
  5. data/lib/peddler/api/aplus_content_2020_11_01.rb +208 -0
  6. data/lib/peddler/api/application_management_2023_11_30.rb +25 -0
  7. data/lib/peddler/api/catalog_items_2020_12_01.rb +70 -0
  8. data/lib/peddler/api/catalog_items_2022_04_01.rb +83 -0
  9. data/lib/peddler/api/catalog_items_v0.rb +90 -0
  10. data/lib/peddler/api/data_kiosk_2023_11_15.rb +92 -0
  11. data/lib/peddler/api/easy_ship_2022_03_23.rb +108 -0
  12. data/lib/peddler/api/fba_inbound_eligibility_v1.rb +36 -0
  13. data/lib/peddler/api/fba_inventory_v1.rb +106 -0
  14. data/lib/peddler/api/feeds_2021_06_30.rb +104 -0
  15. data/lib/peddler/api/finances_v0.rb +121 -0
  16. data/lib/peddler/api/fulfillment_inbound_2024_03_20.rb +660 -0
  17. data/lib/peddler/api/fulfillment_inbound_v0.rb +314 -0
  18. data/lib/peddler/api/fulfillment_outbound_2020_07_01.rb +222 -0
  19. data/lib/peddler/api/listings_items_2020_09_01.rb +84 -0
  20. data/lib/peddler/api/listings_items_2021_08_01.rb +154 -0
  21. data/lib/peddler/api/listings_restrictions_2021_08_01.rb +37 -0
  22. data/lib/peddler/api/merchant_fulfillment_v0.rb +64 -0
  23. data/lib/peddler/api/messaging_v1.rb +241 -0
  24. data/lib/peddler/api/notifications_v1.rb +114 -0
  25. data/lib/peddler/api/orders_v0.rb +264 -0
  26. data/lib/peddler/api/product_fees_v0.rb +69 -0
  27. data/lib/peddler/api/product_pricing_2022_05_01.rb +43 -0
  28. data/lib/peddler/api/product_pricing_v0.rb +144 -0
  29. data/lib/peddler/api/product_type_definitions_2020_09_01.rb +75 -0
  30. data/lib/peddler/api/replenishment_2022_11_07.rb +45 -0
  31. data/lib/peddler/api/reports_2021_06_30.rb +139 -0
  32. data/lib/peddler/api/sales_v1.rb +69 -0
  33. data/lib/peddler/api/sellers_v1.rb +33 -0
  34. data/lib/peddler/api/services_v1.rb +308 -0
  35. data/lib/peddler/api/shipment_invoicing_v0.rb +46 -0
  36. data/lib/peddler/api/shipping_v1.rb +107 -0
  37. data/lib/peddler/api/shipping_v2.rb +267 -0
  38. data/lib/peddler/api/solicitations_v1.rb +53 -0
  39. data/lib/peddler/api/supply_sources_2020_07_01.rb +82 -0
  40. data/lib/peddler/api/tokens_2021_03_01.rb +30 -0
  41. data/lib/peddler/api/uploads_2020_11_01.rb +40 -0
  42. data/lib/peddler/api/vendor_direct_fulfillment_inventory_v1.rb +24 -0
  43. data/lib/peddler/api/vendor_direct_fulfillment_orders_2021_12_28.rb +72 -0
  44. data/lib/peddler/api/vendor_direct_fulfillment_orders_v1.rb +72 -0
  45. data/lib/peddler/api/vendor_direct_fulfillment_payments_v1.rb +23 -0
  46. data/lib/peddler/api/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb +35 -0
  47. data/lib/peddler/api/vendor_direct_fulfillment_shipping_2021_12_28.rb +177 -0
  48. data/lib/peddler/api/vendor_direct_fulfillment_shipping_v1.rb +165 -0
  49. data/lib/peddler/api/vendor_direct_fulfillment_transactions_2021_12_28.rb +24 -0
  50. data/lib/peddler/api/vendor_direct_fulfillment_transactions_v1.rb +24 -0
  51. data/lib/peddler/api/vendor_invoices_v1.rb +22 -0
  52. data/lib/peddler/api/vendor_orders_v1.rb +148 -0
  53. data/lib/peddler/api/vendor_shipments_v1.rb +120 -0
  54. data/lib/peddler/api/vendor_transaction_status_v1.rb +24 -0
  55. data/lib/peddler/api.rb +115 -0
  56. data/lib/peddler/error.rb +30 -0
  57. data/lib/peddler/region.rb +30 -0
  58. data/lib/peddler/version.rb +1 -1
  59. data/lib/peddler.rb +52 -1
  60. metadata +70 -80
  61. data/lib/mws/easy_ship/client.rb +0 -93
  62. data/lib/mws/easy_ship.rb +0 -3
  63. data/lib/mws/feeds/client.rb +0 -122
  64. data/lib/mws/feeds.rb +0 -3
  65. data/lib/mws/finances/client.rb +0 -82
  66. data/lib/mws/finances.rb +0 -3
  67. data/lib/mws/fulfillment_inbound_shipment/client.rb +0 -388
  68. data/lib/mws/fulfillment_inbound_shipment.rb +0 -3
  69. data/lib/mws/fulfillment_inventory/client.rb +0 -57
  70. data/lib/mws/fulfillment_inventory.rb +0 -3
  71. data/lib/mws/fulfillment_outbound_shipment/client.rb +0 -211
  72. data/lib/mws/fulfillment_outbound_shipment.rb +0 -3
  73. data/lib/mws/merchant_fulfillment/client.rb +0 -87
  74. data/lib/mws/merchant_fulfillment.rb +0 -3
  75. data/lib/mws/off_amazon_payments.rb +0 -3
  76. data/lib/mws/orders/client.rb +0 -120
  77. data/lib/mws/orders.rb +0 -3
  78. data/lib/mws/products/client.rb +0 -268
  79. data/lib/mws/products.rb +0 -3
  80. data/lib/mws/recommendations/client.rb +0 -72
  81. data/lib/mws/recommendations.rb +0 -3
  82. data/lib/mws/reports/client.rb +0 -236
  83. data/lib/mws/reports.rb +0 -3
  84. data/lib/mws/sellers/client.rb +0 -44
  85. data/lib/mws/sellers.rb +0 -3
  86. data/lib/mws/shipment_invoicing/client.rb +0 -74
  87. data/lib/mws/shipment_invoicing.rb +0 -3
  88. data/lib/mws/subscriptions/client.rb +0 -179
  89. data/lib/mws/subscriptions.rb +0 -3
  90. data/lib/mws.rb +0 -29
  91. data/lib/peddler/client.rb +0 -159
  92. data/lib/peddler/errors/builder.rb +0 -64
  93. data/lib/peddler/errors/class_generator.rb +0 -40
  94. data/lib/peddler/errors/error.rb +0 -45
  95. data/lib/peddler/errors/parser.rb +0 -28
  96. data/lib/peddler/flat_file_parser.rb +0 -56
  97. data/lib/peddler/headers.rb +0 -102
  98. data/lib/peddler/marketplace.rb +0 -79
  99. data/lib/peddler/operation.rb +0 -78
  100. data/lib/peddler/parser.rb +0 -33
  101. data/lib/peddler/structured_list.rb +0 -23
  102. data/lib/peddler/vcr_matcher.rb +0 -97
  103. data/lib/peddler/xml_parser.rb +0 -38
  104. data/lib/peddler/xml_response_parser.rb +0 -25
@@ -0,0 +1,154 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "peddler/api"
4
+
5
+ module Peddler
6
+ class API
7
+ # Selling Partner API for Listings Items
8
+ #
9
+ # The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner
10
+ # listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which
11
+ # you use to retrieve the information about Amazon product types needed to use the Listings Items API. For more
12
+ # information, see the [Listings Items API Use Case
13
+ # Guide](https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-use-case-guide).
14
+ class ListingsItems20210801 < API
15
+ # Delete a listings item for a selling partner.
16
+ # @note The parameters associated with this operation may contain special characters that must be encoded to
17
+ # successfully call the API. To avoid errors with SKUs when encoding URLs, refer to [URL
18
+ # Encoding](https://developer-docs.amazon.com/sp-api/docs/url-encoding).
19
+ #
20
+ # @param [String] seller_id A selling partner identifier, such as a merchant account or vendor code.
21
+ # @param [String] sku A selling partner provided identifier for an Amazon listing.
22
+ # @param [Array<String>] marketplace_ids A comma-delimited list of Amazon marketplace identifiers for the request.
23
+ # @param [String] issue_locale A locale for localization of issues. When not provided, the default language code
24
+ # of the first marketplace is used. Examples: `en_US`, `fr_CA`, `fr_FR`. Localized messages default to `en_US`
25
+ # when a localization is not available in the specified locale.
26
+ # @return [Hash] The API response
27
+ def delete_listings_item(seller_id, sku, marketplace_ids, issue_locale: nil)
28
+ path = "/listings/2021-08-01/items/#{seller_id}/#{sku}"
29
+ params = {
30
+ "marketplaceIds" => marketplace_ids,
31
+ "issueLocale" => issue_locale,
32
+ }.compact
33
+
34
+ rate_limit(5.0).delete(path, params:)
35
+ end
36
+
37
+ # Returns details about a listings item for a selling partner.
38
+ # @note The parameters associated with this operation may contain special characters that must be encoded to
39
+ # successfully call the API. To avoid errors with SKUs when encoding URLs, refer to [URL
40
+ # Encoding](https://developer-docs.amazon.com/sp-api/docs/url-encoding).
41
+ #
42
+ # @param [String] seller_id A selling partner identifier, such as a merchant account or vendor code.
43
+ # @param [String] sku A selling partner provided identifier for an Amazon listing.
44
+ # @param [Array<String>] marketplace_ids A comma-delimited list of Amazon marketplace identifiers for the request.
45
+ # @param [String] issue_locale A locale for localization of issues. When not provided, the default language code
46
+ # of the first marketplace is used. Examples: `en_US`, `fr_CA`, `fr_FR`. Localized messages default to `en_US`
47
+ # when a localization is not available in the specified locale.
48
+ # @param [Array<String>] included_data A comma-delimited list of data sets to include in the response. Default:
49
+ # `summaries`.
50
+ # @return [Hash] The API response
51
+ def get_listings_item(seller_id, sku, marketplace_ids, issue_locale: nil, included_data: nil)
52
+ path = "/listings/2021-08-01/items/#{seller_id}/#{sku}"
53
+ params = {
54
+ "marketplaceIds" => marketplace_ids,
55
+ "issueLocale" => issue_locale,
56
+ "includedData" => included_data,
57
+ }.compact
58
+
59
+ rate_limit(5.0).get(path, params:)
60
+ end
61
+
62
+ # Partially update (patch) a listings item for a selling partner. Only top-level listings item attributes can be
63
+ # patched. Patching nested attributes is not supported.
64
+ # @note This operation has a throttling rate of one request per second when `mode` is `VALIDATION_PREVIEW`.
65
+ # @note The parameters associated with this operation may contain special characters that must be encoded to
66
+ # successfully call the API. To avoid errors with SKUs when encoding URLs, refer to [URL
67
+ # Encoding](https://developer-docs.amazon.com/sp-api/docs/url-encoding).
68
+ #
69
+ # @param [String] seller_id A selling partner identifier, such as a merchant account or vendor code.
70
+ # @param [String] sku A selling partner provided identifier for an Amazon listing.
71
+ # @param [Array<String>] marketplace_ids A comma-delimited list of Amazon marketplace identifiers for the request.
72
+ # @param [Array<String>] included_data A comma-delimited list of data sets to include in the response. Default:
73
+ # `issues`.
74
+ # @param [String] mode The mode of operation for the request.
75
+ # @param [String] issue_locale A locale for localization of issues. When not provided, the default language code
76
+ # of the first marketplace is used. Examples: `en_US`, `fr_CA`, `fr_FR`. Localized messages default to `en_US`
77
+ # when a localization is not available in the specified locale.
78
+ # @param [Hash] body The request body schema for the `patchListingsItem` operation.
79
+ # @return [Hash] The API response
80
+ def patch_listings_item(seller_id, sku, marketplace_ids, body, included_data: nil, mode: nil, issue_locale: nil)
81
+ path = "/listings/2021-08-01/items/#{seller_id}/#{sku}"
82
+ params = {
83
+ "marketplaceIds" => marketplace_ids,
84
+ "includedData" => included_data,
85
+ "mode" => mode,
86
+ "issueLocale" => issue_locale,
87
+ }.compact
88
+
89
+ rate_limit(5.0).patch(path, body:, params:)
90
+ end
91
+
92
+ # Creates or fully updates an existing listings item for a selling partner.
93
+ # @note This operation has a throttling rate of one request per second when `mode` is `VALIDATION_PREVIEW`.
94
+ # @note The parameters associated with this operation may contain special characters that must be encoded to
95
+ # successfully call the API. To avoid errors with SKUs when encoding URLs, refer to [URL
96
+ # Encoding](https://developer-docs.amazon.com/sp-api/docs/url-encoding).
97
+ #
98
+ # @param [String] seller_id A selling partner identifier, such as a merchant account or vendor code.
99
+ # @param [String] sku A selling partner provided identifier for an Amazon listing.
100
+ # @param [Array<String>] marketplace_ids A comma-delimited list of Amazon marketplace identifiers for the request.
101
+ # @param [Array<String>] included_data A comma-delimited list of data sets to include in the response. Default:
102
+ # `issues`.
103
+ # @param [String] mode The mode of operation for the request.
104
+ # @param [String] issue_locale A locale for localization of issues. When not provided, the default language code
105
+ # of the first marketplace is used. Examples: `en_US`, `fr_CA`, `fr_FR`. Localized messages default to `en_US`
106
+ # when a localization is not available in the specified locale.
107
+ # @param [Hash] body The request body schema for the `putListingsItem` operation.
108
+ # @return [Hash] The API response
109
+ def put_listings_item(seller_id, sku, marketplace_ids, body, included_data: nil, mode: nil, issue_locale: nil)
110
+ path = "/listings/2021-08-01/items/#{seller_id}/#{sku}"
111
+ params = {
112
+ "marketplaceIds" => marketplace_ids,
113
+ "includedData" => included_data,
114
+ "mode" => mode,
115
+ "issueLocale" => issue_locale,
116
+ }.compact
117
+
118
+ rate_limit(5.0).put(path, body:, params:)
119
+ end
120
+
121
+ # Search for and return list of listings items and respective details for a selling partner.
122
+ #
123
+ # @param [String] seller_id A selling partner identifier, such as a merchant account or vendor code.
124
+ # @param [Array<String>] marketplace_ids A comma-delimited list of Amazon marketplace identifiers for the request.
125
+ # @param [Array<String>] identifiers A comma-delimited list of product identifiers to search for listings items
126
+ # by. **Note**: 1. Required when `identifiersType` is provided.
127
+ # @param [String] identifiers_type Type of product identifiers to search for listings items by. **Note**: 1.
128
+ # Required when `identifiers` is provided.
129
+ # @param [Integer] page_size Number of results to be returned per page.
130
+ # @param [String] page_token A token to fetch a certain page when there are multiple pages worth of results.
131
+ # @param [Array<String>] included_data A comma-delimited list of data sets to include in the response. Default:
132
+ # summaries.
133
+ # @param [String] issue_locale A locale for localization of issues. When not provided, the default language code
134
+ # of the first marketplace is used. Examples: "en_US", "fr_CA", "fr_FR". Localized messages default to "en_US"
135
+ # when a localization is not available in the specified locale.
136
+ # @return [Hash] The API response
137
+ def search_listings_items(seller_id, marketplace_ids, identifiers: nil, identifiers_type: nil, page_size: nil,
138
+ page_token: nil, included_data: nil, issue_locale: nil)
139
+ path = "/listings/2021-08-01/items/#{seller_id}"
140
+ params = {
141
+ "marketplaceIds" => marketplace_ids,
142
+ "identifiers" => identifiers,
143
+ "identifiersType" => identifiers_type,
144
+ "pageSize" => page_size,
145
+ "pageToken" => page_token,
146
+ "includedData" => included_data,
147
+ "issueLocale" => issue_locale,
148
+ }.compact
149
+
150
+ rate_limit(5.0).get(path, params:)
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "peddler/api"
4
+
5
+ module Peddler
6
+ class API
7
+ # Selling Partner API for Listings Restrictions
8
+ #
9
+ # The Selling Partner API for Listings Restrictions provides programmatic access to restrictions on Amazon catalog
10
+ # listings. For more information, see the [Listings Restrictions API Use Case
11
+ # Guide](doc:listings-restrictions-api-v2021-08-01-use-case-guide).
12
+ class ListingsRestrictions20210801 < API
13
+ # Returns listing restrictions for an item in the Amazon Catalog.
14
+ #
15
+ # @param [String] asin The Amazon Standard Identification Number (ASIN) of the item.
16
+ # @param [String] condition_type The condition used to filter restrictions.
17
+ # @param [String] seller_id A selling partner identifier, such as a merchant account.
18
+ # @param [Array<String>] marketplace_ids A comma-delimited list of Amazon marketplace identifiers for the request.
19
+ # @param [String] reason_locale A locale for reason text localization. When not provided, the default language
20
+ # code of the first marketplace is used. Examples: "en_US", "fr_CA", "fr_FR". Localized messages default to
21
+ # "en_US" when a localization is not available in the specified locale.
22
+ # @return [Hash] The API response
23
+ def get_listings_restrictions(asin, seller_id, marketplace_ids, condition_type: nil, reason_locale: nil)
24
+ path = "/listings/2021-08-01/restrictions"
25
+ params = {
26
+ "asin" => asin,
27
+ "conditionType" => condition_type,
28
+ "sellerId" => seller_id,
29
+ "marketplaceIds" => marketplace_ids,
30
+ "reasonLocale" => reason_locale,
31
+ }.compact
32
+
33
+ rate_limit(5.0).get(path, params:)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "peddler/api"
4
+
5
+ module Peddler
6
+ class API
7
+ # Selling Partner API for Merchant Fulfillment
8
+ #
9
+ # The Selling Partner API for Merchant Fulfillment helps you build applications that let sellers purchase shipping
10
+ # for non-Prime and Prime orders using Amazon’s Buy Shipping Services.
11
+ class MerchantFulfillmentV0 < API
12
+ # Returns a list of shipping service offers that satisfy the specified shipment request details.
13
+ #
14
+ # @param [Hash] body Request schema for GetEligibleShipmentServices operation.
15
+ # @return [Hash] The API response
16
+ def get_eligible_shipment_services(body)
17
+ path = "/mfn/v0/eligibleShippingServices"
18
+
19
+ rate_limit(5.0).post(path, body:)
20
+ end
21
+
22
+ # Returns the shipment information for an existing shipment.
23
+ #
24
+ # @param [String] shipment_id The Amazon-defined shipment identifier for the shipment.
25
+ # @return [Hash] The API response
26
+ def get_shipment(shipment_id)
27
+ path = "/mfn/v0/shipments/#{shipment_id}"
28
+
29
+ rate_limit(1.0).get(path)
30
+ end
31
+
32
+ # Cancel the shipment indicated by the specified shipment identifier.
33
+ #
34
+ # @param [String] shipment_id The Amazon-defined shipment identifier for the shipment to cancel.
35
+ # @return [Hash] The API response
36
+ def cancel_shipment(shipment_id)
37
+ path = "/mfn/v0/shipments/#{shipment_id}"
38
+
39
+ rate_limit(1.0).delete(path)
40
+ end
41
+
42
+ # Create a shipment with the information provided.
43
+ #
44
+ # @param [Hash] body Request schema for CreateShipment operation.
45
+ # @return [Hash] The API response
46
+ def create_shipment(body)
47
+ path = "/mfn/v0/shipments"
48
+
49
+ rate_limit(1.0).post(path, body:)
50
+ end
51
+
52
+ # Gets a list of additional seller inputs required for a ship method. This is generally used for international
53
+ # shipping.
54
+ #
55
+ # @param [Hash] body Request schema for GetAdditionalSellerInputs operation.
56
+ # @return [Hash] The API response
57
+ def get_additional_seller_inputs(body)
58
+ path = "/mfn/v0/additionalSellerInputs"
59
+
60
+ rate_limit(1.0).post(path, body:)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,241 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "peddler/api"
4
+
5
+ module Peddler
6
+ class API
7
+ # Selling Partner API for Messaging
8
+ #
9
+ # With the Messaging API you can build applications that send messages to buyers. You can get a list of message
10
+ # types that are available for an order that you specify, then call an operation that sends a message to the buyer
11
+ # for that order. The Messaging API returns responses that are formed according to the <a
12
+ # href=https://tools.ietf.org/html/draft-kelly-json-hal-08>JSON Hypertext Application Language</a> (HAL) standard.
13
+ class MessagingV1 < API
14
+ # Returns a list of message types that are available for an order that you specify. A message type is represented
15
+ # by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to
16
+ # call an operation that sends a message.
17
+ #
18
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which you want a list
19
+ # of available message types.
20
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
21
+ # order was placed. Only one marketplace can be specified.
22
+ # @return [Hash] The API response
23
+ def get_messaging_actions_for_order(amazon_order_id, marketplace_ids)
24
+ path = "/messaging/v1/orders/#{amazon_order_id}"
25
+ params = {
26
+ "marketplaceIds" => marketplace_ids,
27
+ }.compact
28
+
29
+ rate_limit(1.0).get(path, params:)
30
+ end
31
+
32
+ # Sends a message asking a buyer to provide or verify customization details such as name spelling, images,
33
+ # initials, etc.
34
+ #
35
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
36
+ # sent.
37
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
38
+ # order was placed. Only one marketplace can be specified.
39
+ # @param [Hash] body
40
+ # @return [Hash] The API response
41
+ def confirm_customization_details(amazon_order_id, marketplace_ids, body)
42
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/confirmCustomizationDetails"
43
+ params = {
44
+ "marketplaceIds" => marketplace_ids,
45
+ }.compact
46
+
47
+ rate_limit(1.0).post(path, body:, params:)
48
+ end
49
+
50
+ # Sends a message to a buyer to arrange a delivery or to confirm contact information for making a delivery.
51
+ #
52
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
53
+ # sent.
54
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
55
+ # order was placed. Only one marketplace can be specified.
56
+ # @param [Hash] body
57
+ # @return [Hash] The API response
58
+ def create_confirm_delivery_details(amazon_order_id, marketplace_ids, body)
59
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/confirmDeliveryDetails"
60
+ params = {
61
+ "marketplaceIds" => marketplace_ids,
62
+ }.compact
63
+
64
+ rate_limit(1.0).post(path, body:, params:)
65
+ end
66
+
67
+ # Sends a critical message that contains documents that a seller is legally obligated to provide to the buyer.
68
+ # This message should only be used to deliver documents that are required by law.
69
+ #
70
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
71
+ # sent.
72
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
73
+ # order was placed. Only one marketplace can be specified.
74
+ # @param [Hash] body
75
+ # @return [Hash] The API response
76
+ def create_legal_disclosure(amazon_order_id, marketplace_ids, body)
77
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/legalDisclosure"
78
+ params = {
79
+ "marketplaceIds" => marketplace_ids,
80
+ }.compact
81
+
82
+ rate_limit(1.0).post(path, body:, params:)
83
+ end
84
+
85
+ # Sends a non-critical message that asks a buyer to remove their negative feedback. This message should only be
86
+ # sent after the seller has resolved the buyer's problem.
87
+ #
88
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
89
+ # sent.
90
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
91
+ # order was placed. Only one marketplace can be specified.
92
+ # @return [Hash] The API response
93
+ def create_negative_feedback_removal(amazon_order_id, marketplace_ids)
94
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/negativeFeedbackRemoval"
95
+ params = {
96
+ "marketplaceIds" => marketplace_ids,
97
+ }.compact
98
+
99
+ rate_limit(1.0).post(path, params:)
100
+ end
101
+
102
+ # Sends a message to ask a buyer an order-related question prior to shipping their order.
103
+ #
104
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
105
+ # sent.
106
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
107
+ # order was placed. Only one marketplace can be specified.
108
+ # @param [Hash] body
109
+ # @return [Hash] The API response
110
+ def create_confirm_order_details(amazon_order_id, marketplace_ids, body)
111
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/confirmOrderDetails"
112
+ params = {
113
+ "marketplaceIds" => marketplace_ids,
114
+ }.compact
115
+
116
+ rate_limit(1.0).post(path, body:, params:)
117
+ end
118
+
119
+ # Sends a message to contact a Home Service customer to arrange a service call or to gather information prior to a
120
+ # service call.
121
+ #
122
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
123
+ # sent.
124
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
125
+ # order was placed. Only one marketplace can be specified.
126
+ # @param [Hash] body
127
+ # @return [Hash] The API response
128
+ def create_confirm_service_details(amazon_order_id, marketplace_ids, body)
129
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/confirmServiceDetails"
130
+ params = {
131
+ "marketplaceIds" => marketplace_ids,
132
+ }.compact
133
+
134
+ rate_limit(1.0).post(path, body:, params:)
135
+ end
136
+
137
+ # Sends a message to a buyer to provide details about an Amazon Motors order. This message can only be sent by
138
+ # Amazon Motors sellers.
139
+ #
140
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
141
+ # sent.
142
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
143
+ # order was placed. Only one marketplace can be specified.
144
+ # @param [Hash] body
145
+ # @return [Hash] The API response
146
+ def create_amazon_motors(amazon_order_id, marketplace_ids, body)
147
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/amazonMotors"
148
+ params = {
149
+ "marketplaceIds" => marketplace_ids,
150
+ }.compact
151
+
152
+ rate_limit(1.0).post(path, body:, params:)
153
+ end
154
+
155
+ # Sends a message to a buyer to provide details about warranty information on a purchase in their order.
156
+ #
157
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
158
+ # sent.
159
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
160
+ # order was placed. Only one marketplace can be specified.
161
+ # @param [Hash] body
162
+ # @return [Hash] The API response
163
+ def create_warranty(amazon_order_id, marketplace_ids, body)
164
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/warranty"
165
+ params = {
166
+ "marketplaceIds" => marketplace_ids,
167
+ }.compact
168
+
169
+ rate_limit(1.0).post(path, body:, params:)
170
+ end
171
+
172
+ # Returns a response containing attributes related to an order. This includes buyer preferences.
173
+ #
174
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
175
+ # sent.
176
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
177
+ # order was placed. Only one marketplace can be specified.
178
+ # @return [Hash] The API response
179
+ def get_attributes(amazon_order_id, marketplace_ids)
180
+ path = "/messaging/v1/orders/#{amazon_order_id}/attributes"
181
+ params = {
182
+ "marketplaceIds" => marketplace_ids,
183
+ }.compact
184
+
185
+ rate_limit(1.0).get(path, params:)
186
+ end
187
+
188
+ # Sends a message to a buyer to share a digital access key needed to utilize digital content in their order.
189
+ #
190
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
191
+ # sent.
192
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
193
+ # order was placed. Only one marketplace can be specified.
194
+ # @param [Hash] body
195
+ # @return [Hash] The API response
196
+ def create_digital_access_key(amazon_order_id, marketplace_ids, body)
197
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/digitalAccessKey"
198
+ params = {
199
+ "marketplaceIds" => marketplace_ids,
200
+ }.compact
201
+
202
+ rate_limit(1.0).post(path, body:, params:)
203
+ end
204
+
205
+ # Sends a critical message to a buyer that an unexpected problem was encountered affecting the completion of the
206
+ # order.
207
+ #
208
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
209
+ # sent.
210
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
211
+ # order was placed. Only one marketplace can be specified.
212
+ # @param [Hash] body
213
+ # @return [Hash] The API response
214
+ def create_unexpected_problem(amazon_order_id, marketplace_ids, body)
215
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/unexpectedProblem"
216
+ params = {
217
+ "marketplaceIds" => marketplace_ids,
218
+ }.compact
219
+
220
+ rate_limit(1.0).post(path, body:, params:)
221
+ end
222
+
223
+ # Sends a message providing the buyer an invoice
224
+ #
225
+ # @param [String] amazon_order_id An Amazon order identifier. This specifies the order for which a message is
226
+ # sent.
227
+ # @param [Array<String>] marketplace_ids A marketplace identifier. This specifies the marketplace in which the
228
+ # order was placed. Only one marketplace can be specified.
229
+ # @param [Hash] body
230
+ # @return [Hash] The API response
231
+ def send_invoice(amazon_order_id, marketplace_ids, body)
232
+ path = "/messaging/v1/orders/#{amazon_order_id}/messages/invoice"
233
+ params = {
234
+ "marketplaceIds" => marketplace_ids,
235
+ }.compact
236
+
237
+ post(path, body:, params:)
238
+ end
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "peddler/api"
4
+
5
+ module Peddler
6
+ class API
7
+ # Selling Partner API for Notifications
8
+ #
9
+ # The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling
10
+ # partner's business. Using this API you can create a destination to receive notifications, subscribe to
11
+ # notifications, delete notification subscriptions, and more. For more information, refer to the [Notifications Use
12
+ # Case Guide](https://developer-docs.amazon.com/sp-api/docs/notifications-api-v1-use-case-guide).
13
+ class NotificationsV1 < API
14
+ # Returns information about subscription of the specified notification type and payload version. `payloadVersion`
15
+ # is an optional parameter. When `payloadVersion` is not provided, it will return latest payload version
16
+ # subscription's information. You can use this API to get subscription information when you do not have a
17
+ # subscription identifier.
18
+ #
19
+ # @param [String] payload_version The version of the payload object to be used in the notification.
20
+ # @return [Hash] The API response
21
+ def get_subscription(payload_version: nil)
22
+ path = "/notifications/v1/subscriptions/#{notification_type}"
23
+ params = {
24
+ "payloadVersion" => payload_version,
25
+ }.compact
26
+
27
+ rate_limit(1.0).get(path, params:)
28
+ end
29
+
30
+ # Creates a subscription for the specified notification type to be delivered to the specified destination. Before
31
+ # you can subscribe, you must first create the destination by calling the `createDestination` operation. In cases
32
+ # where the specified notification type supports multiple payload versions, you can utilize this API to subscribe
33
+ # to a different payload version if you already have an existing subscription for a different payload version.
34
+ #
35
+ # @param [Hash] body
36
+ # @return [Hash] The API response
37
+ def create_subscription(body)
38
+ path = "/notifications/v1/subscriptions/#{notification_type}"
39
+
40
+ rate_limit(1.0).post(path, body:)
41
+ end
42
+
43
+ # Returns information about a subscription for the specified notification type. The `getSubscriptionById`
44
+ # operation is grantless. For more information, refer to [Grantless
45
+ # operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).
46
+ #
47
+ # @param [String] subscription_id The identifier for the subscription that you want to get.
48
+ # @return [Hash] The API response
49
+ def get_subscription_by_id(subscription_id)
50
+ path = "/notifications/v1/subscriptions/#{notification_type}/#{subscription_id}"
51
+
52
+ rate_limit(1.0).get(path)
53
+ end
54
+
55
+ # Deletes the subscription indicated by the subscription identifier and notification type that you specify. The
56
+ # subscription identifier can be for any subscription associated with your application. After you successfully
57
+ # call this operation, notifications will stop being sent for the associated subscription. The
58
+ # `deleteSubscriptionById` operation is grantless. For more information, refer to [Grantless
59
+ # operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).
60
+ #
61
+ # @param [String] subscription_id The identifier for the subscription that you want to delete.
62
+ # @return [Hash] The API response
63
+ def delete_subscription_by_id(subscription_id)
64
+ path = "/notifications/v1/subscriptions/#{notification_type}/#{subscription_id}"
65
+
66
+ rate_limit(1.0).delete(path)
67
+ end
68
+
69
+ # Returns information about all destinations. The `getDestinations` operation is grantless. For more information,
70
+ # refer to [Grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).
71
+ # @return [Hash] The API response
72
+ def get_destinations
73
+ path = "/notifications/v1/destinations"
74
+
75
+ rate_limit(1.0).get(path)
76
+ end
77
+
78
+ # Creates a destination resource to receive notifications. The `createDestination` operation is grantless. For
79
+ # more information, refer to [Grantless
80
+ # operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).
81
+ #
82
+ # @param [Hash] body
83
+ # @return [Hash] The API response
84
+ def create_destination(body)
85
+ path = "/notifications/v1/destinations"
86
+
87
+ rate_limit(1.0).post(path, body:)
88
+ end
89
+
90
+ # Returns information about the destination that you specify. The `getDestination` operation is grantless. For
91
+ # more information, refer to [Grantless
92
+ # operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).
93
+ #
94
+ # @param [String] destination_id The identifier generated when you created the destination.
95
+ # @return [Hash] The API response
96
+ def get_destination(destination_id)
97
+ path = "/notifications/v1/destinations/#{destination_id}"
98
+
99
+ rate_limit(1.0).get(path)
100
+ end
101
+
102
+ # Deletes the destination that you specify. The `deleteDestination` operation is grantless. For more information,
103
+ # refer to [Grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).
104
+ #
105
+ # @param [String] destination_id The identifier for the destination that you want to delete.
106
+ # @return [Hash] The API response
107
+ def delete_destination(destination_id)
108
+ path = "/notifications/v1/destinations/#{destination_id}"
109
+
110
+ rate_limit(1.0).delete(path)
111
+ end
112
+ end
113
+ end
114
+ end