Skip to content

Commit d4763f3

Browse files
Calendly - Improve List Events action and New Event Scheduled source (#17687)
* updates * pnpm-lock.yaml * versions * error handling * Fix invitee_email prop * updates * pnpm-lock.yaml --------- Co-authored-by: Leo Vu <[email protected]>
1 parent dbcd420 commit d4763f3

File tree

13 files changed

+208
-42
lines changed

13 files changed

+208
-42
lines changed

components/calendly_v2/actions/create-invitee-no-show/create-invitee-no-show.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "calendly_v2-create-invitee-no-show",
66
name: "Create Invitee No Show",
77
description: "Marks an Invitee as a No Show in Calendly. [See the documentation](https://calendly.stoplight.io/docs/api-docs/cebd8c3170790-create-invitee-no-show).",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
calendly,

components/calendly_v2/actions/create-scheduling-link/create-scheduling-link.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "calendly_v2-create-scheduling-link",
55
name: "Create a Scheduling Link",
66
description: "Creates a single-use scheduling link. [See the documentation](https://calendly.stoplight.io/docs/api-docs/b3A6MzQyNTM0OQ-create-single-use-scheduling-link)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
calendly,

components/calendly_v2/actions/get-event/get-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "calendly_v2-get-event",
77
name: "Get Event",
88
description: "Gets information about an Event associated with a URI. [See the documentation](https://developer.calendly.com/api-docs/e2f95ebd44914-get-event).",
9-
version: "0.1.5",
9+
version: "0.1.6",
1010
type: "action",
1111
props: {
1212
calendly,

components/calendly_v2/actions/list-event-invitees/list-event-invitees.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "calendly_v2-list-event-invitees",
55
name: "List Event Invitees",
66
description: "List invitees for an event. [See the documentation](https://calendly.stoplight.io/docs/api-docs/b3A6NTkxNDEx-list-event-invitees)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
calendly,

components/calendly_v2/actions/list-events/list-events.mjs

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,30 @@ export default {
44
key: "calendly_v2-list-events",
55
name: "List Events",
66
description: "List events for an user. [See the documentation](https://calendly.stoplight.io/docs/api-docs/b3A6NTkxNDEy-list-events)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
calendly,
11+
alert: {
12+
propDefinition: [
13+
calendly,
14+
"listEventsAlert",
15+
],
16+
},
17+
scope: {
18+
propDefinition: [
19+
calendly,
20+
"listEventsScope",
21+
],
22+
reloadProps: true,
23+
},
1124
organization: {
1225
propDefinition: [
1326
calendly,
1427
"organization",
1528
],
29+
optional: true,
30+
hidden: true,
1631
},
1732
user: {
1833
propDefinition: [
@@ -24,6 +39,19 @@ export default {
2439
],
2540
description: "Returns events for a specified user",
2641
optional: true,
42+
hidden: true,
43+
},
44+
group: {
45+
propDefinition: [
46+
calendly,
47+
"groupId",
48+
(c) => ({
49+
organization: c.organization,
50+
}),
51+
],
52+
description: "Returns events for a specified group",
53+
optional: true,
54+
hidden: true,
2755
},
2856
inviteeEmail: {
2957
propDefinition: [
@@ -51,14 +79,26 @@ export default {
5179
],
5280
},
5381
},
82+
async additionalProps(props) {
83+
return this.calendly.listEventsAdditionalProps(props, this.scope);
84+
},
5485
async run({ $ }) {
5586
const params = {
56-
organization: this.organization,
87+
invitee_email: this.inviteeEmail,
88+
status: this.status,
89+
paginate: this.paginate,
90+
maxResults: this.maxResults,
5791
};
58-
if (this.inviteeEmail) params.invitee_email = this.inviteeEmail;
59-
if (this.status) params.status = this.status;
60-
if (this.paginate) params.paginate = this.paginate;
61-
if (this.maxResults) params.maxResults = this.maxResults;
92+
93+
if (this.scope !== "authenticatedUser") {
94+
params.organization = this.organization;
95+
}
96+
if (this.scope === "user") {
97+
params.user = this.user;
98+
}
99+
if (this.scope === "group") {
100+
params.group = this.group;
101+
}
62102

63103
const response = await this.calendly.listEvents(params, this.user, $);
64104
$.export("$summary", `Found ${response.pagination.count} event(s)`);

components/calendly_v2/actions/list-user-availability-schedules/list-user-availability-schedules.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "calendly_v2-list-user-availability-schedules",
55
name: "List User Availability Schedules",
66
description: "List the availability schedules of the given user. [See the documentation](https://developer.calendly.com/api-docs/8098de44af94c-list-user-availability-schedules)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
calendly,

components/calendly_v2/calendly_v2.app.mjs

Lines changed: 83 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ export default {
5656
});
5757
},
5858
},
59+
groupId: {
60+
type: "string",
61+
label: "Group ID",
62+
description: "A group UUID",
63+
async options({
64+
prevContext, organization,
65+
}) {
66+
prevContext.organization = organization;
67+
return await this._makeAsyncOptionsRequest({
68+
prevContext,
69+
requestType: "listGroups",
70+
optionsCallbackFn: this._getNameOptions,
71+
});
72+
},
73+
},
5974
inviteeEmail: {
6075
type: "string",
6176
label: "Inviteee Email",
@@ -93,6 +108,22 @@ export default {
93108
description: "Indicates if the webhook subscription scope will be `organization` or `user`",
94109
options: constants.scopes,
95110
},
111+
listEventsScope: {
112+
type: "string",
113+
label: "Scope",
114+
description: "The scope to fetch events for",
115+
options: constants.listEventsScopes,
116+
default: "authenticatedUser",
117+
},
118+
listEventsAlert: {
119+
type: "alert",
120+
alertType: "info",
121+
content: `
122+
Select "authenticatedUser" scope to return events for the authenticated user
123+
Select "organization" scope to return events for that organization (requires admin/owner privilege)
124+
Select "user" scope to return events for a specific User in your organization (requires admin/owner privilege)
125+
Select "group" scope to return events for a specific Group (requires organization admin/owner or group admin privilege)`,
126+
},
96127
},
97128
methods: {
98129
_baseUri() {
@@ -101,6 +132,9 @@ export default {
101132
_buildUserUri(user) {
102133
return `${this._baseUri()}/users/${user}`;
103134
},
135+
_buildGroupUri(group) {
136+
return `${this._baseUri()}/groups/${group}`;
137+
},
104138
_buildEventType(eventType) {
105139
return `${this._baseUri()}/event_types/${eventType}`;
106140
},
@@ -184,23 +218,27 @@ export default {
184218
delete opts.params.paginate;
185219
delete opts.params.maxResults;
186220

187-
do {
188-
const res = await axios(
189-
$ ?? this,
190-
this._makeRequestOpts(opts),
191-
);
192-
response.collection.push(...res.collection);
193-
response.pagination.count += res.pagination.count;
194-
response.pagination.next_page = res.pagination.next_page;
195-
opts.params.page_token = this._extractNextPageToken(res.pagination.next_page);
196-
} while (paginate && opts.params.page_token && response.collection.length < maxResults);
221+
try {
222+
do {
223+
const res = await axios(
224+
$ ?? this,
225+
this._makeRequestOpts(opts),
226+
);
227+
response.collection.push(...res.collection);
228+
response.pagination.count += res.pagination.count;
229+
response.pagination.next_page = res.pagination.next_page;
230+
opts.params.page_token = this._extractNextPageToken(res.pagination.next_page);
231+
} while (paginate && opts.params.page_token && response.collection.length < maxResults);
197232

198-
if (response.collection.length > maxResults) {
199-
response.collection.length = maxResults;
200-
response.pagination.count = maxResults;
201-
}
233+
if (response.collection.length > maxResults) {
234+
response.collection.length = maxResults;
235+
response.pagination.count = maxResults;
236+
}
202237

203-
return response;
238+
return response;
239+
} catch (error) {
240+
throw new Error(`${error.response.data.title} - ${error.response.data.message}`);
241+
}
204242
},
205243
async getUserInfo(user, $) {
206244
const opts = {
@@ -239,18 +277,19 @@ export default {
239277
);
240278
},
241279
async listEvents(params, uuid, $) {
242-
const user = uuid
243-
? this._buildUserUri(uuid)
244-
: !params?.organization
245-
? await this.defaultUser($)
246-
: undefined;
280+
if (uuid) {
281+
params.user = this._buildUserUri(uuid);
282+
}
283+
if (params.group) {
284+
params.group = this._buildGroupUri(params.group);
285+
}
286+
if (!params.organization && !params.group && !params.user) {
287+
params.user = await this.defaultUser($);
288+
}
247289

248290
const opts = {
249291
path: "/scheduled_events",
250-
params: {
251-
user,
252-
...params,
253-
},
292+
params,
254293
};
255294

256295
return this._makeRequest(opts, $);
@@ -298,6 +337,14 @@ export default {
298337

299338
return this._makeRequest(opts, $);
300339
},
340+
async listGroups(params, $) {
341+
const opts = {
342+
path: "/groups",
343+
params,
344+
};
345+
346+
return this._makeRequest(opts, $);
347+
},
301348
async createSchedulingLink(params, $) {
302349
params.owner = this._buildEventType(params.owner);
303350

@@ -344,5 +391,17 @@ export default {
344391
this._makeRequestOpts(opts),
345392
);
346393
},
394+
listEventsAdditionalProps(props, scope) {
395+
props.organization.hidden = scope === "authenticatedUser";
396+
props.organization.optional = scope === "authenticatedUser";
397+
398+
props.group.hidden = scope !== "group";
399+
props.group.optional = scope !== "group";
400+
401+
props.user.hidden = scope !== "user";
402+
props.user.optional = scope !== "user";
403+
404+
return {};
405+
},
347406
},
348407
};

components/calendly_v2/common/constants.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ export default {
77
"active",
88
"canceled",
99
],
10+
listEventsScopes: [
11+
"authenticatedUser",
12+
"organization",
13+
"user",
14+
"group",
15+
],
1016
};

components/calendly_v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/calendly_v2",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Pipedream Calendly V2 Components",
55
"main": "calendly_v2.app.mjs",
66
"keywords": [

components/calendly_v2/sources/invitee-canceled/invitee-canceled.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "calendly_v2-invitee-canceled",
66
name: "New Invitee Canceled",
77
description: "Emit new event when an event is canceled.",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "source",
1010
dedupe: "unique",
1111
props: {

0 commit comments

Comments
 (0)