import { MaerskApiClient } from 'app/common/clients/maerskApi.client'; import { isEmpty } from 'lodash'; import { map } from 'rxjs/operators'; export class ContactService { private apiClient: MaerskApiClient; constructor(apiClient) { this.apiClient = apiClient; } createContactSections(data) { return { sections: data.map((item) => ({ title: item.name, topics: item.topics, contacts: (!isEmpty(item.people)) ? item.people.map((contactInfo) => ({ name: contactInfo.name, thumbnail: contactInfo.imageUrl, pool: contactInfo.poolTitle, position: contactInfo.title, phone: contactInfo.phoneNumber, email: contactInfo.email, })) : [], })), }; } getContacts() { return this.apiClient.getContactDepartments().pipe( map(this.createContactSections), ); } }