@aurigma/axios-storefront-products-api-client
Version:
Axios API Client for Storefront API service of Customer's Canvas web-to-print system.
1,085 lines • 130 kB
JavaScript
"use strict";
/* tslint:disable */
/* eslint-disable */
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v13.15.5.0 (NJsonSchema v10.6.6.0 (Newtonsoft.Json v11.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------
// ReSharper disable InconsistentNaming
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiException = exports.SurfaceUsageType = exports.ProductVariantMockupType = exports.ProductVariantResourceType = exports.WorkflowType = exports.ProductFilterType = exports.AppearanceDataType = exports.OptionType = exports.ConflictType = exports.ProductsApiClient = exports.ProductReferencesApiClient = exports.ApiClientBase = exports.ApiClientConfiguration = void 0;
const axios_1 = require("axios");
class ApiClientConfiguration {
apiUrl;
apiKey = '';
authorizationToken = null;
async getAuthorizationToken() { return this.authorizationToken; }
;
setAuthorizationToken(token) { this.authorizationToken = token; }
;
}
exports.ApiClientConfiguration = ApiClientConfiguration;
class ApiClientBase {
configuration;
constructor(configuration) {
this.configuration = configuration;
}
async transformOptions(options) {
const token = await this.configuration.getAuthorizationToken();
if (token != null) {
options.headers = { ...options.headers, authorization: ' Bearer ' + token };
}
else {
options.headers = { ...options.headers, 'X-API-Key': this.configuration.apiKey };
}
options = { ...options, transformResponse: (res) => res };
if (!options.responseType) {
options.responseType = 'json';
}
if (options.responseType == 'blob') {
options.responseType = 'arraybuffer';
}
return options;
}
getBaseUrl(defultUrl) {
if (this.configuration.apiUrl.endsWith('/')) {
return this.configuration.apiUrl.slice(0, -1);
}
return this.configuration.apiUrl;
}
transformResult(url, res, cb) {
return cb(res);
}
}
exports.ApiClientBase = ApiClientBase;
class ProductReferencesApiClient extends ApiClientBase {
instance;
baseUrl;
jsonParseReviver = undefined;
constructor(configuration, baseUrl, instance) {
super(configuration);
this.instance = instance ? instance : axios_1.create();
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("");
}
/**
* Returns all storefront product references relevant to the specified query parameters.
* @param storefrontId Storefront identifier.
* @param productReference (optional) Product reference filter. Product reference is an external reference to Customer's Canvas product specification, e.g online store product identifier.
* @param productId (optional) Cusomer's Canvas product filter.
* @param productLinkId (optional) Cusomer's Canvas product link filter.
* @param skip (optional) Defines page start offset from beginning of sorted result list.
* @param take (optional) Defines page length (how many consequent items of sorted result list should be taken).
* @param sorting (optional) Defines sorting order of result list e.g.: "Title ASC, LastModified DESC".
* @param search (optional) Search string for partial match.
* @param sku (optional) SKU filter.
* @param tags (optional) List of tags that product should have.
* @param customFields (optional) Serialized custom fields dictionary filter. For example: {"public":"true","name":"my item"}.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getAll(storefrontId, productReference, productId, productLinkId, skip, take, sorting, search, sku, tags, customFields, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext?";
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (productReference !== undefined && productReference !== null)
url_ += "productReference=" + encodeURIComponent("" + productReference) + "&";
if (productId !== undefined && productId !== null)
url_ += "productId=" + encodeURIComponent("" + productId) + "&";
if (productLinkId !== undefined && productLinkId !== null)
url_ += "productLinkId=" + encodeURIComponent("" + productLinkId) + "&";
if (skip !== undefined && skip !== null)
url_ += "skip=" + encodeURIComponent("" + skip) + "&";
if (take !== undefined && take !== null)
url_ += "take=" + encodeURIComponent("" + take) + "&";
if (sorting !== undefined && sorting !== null)
url_ += "sorting=" + encodeURIComponent("" + sorting) + "&";
if (search !== undefined && search !== null)
url_ += "search=" + encodeURIComponent("" + search) + "&";
if (sku !== undefined && sku !== null)
url_ += "sku=" + encodeURIComponent("" + sku) + "&";
if (tags !== undefined && tags !== null)
tags && tags.forEach(item => { url_ += "tags=" + encodeURIComponent("" + item) + "&"; });
if (customFields !== undefined && customFields !== null)
url_ += "customFields=" + encodeURIComponent("" + customFields) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetAll(_response));
});
}
processGetAll(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a storefront product reference.
* @param reference Product reference - external reference to Customer's Canvas products, e.g online store product identifier.
* @param storefrontId Storefront identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
get(reference, storefrontId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/{reference}?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGet(_response));
});
}
processGet(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a list of product links associated with storefront product references relevant to the specified query parameters.
* @param storefrontId Storefront identifier.
* @param productReference (optional) Product reference filter. Product reference is an external reference to Customer's Canvas product specification, e.g online store product identifier.
* @param productId (optional) Cusomer's Canvas product filter.
* @param productLinkId (optional) Cusomer's Canvas product link filter.
* @param skip (optional) Defines page start offset from beginning of sorted result list.
* @param take (optional) Defines page length (how many consequent items of sorted result list should be taken).
* @param sorting (optional) Defines sorting order of result list e.g.: "Title ASC, LastModified DESC".
* @param search (optional) Search string for partial match.
* @param sku (optional) SKU filter.
* @param tags (optional) List of tags that product should have.
* @param customFields (optional) Serialized custom fields dictionary filter. For example: {"public":"true","name":"my item"}.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getAllProductLinks(storefrontId, productReference, productId, productLinkId, skip, take, sorting, search, sku, tags, customFields, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/product-links?";
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (productReference !== undefined && productReference !== null)
url_ += "productReference=" + encodeURIComponent("" + productReference) + "&";
if (productId !== undefined && productId !== null)
url_ += "productId=" + encodeURIComponent("" + productId) + "&";
if (productLinkId !== undefined && productLinkId !== null)
url_ += "productLinkId=" + encodeURIComponent("" + productLinkId) + "&";
if (skip !== undefined && skip !== null)
url_ += "skip=" + encodeURIComponent("" + skip) + "&";
if (take !== undefined && take !== null)
url_ += "take=" + encodeURIComponent("" + take) + "&";
if (sorting !== undefined && sorting !== null)
url_ += "sorting=" + encodeURIComponent("" + sorting) + "&";
if (search !== undefined && search !== null)
url_ += "search=" + encodeURIComponent("" + search) + "&";
if (sku !== undefined && sku !== null)
url_ += "sku=" + encodeURIComponent("" + sku) + "&";
if (tags !== undefined && tags !== null)
tags && tags.forEach(item => { url_ += "tags=" + encodeURIComponent("" + item) + "&"; });
if (customFields !== undefined && customFields !== null)
url_ += "customFields=" + encodeURIComponent("" + customFields) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetAllProductLinks(_response));
});
}
processGetAllProductLinks(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a product by storefront product reference.
* @param reference Product reference - external reference to Customer's Canvas product, e.g online store product identifier.
* @param storefrontId Storefront identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getProduct(reference, storefrontId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/{reference}/product?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetProduct(_response));
});
}
processGetProduct(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a product summary by storefront product reference.
* @param reference Product reference - external reference to Customer's Canvas product, e.g online store product identifier.
* @param storefrontId Storefront identifier.
* @param productVariantId (optional) Product variant identifier.
* @param sku (optional) Product variant SKU.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getProductSummary(reference, storefrontId, productVariantId, sku, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/{reference}/product-summary?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (productVariantId !== undefined && productVariantId !== null)
url_ += "productVariantId=" + encodeURIComponent("" + productVariantId) + "&";
if (sku !== undefined && sku !== null)
url_ += "sku=" + encodeURIComponent("" + sku) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetProductSummary(_response));
});
}
processGetProductSummary(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a product link by storefront product reference.
* @param reference Product reference - external reference to Customer's Canvas product, e.g online store product identifier.
* @param storefrontId Storefront identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getProductLink(reference, storefrontId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/{reference}/product-link?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetProductLink(_response));
});
}
processGetProductLink(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a product filter by storefront product reference.
* @param reference Product reference - external reference to Customer's Canvas product, e.g online store product identifier.
* @param storefrontId Storefront identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getProductFilter(reference, storefrontId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/{reference}/product-filter?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetProductFilter(_response));
});
}
processGetProductFilter(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a product cost details from ecommerce system.
* @param reference Product reference - external reference to Customer's Canvas product product specification, e.g online store product identifier.
* @param sku Product SKU.
* @param storefrontId Storefront identifier.
* @param storefrontUserId (optional) Storefront user identifier.
* @param currencyCode (optional) Product cost currency code.
* @param quantity (optional) Product quantity.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getProductCostDetails(reference, sku, storefrontId, storefrontUserId, currencyCode, quantity, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/{reference}/product-cost-details?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (sku === undefined || sku === null)
throw new Error("The parameter 'sku' must be defined and cannot be null.");
else
url_ += "sku=" + encodeURIComponent("" + sku) + "&";
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (storefrontUserId !== undefined && storefrontUserId !== null)
url_ += "storefrontUserId=" + encodeURIComponent("" + storefrontUserId) + "&";
if (currencyCode !== undefined && currencyCode !== null)
url_ += "currencyCode=" + encodeURIComponent("" + currencyCode) + "&";
if (quantity === null)
throw new Error("The parameter 'quantity' cannot be null.");
else if (quantity !== undefined)
url_ += "quantity=" + encodeURIComponent("" + quantity) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetProductCostDetails(_response));
});
}
processGetProductCostDetails(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a product personalization workflow description by storefront product reference.
* @param reference Product reference - external reference to Customer's Canvas product, e.g online store product identifier.
* @param storefrontId Storefront identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getPersonalizationWorkflow(reference, storefrontId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/{reference}/personalization-workflow?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetPersonalizationWorkflow(_response));
});
}
processGetPersonalizationWorkflow(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = JSON.parse(resultData200);
return Promise.resolve(result200);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a product personalization workflow configuration by storefront product reference.
* @param reference Product reference - external reference to Customer's Canvas product specification, e.g online store product identifier.
* @param storefrontId Storefront identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
getProductPersonalizationWorkflow(reference, storefrontId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/ext/{reference}/product-personalization-workflow?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "text/plain"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processGetProductPersonalizationWorkflow(_response));
});
}
processGetProductPersonalizationWorkflow(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = resultData200;
return Promise.resolve(result200);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
/**
* Returns a product personalization workflow configuration by storefront product reference.
* @param reference Product reference - external reference to Customer's Canvas product specification, e.g online store product identifier.
* @param storefrontId Storefront identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
* @deprecated
*/
obsoleteGetProductPersonalizationWorkflow(reference, storefrontId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/{reference}/product-personalization-workflow?";
if (reference === undefined || reference === null)
throw new Error("The parameter 'reference' must be defined.");
url_ = url_.replace("{reference}", encodeURIComponent("" + reference));
if (storefrontId === undefined || storefrontId === null)
throw new Error("The parameter 'storefrontId' must be defined and cannot be null.");
else
url_ += "storefrontId=" + encodeURIComponent("" + storefrontId) + "&";
if (tenantId !== undefined && tenantId !== null)
url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
url: url_,
headers: {
"Accept": "text/plain"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
}
else {
throw _error;
}
}).then((_response) => {
return this.transformResult(url_, _response, (_response) => this.processObsoleteGetProductPersonalizationWorkflow(_response));
});
}
processObsoleteGetProductPersonalizationWorkflow(response) {
const status = response.status;
let _headers = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200 = null;
let resultData200 = _responseText;
result200 = resultData200;
return Promise.resolve(result200);
}
else if (status === 404) {
const _responseText = response.data;
let result404 = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
}
else if (status === 409) {
const _responseText = response.data;
let result409 = null;
let resultData409 = _responseText;
result409 = JSON.parse(resultData409);
return throwException("Conflict", status, _responseText, _headers, result409);
}
else if (status === 401) {
const _responseText = response.data;
return throwException("Unauthorized", status, _responseText, _headers);
}
else if (status === 403) {
const _responseText = response.data;
return throwException("Forbidden", status, _responseText, _headers);
}
else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
}
exports.ProductReferencesApiClient = ProductReferencesApiClient;
class ProductsApiClient extends ApiClientBase {
instance;
baseUrl;
jsonParseReviver = undefined;
constructor(configuration, baseUrl, instance) {
super(configuration);
this.instance = instance ? instance : axios_1.create();
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("");
}
/**
* Returns all products, relevant to the specified query parameters.
* @param skip (optional) Defines page start offset from beginning of sorted result list.
* @param take (optional) Defines page length (how many consequent items of sorted