UNPKG

@sp-api-sdk/fba-inbound-eligibility-api-v1

Version:

With the FBA Inbound Eligibility API, you can build applications that let sellers get eligibility previews for items before shipping them to Amazon's fulfillment centers. With this API you can find out if an item is eligible for inbound shipment to Amazon

331 lines (324 loc) 15.2 kB
// src/client.ts import { createAxiosInstance } from "@sp-api-sdk/common"; // src/api-model/api/fba-inbound-eligibility-api.ts import globalAxios2 from "axios"; // src/api-model/base.ts import globalAxios from "axios"; var BASE_PATH = "https://sellingpartnerapi-na.amazon.com".replace(/\/+$/, ""); var COLLECTION_FORMATS = { csv: ",", ssv: " ", tsv: " ", pipes: "|" }; var BaseAPI = class { constructor(configuration, basePath = BASE_PATH, axios = globalAxios) { this.basePath = basePath; this.axios = axios; if (configuration) { this.configuration = configuration; this.basePath = configuration.basePath ?? basePath; } } basePath; axios; configuration; }; var RequiredError = class extends Error { constructor(field, msg) { super(msg); this.field = field; this.name = "RequiredError"; } field; }; var operationServerMap = {}; // src/api-model/common.ts var DUMMY_BASE_URL = "https://example.com"; var assertParamExists = function(functionName, paramName, paramValue) { if (paramValue === null || paramValue === void 0) { throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); } }; function setFlattenedQueryParams(urlSearchParams, parameter, key = "") { if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter) || parameter instanceof Set) { parameter.forEach((item) => setFlattenedQueryParams(urlSearchParams, item, key)); } else { Object.keys(parameter).forEach( (currentKey) => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== "" ? "." : ""}${currentKey}`) ); } } else { if (urlSearchParams.has(key)) { urlSearchParams.append(key, parameter); } else { urlSearchParams.set(key, parameter); } } } var setSearchParams = function(url, ...objects) { const searchParams = new URLSearchParams(url.search); setFlattenedQueryParams(searchParams, objects); url.search = searchParams.toString(); }; var toPathString = function(url) { return url.pathname + url.search + url.hash; }; var createRequestFunction = function(axiosArgs, globalAxios3, BASE_PATH2, configuration) { return (axios = globalAxios3, basePath = BASE_PATH2) => { const axiosRequestArgs = { ...axiosArgs.options, url: (axios.defaults.baseURL ? "" : configuration?.basePath ?? basePath) + axiosArgs.url }; return axios.request(axiosRequestArgs); }; }; // src/api-model/api/fba-inbound-eligibility-api.ts var FbaInboundEligibilityApiAxiosParamCreator = function(configuration) { return { /** * This operation gets an eligibility preview for an item that you specify. You can specify the type of eligibility preview that you want (INBOUND or COMMINGLING). For INBOUND previews, you can specify the marketplace in which you want to determine the item\'s eligibility. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | 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](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). * @param {string} asin The ASIN of the item for which you want an eligibility preview. * @param {GetItemEligibilityPreviewProgramEnum} program The program that you want to check eligibility against. * @param {Array<string>} [marketplaceIds] The identifier for the marketplace in which you want to determine eligibility. Required only when program&#x3D;INBOUND. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getItemEligibilityPreview: async (asin, program, marketplaceIds, options = {}) => { assertParamExists("getItemEligibilityPreview", "asin", asin); assertParamExists("getItemEligibilityPreview", "program", program); const localVarPath = `/fba/inbound/v1/eligibility/itemPreview`; const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: "GET", ...baseOptions, ...options }; const localVarHeaderParameter = {}; const localVarQueryParameter = {}; if (marketplaceIds) { localVarQueryParameter["marketplaceIds"] = marketplaceIds.join(COLLECTION_FORMATS.csv); } if (asin !== void 0) { localVarQueryParameter["asin"] = asin; } if (program !== void 0) { localVarQueryParameter["program"] = program; } localVarHeaderParameter["Accept"] = "application/json,ItemEligibilityPreview"; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions }; } }; }; var FbaInboundEligibilityApiFp = function(configuration) { const localVarAxiosParamCreator = FbaInboundEligibilityApiAxiosParamCreator(configuration); return { /** * This operation gets an eligibility preview for an item that you specify. You can specify the type of eligibility preview that you want (INBOUND or COMMINGLING). For INBOUND previews, you can specify the marketplace in which you want to determine the item\'s eligibility. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | 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](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). * @param {string} asin The ASIN of the item for which you want an eligibility preview. * @param {GetItemEligibilityPreviewProgramEnum} program The program that you want to check eligibility against. * @param {Array<string>} [marketplaceIds] The identifier for the marketplace in which you want to determine eligibility. Required only when program&#x3D;INBOUND. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getItemEligibilityPreview(asin, program, marketplaceIds, options) { const localVarAxiosArgs = await localVarAxiosParamCreator.getItemEligibilityPreview(asin, program, marketplaceIds, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap["FbaInboundEligibilityApi.getItemEligibilityPreview"]?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); } }; }; var FbaInboundEligibilityApiFactory = function(configuration, basePath, axios) { const localVarFp = FbaInboundEligibilityApiFp(configuration); return { /** * This operation gets an eligibility preview for an item that you specify. You can specify the type of eligibility preview that you want (INBOUND or COMMINGLING). For INBOUND previews, you can specify the marketplace in which you want to determine the item\'s eligibility. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | 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](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). * @param {FbaInboundEligibilityApiGetItemEligibilityPreviewRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getItemEligibilityPreview(requestParameters, options) { return localVarFp.getItemEligibilityPreview(requestParameters.asin, requestParameters.program, requestParameters.marketplaceIds, options).then((request) => request(axios, basePath)); } }; }; var FbaInboundEligibilityApi = class extends BaseAPI { /** * This operation gets an eligibility preview for an item that you specify. You can specify the type of eligibility preview that you want (INBOUND or COMMINGLING). For INBOUND previews, you can specify the marketplace in which you want to determine the item\'s eligibility. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | 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](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). * @param {FbaInboundEligibilityApiGetItemEligibilityPreviewRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getItemEligibilityPreview(requestParameters, options) { return FbaInboundEligibilityApiFp(this.configuration).getItemEligibilityPreview(requestParameters.asin, requestParameters.program, requestParameters.marketplaceIds, options).then((request) => request(this.axios, this.basePath)); } }; var GetItemEligibilityPreviewProgramEnum = { Inbound: "INBOUND", Commingling: "COMMINGLING" }; // src/api-model/configuration.ts var Configuration = class { /** * parameter for apiKey security * @param name security name */ apiKey; /** * parameter for basic security */ username; /** * parameter for basic security */ password; /** * parameter for oauth2 security * @param name security name * @param scopes oauth2 scope */ accessToken; /** * parameter for aws4 signature security * @param {Object} AWS4Signature - AWS4 Signature security * @param {string} options.region - aws region * @param {string} options.service - name of the service. * @param {string} credentials.accessKeyId - aws access key id * @param {string} credentials.secretAccessKey - aws access key * @param {string} credentials.sessionToken - aws session token * @memberof Configuration */ awsv4; /** * override base path */ basePath; /** * override server index */ serverIndex; /** * base options for axios calls */ baseOptions; /** * The FormData constructor that will be used to create multipart form data * requests. You can inject this here so that execution environments that * do not support the FormData class can still run the generated client. * * @type {new () => FormData} */ formDataCtor; constructor(param = {}) { this.apiKey = param.apiKey; this.username = param.username; this.password = param.password; this.accessToken = param.accessToken; this.awsv4 = param.awsv4; this.basePath = param.basePath; this.serverIndex = param.serverIndex; this.baseOptions = { ...param.baseOptions, headers: { ...param.baseOptions?.headers } }; this.formDataCtor = param.formDataCtor; } /** * Check if the given MIME is a JSON MIME. * JSON MIME examples: * application/json * application/json; charset=UTF8 * APPLICATION/JSON * application/vnd.company+json * @param mime - MIME (Multipurpose Internet Mail Extensions) * @return True if the given MIME is JSON, false otherwise. */ isJsonMime(mime) { const jsonMime = /^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$/i; return mime !== null && jsonMime.test(mime); } }; // src/api-model/models/item-eligibility-preview.ts var ItemEligibilityPreviewProgramEnum = { Inbound: "INBOUND", Commingling: "COMMINGLING" }; var ItemEligibilityPreviewIneligibilityReasonListEnum = { FbaInb0004: "FBA_INB_0004", FbaInb0006: "FBA_INB_0006", FbaInb0007: "FBA_INB_0007", FbaInb0008: "FBA_INB_0008", FbaInb0009: "FBA_INB_0009", FbaInb0010: "FBA_INB_0010", FbaInb0011: "FBA_INB_0011", FbaInb0012: "FBA_INB_0012", FbaInb0013: "FBA_INB_0013", FbaInb0014: "FBA_INB_0014", FbaInb0015: "FBA_INB_0015", FbaInb0016: "FBA_INB_0016", FbaInb0017: "FBA_INB_0017", FbaInb0018: "FBA_INB_0018", FbaInb0019: "FBA_INB_0019", FbaInb0034: "FBA_INB_0034", FbaInb0035: "FBA_INB_0035", FbaInb0036: "FBA_INB_0036", FbaInb0037: "FBA_INB_0037", FbaInb0038: "FBA_INB_0038", FbaInb0050: "FBA_INB_0050", FbaInb0051: "FBA_INB_0051", FbaInb0053: "FBA_INB_0053", FbaInb0055: "FBA_INB_0055", FbaInb0056: "FBA_INB_0056", FbaInb0059: "FBA_INB_0059", FbaInb0065: "FBA_INB_0065", FbaInb0066: "FBA_INB_0066", FbaInb0067: "FBA_INB_0067", FbaInb0068: "FBA_INB_0068", FbaInb0095: "FBA_INB_0095", FbaInb0097: "FBA_INB_0097", FbaInb0098: "FBA_INB_0098", FbaInb0099: "FBA_INB_0099", FbaInb0100: "FBA_INB_0100", FbaInb0103: "FBA_INB_0103", FbaInb0104: "FBA_INB_0104", FbaInb0197: "FBA_INB_0197", FbaInb0342: "FBA_INB_0342", FbaInb0465: "FBA_INB_0465", UnknownInbErrorCode: "UNKNOWN_INB_ERROR_CODE" }; // src/client.ts var clientRateLimits = [ { method: "get", // eslint-disable-next-line prefer-regex-literals urlRegex: new RegExp("^/fba/inbound/v1/eligibility/itemPreview$"), rate: 1, burst: 1 } ]; var FbaInboundEligibilityApiClient = class extends FbaInboundEligibilityApi { constructor(configuration) { const { axios, endpoint } = createAxiosInstance(configuration, clientRateLimits); super(new Configuration(), endpoint, axios); } }; export { FbaInboundEligibilityApi, FbaInboundEligibilityApiAxiosParamCreator, FbaInboundEligibilityApiClient, FbaInboundEligibilityApiFactory, FbaInboundEligibilityApiFp, GetItemEligibilityPreviewProgramEnum, ItemEligibilityPreviewIneligibilityReasonListEnum, ItemEligibilityPreviewProgramEnum, clientRateLimits }; //# sourceMappingURL=index.js.map