|
|
@@ -0,0 +1,32 @@
|
|
|
+import { ContactItem } from "./contact-item";
|
|
|
+
|
|
|
+export class ContactBook {
|
|
|
+
|
|
|
+ public readonly items: ContactItem[];
|
|
|
+
|
|
|
+ constructor(items: ContactItem[]) {
|
|
|
+ this.items = items;
|
|
|
+ }
|
|
|
+
|
|
|
+ public getPrimaryEmailAddress() {
|
|
|
+ for (const item of this.items) {
|
|
|
+ for (const address of item.canSendFromAddrs) {
|
|
|
+ if (address.startsWith('email:')) {
|
|
|
+ return address;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public getPrimaryPhoneNumber() {
|
|
|
+ for (const item of this.items) {
|
|
|
+ for (const address of item.canSendFromAddrs) {
|
|
|
+ if (address.startsWith('phone:')) {
|
|
|
+ return address;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|