/** * @Name: Util * @Creation Date: Aug 3, 2017 * @Author: sbaireddy * @Version: 1.0 : */ import { RequestOptions } from '@angular/http'; import { Observable } from 'rxjs/Rx'; import { KeyValue } from './modal/key.value'; import { IRateplan, IDevice, IDeviceItem, IFeature, IAccessory, IAccessoryItem, IFilterList, IFilter, IOrderList, IDormantProperties } from './modal/common'; import { User } from './modal/user'; import { Cart } from './modal/cart'; import { Customer } from './modal/customer'; /** Deafult Class representing the common utils for application. */ export default class Utils { private COMPONENT_NAME; /** Gets the request options for any rest service call. */ static getRequestOptions(): RequestOptions; /** * Replace a url string with path path params. * @param url - The url string containing rest service end point. * @param pathParams - The pathParams . */ static replacePathParams(url: string, pathParams: Array): string; /** * Append a url string with query params. * @param url - The url string containing rest service end point. * @param queryParams - The pathParams . */ static appendQueryParams(url: string, queryParams: Array): string; /** * Replace and apppend a url string with path params and query params. * @param url - The url string containing rest service end point. * @param pathParams - The pathParams . * @param queryParams - The pathParams . */ static replaceAppendParams(url: string, pathParams: Array, queryParams: Array): string; /** Clears the master catalog from local cache. */ static clearMasterList(): void; /** Stroes the master rateplan list to local cache. */ static storeRateplanList(rateplanList: IRateplan[], productType: string): void; /** Gets the master rateplan list from local cache. */ static getRateplanList(productType: string): IRateplan[]; /** Stroes the master rateplan filter list to local cache. */ static storeRateplanFilterList(rateplanFilterList: IFilterList[], productType: string): void; /** Gets the master rateplan filter list from local cache. */ static getRateplanFilterList(productType: string): IFilterList[]; /** Stroes the master device list to local cache. */ static storeDeviceList(deviceList: IDevice[], productType: string): void; /** Gets the master device list from local cache. */ static getDeviceList(productType: string): IDevice[]; /** Excluding the legacy items from list*/ static excludeProductItems(products: any[], logonTime: Date): Array; /** Gets the device item from local cache. */ static getDeviceItem(deviceSKU: string): IDeviceItem; /** Gets the parent device item from local cache. */ static getDeviceParent(deviceSKU: string): IDevice; /** Gets the device from local cache. */ static getDevice(productId: number): IDevice; /** Stroes the master device filter list to local cache. */ static storeDeviceFilterList(deviceFilterList: IFilterList[], productType: string): void; /** Gets the master device filter list from local cache. */ static getDeviceFilterList(productType: string): IFilterList[]; /** Gets the device brands from local cache. */ static getDeviceBrands(productType: string): IFilter[]; /** Gets the device items from local cache. */ static getDeviceItems(productIds: number[]): any; /** Stroes the master feature list to local cache. */ static storeFeatureList(featureList: IFeature[]): void; /** Gets the master feature list from local cache. */ static getFeatureList(): IFeature[]; /** Stroes the master feature filter list to local cache. */ static storeFeatureFilterList(featureFilterList: IFilterList[]): void; /** Gets the master feature filter list from local cache. */ static getFeatureFilterList(): IFilterList[]; /** Stroes the master accesory list to local cache. */ static storeAccessoryList(accessoryList: IAccessory[]): void; /** Gets the master accessory list from local cache. */ static getAccessoryList(): IAccessory[]; /** Gets the accessory item from local cache. */ static getAccessoryItem(accessorySKU: string): IAccessoryItem; /** Gets the parent accessory item from local cache. */ static getAccessory(productId: number): IAccessory; /** Gets the parent accessory item from local cache. */ static getAccessoryParent(accessorySKU: string): IAccessory; /** Stroes the master accessory filter list to local cache. */ static storeAccessoryFilterList(accessoryFilterList: IFilterList[]): void; /** Gets the master accessory filter list from local cache. */ static getAccessoryFilterList(): IFilterList[]; /** Gets the payment public key from local cache. */ static getPaymentPublicKey(): any; /** Clears the data from session cache. */ static clearSessionData(): void; /** Stroes the user to local cache. */ static storeUserDetail(user: User): void; /** Gets the user from local cache. */ static getUserDetail(): User; /** Stroes the cart deatils to local cache. */ static storeCartDetails(cart: Cart): void; /** Gets the cart deatils from local cache. */ static getReturnCartDetails(): Cart; /** Stroes the cart deatils to local cache. */ static storeReturnCartDetails(cart: Cart): void; /** Gets the cart deatils from local cache. */ static getCartDetails(): Cart; /** Stroes the customer profile deatils to local cache. */ static storeCustomerDetails(customer: Customer): void; /** Gets the customer deatils from local cache. */ static getCustomerDetails(): Customer; /** Stroes the credit deatils to local cache. */ static storeCreditDetails(creditDetail: any): void; /** Gets the customer deatils from local cache. */ static getCreditDetails(): any; /** Stroes the order serch result deatils to local cache. */ static storeOrderListDetails(orderList: IOrderList): void; /** Gets the order search deatils from local cache. */ static getOrderListDetails(): IOrderList; /** Stroes the order deatils to local cache. */ static storeOrderDetails(order: Cart): void; /** Gets the order deatils from local cache. */ static getOrderDetails(): Cart; /** Stroes the order deatils to local cache. */ static storeDormantProperties(properties: IDormantProperties): void; /** Gets the order deatils from local cache. */ static getDormantProperties(): IDormantProperties; /** Gets the cart deatils from local cache. */ static getSAPBlindCartDetails(): Cart; /** Stroes the cart deatils to local cache. */ static storeSAPBlindCartDetails(cart: Cart): void; static groupByProductCount(): number; static totalCardsPerPage(): number; static hasStoreAccess(storeId: number): boolean; /** Group the products with defined number */ static groupProducts(products: any[], count: number): Array>; /** Search products with given filters */ static serachFilter(products: any[], filters: IFilterList[]): Array; /** Search products with given sory by selection */ static serachSortBy(products: any[], sortBykey: string): Array; /** Search products with given search text */ static serachProducts(products: any[], serachText: string): Array; /** Keeping only finance items */ static keepFinanceItems(products: any[], financeType: string, crp: number): Array; /** Search products with given finance type */ static sortByFinance(products: any[], financeType: string, crp: number): Array; static getPager(totalItems: number, currentPage?: number, pageSize?: number): { totalItems: number; currentPage: number; pageSize: number; totalPages: number; startPage: number; endPage: number; startIndex: number; endIndex: number; pages: any; }; static matchFiltersProducts(filters: IFilter[], products: any[]): Array; static canDisableButton(item: any, financeType: string, crp: number): boolean; static getLoanCrp(creditType: string): number; static getLeaseCrp(creditType: string): number; static hasOffer(item: any): boolean; static getErrorValue(errorKey: string): string; static getErrorContains(errorKey: string): string; static getErrorKey(errorVal: string): string; static getConflictsMsg(errorKey: string, param: string): string; /** * Handle HTTP error */ static handleError(error: any): Observable; static validate(dateType: string, date: any): number; static isValidImei(imei: any): boolean; static luhn_checksum(code: any): number; static isHexaDecimal(input: any): boolean; static keysToArray(input: any): string[]; static setOrderItemsIdTradeInInfo(tradeInlist: any, orderItemsId: number, tradeInfo: any[]): any; static getTradeInInfoOrder(orderItemsId: number, tradeInfo: any): any; static setFinanceTypeForReturn(exChangeCart: Cart, returnCart: Cart, type: String): string; static formatPhoneNumber(phoneNumber: string): string; static nonFormatPhoneNumber(phoneNumber: string): string; static nonFormatSSN(SSN: string): string; static nonFormatDate(dateExp: string): string; static formatBirthDate(dateString: string): string; static formatDecimal(decimalString: string): string; static trimZipCode(zipCode: any): string; static checkDealerCode(dealercode: any): boolean; /** * This function is used to update product Item Index based on device stock priority. * @param {IDevice} product contains device info. * @returns number */ static getItemIndex(product: IDevice): number; static hasActLineLevelError(errorParameters: any): boolean; static formatActErrorMessage(errorParameters: any): string; static getCreditProfile(creditClass: string): any; }