@sp-api-sdk/sellers-api-v1
Version:
The Selling Partner API for Sellers (Sellers API) provides essential information about seller accounts, such as: The marketplaces a seller can list in The default language and currency of a marketplace Whether the seller has suspended listings Refer to th
338 lines (337 loc) • 16.9 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
let _sp_api_sdk_common = require("@sp-api-sdk/common");
let axios = require("axios");
axios = __toESM(axios, 1);
//#region src/api-model/base.ts
const BASE_PATH = "https://sellingpartnerapi-na.amazon.com".replace(/\/+$/, "");
var BaseAPI = class {
basePath;
axios;
configuration;
constructor(configuration, basePath = BASE_PATH, axios$4 = axios.default) {
this.basePath = basePath;
this.axios = axios$4;
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath ?? basePath;
}
}
};
const operationServerMap = {};
//#endregion
//#region src/api-model/common.ts
const DUMMY_BASE_URL = "https://example.com";
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);
}
const setSearchParams = function(url, ...objects) {
const searchParams = new URLSearchParams(url.search);
setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString();
};
const toPathString = function(url) {
return url.pathname + url.search + url.hash;
};
const createRequestFunction = function(axiosArgs, globalAxios, BASE_PATH, configuration) {
return (axios = globalAxios, basePath = BASE_PATH) => {
const axiosRequestArgs = {
...axiosArgs.options,
url: (axios.defaults.baseURL ? "" : configuration?.basePath ?? basePath) + axiosArgs.url
};
return axios.request(axiosRequestArgs);
};
};
//#endregion
//#region src/api-model/api/sellers-api.ts
/**
* SellersApi - axios parameter creator
*/
const SellersApiAxiosParamCreator = function(configuration) {
return {
/**
* Returns information about a seller account and its marketplaces. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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 {*} [options] Override http request option.
* @throws {RequiredError}
*/
getAccount: async (options = {}) => {
const localVarUrlObj = new URL(`/sellers/v1/account`, DUMMY_BASE_URL);
let baseOptions;
if (configuration) baseOptions = configuration.baseOptions;
const localVarRequestOptions = {
method: "GET",
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
localVarHeaderParameter["Accept"] = "application/json";
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
},
/**
* Returns a list of marketplaces where the seller can list items and information about the seller\'s participation in those marketplaces. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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 {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMarketplaceParticipations: async (options = {}) => {
const localVarUrlObj = new URL(`/sellers/v1/marketplaceParticipations`, DUMMY_BASE_URL);
let baseOptions;
if (configuration) baseOptions = configuration.baseOptions;
const localVarRequestOptions = {
method: "GET",
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
localVarHeaderParameter["Accept"] = "application/json,payload";
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
}
};
};
/**
* SellersApi - functional programming interface
*/
const SellersApiFp = function(configuration) {
const localVarAxiosParamCreator = SellersApiAxiosParamCreator(configuration);
return {
/**
* Returns information about a seller account and its marketplaces. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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 {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getAccount(options) {
const localVarAxiosArgs = await localVarAxiosParamCreator.getAccount(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap["SellersApi.getAccount"]?.[localVarOperationServerIndex]?.url;
return (axios$1, basePath) => createRequestFunction(localVarAxiosArgs, axios.default, BASE_PATH, configuration)(axios$1, localVarOperationServerBasePath || basePath);
},
/**
* Returns a list of marketplaces where the seller can list items and information about the seller\'s participation in those marketplaces. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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 {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getMarketplaceParticipations(options) {
const localVarAxiosArgs = await localVarAxiosParamCreator.getMarketplaceParticipations(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap["SellersApi.getMarketplaceParticipations"]?.[localVarOperationServerIndex]?.url;
return (axios$2, basePath) => createRequestFunction(localVarAxiosArgs, axios.default, BASE_PATH, configuration)(axios$2, localVarOperationServerBasePath || basePath);
}
};
};
/**
* SellersApi - factory interface
*/
const SellersApiFactory = function(configuration, basePath, axios$3) {
const localVarFp = SellersApiFp(configuration);
return {
/**
* Returns information about a seller account and its marketplaces. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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 {*} [options] Override http request option.
* @throws {RequiredError}
*/
getAccount(options) {
return localVarFp.getAccount(options).then((request) => request(axios$3, basePath));
},
/**
* Returns a list of marketplaces where the seller can list items and information about the seller\'s participation in those marketplaces. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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 {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMarketplaceParticipations(options) {
return localVarFp.getMarketplaceParticipations(options).then((request) => request(axios$3, basePath));
}
};
};
/**
* SellersApi - object-oriented interface
*/
var SellersApi = class extends BaseAPI {
/**
* Returns information about a seller account and its marketplaces. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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 {*} [options] Override http request option.
* @throws {RequiredError}
*/
getAccount(options) {
return SellersApiFp(this.configuration).getAccount(options).then((request) => request(this.axios, this.basePath));
}
/**
* Returns a list of marketplaces where the seller can list items and information about the seller\'s participation in those marketplaces. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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 {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMarketplaceParticipations(options) {
return SellersApiFp(this.configuration).getMarketplaceParticipations(options).then((request) => request(this.axios, this.basePath));
}
};
//#endregion
//#region 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) {
return mime !== null && /^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$/i.test(mime);
}
};
//#endregion
//#region src/api-model/models/account.ts
const AccountBusinessTypeEnum = {
Charity: "CHARITY",
Craftsman: "CRAFTSMAN",
NaturalPersonCompany: "NATURAL_PERSON_COMPANY",
PublicListed: "PUBLIC_LISTED",
PrivateLimited: "PRIVATE_LIMITED",
SoleProprietorship: "SOLE_PROPRIETORSHIP",
StateOwned: "STATE_OWNED",
Individual: "INDIVIDUAL"
};
const AccountSellingPlanEnum = {
Professional: "PROFESSIONAL",
Individual: "INDIVIDUAL"
};
//#endregion
//#region src/client.ts
const clientRateLimits = [{
method: "get",
urlRegex: /^\/sellers\/v1\/marketplaceParticipations$/v,
rate: .016,
burst: 15
}, {
method: "get",
urlRegex: /^\/sellers\/v1\/account$/v,
rate: .016,
burst: 15
}];
var SellersApiClient = class extends SellersApi {
constructor(configuration) {
const { axios, endpoint } = (0, _sp_api_sdk_common.createAxiosInstance)(configuration, clientRateLimits);
super(new Configuration(), endpoint, axios);
}
};
//#endregion
exports.AccountBusinessTypeEnum = AccountBusinessTypeEnum;
exports.AccountSellingPlanEnum = AccountSellingPlanEnum;
exports.SellersApi = SellersApi;
exports.SellersApiAxiosParamCreator = SellersApiAxiosParamCreator;
exports.SellersApiClient = SellersApiClient;
exports.SellersApiFactory = SellersApiFactory;
exports.SellersApiFp = SellersApiFp;
exports.clientRateLimits = clientRateLimits;
//# sourceMappingURL=index.cjs.map