@aurigma/axios-storefront-api-client
Version:
Axios API Client for Storefront API service of Customer's Canvas web-to-print system.
1,069 lines • 268 kB
JavaScript
/* 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
import axios from 'axios';
export class ApiClientConfiguration {
apiUrl;
apiKey = '';
authorizationToken = null;
async getAuthorizationToken() { return this.authorizationToken; }
;
setAuthorizationToken(token) { this.authorizationToken = token; }
;
}
export 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);
}
}
export class BuildInfoApiClient extends ApiClientBase {
instance;
baseUrl;
jsonParseReviver = undefined;
constructor(configuration, baseUrl, instance) {
super(configuration);
this.instance = instance ? instance : axios.create();
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("");
}
/**
* Returns an assembly build info.
* @return Success
*/
headInfo(cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/info";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "HEAD",
url: url_,
headers: {},
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.processHeadInfo(_response));
});
}
processHeadInfo(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;
return Promise.resolve(null);
}
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 an assembly build info.
* @return Success
*/
getInfo(cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/info";
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.processGetInfo(_response));
});
}
processGetInfo(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 !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve(null);
}
}
export class ProcessingPipelinesApiClient extends ApiClientBase {
instance;
baseUrl;
jsonParseReviver = undefined;
constructor(configuration, baseUrl, instance) {
super(configuration);
this.instance = instance ? instance : axios.create();
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("");
}
/**
* Returns all processing pipelines 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 result list should be taken).
* @param search (optional) Search string for partial by processing pipeline name.
* @param tenantId (optional) Tenant identifier.
* @return Success
*/
getAll(skip, take, search, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/processing-pipelines?";
if (skip !== undefined && skip !== null)
url_ += "skip=" + encodeURIComponent("" + skip) + "&";
if (take !== undefined && take !== null)
url_ += "take=" + encodeURIComponent("" + take) + "&";
if (search !== undefined && search !== null)
url_ += "search=" + encodeURIComponent("" + search) + "&";
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 === 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 processing pipeline.
* @param id Processing pipeline identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
*/
get(id, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/processing-pipelines/{id}?";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined.");
url_ = url_.replace("{id}", encodeURIComponent("" + id));
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 === 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);
}
}
export class ProductLinksApiClient extends ApiClientBase {
instance;
baseUrl;
jsonParseReviver = undefined;
constructor(configuration, baseUrl, instance) {
super(configuration);
this.instance = instance ? instance : axios.create();
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("");
}
/**
* Returns all product links, 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 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 tenantId (optional) Tenant identifier.
* @return Success
*/
getAllProductLinks(skip, take, sorting, search, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-links?";
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 (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 === 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 its identifier.
* @param id Product identifier.
* @param productLinkVersionId (optional) Product link version identifier. Optional
* @param productVersionId (optional) Product version identifier which represents linked product version. Optional
* @param tenantId (optional) Tenant identifier.
* @return Success
*/
getProductLink(id, productLinkVersionId, productVersionId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-links/{id}?";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined.");
url_ = url_.replace("{id}", encodeURIComponent("" + id));
if (productLinkVersionId !== undefined && productLinkVersionId !== null)
url_ += "productLinkVersionId=" + encodeURIComponent("" + productLinkVersionId) + "&";
if (productVersionId !== undefined && productVersionId !== null)
url_ += "productVersionId=" + encodeURIComponent("" + productVersionId) + "&";
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 link summary by product link identifier.
* @param id Product link identifier.
* @param productLinkVersionId (optional) Product link version identifier.
* @param productVersionId (optional) Product link identifier.
* @param productVariantId (optional) Product variant identifier.
* @param sku (optional) Product variant SKU.
* @param tenantId (optional) Tenant identifier.
* @return Success
*/
getProductSummary(id, productLinkVersionId, productVersionId, productVariantId, sku, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-links/{id}/summary?";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined.");
url_ = url_.replace("{id}", encodeURIComponent("" + id));
if (productLinkVersionId !== undefined && productLinkVersionId !== null)
url_ += "productLinkVersionId=" + encodeURIComponent("" + productLinkVersionId) + "&";
if (productVersionId !== undefined && productVersionId !== null)
url_ += "productVersionId=" + encodeURIComponent("" + productVersionId) + "&";
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 personalization workflow description by product link identifier.
* @param id Product link identifier.
* @param productLinkVersionId (optional) Product link version identifier.
* @param productVersionId (optional) Product version identifier.
* @param productFilterId (optional) Product filter identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
*/
getPersonalizationWorkflow(id, productLinkVersionId, productVersionId, productFilterId, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-links/{id}/personalization-workflow?";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined.");
url_ = url_.replace("{id}", encodeURIComponent("" + id));
if (productLinkVersionId !== undefined && productLinkVersionId !== null)
url_ += "productLinkVersionId=" + encodeURIComponent("" + productLinkVersionId) + "&";
if (productVersionId !== undefined && productVersionId !== null)
url_ += "productVersionId=" + encodeURIComponent("" + productVersionId) + "&";
if (productFilterId !== undefined && productFilterId !== null)
url_ += "productFilterId=" + encodeURIComponent("" + productFilterId) + "&";
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);
}
}
export class ProductReferencesApiClient extends ApiClientBase {
instance;
baseUrl;
jsonParseReviver = undefined;
constructor(configuration, baseUrl, instance) {
super(configuration);
this.instance = instance ? instance : axios.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, e.g online store product identifier.
* @param productSpecificationId (optional) Customer's Canvas product specification filter.
* @param productId (optional) Customer's Canvas product filter.
* @param productLinkId (optional) Customer'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
*/
getAll(storefrontId, productReference, productSpecificationId, productId, productLinkId, skip, take, sorting, search, sku, tags, customFields, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references?";
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 (productSpecificationId !== undefined && productSpecificationId !== null)
url_ += "productSpecificationId=" + encodeURIComponent("" + productSpecificationId) + "&";
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 list of product specifications 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, e.g online store product identifier.
* @param productSpecificationId (optional) Customer's Canvas product specification filter.
* @param productId (optional) Customer's Canvas product filter.
* @param productLinkId (optional) Customer'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
*/
getAllProductSpecifications(storefrontId, productReference, productSpecificationId, productId, productLinkId, skip, take, sorting, search, sku, tags, customFields, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/product-specifications?";
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 (productSpecificationId !== undefined && productSpecificationId !== null)
url_ += "productSpecificationId=" + encodeURIComponent("" + productSpecificationId) + "&";
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.processGetAllProductSpecifications(_response));
});
}
processGetAllProductSpecifications(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 list of products 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, e.g online store product identifier.
* @param productSpecificationId (optional) Customer's Canvas product specification filter.
* @param productId (optional) Customer's Canvas product filter.
* @param productLinkId (optional) Customer'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
*/
getAllProducts(storefrontId, productReference, productSpecificationId, productId, productLinkId, skip, take, sorting, search, sku, tags, customFields, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/products?";
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 (productSpecificationId !== undefined && productSpecificationId !== null)
url_ += "productSpecificationId=" + encodeURIComponent("" + productSpecificationId) + "&";
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.processGetAllProducts(_response));
});
}
processGetAllProducts(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 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, e.g online store product identifier.
* @param productSpecificationId (optional) Customer's Canvas product specification filter.
* @param productId (optional) Customer's Canvas product filter.
* @param productLinkId (optional) Customer'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
*/
getAllProductLinks(storefrontId, productReference, productSpecificationId, productId, productLinkId, skip, take, sorting, search, sku, tags, customFields, tenantId, cancelToken) {
let url_ = this.baseUrl + "/api/storefront/v1/product-references/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 (productSpecificationId !== undefined && productSpecificationId !== null)
url_ += "productSpecificationId=" + encodeURIComponent("" + productSpecificationId) + "&";
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 (respo