@aurigma/ng-storefront-api-client
Version:
Angular API Client for Storefront API service of Customer's Canvas web-to-print system.
1,011 lines (1,010 loc) • 314 kB
JavaScript
import { InjectionToken, ɵɵdefineInjectable, ɵɵinject, Injectable, Inject, Optional, NgModule } from '@angular/core';
import { __awaiter } from 'tslib';
import { mergeMap, catchError } from 'rxjs/operators';
import { from, throwError, Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponseBase, HttpResponse, HttpClient } from '@angular/common/http';
const API_BASE_URL = new InjectionToken('API_BASE_URL');
class ApiClientConfiguration {
constructor() {
this.apiKey = '';
this.authorizationToken = null;
}
getAuthorizationToken() {
return __awaiter(this, void 0, void 0, function* () { return this.authorizationToken; });
}
;
setAuthorizationToken(token) { this.authorizationToken = token; }
;
}
class ApiClientBase {
constructor(configuration) {
this.configuration = configuration;
}
transformOptions(options) {
return __awaiter(this, void 0, void 0, function* () {
const token = yield this.configuration.getAuthorizationToken();
if (token != null) {
options.headers = options.headers.append("authorization", "Bearer " + token);
}
else {
options.headers = options.headers.append("X-API-Key", this.configuration.apiKey);
}
//options = { ...options, transformResponse: (res) => res, responseType: 'json' };
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);
}
}
class BuildInfoApiClient extends ApiClientBase {
constructor(configuration, http, baseUrl) {
super(configuration);
this.jsonParseReviver = undefined;
this.http = http;
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("");
}
/**
* Returns an assembly build info.
* @return Success
*/
headInfo() {
let url_ = this.baseUrl + "/api/storefront/v1/info";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("head", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processHeadInfo(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processHeadInfo(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processHeadInfo(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return of(null);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(null);
}
/**
* Returns an assembly build info.
* @return Success
*/
getInfo() {
let url_ = this.baseUrl + "/api/storefront/v1/info";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGetInfo(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGetInfo(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGetInfo(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(null);
}
}
BuildInfoApiClient.ɵprov = ɵɵdefineInjectable({ factory: function BuildInfoApiClient_Factory() { return new BuildInfoApiClient(ɵɵinject(ApiClientConfiguration), ɵɵinject(HttpClient), ɵɵinject(API_BASE_URL, 8)); }, token: BuildInfoApiClient, providedIn: "root" });
BuildInfoApiClient.decorators = [
{ type: Injectable, args: [{
providedIn: 'root'
},] }
];
BuildInfoApiClient.ctorParameters = () => [
{ type: ApiClientConfiguration, decorators: [{ type: Inject, args: [ApiClientConfiguration,] }] },
{ type: HttpClient, decorators: [{ type: Inject, args: [HttpClient,] }] },
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [API_BASE_URL,] }] }
];
class ProcessingPipelinesApiClient extends ApiClientBase {
constructor(configuration, http, baseUrl) {
super(configuration);
this.jsonParseReviver = undefined;
this.http = http;
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) {
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_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGetAll(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGetAll(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGetAll(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status === 401) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Unauthorized", status, _responseText, _headers);
}));
}
else if (status === 403) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Forbidden", status, _responseText, _headers);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(null);
}
/**
* Returns a processing pipeline.
* @param id Processing pipeline identifier.
* @param tenantId (optional) Tenant identifier.
* @return Success
*/
get(id, tenantId) {
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_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGet(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGet(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGet(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status === 404) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result404 = null;
result404 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Not Found", status, _responseText, _headers, result404);
}));
}
else if (status === 401) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Unauthorized", status, _responseText, _headers);
}));
}
else if (status === 403) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Forbidden", status, _responseText, _headers);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(null);
}
}
ProcessingPipelinesApiClient.ɵprov = ɵɵdefineInjectable({ factory: function ProcessingPipelinesApiClient_Factory() { return new ProcessingPipelinesApiClient(ɵɵinject(ApiClientConfiguration), ɵɵinject(HttpClient), ɵɵinject(API_BASE_URL, 8)); }, token: ProcessingPipelinesApiClient, providedIn: "root" });
ProcessingPipelinesApiClient.decorators = [
{ type: Injectable, args: [{
providedIn: 'root'
},] }
];
ProcessingPipelinesApiClient.ctorParameters = () => [
{ type: ApiClientConfiguration, decorators: [{ type: Inject, args: [ApiClientConfiguration,] }] },
{ type: HttpClient, decorators: [{ type: Inject, args: [HttpClient,] }] },
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [API_BASE_URL,] }] }
];
class ProductLinksApiClient extends ApiClientBase {
constructor(configuration, http, baseUrl) {
super(configuration);
this.jsonParseReviver = undefined;
this.http = http;
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) {
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_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGetAllProductLinks(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGetAllProductLinks(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGetAllProductLinks(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status === 401) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Unauthorized", status, _responseText, _headers);
}));
}
else if (status === 403) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Forbidden", status, _responseText, _headers);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(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) {
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_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGetProductLink(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGetProductLink(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGetProductLink(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status === 404) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result404 = null;
result404 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Not Found", status, _responseText, _headers, result404);
}));
}
else if (status === 409) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result409 = null;
result409 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Conflict", status, _responseText, _headers, result409);
}));
}
else if (status === 401) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Unauthorized", status, _responseText, _headers);
}));
}
else if (status === 403) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Forbidden", status, _responseText, _headers);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(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) {
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_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGetProductSummary(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGetProductSummary(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGetProductSummary(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status === 404) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result404 = null;
result404 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Not Found", status, _responseText, _headers, result404);
}));
}
else if (status === 409) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result409 = null;
result409 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Conflict", status, _responseText, _headers, result409);
}));
}
else if (status === 401) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Unauthorized", status, _responseText, _headers);
}));
}
else if (status === 403) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Forbidden", status, _responseText, _headers);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(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) {
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_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGetPersonalizationWorkflow(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGetPersonalizationWorkflow(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGetPersonalizationWorkflow(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status === 404) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result404 = null;
result404 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Not Found", status, _responseText, _headers, result404);
}));
}
else if (status === 409) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result409 = null;
result409 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Conflict", status, _responseText, _headers, result409);
}));
}
else if (status === 401) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Unauthorized", status, _responseText, _headers);
}));
}
else if (status === 403) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Forbidden", status, _responseText, _headers);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(null);
}
}
ProductLinksApiClient.ɵprov = ɵɵdefineInjectable({ factory: function ProductLinksApiClient_Factory() { return new ProductLinksApiClient(ɵɵinject(ApiClientConfiguration), ɵɵinject(HttpClient), ɵɵinject(API_BASE_URL, 8)); }, token: ProductLinksApiClient, providedIn: "root" });
ProductLinksApiClient.decorators = [
{ type: Injectable, args: [{
providedIn: 'root'
},] }
];
ProductLinksApiClient.ctorParameters = () => [
{ type: ApiClientConfiguration, decorators: [{ type: Inject, args: [ApiClientConfiguration,] }] },
{ type: HttpClient, decorators: [{ type: Inject, args: [HttpClient,] }] },
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [API_BASE_URL,] }] }
];
class ProductReferencesApiClient extends ApiClientBase {
constructor(configuration, http, baseUrl) {
super(configuration);
this.jsonParseReviver = undefined;
this.http = http;
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) {
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_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGetAll(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGetAll(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGetAll(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status === 409) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result409 = null;
result409 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Conflict", status, _responseText, _headers, result409);
}));
}
else if (status === 401) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Unauthorized", status, _responseText, _headers);
}));
}
else if (status === 403) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Forbidden", status, _responseText, _headers);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(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) {
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_ = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Accept": "application/json"
})
};
return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => {
return this.http.request("get", url_, transformedOptions_);
})).pipe(mergeMap((response_) => {
return this.transformResult(url_, response_, (r) => this.processGetAllProductSpecifications(r));
})).pipe(catchError((response_) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.transformResult(url_, response_, (r) => this.processGetAllProductSpecifications(r));
}
catch (e) {
return throwError(e);
}
}
else
return throwError(response_);
}));
}
processGetAllProductSpecifications(response) {
const status = response.status;
const responseBlob = response instanceof HttpResponse ? response.body :
response.error instanceof Blob ? response.error : undefined;
let _headers = {};
if (response.headers) {
for (let key of response.headers.keys()) {
_headers[key] = response.headers.get(key);
}
}
if (status === 200) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return of(result200);
}));
}
else if (status === 409) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
let result409 = null;
result409 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return throwException("Conflict", status, _responseText, _headers, result409);
}));
}
else if (status === 401) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Unauthorized", status, _responseText, _headers);
}));
}
else if (status === 403) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("Forbidden", status, _responseText, _headers);
}));
}
else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(mergeMap(_responseText => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return of(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) {
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_ += "