/* tslint:disable */ /* eslint-disable */ //---------------------- // // Generated using the NSwag toolchain v13.10.8.0 (NJsonSchema v10.3.11.0 (Newtonsoft.Json v11.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming export class CartClient { private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }; private baseUrl: string; protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { this.http = http ? http : window; this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:5000"; } get(): Promise { let url_ = this.baseUrl + "/api/Cart"; url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "GET", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processGet(_response); }); } protected processGet(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } post(model: CartCreateUpdateModel): Promise { let url_ = this.baseUrl + "/api/Cart"; url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(model); let options_ = { body: content_, method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processPost(_response); }); } protected processPost(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } getFromCustomer(customerId: string): Promise { let url_ = this.baseUrl + "/api/Cart/{customerId}"; if (customerId === undefined || customerId === null) throw new Error("The parameter 'customerId' must be defined."); url_ = url_.replace("{customerId}", encodeURIComponent("" + customerId)); url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "GET", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processGetFromCustomer(_response); }); } protected processGetFromCustomer(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } delete(model: CartDeleteModel): Promise { let url_ = this.baseUrl + "/api/Cart/delete"; url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(model); let options_ = { body: content_, method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processDelete(_response); }); } protected processDelete(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } } export class CustomerClient { private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }; private baseUrl: string; protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { this.http = http ? http : window; this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:5000"; } getAll(): Promise { let url_ = this.baseUrl + "/api/Customer"; url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "GET", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processGetAll(_response); }); } protected processGetAll(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } post(model: CustomerCreateUpdateModel): Promise { let url_ = this.baseUrl + "/api/Customer"; url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(model); let options_ = { body: content_, method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processPost(_response); }); } protected processPost(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } get(id: string): Promise { let url_ = this.baseUrl + "/api/Customer/{id}"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "GET", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processGet(_response); }); } protected processGet(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } put(id: string, model: CustomerCreateUpdateModel): Promise { let url_ = this.baseUrl + "/api/Customer/{id}"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(model); let options_ = { body: content_, method: "PUT", headers: { "Content-Type": "application/json", "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processPut(_response); }); } protected processPut(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } delete(id: string): Promise { let url_ = this.baseUrl + "/api/Customer/{id}"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "DELETE", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processDelete(_response); }); } protected processDelete(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } } export class MathClient { private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }; private baseUrl: string; protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { this.http = http ? http : window; this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:5000"; } get(): Promise { let url_ = this.baseUrl + "/api/Math"; url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "GET", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processGet(_response); }); } protected processGet(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } } export class ProductClient { private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }; private baseUrl: string; protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { this.http = http ? http : window; this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:5000"; } getAll(): Promise { let url_ = this.baseUrl + "/api/Product"; url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "GET", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processGetAll(_response); }); } protected processGetAll(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } post(model: ProductCreateUpdateModel): Promise { let url_ = this.baseUrl + "/api/Product"; url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(model); let options_ = { body: content_, method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processPost(_response); }); } protected processPost(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } get(id: string): Promise { let url_ = this.baseUrl + "/api/Product/{id}"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "GET", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processGet(_response); }); } protected processGet(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } put(id: string, model: ProductCreateUpdateModel): Promise { let url_ = this.baseUrl + "/api/Product/{id}"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(model); let options_ = { body: content_, method: "PUT", headers: { "Content-Type": "application/json", "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processPut(_response); }); } protected processPut(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } delete(id: string): Promise { let url_ = this.baseUrl + "/api/Product/{id}"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); url_ = url_.replace("{id}", encodeURIComponent("" + id)); url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "DELETE", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processDelete(_response); }); } protected processDelete(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } } export class SettingsClient { private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }; private baseUrl: string; protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { this.http = http ? http : window; this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:5000"; } get(): Promise { let url_ = this.baseUrl + "/api/Settings"; url_ = url_.replace(/[?&]$/, ""); let options_ = { method: "GET", headers: { "Accept": "application/json" } }; return this.http.fetch(url_, options_).then((_response: Response) => { return this.processGet(_response); }); } protected processGet(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); return result200; }); } else if (status !== 200 && status !== 204) { return response.text().then((_responseText) => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } return Promise.resolve(null); } } export interface CartCustomerListItem { productID: string; productName?: string | undefined; productPrice: number; customerName?: string | undefined; customerEmail?: string | undefined; quantity: number; } export interface CartListItem { productID: string; productName?: string | undefined; productPrice: number; quantity: number; } export interface CartCreateUpdateModel { customerID: string; productID: string; quantity: number; } export interface CartDeleteModel { customerID: string; productID: string; } export interface CustomerListItem { customerID: string; name: string; email: string; } export interface CustomerCreateUpdateModel { name: string; email: string; } export interface ProductListItem { productID: string; name: string; price: number; } export interface ProductCreateUpdateModel { name: string; price: number; } export class ApiException extends Error { message: string; status: number; response: string; headers: { [key: string]: any; }; result: any; constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) { super(); this.message = message; this.status = status; this.response = response; this.headers = headers; this.result = result; } protected isApiException = true; static isApiException(obj: any): obj is ApiException { return obj.isApiException === true; } } function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any { if (result !== null && result !== undefined) throw result; else throw new ApiException(message, status, response, headers, null); }