@scaleleap/selling-partner-api-sdk
Version:
📦 A fully typed TypeScript and Node.js SDK library for Amazon Selling Partner API
175 lines • 20 kB
JavaScript
;
/* tslint:disable */
/* eslint-disable */
/**
* Selling Partner API for Sales
* The Selling Partner API for Sales provides APIs related to sales performance.
*
* The version of the OpenAPI document: v1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SalesApi = exports.SalesApiFactory = exports.SalesApiFp = exports.SalesApiAxiosParamCreator = void 0;
const axios_1 = __importDefault(require("axios"));
// Some imports not used depending on template conditions
// @ts-ignore
const common_1 = require("./common");
// @ts-ignore
const base_1 = require("./base");
/**
* SalesApi - axios parameter creator
* @export
*/
const SalesApiAxiosParamCreator = function (configuration) {
return {
/**
* Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | .5 | 15 | 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](doc:usage-plans-and-rate-limits-in-the-sp-api).
* @param {Array<string>} marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. For example, ATVPDKIKX0DER indicates the US marketplace.
* @param {string} interval A time interval used for selecting order metrics. This takes the form of two dates separated by two hyphens (first date is inclusive; second date is exclusive). Dates are in ISO8601 format and must represent absolute time (either Z notation or offset notation). Example: 2018-09-01T00:00:00-07:00--2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the -07:00 zone.
* @param {'Hour' | 'Day' | 'Week' | 'Month' | 'Year' | 'Total'} granularity The granularity of the grouping of order metrics, based on a unit of time. Specifying granularity=Hour results in a successful request only if the interval specified is less than or equal to 30 days from now. For all other granularities, the interval specified must be less or equal to 2 years from now. Specifying granularity=Total results in order metrics that are aggregated over the entire interval that you specify. If the interval start and end date don’t align with the specified granularity, the head and tail end of the response interval will contain partial data. Example: Day to get a daily breakdown of the request interval, where the day boundary is defined by the granularityTimeZone.
* @param {string} [granularityTimeZone] An IANA-compatible time zone for determining the day boundary. Required when specifying a granularity value greater than Hour. The granularityTimeZone value must align with the offset of the specified interval value. For example, if the interval value uses Z notation, then granularityTimeZone must be UTC. If the interval value uses an offset, then granularityTimeZone must be an IANA-compatible time zone that matches the offset. Example: US/Pacific to compute day boundaries, accounting for daylight time savings, for US/Pacific zone.
* @param {'B2B' | 'B2C' | 'All'} [buyerType] Filters the results by the buyer type that you specify, B2B (business to business) or B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers.
* @param {string} [fulfillmentNetwork] Filters the results by the fulfillment network that you specify, MFN (merchant fulfillment network) or AFN (Amazon fulfillment network). Do not include this filter if you want the response to include order metrics for all fulfillment networks. Example: AFN, if you want the response to include order metrics for only Amazon fulfillment network.
* @param {'Monday' | 'Sunday'} [firstDayOfWeek] Specifies the day that the week starts on when granularity=Week, either Monday or Sunday. Default: Monday. Example: Sunday, if you want the week to start on a Sunday.
* @param {string} [asin] Filters the results by the ASIN that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all ASINs. Example: B0792R1RSN, if you want the response to include order metrics for only ASIN B0792R1RSN.
* @param {string} [sku] Filters the results by the SKU that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all SKUs. Example: TestSKU, if you want the response to include order metrics for only SKU TestSKU.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getOrderMetrics: async (marketplaceIds, interval, granularity, granularityTimeZone, buyerType, fulfillmentNetwork, firstDayOfWeek, asin, sku, options = {}) => {
// verify required parameter 'marketplaceIds' is not null or undefined
(0, common_1.assertParamExists)('getOrderMetrics', 'marketplaceIds', marketplaceIds);
// verify required parameter 'interval' is not null or undefined
(0, common_1.assertParamExists)('getOrderMetrics', 'interval', interval);
// verify required parameter 'granularity' is not null or undefined
(0, common_1.assertParamExists)('getOrderMetrics', 'granularity', granularity);
const localVarPath = `/sales/v1/orderMetrics`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.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(base_1.COLLECTION_FORMATS.csv);
}
if (interval !== undefined) {
localVarQueryParameter['interval'] = interval;
}
if (granularityTimeZone !== undefined) {
localVarQueryParameter['granularityTimeZone'] = granularityTimeZone;
}
if (granularity !== undefined) {
localVarQueryParameter['granularity'] = granularity;
}
if (buyerType !== undefined) {
localVarQueryParameter['buyerType'] = buyerType;
}
if (fulfillmentNetwork !== undefined) {
localVarQueryParameter['fulfillmentNetwork'] = fulfillmentNetwork;
}
if (firstDayOfWeek !== undefined) {
localVarQueryParameter['firstDayOfWeek'] = firstDayOfWeek;
}
if (asin !== undefined) {
localVarQueryParameter['asin'] = asin;
}
if (sku !== undefined) {
localVarQueryParameter['sku'] = sku;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
},
};
};
exports.SalesApiAxiosParamCreator = SalesApiAxiosParamCreator;
/**
* SalesApi - functional programming interface
* @export
*/
const SalesApiFp = function (configuration) {
const localVarAxiosParamCreator = (0, exports.SalesApiAxiosParamCreator)(configuration);
return {
/**
* Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | .5 | 15 | 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](doc:usage-plans-and-rate-limits-in-the-sp-api).
* @param {Array<string>} marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. For example, ATVPDKIKX0DER indicates the US marketplace.
* @param {string} interval A time interval used for selecting order metrics. This takes the form of two dates separated by two hyphens (first date is inclusive; second date is exclusive). Dates are in ISO8601 format and must represent absolute time (either Z notation or offset notation). Example: 2018-09-01T00:00:00-07:00--2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the -07:00 zone.
* @param {'Hour' | 'Day' | 'Week' | 'Month' | 'Year' | 'Total'} granularity The granularity of the grouping of order metrics, based on a unit of time. Specifying granularity=Hour results in a successful request only if the interval specified is less than or equal to 30 days from now. For all other granularities, the interval specified must be less or equal to 2 years from now. Specifying granularity=Total results in order metrics that are aggregated over the entire interval that you specify. If the interval start and end date don’t align with the specified granularity, the head and tail end of the response interval will contain partial data. Example: Day to get a daily breakdown of the request interval, where the day boundary is defined by the granularityTimeZone.
* @param {string} [granularityTimeZone] An IANA-compatible time zone for determining the day boundary. Required when specifying a granularity value greater than Hour. The granularityTimeZone value must align with the offset of the specified interval value. For example, if the interval value uses Z notation, then granularityTimeZone must be UTC. If the interval value uses an offset, then granularityTimeZone must be an IANA-compatible time zone that matches the offset. Example: US/Pacific to compute day boundaries, accounting for daylight time savings, for US/Pacific zone.
* @param {'B2B' | 'B2C' | 'All'} [buyerType] Filters the results by the buyer type that you specify, B2B (business to business) or B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers.
* @param {string} [fulfillmentNetwork] Filters the results by the fulfillment network that you specify, MFN (merchant fulfillment network) or AFN (Amazon fulfillment network). Do not include this filter if you want the response to include order metrics for all fulfillment networks. Example: AFN, if you want the response to include order metrics for only Amazon fulfillment network.
* @param {'Monday' | 'Sunday'} [firstDayOfWeek] Specifies the day that the week starts on when granularity=Week, either Monday or Sunday. Default: Monday. Example: Sunday, if you want the week to start on a Sunday.
* @param {string} [asin] Filters the results by the ASIN that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all ASINs. Example: B0792R1RSN, if you want the response to include order metrics for only ASIN B0792R1RSN.
* @param {string} [sku] Filters the results by the SKU that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all SKUs. Example: TestSKU, if you want the response to include order metrics for only SKU TestSKU.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getOrderMetrics(marketplaceIds, interval, granularity, granularityTimeZone, buyerType, fulfillmentNetwork, firstDayOfWeek, asin, sku, options) {
const localVarAxiosArgs = await localVarAxiosParamCreator.getOrderMetrics(marketplaceIds, interval, granularity, granularityTimeZone, buyerType, fulfillmentNetwork, firstDayOfWeek, asin, sku, options);
return (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration);
},
};
};
exports.SalesApiFp = SalesApiFp;
/**
* SalesApi - factory interface
* @export
*/
const SalesApiFactory = function (configuration, basePath, axios) {
const localVarFp = (0, exports.SalesApiFp)(configuration);
return {
/**
* Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | .5 | 15 | 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](doc:usage-plans-and-rate-limits-in-the-sp-api).
* @param {Array<string>} marketplaceIds A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. For example, ATVPDKIKX0DER indicates the US marketplace.
* @param {string} interval A time interval used for selecting order metrics. This takes the form of two dates separated by two hyphens (first date is inclusive; second date is exclusive). Dates are in ISO8601 format and must represent absolute time (either Z notation or offset notation). Example: 2018-09-01T00:00:00-07:00--2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the -07:00 zone.
* @param {'Hour' | 'Day' | 'Week' | 'Month' | 'Year' | 'Total'} granularity The granularity of the grouping of order metrics, based on a unit of time. Specifying granularity=Hour results in a successful request only if the interval specified is less than or equal to 30 days from now. For all other granularities, the interval specified must be less or equal to 2 years from now. Specifying granularity=Total results in order metrics that are aggregated over the entire interval that you specify. If the interval start and end date don’t align with the specified granularity, the head and tail end of the response interval will contain partial data. Example: Day to get a daily breakdown of the request interval, where the day boundary is defined by the granularityTimeZone.
* @param {string} [granularityTimeZone] An IANA-compatible time zone for determining the day boundary. Required when specifying a granularity value greater than Hour. The granularityTimeZone value must align with the offset of the specified interval value. For example, if the interval value uses Z notation, then granularityTimeZone must be UTC. If the interval value uses an offset, then granularityTimeZone must be an IANA-compatible time zone that matches the offset. Example: US/Pacific to compute day boundaries, accounting for daylight time savings, for US/Pacific zone.
* @param {'B2B' | 'B2C' | 'All'} [buyerType] Filters the results by the buyer type that you specify, B2B (business to business) or B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers.
* @param {string} [fulfillmentNetwork] Filters the results by the fulfillment network that you specify, MFN (merchant fulfillment network) or AFN (Amazon fulfillment network). Do not include this filter if you want the response to include order metrics for all fulfillment networks. Example: AFN, if you want the response to include order metrics for only Amazon fulfillment network.
* @param {'Monday' | 'Sunday'} [firstDayOfWeek] Specifies the day that the week starts on when granularity=Week, either Monday or Sunday. Default: Monday. Example: Sunday, if you want the week to start on a Sunday.
* @param {string} [asin] Filters the results by the ASIN that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all ASINs. Example: B0792R1RSN, if you want the response to include order metrics for only ASIN B0792R1RSN.
* @param {string} [sku] Filters the results by the SKU that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all SKUs. Example: TestSKU, if you want the response to include order metrics for only SKU TestSKU.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getOrderMetrics(marketplaceIds, interval, granularity, granularityTimeZone, buyerType, fulfillmentNetwork, firstDayOfWeek, asin, sku, options) {
return localVarFp.getOrderMetrics(marketplaceIds, interval, granularity, granularityTimeZone, buyerType, fulfillmentNetwork, firstDayOfWeek, asin, sku, options).then((request) => request(axios, basePath));
},
};
};
exports.SalesApiFactory = SalesApiFactory;
/**
* SalesApi - object-oriented interface
* @export
* @class SalesApi
* @extends {BaseAPI}
*/
class SalesApi extends base_1.BaseAPI {
/**
* Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | .5 | 15 | 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](doc:usage-plans-and-rate-limits-in-the-sp-api).
* @param {SalesApiGetOrderMetricsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SalesApi
*/
getOrderMetrics(requestParameters, options) {
return (0, exports.SalesApiFp)(this.configuration).getOrderMetrics(requestParameters.marketplaceIds, requestParameters.interval, requestParameters.granularity, requestParameters.granularityTimeZone, requestParameters.buyerType, requestParameters.fulfillmentNetwork, requestParameters.firstDayOfWeek, requestParameters.asin, requestParameters.sku, options).then((request) => request(this.axios, this.basePath));
}
}
exports.SalesApi = SalesApi;
//# sourceMappingURL=api.js.map