amz-tools / amazon-sp-api

Amazon Selling Partner API Client
MIT License
230 stars 119 forks source link

Unable to retrieve warehouse locations along with inventory #280

Open sanatg opened 2 months ago

sanatg commented 2 months ago

Hello,

I've been using the Amazon SP API to fetch inventory summaries, and previously, when using a PHP package, I was able to retrieve the warehouse locations associated with the inventory items. However, after reimplementing this functionality in Node.js using the amazon-sp-api package, I am unable to find the endpoint or method to retrieve the warehouse locations.

Here is a snippet of my current implementation:

async function fetchInventorySummaries(nextToken = null, allSummaries = []) {
  try {
    const query = {
      marketplaceIds: ["A21TJRUUN4KGV"],
      details: true,
      granularityType: "Marketplace",
      granularityId: "A21TJRUUN4KGV",
      nextToken: null
    };

    if (nextToken) {
      query.nextToken = nextToken;
    } else {
      query.nextToken = null;
    }

    const inventorySummaries = await spClient.callAPI({
      operation: "getInventorySummaries",
      endpoint: "fbaInventory",
      query: query
    });

    allSummaries.push(...(inventorySummaries.inventorySummaries as []));

    if (inventorySummaries.nextToken) {
      return await fetchInventorySummaries(inventorySummaries.nextToken, allSummaries);
    }

    return allSummaries;

  } catch (error) {
    throw new Error(`Failed to fetch inventory summaries: ${(error as any).message}`);
  }
}

Any guidance would be appreciated. Thanks in advance!

amz-tools commented 1 month ago

@sanatg This should be included in the report GET_LEDGER_DETAIL_VIEW_DATA.