Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 29x 8x 11x 19x 3x 16x | import { CustomerData } from './customer.interface'; import { Customer, CustomerUserType } from './customer.model'; export class CustomerMapper { /** * Get User data for the logged in Business Customer. */ static mapLoginData(data: CustomerData): CustomerUserType { return CustomerMapper.isBusinessCustomer(data) ? { customer: CustomerMapper.fromData(data), user: undefined, } : { customer: CustomerMapper.fromData(data), user: { title: data.title, firstName: data.firstName, lastName: data.lastName, preferredLanguage: data.preferredLanguage, phoneHome: data.phoneHome, phoneBusiness: data.phoneBusiness, phoneMobile: data.phoneMobile, fax: data.fax, email: data.email, login: data.login, preferredInvoiceToAddressUrn: data.preferredInvoiceToAddress?.urn, preferredShipToAddressUrn: data.preferredShipToAddress?.urn, preferredPaymentInstrumentId: data.preferredPaymentInstrument?.id, birthday: data.birthday, }, }; } /** * Map customer data in dependence of the customer type (PrivateCustomer/SMBCustomer) */ static fromData(data: CustomerData): Customer { return CustomerMapper.isBusinessCustomer(data) ? { customerNo: data.customerNo, isBusinessCustomer: true, companyName: data.companyName, companyName2: data.companyName2, taxationID: data.taxationID, industry: data.industry, description: data.description, } : { customerNo: data.customerNo, isBusinessCustomer: false, }; } private static isBusinessCustomer(data: CustomerData): boolean { if (data.type === 'PrivateCustomer') { return false; } return true; } } |