Skip to content

Commit d1e4879

Browse files
Ringcentral new action (#16313)
* package / pnpm bumps * Create Contact action * Adding optional JSON parsing * version --------- Co-authored-by: michelle0927 <michellelbergero@hotmail.com>
1 parent ece4738 commit d1e4879

File tree

5 files changed

+115
-5
lines changed

5 files changed

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

components/ringcentral/actions/send-sms/send-sms.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "ringcentral-send-sms",
66
name: "Send SMS",
77
description: "Creates and sends a new text message. See the API docs [here](https://developers.ringcentral.com/api-reference/SMS/createSMSMessage)",
8-
version: "0.5.1",
8+
version: "0.5.2",
99
type: "action",
1010
props: {
1111
ringcentral,

components/ringcentral/common/utils.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,32 @@ function parse(value) {
4747
}
4848
}
4949

50+
function optionalParseAsJSON(value) {
51+
try {
52+
return JSON.parse(value);
53+
} catch (e) {
54+
return value;
55+
}
56+
}
57+
58+
function parseObjectEntries(value) {
59+
const obj = typeof value === "string"
60+
? JSON.parse(value)
61+
: value;
62+
return Object.fromEntries(
63+
Object.entries(obj).map(([
64+
key,
65+
value,
66+
]) => [
67+
key,
68+
optionalParseAsJSON(value),
69+
]),
70+
);
71+
}
72+
5073
export default {
5174
emptyStrToUndefined,
5275
parse,
5376
emptyObjectToUndefined,
77+
parseObjectEntries,
5478
};

components/ringcentral/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/ringcentral",
3-
"version": "0.4.1",
3+
"version": "0.5.0",
44
"description": "Pipedream Ringcentral Components",
55
"main": "ringcentral.app.mjs",
66
"keywords": [
@@ -14,6 +14,6 @@
1414
"access": "public"
1515
},
1616
"dependencies": {
17-
"@pipedream/platform": "^1.2.0"
17+
"@pipedream/platform": "^3.0.3"
1818
}
1919
}

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)