Skip to content

Lightweight helper to determine whether a given SP-API GET operation should have usage computed and to map GET operation names to their URL paths.

License

Notifications You must be signed in to change notification settings

sellerartifact/spapi-get-usage-count

Repository files navigation

spapi-get-usage-count

Lightweight helper to determine whether a given SP-API GET operation should have usage computed and to map GET operation names to their URL paths.

Install

pnpm add spapi-get-usage-count

Usage

To use the functions checkIsNeedComputeUsageByGetApi and transformGetApiOperationToUrlPath from the spapi-get-usage-count package, you can import them as follows:

import { checkIsNeedComputeUsageByGetApi, transformGetApiOperationToUrlPath } from 'spapi-get-usage-count';

Example

Here's a basic example of how you might use these functions in your code:

const operationName = 'getFeed';
const isComputeUsageNeeded = checkIsNeedComputeUsageByGetApi(operationName);

if (isComputeUsageNeeded) {
  const urlPath = transformGetApiOperationToUrlPath(operationName);
  console.log(`The URL path for the operation is: ${urlPath}`);
} else {
  console.log('No usage computation needed for this operation.');
}

API

checkIsNeedComputeUsageByGetApi(operationName: string): boolean

Determines if usage computation is needed for the given SP-API GET operation.

  • operationName: The name of the SP-API GET operation.
  • Returns true if usage computation is needed, false otherwise.

transformGetApiOperationToUrlPath(operationName: string): string

Maps the given SP-API GET operation name to its corresponding URL path.

  • operationName: The name of the SP-API GET operation.
  • Returns the URL path as a string.

About

Lightweight helper to determine whether a given SP-API GET operation should have usage computed and to map GET operation names to their URL paths.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published