Skip to content

Commit 024ff89

Browse files
committed
Create Contact action
1 parent ec18b1c commit 024ff89

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import ringcentral from "../../ringcentral.app.mjs";
2+
3+
export default {
4+
key: "ringcentral-create-contact",
5+
name: "Create Contact",
6+
description: "Creates a user personal contact. [See the documentation](https://developers.ringcentral.com/api-reference/External-Contacts/createContact)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
ringcentral,
11+
accountId: {
12+
propDefinition: [
13+
ringcentral,
14+
"accountId",
15+
],
16+
},
17+
extensionId: {
18+
propDefinition: [
19+
ringcentral,
20+
"extensionId",
21+
],
22+
description: "Internal identifier of the RingCentral extension/user",
23+
},
24+
email: {
25+
type: "string",
26+
label: "Email",
27+
description: "Email address of the contact",
28+
optional: true,
29+
},
30+
firstName: {
31+
type: "string",
32+
label: "First Name",
33+
description: "First name of the contact",
34+
optional: true,
35+
},
36+
lastName: {
37+
type: "string",
38+
label: "Last Name",
39+
description: "Last name of the contact",
40+
optional: true,
41+
},
42+
mobilePhone: {
43+
type: "string",
44+
label: "Mobile Phone",
45+
description: "Mobile phone of the contact",
46+
optional: true,
47+
},
48+
additionalOptions: {
49+
type: "object",
50+
label: "Additional Options",
51+
description: "Additional parameters to set for the contact. [See the documentation](https://developers.ringcentral.com/api-reference/External-Contacts/createContact) for all available parameters. Example: `{ \"notes\": \"Notes for the contact\" }`",
52+
optional: true,
53+
},
54+
},
55+
methods: {
56+
createContact({
57+
accountId, extensionId, ...args
58+
}) {
59+
return this.ringcentral.makeRequest({
60+
method: "POST",
61+
path: `/account/${accountId}/extension/${extensionId}/address-book/contact`,
62+
...args,
63+
});
64+
},
65+
},
66+
async run({ $ }) {
67+
const { // eslint-disable-next-line no-unused-vars
68+
ringcentral, createContact, accountId, extensionId, additionalOptions, ...data
69+
} = this;
70+
71+
const response =
72+
await createContact({
73+
$,
74+
accountId,
75+
extensionId,
76+
data: {
77+
...data,
78+
...additionalOptions,
79+
},
80+
});
81+
82+
$.export("$summary", `Successfully created contact (ID: ${response.id})`);
83+
return response;
84+
},
85+
};

0 commit comments

Comments
 (0)