Class: Peddler::API::FBAInventoryV1

Inherits:
Peddler::API show all
Defined in:
lib/peddler/api/fba_inventory_v1.rb

Overview

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.

Instance Attribute Summary

Attributes inherited from Peddler::API

#access_token, #endpoint

Instance Method Summary collapse

Methods inherited from Peddler::API

#cannot_sandbox!, #endpoint_uri, #http, #initialize, #meter, #must_sandbox!, #retriable, #sandbox, #sandbox?, #use, #via

Constructor Details

This class inherits a constructor from Peddler::API

Instance Method Details

#add_inventory(x_amzn_idempotency_token, add_inventory_request_body, rate_limit: nil) ⇒ Hash

Note:

This operation can make a dynamic sandbox call.

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 for more information.

Parameters:

  • x_amzn_idempotency_token (String)

    A unique token/requestId provided with each call to ensure idempotency.

  • add_inventory_request_body (Hash)

    List of items to add to Sandbox inventory.

  • rate_limit (Float) (defaults to: nil)

    Requests per second

Returns:

  • (Hash)

    The API response



113
114
115
116
117
118
119
120
# File 'lib/peddler/api/fba_inventory_v1.rb', line 113

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

#create_inventory_item(create_inventory_item_request_body, rate_limit: nil) ⇒ Hash

Note:

This operation can make a dynamic sandbox call.

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 for more information.

Parameters:

  • create_inventory_item_request_body (Hash)

    CreateInventoryItem Request Body Parameter.

  • rate_limit (Float) (defaults to: nil)

    Requests per second

Returns:

  • (Hash)

    The API response



74
75
76
77
78
79
80
81
# File 'lib/peddler/api/fba_inventory_v1.rb', line 74

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

#delete_inventory_item(seller_sku, marketplace_id, rate_limit: nil) ⇒ Hash

Note:

This operation can make a dynamic sandbox call.

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 for more information.

Parameters:

  • seller_sku (String)

    A single seller SKU used for querying the specified seller SKU inventory summaries.

  • marketplace_id (String)

    The marketplace ID for the marketplace for which the sellerSku is to be deleted.

  • rate_limit (Float) (defaults to: nil)

    Requests per second

Returns:

  • (Hash)

    The API response



92
93
94
95
96
97
98
99
100
101
# File 'lib/peddler/api/fba_inventory_v1.rb', line 92

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

  delete(path, params:)
end

#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) ⇒ Hash

Note:

This operation can make a dynamic sandbox call.

Returns a list of inventory summaries. The summaries returned depend on the presence or absence of the startDateTime, sellerSkus and sellerSku parameters: - All inventory summaries with available details are returned when the startDateTime, sellerSkus and sellerSku parameters are omitted. - When startDateTime is provided, the operation returns inventory summaries that have had changes after the date and time specified. The sellerSkus and sellerSku parameters are ignored. Important: To avoid errors, use both startDateTime and 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.

Parameters:

  • details (Boolean) (defaults to: nil)

    true to return inventory summaries with additional summarized inventory details and quantities. Otherwise, returns inventory summaries only (default value).

  • granularity_type (String)

    The granularity type for the inventory aggregation level.

  • granularity_id (String)

    The granularity ID for the inventory aggregation level.

  • start_date_time (String) (defaults to: nil)

    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.

  • seller_skus (Array<String>) (defaults to: nil)

    A list of seller SKUs for which to return inventory summaries. You may specify up to 50 SKUs.

  • seller_sku (String) (defaults to: nil)

    A single seller SKU used for querying the specified seller SKU inventory summaries.

  • next_token (String) (defaults to: nil)

    String token returned in the response of your previous request. The string token will expire 30 seconds after being created.

  • marketplace_ids (Array<String>)

    The marketplace ID for the marketplace for which to return inventory summaries.

  • rate_limit (Float) (defaults to: 2.0)

    Requests per second

Returns:

  • (Hash)

    The API response



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/peddler/api/fba_inventory_v1.rb', line 49

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,
    "startDateTime" => start_date_time,
    "sellerSkus" => seller_skus,
    "sellerSku" => seller_sku,
    "nextToken" => next_token,
    "marketplaceIds" => marketplace_ids,
  }.compact

  meter(rate_limit).get(path, params:)
end