| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- const contact_address_1 = require("./contact-address");
- class ContactBook {
- constructor(items) {
- this.items = items;
- }
- getPrimaryEmailAddress() {
- return this.getFromEmailAddresses()[0];
- }
- getPrimaryPhoneNumber() {
- return this.getFromPhoneNumbers()[0];
- }
- getFromPhoneNumbers() {
- const result = [];
- for (const item of this.items) {
- if (item.me) {
- for (const address of item.addrs) {
- if (address.type === 'phone') {
- result.push(contact_address_1.ContactAddress.formatPhoneNumber(address.address));
- }
- }
- }
- }
- return result;
- }
- getFromEmailAddresses() {
- const result = [];
- for (const item of this.items) {
- if (item.me) {
- for (const address of item.addrs) {
- if (address.type === 'email') {
- result.push(address.address);
- }
- }
- }
- }
- return result;
- }
- getAllGroups() {
- return Object.keys(this.items.reduce((accum, contact) => {
- for (const group of contact.groups) {
- accum[group] = true;
- }
- return accum;
- }, {}));
- }
- lookupByAddress(addressType, addressValue) {
- return this.items.find(item => item.matchesAddressExactly(addressType, addressValue));
- }
- lookupById(id) {
- return this.items.find(item => item.id === id);
- }
- search(search) {
- return this.items.filter(i => i.search(search));
- }
- }
- exports.ContactBook = ContactBook;
- //# sourceMappingURL=contact-book.js.map
|