import { catchError, tap, map } from 'rxjs/operators'; /** * @Service: Cart Service * @Creation Date: Aug 4, 2017 * @Author: sbaireddy * @Version: 1.0 */ import { Injectable, Output, EventEmitter } from '@angular/core'; // import { HttpClient, Headers, RequestOptions, Response } from '@angular/_http'; import { HttpClient } from '@angular/common/http'; // import { Observable } from 'rxjs/observable'; import { Observable } from 'rxjs/Rx'; // import { Subject } from 'rxjs/Subject'; // for debugging import { BaseService } from './base.service'; import * as ServiceConstants from '../shared/service.constants'; import Utils from '../shared/utils'; import CartUtils from '../shared/cart.utils'; import { restUrl } from '../rest.url'; import { KeyValue } from '../shared/modal/key.value'; import { IError, IFinance, IShipping, IPayment, IPromotion, IPackage, IZipMarket } from '../shared/modal/common'; import { Cart } from '../shared/modal/cart'; /** * This class provides the Cart Service with methods to get, create, delete cart. */ @Injectable({ providedIn: 'root' }) export class CartService extends BaseService { @Output() hasUpdate: EventEmitter = new EventEmitter(); public cart: Cart; public returnCart: Cart; public sapBlindCart: Cart; public returnableItems: any; /** * Creates a new UserService with the injected HttpClient. * @param {HttpClient} _http - The injected HttpClient. * @constructor */ constructor(public _http: HttpClient) { super(); } /**Gets the Cart */ getCart(): Cart { if (this.cart) { return this.cart; } else { return Utils.getCartDetails(); } } /**Sets the Cart */ setCart(cart: Cart): void { this.cart = cart; Utils.storeCartDetails(cart); this.hasUpdate.emit(true); } /**Gets the Cart */ getReturnCart(): Cart { if (this.returnCart) { return this.returnCart; } else { return Utils.getReturnCartDetails(); } } /**Sets the Cart */ setReturnCart(cart: Cart): void { this.returnCart = cart; Utils.storeReturnCartDetails(cart); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ createCartDetails(storeId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createCartDetails ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.createCart, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createCartDetails ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Cart} The Observable for the HTTP request. */ updateCartDetails(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.updateCartDetails ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.updateCart, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.updateCartDetails ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ createPackageDetails(storeId: number, orderId: number, requestParams: any): Observable { // getting the request options if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createPackageDetails ()'); } const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.createPackage, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res.packages), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createPackageDetails ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {void} The Observable for the HTTP request. */ deletePackageDetails(storeId: number, orderId: number, packageId: number, lineId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.deletePackageDetails ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.deletePackage, pathParams); // service calling return this._http.delete(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.deletePackageDetails ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ copyPackage(storeId: number, orderId: number, packageId: number, lineId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createPackage ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.copyPackage, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createPackage ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ createRateplan(storeId: number, orderId: number, packageId: number, lineId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createRateplan ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.createRateplan, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createRateplan ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ updateRateplan(storeId: number, orderId: number, packageId: number, lineId: number, orderItemId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.updateRateplan ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ITEM_ID, orderItemId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.updateRateplan, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.updateRateplan ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage} The Observable for the HTTP request. */ deleteRateplan(storeId: number, orderId: number, packageId: number, lineId: number, orderItemId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.deleteRateplan ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ITEM_ID, orderItemId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.deleteRateplan, pathParams); // service calling return this._http.delete(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.deleteRateplan ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ createDevice(storeId: number, orderId: number, packageId: number, lineId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createDevice ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.createDevice, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createDevice ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ updateDevice(storeId: number, orderId: number, packageId: number, lineId: number, orderItemId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.updateDevice ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ITEM_ID, orderItemId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.updateDevice, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.updateDevice ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage} The Observable for the HTTP request. */ deleteDevice(storeId: number, orderId: number, packageId: number, lineId: number, orderItemId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.deleteDevice ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ITEM_ID, orderItemId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.deleteDevice, pathParams); // service calling return this._http.delete(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.deleteDevice ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ createFeature(storeId: number, orderId: number, packageId: number, lineId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createFeature ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.createFeature, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createFeature ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ updateFeature(storeId: number, orderId: number, packageId: number, lineId: number, orderItemId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.updateFeature ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ITEM_ID, orderItemId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.updateFeature, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.updateFeature ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage} The Observable for the HTTP request. */ deleteFeature(storeId: number, orderId: number, packageId: number, lineId: number, orderItemId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.deleteFeature ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ITEM_ID, orderItemId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.deleteFeature, pathParams); // service calling return this._http.delete(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.deleteFeature ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ createAccessory(storeId: number, orderId: number, packageId: number, lineId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createAccessory ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.createAccessory, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createAccessory ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ updateAccessory(storeId: number, orderId: number, packageId: number, lineId: number, orderItemId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.updateAccessory ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ITEM_ID, orderItemId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.updateAccessory, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.updateAccessory ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage} The Observable for the HTTP request. */ deleteAccessory(storeId: number, orderId: number, packageId: number, lineId: number, orderItemId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.deleteAccessory ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PACKAGE_ID, packageId)); pathParams.push(new KeyValue(ServiceConstants.LINE_ID, lineId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ITEM_ID, orderItemId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.deleteAccessory, pathParams); // service calling return this._http.delete(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.deleteAccessory ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ applyPromotion(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.applyPromotion ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.applyPromo, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.applyPromotion ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ deletePromotion(storeId: number, orderId: number, promoCode: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.deletePromotion ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.PROMO_CODE, promoCode)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.deletePromo, pathParams); // service calling return this._http.delete(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.deletePromotion ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ payExtraAmount(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.payExtraAmount ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.payExtra, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.payExtraAmount ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ adjustPrice(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.adjustPrice ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.adjustPrice, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.adjustPrice ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ resolveConflicts(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.resolveConflicts ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.resloveConflicts, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.resolveConflicts ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ validateCart(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.validateCart ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.validateCart, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.validateCart ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ calculate(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.checkout ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.calculate, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.checkout ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Cart} The Observable for the HTTP request. */ getCartDeatils(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartDeatils ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.getCart, pathParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartDeatils ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Cart} The Observable for the HTTP request. */ getCartSummary(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartSummary ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url // service calling const url = Utils.replacePathParams(restUrl.cart.getCartSummary, pathParams); // service calling var ran = new Date().getTime(); // return this.http.get ('assets/data/order-summary.json', options).pipe( return this._http.get(url + '?v=' + ran, options).pipe( //added ran to api so that caching will be removed from the frontend side map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartDeatils ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Cart} The Observable for the HTTP request. */ getCartSummaryInclCancelled(storeId: number, orderId: number, includeCanceled: boolean): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartSummaryInclCancelled ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url // service calling const queryParams: Array = new Array(); if (includeCanceled) { queryParams.push(new KeyValue('includeCanceled', includeCanceled)); } // getting the final url const url = Utils.replaceAppendParams(restUrl.cart.getCancelSummary, pathParams, queryParams); // service calling // return this._http.get ('assets/data/order-summary.json', options).pipe( return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartSummaryInclCancelled ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Cart} The Observable for the HTTP request. */ getReturnCartSummary(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartSummary ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.getCartSummary, pathParams); // service calling // return this._http.get ('assets/data/return-cart-summary.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartSummary ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Cart} The Observable for the HTTP request. */ getExchangeCartSummary(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartSummary ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.getCartSummary, pathParams); // service calling // return this._http.get ('assets/data/exchange-cart-summary.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartSummary ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IFinance} The Observable for the HTTP request. */ getCartFinance(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartFinance ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.getCartFinance, pathParams); // service calling // return this._http.get ('assets/data/order-finance.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartFinance ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IShipping} The Observable for the HTTP request. */ getCartShipping(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartShipping ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.getCartShipping, pathParams); // service calling // return this._http.get ('assets/data/order-shipping.json', options) return this._http.get(url, options).pipe( map((res: any) => res.shippingInfo), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartShipping ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPayment} The Observable for the HTTP request. */ getCartPayment(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartPayment ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.getCartPayment, pathParams); // service calling // return this._http.get ('assets/data/order-payment.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartPayment ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ getAssociatedOrders(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getAssociatedOrders ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.getAssociatedOrders, pathParams); // service calling // return this._http.get ('assets/data/order-payment.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getAssociatedOrders ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ getReturnableItems(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getReturnableItems ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.order.getReturnItems, pathParams); // service calling // return this._http.get ('assets/data/order-payment.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getReturnableItems ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPayment} The Observable for the HTTP request. */ getCartPromo(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getCartPromo ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.getCartPromotions, pathParams); // service calling // return this._http.get ('assets/data/order-promo.json', options) return this._http.get(url, options).pipe( map((res: any) => res.promotionInfo), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getCartPromo ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ createReturnItems(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createReturnItems ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.returnItems, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createReturnItems ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ createExchangeItems(storeId: number, orderId: number, returnOrderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.createExchangeItems ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.RETURN_ORDER_ID, returnOrderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.exchangeItems, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.createExchangeItems ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ saveDigitsMapping(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.saveDigitsMapping ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.saveDigitsMapping, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.saveDigitsMapping ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Cart} The Observable for the HTTP request. */ returnExchangeItems(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.returnExchangeItems ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.returnExchangeItems, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.returnExchangeItems ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ issueCredit(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.issueCredit ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.issueCredit, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.issueCredit ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ issueCreditItems(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.issueCredit ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.issueCreditItems, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.issueCredit ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ convertFullPrice(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-convertFullprice.convertFullPrice ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.convertFullPrice, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.convertFullPrice ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ lookupNpaList(storeId: number, orderId: number, zipCode: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-convertFullprice.getNPALookup ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); pathParams.push(new KeyValue(ServiceConstants.ZIP_CODE, zipCode)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.lookupNpa, pathParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res.npaList), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getNPALookup ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ clearProducts(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.clearProducts ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.clearProducts, pathParams); // service calling return this._http.delete(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.clearProducts ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IUsableShipping} The Observable for the HTTP request. */ getTrakingInfo(storeId: number, orderId: number, trackingNumber: string, orderCreateDate: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CheckoutService.getTrackingInfo ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); const queryParams: Array = new Array(); queryParams.push(new KeyValue('returnTrackingNumber', trackingNumber)); queryParams.push(new KeyValue('createdDate', orderCreateDate)); // getting the final url const url = Utils.replaceAppendParams(restUrl.cart.trackingInfo, pathParams, queryParams); // service calling // return this._http.get ('assets/data/trackingInfo.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CheckoutService.getTrakingInfo ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IUsableShipping} The Observable for the HTTP request. */ createResendShippingLabel(storeId: number, orderId: number, inputCart: Cart): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CheckoutService.createResendShippingLabel ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.shippingLabel, pathParams); // service calling // return this._http.get ('assets/data/order-shippinglabel.json', options) return this._http.post(url, inputCart, options).pipe( // return this._http.get (url, options) map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CheckoutService.createResendShippingLabel ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IUsableShipping} The Observable for the HTTP request. */ getSapOrderList(storeId: number, fullOrderId: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CheckoutService.getSapOrderList()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, fullOrderId)); // getting the final url const url = Utils.replacePathParams(restUrl.checkout.saporderlist, pathParams); // service calling // return this._http.get ('assets/data/order-shippinglabel.json', options) return this._http.get(url, options).pipe( // return this._http.get (url, options) map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CheckoutService.getSapOrderList()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IUsableShipping} The Observable for the HTTP request. */ getSapItemDetails(storeId: number, orderId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CheckoutService.getSapItemDetails()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.checkout.sapitemdetails, pathParams); // service calling return this._http.get(url, options).pipe( // return this._http.get (url, options) map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CheckoutService.getSapItemDetails()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ dmSync(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CartService.dmSync ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.dmSync, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.dmSync ()'); } }), // for debug catchError(this.handleError)); } /**Gets the Cart */ getSAPBlindCart(): Cart { if (this.sapBlindCart) { return this.sapBlindCart; } else { return Utils.getSAPBlindCartDetails(); } } /**Sets the Cart */ setSAPBlindCart(cart: Cart): void { this.sapBlindCart = cart; Utils.storeSAPBlindCartDetails(cart); } setRefundableItems(returnableItems: any) { this.returnableItems = returnableItems; } getRefundableItems() { return this.returnableItems; } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ deviceFeatureConflicts(storeId: number, orderId: number, inputCart: Cart): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cart.deviceFeatureConflicts ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // constracting the query params const queryParams: Array = new Array(); // getting the final url const url = Utils.replaceAppendParams(restUrl.cart.featureConflicts, pathParams, queryParams); // service calling return this._http.post(url, inputCart, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartservice.deviceFeatureConflicts ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ calculateTax(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.calculateTax ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.cart.calculateTax, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.calculateTax ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ publishcart(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.biReport ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ORDER_ID, orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.checkout.biReport, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.biReport ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPackage[]} The Observable for the HTTP request. */ sendSurvery(storeId: number, userId: number, requestParams: any): Observable { // getting the request options if (ServiceConstants.LOGGING) { console.log('[start]-cartService.sendSurvery ()'); } const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.USER_ID, userId)); // getting the final url const url = Utils.replacePathParams(restUrl.user.sendSurvery, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.sendSurvery ()'); } }), // for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Observable} The Observable for the HTTP request. */ getSurveyStatus(storeId: number, userId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-cartService.getSurveyStatus ( )'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue(ServiceConstants.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.USER_ID, userId)); // getting the final url const url = Utils.replacePathParams(restUrl.user.getSurvey, pathParams); // service calling // return this._http.get ( 'assets/data/devices.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-cartService.getSurveyStatus ( )'); } }), // for debug catchError(this.handleError)); } /** * This function is used to update the active package to the cart. * @param {number} packageId - contains active packageId. * @param {number} lineId - contains active lineId. * @returns boolean */ isActivePackage(packageId: number, lineId: number): boolean { const METHOD_NAME: string = 'isActivePackage()'; let isActive: boolean = false; if (this.cart) { if (this.cart.activePackageId == null || this.cart.activeLineId == null) { this.cart.activePackageId = this.cart.packages[0].packageId; this.cart.activeLineId = this.cart.packages[0].lineId; this.setCart(this.cart); } isActive = this.cart.activePackageId === packageId && this.cart.activeLineId === lineId; if (!isActive) { const packages: IPackage[] = this.cart.packages.filter((item) => { return item.packageId === this.cart.activePackageId && item.lineId === this.cart.activeLineId }); if (!packages || packages.length === 0) { this.cart.activePackageId = this.cart.packages[0].packageId; this.cart.activeLineId = this.cart.packages[0].lineId; this.setCart(this.cart); } isActive = this.cart.activePackageId === packageId && this.cart.activeLineId === lineId; } } return isActive; } }