import {catchError, tap, map} from 'rxjs/operators'; /** * @Service: Customer Service * @Creation Date: Aug 3, 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'; // for debugging import { BaseService } from './base.service'; import { CartService } from '../services/cart.service'; import * as ServiceConstants from '../shared/service.constants'; import Utils from '../shared/utils'; // import * as Constants from '../shared/constants'; import { restUrl } from '../rest.url'; import { KeyValue } from '../shared/modal/key.value'; import { ISubscriber, ICreditLine, IOrder, IPreferredPrice } from '../shared/modal/common'; import { Customer, ICreditCheck, ICreditEligibilityReq, ICreditEligibilityRes } from '../shared/modal/customer'; /** * This class provides the Customer Service with methods to get, create, credit line, subscriber and order history */ @Injectable({providedIn:'root'}) export class CustomerService extends BaseService { public customerModel: any; public customer: Customer; public creditDetail: any; /** * Creates a new UserService with the injected HttpClient. * @param {HttpClient} _http - The injected HttpClient. * @constructor */ constructor(public _http: HttpClient, public cartService: CartService) { super(); } getCustomerModel(): any { return this.customerModel; } setCustomerModel(customerModel: any): void { this.customerModel = (this.customerModel) ? this.customerModel : {}; if (customerModel) { this.customerModel = Object.assign(this.customerModel, customerModel); } else { this.customerModel = customerModel; } } /**Gets the customer profile */ getCustomer(): Customer { if (this.customer) { return this.customer; } else { return Utils.getCustomerDetails(); } } /**Sets the customer profile */ setCustomer(customer: Customer) { this.customer = customer; Utils.storeCustomerDetails(customer); } /**Gets the credit details */ getCreditDetails(): any { if (this.creditDetail) { return this.creditDetail; } else { return Utils.getCreditDetails(); } } /**Sets the credit details */ setCreditDetails(creditDetail: any) { this.creditDetail = creditDetail; Utils.storeCreditDetails(creditDetail); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Customer} The Observable for the HTTP request. */ getCustomerProfile(storeId: number, orderId: number, creditType: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.getCustomerProfile ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('orderId', orderId)); // constracting the path params const queryParams: Array = new Array(); if (creditType) { queryParams.push(new KeyValue('creditType', creditType)) }; // getting the final url const url = Utils.replaceAppendParams(restUrl.customer.getCustomer, pathParams, queryParams); // service calling // return this._http.get ('assets/data/order-customer.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.getCustomerProfile ()'); } }),// 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. */ createCustomer(storeId: number, customer: Customer): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.createCustomer ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.createCustomer, pathParams); // service calling return this._http.post(url, customer, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.createCustomer ()'); } }),// 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. */ validateAddress(storeId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.validateAddress ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.validateAddress, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.validateAddress ()'); } }),// 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. */ getSocConflicts(storeId: number, rateplanSOC: string, accountNumber: number, accountType: string, accountSubType: string, phoneNumber: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.getSocConflicts ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('accountNumber', accountNumber)); pathParams.push(new KeyValue('rateplanSOC', rateplanSOC)); // constracting the query params const queryParams: Array = new Array(); if (accountType) { queryParams.push(new KeyValue('accountType', accountType)); } if (accountSubType) { queryParams.push(new KeyValue('accountSubType', accountSubType)); } if (phoneNumber) { queryParams.push(new KeyValue('phoneNumber', phoneNumber)); } // getting the final url const url = Utils.replaceAppendParams(restUrl.customer.getRateplanConflict, pathParams, queryParams); // service calling // return this._http.get ('assets/data/order-customer.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.getSocConflicts ()'); } }),// 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. */ creditCheck(storeId: number, creditCheck: ICreditCheck): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.creditCheck ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.creditCheck, pathParams); // service calling //return this._http.get ('assets/data/credit-check.json', options).pipe( return this._http.post(url, creditCheck, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.creditCheck ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Customer} The Observable for the HTTP request. */ refreshCreditClass(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.refreshCreditClass ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('orderId', orderId)); // getting the final url const url = Utils.replacePathParams(restUrl.order.refreshCreditClass, pathParams); // service calling // return this._http.get ('assets/data/credit-check.json', options) return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.refreshCreditClass ()'); } }),// 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. */ switchCreditType(storeId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.switchCreditType ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.switchCreditType, pathParams); // service calling // return this._http.get ('assets/data/credit-check.json', options) return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.switchCreditType ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {ICreditLine} The Observable for the HTTP request. */ getCreditLine(storeId: number, accountNumber: number, planType: string, creditClass: string, accountType: string, accountSubType: string, accountStatus: string, accountTenure: string, behaviorScore: string, onyxReferenceNumber: string, loanCrp: number, leaseCrp: number, state: string, numberOfLines: number, activeDataLines: number, activeVoiceLines: number ): Observable { // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('accountNumber', accountNumber)); // constracting the query params const queryParams: Array = new Array(); if (planType) { queryParams.push(new KeyValue('planType', planType)); } if (creditClass) { queryParams.push(new KeyValue('creditClass', creditClass)); } if (accountType) { queryParams.push(new KeyValue('accountType', accountType)); } if (accountSubType) { queryParams.push(new KeyValue('accountSubType', accountSubType)); } if (accountStatus) { queryParams.push(new KeyValue('accountStatus', accountStatus)); } if (accountTenure) { queryParams.push(new KeyValue('accountTenure', accountTenure)); } if (behaviorScore) { queryParams.push(new KeyValue('behaviorScore', behaviorScore)); } if (onyxReferenceNumber) { queryParams.push(new KeyValue('onyxReferenceNumber', onyxReferenceNumber)); } if (loanCrp) { queryParams.push(new KeyValue('loanCrp', loanCrp)); } if (leaseCrp) { queryParams.push(new KeyValue('leaseCrp', leaseCrp)); } if (state) { queryParams.push(new KeyValue('state', state)); } if (numberOfLines) { queryParams.push(new KeyValue('numberOfLines', numberOfLines)); } // getting the final url if (ServiceConstants.LOGGING) { console.log('[start]-customerService.getCreditLine ()'); } const url = Utils.replaceAppendParams(restUrl.customer.getCreditLine, pathParams, queryParams); // service calling // return this._http.get ('assets/data/customer.creditline.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.getCreditLine ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IOrderList} The Observable for the HTTP request. */ getOrderList(storeId: number, accountNumber: number): Observable { // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('accountNumber', accountNumber)); // getting the final url if (ServiceConstants.LOGGING) { console.log('[start]-customerService.getOrderList ()'); } const url = Utils.replacePathParams(restUrl.customer.getOrderList, pathParams); // service calling // return this._http.get ('assets/data/customer-orders.json', options) return this._http.get(url, options).pipe( map((res: any) => res.orders), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.getOrderList ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {ISubscriber[]} The Observable for the HTTP request. */ getSubscriberList(storeId: number, accountNumber: number, phoneNumbers: string, hasDuplicateLines: boolean): Observable { // getting the request options const options = this.httpOptions(); // constracting the path params if (ServiceConstants.LOGGING) { console.log('[start]-customerService.getSubscriberList ()'); } const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('accountNumber', accountNumber)); // constracting the query params const queryParams: Array = new Array(); if (phoneNumbers) { queryParams.push(new KeyValue('phoneNumbers', phoneNumbers)); } if (hasDuplicateLines) { queryParams.push(new KeyValue('hasDuplicateLines', hasDuplicateLines)); } // getting the final url const url = Utils.replaceAppendParams(restUrl.customer.getSubscriberList, pathParams, queryParams); // service calling // return this._http.get ('assets/data/customer-subscribers.json', options) return this._http.get(url, options).pipe( map((res: any) => res.subscribers), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.getSubscriberList ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {IPreferredPrice} The Observable for the HTTP request. */ getPreferredPrice(storeId: number, accountNumber: number, creditClass: string): Observable { // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('accountNumber', accountNumber)); pathParams.push(new KeyValue('creditClass', creditClass)); // getting the final url if (ServiceConstants.LOGGING) { console.log('[start]-customerService.getPreferredPrice ()'); } const url = Utils.replacePathParams(restUrl.customer.getPreferredPrice, pathParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.getPreferredPrice ()'); } }),// 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. */ resendSAEmail(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.resendSAEmail ()'); } // 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.resendSAEmail, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.resendSAEmail ()'); } }),// 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. */ resendDiscloserEmail(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.resendDiscloserEmail ()'); } // 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.resendDiscloserEmail, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.resendDiscloserEmail ()'); } }),// 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. */ rateplanConflicts(storeId: number, accountNumber: number, rateplanSOC: string, accountType: string, accountSubType: string, phoneNumber: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.rateplanConflicts ()'); } // 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('rateplanSOC', rateplanSOC)); // constracting the query params const queryParams: Array = new Array(); if (accountNumber) { queryParams.push(new KeyValue('accountNumber', accountNumber)); } if (accountType) { queryParams.push(new KeyValue('accountType', accountType)); } if (accountSubType) { queryParams.push(new KeyValue('accountSubType', accountSubType)); } if (phoneNumber) { queryParams.push(new KeyValue('phoneNumber', phoneNumber)); } // getting the final url const url = Utils.replaceAppendParams(restUrl.customer.rateplanConflicts, pathParams, queryParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.rateplanConflicts ()'); } }),// 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. */ doubleEIPEcl(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.doubleEIPEcl ()'); } // 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.doubleEIPEcl, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.doubleEIPEcl ()'); } }),// 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. */ getToggleKey(storeId: number, toggleKey: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.getToggleKey ()'); } // 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('toggleKey', toggleKey)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.getToggleKey, pathParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.getToggleKey ()'); } }),// 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. */ validatePINFormat(storeId: number, pinCode: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CheckoutService.validatePINFormat ()'); } // 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('pinCode', pinCode)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.validatePINFormat, pathParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CheckoutService.validatePINFormat ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Customer} The Observable for the HTTP request. */ profileByBAN(storeId: number, accountNumber: string, profileType: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.profileByBAN ()'); } // 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('accountNumber', accountNumber)); // constracting the query params const queryParams: Array = new Array(); if (profileType) { queryParams.push(new KeyValue('profileType', profileType)); } // getting the final url const url = Utils.replaceAppendParams(restUrl.customer.profileByBAN, pathParams, queryParams); // service calling // return this._http.get ('assets/data/customer-profile.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.profileByBAN ()'); } }),// for debug catchError(this.handleError)); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {Customer} The Observable for the HTTP request. */ profileByMSISDN(storeId: number, phoneNumber: string, profileType: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.profileByMSISDN ()'); } // 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('phoneNumber', phoneNumber)); // constracting the query params const queryParams: Array = new Array(); if (profileType) { queryParams.push(new KeyValue('profileType', profileType)); } // getting the final url const url = Utils.replaceAppendParams(restUrl.customer.profileByMSISDN, pathParams, queryParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.profileByMSISDN ()'); } }),// 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. */ profileByToken(storeId: number, toggleKey: string, profileType: string): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.profileByToken ()'); } // 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('toggleKey', toggleKey)); // constracting the query params const queryParams: Array = new Array(); if (profileType) { queryParams.push(new KeyValue('profileType', profileType)); } // getting the final url const url = Utils.replaceAppendParams(restUrl.customer.profileByToken, pathParams, queryParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.profileByToken ()'); } }),// 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. */ otpGenerate(storeId: number, accountNumber: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.otpGenerate ()'); } // 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('accountNumber', accountNumber)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.otpGenerate, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.otpGenerate ()'); } }),// 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. */ otpValidate(storeId: number, accountNumber: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.otpValidate ()'); } // 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('accountNumber', accountNumber)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.otpValidate, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.otpValidate ()'); } }),// 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. */ paymentArrangement(storeId: number, accountNumber: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.paymentArrangement ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('accountNumber', accountNumber)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.paymentArrangement, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.paymentArrangement ()'); } }),// 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. */ searchMemo(storeId: number, accountNumber: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-customerService.searchMemo ()'); } // getting the request options const options = this.httpOptions(); // constracting the path params const pathParams: Array = new Array(); pathParams.push(new KeyValue('storeId', storeId)); pathParams.push(new KeyValue('accountNumber', accountNumber)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.searchMemo, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-customerService.searchMemo ()'); } }),// 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. */ generateMemo(storeId: number, orderId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.generateMemo ()'); } // getting the request options let options = this.httpOptions(); options = Object.assign(options, this.getHeaders()); // 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.customer.generateMemo, pathParams); // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.generateMemo ()'); } }),// for debug catchError(this.handleError)); } getHeaders(): any { const headers = new Headers(); const cart = this.cartService.getReturnCart(); if (cart && cart.dealerCode) { headers.append('dealercode', (cart.dealerCode.length === 8) ? (cart.dealerCode.substr(1)) : cart.dealerCode); } else if (cart && cart.agentDealerCode) { headers.append('dealercode', (cart.agentDealerCode.length === 8) ? (cart.agentDealerCode.substr(1)) : cart.agentDealerCode); } else { headers.append('dealercode', '0000000'); } const options = { headers: headers }; return options; } // US335007 As a DASH dev I want UI changes for promotional information displayed when a configured Zip code is entered in Customer Information so that I can offer it to my customer /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ zipCodePromotion(storeId: number, zipCode: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.zipCodePromotion ()'); } // 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.STORE_ID, storeId)); pathParams.push(new KeyValue(ServiceConstants.ZIP_CODE, zipCode)); // getting the final url const url = Utils.replacePathParams(restUrl.promotion.promotionsByZipCode, pathParams); // service calling return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.zipCodePromotion ()'); } }),// 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. */ createTentativeBan(storeId: number, requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.createTentativeBan ()'); } // 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.customer.createTentativeBan, pathParams); // service calling return this._http.put(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.createTentativeBan ()'); } }),// 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. */ getCreditOptionDetails(storeId: number): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-CustomerService.getCreditOptionDetails ()'); } // 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.STORE_ID, storeId)); // getting the final url const url = Utils.replacePathParams(restUrl.customer.getCreditDetails, pathParams); // service calling // return this._http.get ( 'assets/data/credit-details.json', options) return this._http.get(url, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.getCreditOptionDetails ()'); } }),// for debug catchError(this.handleError)); } /** * * @param storeId * @param creditEligibilityReq */ verifyEligibility(storeId: number,creditEligibilityReq:ICreditEligibilityReq):Observable { // verifyEligibility(creditEligibilityReq:ICreditEligibilityReq):Observable { // return this._http.get("assets/data/graduatecheckeligibility.json") // .map((res: Response) => res) // .catch((error: any) => Observable.throw(error || 'Server error')); if (ServiceConstants.LOGGING) { console.log('[start]-customerService.crediteligibilitycheck ()'); } let options = this.httpOptions(); options = Object.assign(options, this.getHeaders()); // 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.customer.crediteligibilitycheck, pathParams); // service calling //return this._http.get("assets/data/graduatecheckeligibility.json").pipe( return this._http.post(url, creditEligibilityReq, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-CustomerService.createTentativeBan ()'); } }),// for debug catchError(this.handleError)); } }