UNPKG

@aurigma/ng-backoffice-api-client

Version:

Angular API Client for BackOffice API service of Customer's Canvas web-to-print system.

1,069 lines (1,067 loc) 196 kB
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 = '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) { 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 assembly build info. * @return Success */ headInfo() { let url_ = this.baseUrl + "/api/backoffice/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 assembly build info. * @return Success */ getInfo() { let url_ = this.baseUrl + "/api/backoffice/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 ProductReferencesManagementApiClient 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/backoffice/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); } /** * Creates a new storefront product reference. * @param storefrontId Storefront identifier. * @param tenantId (optional) Tenant identifier. * @param body (optional) Create operation parameters. * @return Success */ create(storefrontId, tenantId, body) { let url_ = this.baseUrl + "/api/backoffice/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 (tenantId !== undefined && tenantId !== null) url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&"; url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(body); let options_ = { body: content_, observe: "response", responseType: "blob", headers: new HttpHeaders({ "Content-Type": "application/json", "Accept": "application/json" }) }; return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => { return this.http.request("post", url_, transformedOptions_); })).pipe(mergeMap((response_) => { return this.transformResult(url_, response_, (r) => this.processCreate(r)); })).pipe(catchError((response_) => { if (response_ instanceof HttpResponseBase) { try { return this.transformResult(url_, response_, (r) => this.processCreate(r)); } catch (e) { return throwError(e); } } else return throwError(response_); })); } processCreate(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 === 201) { return blobToText(responseBlob).pipe(mergeMap(_responseText => { let result201 = null; result201 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return of(result201); })); } 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 storefront product reference. * @param reference An external reference to Customer's Canvas product, e.g online store product identifier. * @param storefrontId Storefront identifier. * @param tenantId (optional) Tenant identifier. * @return Success */ get(reference, storefrontId, tenantId) { let url_ = this.baseUrl + "/api/backoffice/v1/product-references/{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_ = { 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 === 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 === 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); } /** * Deletes the 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 */ delete(reference, storefrontId, tenantId) { let url_ = this.baseUrl + "/api/backoffice/v1/product-references/{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_ = { observe: "response", responseType: "blob", headers: new HttpHeaders({ "Accept": "application/json" }) }; return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => { return this.http.request("delete", url_, transformedOptions_); })).pipe(mergeMap((response_) => { return this.transformResult(url_, response_, (r) => this.processDelete(r)); })).pipe(catchError((response_) => { if (response_ instanceof HttpResponseBase) { try { return this.transformResult(url_, response_, (r) => this.processDelete(r)); } catch (e) { return throwError(e); } } else return throwError(response_); })); } processDelete(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); } } ProductReferencesManagementApiClient.ɵprov = ɵɵdefineInjectable({ factory: function ProductReferencesManagementApiClient_Factory() { return new ProductReferencesManagementApiClient(ɵɵinject(ApiClientConfiguration), ɵɵinject(HttpClient), ɵɵinject(API_BASE_URL, 8)); }, token: ProductReferencesManagementApiClient, providedIn: "root" }); ProductReferencesManagementApiClient.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; ProductReferencesManagementApiClient.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 ProductsManagementApiClient 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 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 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 of linked ecommerce product. * @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(skip, take, sorting, search, sku, tags, customFields, tenantId) { let url_ = this.baseUrl + "/api/backoffice/v1/products?"; 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.processGetAllProducts(r)); })).pipe(catchError((response_) => { if (response_ instanceof HttpResponseBase) { try { return this.transformResult(url_, response_, (r) => this.processGetAllProducts(r)); } catch (e) { return throwError(e); } } else return throwError(response_); })); } processGetAllProducts(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); } /** * Creates a new product and returns its description. * @param tenantId (optional) Tenant identifier. * @param body (optional) * @return Success */ createProduct(tenantId, body) { let url_ = this.baseUrl + "/api/backoffice/v1/products?"; if (tenantId !== undefined && tenantId !== null) url_ += "tenantId=" + encodeURIComponent("" + tenantId) + "&"; url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(body); let options_ = { body: content_, observe: "response", responseType: "blob", headers: new HttpHeaders({ "Content-Type": "application/json", "Accept": "application/json" }) }; return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => { return this.http.request("post", url_, transformedOptions_); })).pipe(mergeMap((response_) => { return this.transformResult(url_, response_, (r) => this.processCreateProduct(r)); })).pipe(catchError((response_) => { if (response_ instanceof HttpResponseBase) { try { return this.transformResult(url_, response_, (r) => this.processCreateProduct(r)); } catch (e) { return throwError(e); } } else return throwError(response_); })); } processCreateProduct(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 by its identifier. * @param id Product identifier. * @param productVersionId (optional) Product version identifier. * @param tenantId (optional) Tenant identifier. * @return Success */ getProduct(id, productVersionId, tenantId) { let url_ = this.baseUrl + "/api/backoffice/v1/products/{id}?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); 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.processGetProduct(r)); })).pipe(catchError((response_) => { if (response_ instanceof HttpResponseBase) { try { return this.transformResult(url_, response_, (r) => this.processGetProduct(r)); } catch (e) { return throwError(e); } } else return throwError(response_); })); } processGetProduct(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); } /** * Deletes a product by its identifier. * @param id Product identifier. * @param tenantId (optional) Tenant identifier. * @return Success */ deleteProduct(id, tenantId) { let url_ = this.baseUrl + "/api/backoffice/v1/products/{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({}) }; return from(this.transformOptions(options_)).pipe(mergeMap(transformedOptions_ => { return this.http.request("delete", url_, transformedOptions_); })).pipe(mergeMap((response_) => { return this.transformResult(url_, response_, (r) => this.processDeleteProduct(r)); })).pipe(catchError((response_) => { if (response_ instanceof HttpResponseBase) { try { return this.transformResult(url_, response_, (r) => this.processDeleteProduct(r)); } catch (e) { return throwError(e); } } else return throwError(response_); })); } processDeleteProduct(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 === 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 list of product options. * @param id Product identifier. * @param productVersionId (optional) Product version identifier. * @param tenantId (optional) Tenant identifier. * @return Success */ getProductOptions(id, productVersionId, tenantId) { let url_ = this.baseUrl + "/api/backoffice/v1/products/{id}/options?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); 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.processGetProductOptions(r)); })).pipe(catchError((response_) => { if (response_ instanceof HttpResponseBase) { try { return this.transformResult(url_, response_, (r) => this.processGetProductOptions(r)); } catch (e) { return throwError(e); } } else return throwError(response_); })); } processGetProductOptions(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 list of product variants. * @param id Product identifier. * @param productVersionId (optional) Product version identifier. * @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 options (optional) Defines options filter e.g.: "{ "opt1_id": "opt1_val1_id, opt1_val2_id", "opt2_id": "opt2_val1_id" }". * @param productFilterId (optional) Defines special filter based on product filter with specified identifier. * @param takeAvailableOnly (optional) Defines special filter for available product variants. * @param sku (optional) SKU of linked ecommerce product. * @param tenantId (optional) Tenant identifier. * @return Success */ getProductVariants(id, productVersionId, skip, take, options, productFilterId, takeAvailableOnly, sku, tenantId) { let url_ = this.baseUrl + "/api/backoffice/v1/products/{id}/variants?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); if (productVersionId !== undefined && productVersionId !== null) url_ += "productVersionId=" + encodeURIComponent("" + productVersionId) + "&"; if (skip !== undefined && skip !== null) url_ += "skip=" + encodeURIComponent("" + skip) + "&"; if (take !== undefined && take !== null) url_ += "take=" + encodeURIComponent("" + take) + "&"; if (options !== undefined && options !== null) url_ += "options=" + encodeURIComponent("" + options) + "&"; if (productFilterId !== undefined && productFilterId !== null) url_ += "productFilterId=" + encodeURIComponent("" + productFilterId) + "&"; if (takeAvailableOnly !== undefined && takeAvailableOnly !== null) url_ += "takeAvailableOnly=" + encodeURIComponent("" + takeAvailableOnly) + "&"; 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.processGetProductVariants(r)); })).pipe(catchError((response_) => { if (response_ instanceof HttpResponseBase) { try { return this.transformResult(url_, response_, (r) => this.processGetProductVariants(r)); } catch (e) { return throwError(e); } } else return throwError(response_); })); } processGetProductVariants(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()) {