-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathlist-contacts.mjs
43 lines (40 loc) · 1.17 KB
/
list-contacts.mjs
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
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
export default {
type: "action",
key: "microsoft_outlook-list-contacts",
version: "0.0.13",
name: "List Contacts",
description: "Get a contact collection from the default contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
props: {
microsoftOutlook,
filterAddress: {
label: "Email Address",
description: "If this is given, only contacts with the given address will be retrieved.",
type: "string",
optional: true,
},
maxResults: {
propDefinition: [
microsoftOutlook,
"maxResults",
],
},
},
async run({ $ }) {
const items = this.microsoftOutlook.paginate({
fn: this.microsoftOutlook.listContacts,
args: {
$,
filterAddress: this.filterAddress,
},
max: this.maxResults,
});
const contacts = [];
for await (const item of items) {
contacts.push(item);
}
// eslint-disable-next-line multiline-ternary
$.export("$summary", `${contacts.length} contact${contacts.length != 1 ? "s" : ""} retrieved.`);
return contacts;
},
};