user 6 år sedan
förälder
incheckning
a9bd1df89b
4 ändrade filer med 67 tillägg och 0 borttagningar
  1. 7 0
      lib/contact-book.d.ts
  2. 27 0
      lib/contact-book.js
  3. 1 0
      lib/contact-book.js.map
  4. 32 0
      src/contact-book.ts

+ 7 - 0
lib/contact-book.d.ts

@@ -0,0 +1,7 @@
+import { ContactItem } from "./contact-item";
+export declare class ContactBook {
+    readonly items: ContactItem[];
+    constructor(items: ContactItem[]);
+    getPrimaryEmailAddress(): string | undefined;
+    getPrimaryPhoneNumber(): string | undefined;
+}

+ 27 - 0
lib/contact-book.js

@@ -0,0 +1,27 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+class ContactBook {
+    constructor(items) {
+        this.items = items;
+    }
+    getPrimaryEmailAddress() {
+        for (const item of this.items) {
+            for (const address of item.canSendFromAddrs) {
+                if (address.startsWith('email:')) {
+                    return address;
+                }
+            }
+        }
+    }
+    getPrimaryPhoneNumber() {
+        for (const item of this.items) {
+            for (const address of item.canSendFromAddrs) {
+                if (address.startsWith('phone:')) {
+                    return address;
+                }
+            }
+        }
+    }
+}
+exports.ContactBook = ContactBook;
+//# sourceMappingURL=contact-book.js.map

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 0
lib/contact-book.js.map


+ 32 - 0
src/contact-book.ts

@@ -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;
+        }
+      }
+    }
+  }
+
+  
+}