lib/peddler/api/fba_inventory_v1.rb in peddler-3.0.0.beta1 vs lib/peddler/api/fba_inventory_v1.rb in peddler-3.0.0
- old
+ new
@@ -1,10 +1,16 @@
# frozen_string_literal: true
require "peddler/api"
module Peddler
+ class << self
+ def fba_inventory_v1(...)
+ API::FBAInventoryV1.new(...)
+ end
+ end
+
class API
# Selling Partner API for FBA Inventory
#
# The Selling Partner API for FBA Inventory lets you programmatically retrieve information about inventory in
# Amazon's fulfillment network.
@@ -17,34 +23,32 @@
# nextToken to get the next page of inventory summaries that have changed after the date and time specified. -
# When the sellerSkus parameter is provided, the operation returns inventory summaries for only the specified
# sellerSkus. The sellerSku parameter is ignored. - When the sellerSku parameter is provided, the operation
# returns inventory summaries for only the specified sellerSku. Note: The parameters associated with this
# operation may contain special characters that must be encoded to successfully call the API. To avoid errors with
- # SKUs when encoding URLs, refer to URL Encoding. Usage Plan: | Rate (requests per second) | Burst | | ---- | ----
- # | | 2 | 2 | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to
- # the requested operation, when available. The table above indicates the default rate and burst values for this
- # operation. Selling partners whose business demands require higher throughput may see higher rate and burst
- # values than those shown here. For more information, see Usage Plans and Rate Limits in the Selling Partner API.
+ # SKUs when encoding URLs, refer to [URL Encoding](https://developer-docs.amazon.com/sp-api/docs/url-encoding).
#
- # @param [Boolean] details true to return inventory summaries with additional summarized inventory details and
+ # @note This operation can make a dynamic sandbox call.
+ # @param details [Boolean] true to return inventory summaries with additional summarized inventory details and
# quantities. Otherwise, returns inventory summaries only (default value).
- # @param [String] granularity_type The granularity type for the inventory aggregation level.
- # @param [String] granularity_id The granularity ID for the inventory aggregation level.
- # @param [String] start_date_time A start date and time in ISO8601 format. If specified, all inventory summaries
+ # @param granularity_type [String] The granularity type for the inventory aggregation level.
+ # @param granularity_id [String] The granularity ID for the inventory aggregation level.
+ # @param start_date_time [String] A start date and time in ISO8601 format. If specified, all inventory summaries
# that have changed since then are returned. You must specify a date and time that is no earlier than 18 months
# prior to the date and time when you call the API. Note: Changes in inboundWorkingQuantity,
# inboundShippedQuantity and inboundReceivingQuantity are not detected.
- # @param [Array<String>] seller_skus A list of seller SKUs for which to return inventory summaries. You may
+ # @param seller_skus [Array<String>] A list of seller SKUs for which to return inventory summaries. You may
# specify up to 50 SKUs.
- # @param [String] seller_sku A single seller SKU used for querying the specified seller SKU inventory summaries.
- # @param [String] next_token String token returned in the response of your previous request. The string token will
+ # @param seller_sku [String] A single seller SKU used for querying the specified seller SKU inventory summaries.
+ # @param next_token [String] String token returned in the response of your previous request. The string token will
# expire 30 seconds after being created.
- # @param [Array<String>] marketplace_ids The marketplace ID for the marketplace for which to return inventory
+ # @param marketplace_ids [Array<String>] The marketplace ID for the marketplace for which to return inventory
# summaries.
+ # @param rate_limit [Float] Requests per second
# @return [Hash] The API response
- def get_inventory_summaries(granularity_type, granularity_id, marketplace_ids, details: nil,
- start_date_time: nil, seller_skus: nil, seller_sku: nil, next_token: nil)
+ def get_inventory_summaries(granularity_type, granularity_id, marketplace_ids, details: nil, start_date_time: nil,
+ seller_skus: nil, seller_sku: nil, next_token: nil, rate_limit: 2.0)
path = "/fba/inventory/v1/summaries"
params = {
"details" => details,
"granularityType" => granularity_type,
"granularityId" => granularity_id,
@@ -53,34 +57,42 @@
"sellerSku" => seller_sku,
"nextToken" => next_token,
"marketplaceIds" => marketplace_ids,
}.compact
- rate_limit(2.0).get(path, params:)
+ meter(rate_limit).get(path, params:)
end
# Requests that Amazon create product-details in the Sandbox Inventory in the sandbox environment. This is a
# sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling Partner API
# sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more information.
#
- # @param [Hash] create_inventory_item_request_body CreateInventoryItem Request Body Parameter.
+ # @note This operation can make a dynamic sandbox call.
+ # @param create_inventory_item_request_body [Hash] CreateInventoryItem Request Body Parameter.
+ # @param rate_limit [Float] Requests per second
# @return [Hash] The API response
- def create_inventory_item(create_inventory_item_request_body)
+ def create_inventory_item(create_inventory_item_request_body, rate_limit: nil)
+ must_sandbox!
+
path = "/fba/inventory/v1/items"
body = create_inventory_item_request_body
post(path, body:)
end
# Requests that Amazon Deletes an item from the Sandbox Inventory in the sandbox environment. This is a
# sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling Partner API
# sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more information.
#
- # @param [String] seller_sku A single seller SKU used for querying the specified seller SKU inventory summaries.
- # @param [String] marketplace_id The marketplace ID for the marketplace for which the sellerSku is to be deleted.
+ # @note This operation can make a dynamic sandbox call.
+ # @param seller_sku [String] A single seller SKU used for querying the specified seller SKU inventory summaries.
+ # @param marketplace_id [String] The marketplace ID for the marketplace for which the sellerSku is to be deleted.
+ # @param rate_limit [Float] Requests per second
# @return [Hash] The API response
- def delete_inventory_item(seller_sku, marketplace_id)
+ def delete_inventory_item(seller_sku, marketplace_id, rate_limit: nil)
+ must_sandbox!
+
path = "/fba/inventory/v1/items/#{seller_sku}"
params = {
"marketplaceId" => marketplace_id,
}.compact
@@ -90,13 +102,17 @@
# Requests that Amazon add items to the Sandbox Inventory with desired amount of quantity in the sandbox
# environment. This is a sandbox-only operation and must be directed to a sandbox endpoint. Refer to [Selling
# Partner API sandbox](https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox) for more
# information.
#
- # @param [String] x_amzn_idempotency_token A unique token/requestId provided with each call to ensure idempotency.
- # @param [Hash] add_inventory_request_body List of items to add to Sandbox inventory.
+ # @note This operation can make a dynamic sandbox call.
+ # @param x_amzn_idempotency_token [String] A unique token/requestId provided with each call to ensure idempotency.
+ # @param add_inventory_request_body [Hash] List of items to add to Sandbox inventory.
+ # @param rate_limit [Float] Requests per second
# @return [Hash] The API response
- def add_inventory(x_amzn_idempotency_token, add_inventory_request_body)
+ def add_inventory(x_amzn_idempotency_token, add_inventory_request_body, rate_limit: nil)
+ must_sandbox!
+
path = "/fba/inventory/v1/items/inventory"
body = add_inventory_request_body
post(path, body:)
end