Skip to content

Commit a60f0f8

Browse files
authored
CalendarHero new components (#15921)
* pnpm * CalendarHero app/package * pnpm * Adding 'List Meetings' action * Adding 'List Meeting Types' action * Adding 'new event' webhook source * Small adjustments * adjustment
1 parent 88135ca commit a60f0f8

File tree

9 files changed

+214
-22
lines changed

9 files changed

+214
-22
lines changed

components/calendarhero/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../calendarhero.app.mjs";
2+
3+
export default {
4+
key: "calendarhero-list-meeting-types",
5+
name: "List Meeting Types",
6+
description: "Get the user's meeting types. [See the documentation](https://api.calendarhero.com/documentation#/user/getUserMeeting).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
async run({ $ }) {
13+
const response = await this.app.listMeetingTypes({
14+
$,
15+
});
16+
const { length } = Object.keys(response ?? {});
17+
$.export("$summary", `Successfully listed ${length} meeting type${length === 1
18+
? ""
19+
: "s"}`);
20+
return response;
21+
},
22+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import app from "../../calendarhero.app.mjs";
2+
3+
export default {
4+
key: "calendarhero-list-meetings",
5+
name: "List Meetings",
6+
description: "Get the user's meetings within a timeframe. [See the documentation](https://api.calendarhero.com/documentation#/meeting/getMeeting).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
start: {
12+
type: "string",
13+
label: "Start Date/Time",
14+
description: "Initial date/time of the period to list events, in ISO 8601 format, e.g. `2025-03-10T09:00:00Z`",
15+
},
16+
end: {
17+
type: "string",
18+
label: "End Date/Time",
19+
description: "End date/time of the period to list events, in ISO 8601 format, e.g. `2025-03-14T18:00:00Z`",
20+
},
21+
},
22+
async run({ $ }) {
23+
const {
24+
app, ...params
25+
} = this;
26+
const response = await app.listMeetings({
27+
$,
28+
params,
29+
});
30+
const { length } = response;
31+
$.export("$summary", `Successfully listed ${length} meeting${length === 1
32+
? ""
33+
: "s"}`);
34+
return response;
35+
},
36+
};

components/calendarhero/app/calendarhero.app.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { axios } from "@pipedream/platform";
2+
3+
export default {
4+
type: "app",
5+
app: "calendarhero",
6+
propDefinitions: {},
7+
methods: {
8+
async _makeRequest({
9+
$ = this, headers, ...args
10+
} = {}) {
11+
return axios($, {
12+
baseURL: "https://api.calendarhero.com",
13+
headers: {
14+
...headers,
15+
Authorization: `${this.$auth.api_key}`,
16+
},
17+
...args,
18+
});
19+
},
20+
listMeetings(args) {
21+
return this._makeRequest({
22+
url: "/meeting",
23+
...args,
24+
});
25+
},
26+
listMeetingTypes(args) {
27+
return this._makeRequest({
28+
url: "/user/meeting",
29+
...args,
30+
});
31+
},
32+
createWebhook({
33+
event, ...args
34+
}) {
35+
return this._makeRequest({
36+
method: "post",
37+
url: `webhook/${event}`,
38+
...args,
39+
});
40+
},
41+
deleteWebhook({
42+
event, ...args
43+
}) {
44+
return this._makeRequest({
45+
method: "delete",
46+
url: `webhook/${event}`,
47+
...args,
48+
});
49+
},
50+
},
51+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export const WEBHOOK_EVENT_TYPE_OPTIONS = [
2+
{
3+
label: "New Meeting Request",
4+
value: "new_meeting_request",
5+
},
6+
{
7+
label: "Meeting Request Succeeded",
8+
value: "meeting_request_success",
9+
},
10+
{
11+
label: "Meeting Request Expired",
12+
value: "meeting_request_expired",
13+
},
14+
{
15+
label: "Meeting Request Cancelled",
16+
value: "meeting_request_cancelled",
17+
},
18+
{
19+
label: "Meeting Rescheduled",
20+
value: "meeting_rescheduled",
21+
},
22+
{
23+
label: "Meeting Started",
24+
value: "meeting_started",
25+
},
26+
{
27+
label: "Meeting Completed",
28+
value: "meeting_completed",
29+
},
30+
{
31+
label: "New Contact Added",
32+
value: "new_contact_added",
33+
},
34+
];
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "@pipedream/calendarhero",
3-
"version": "0.0.3",
3+
"version": "0.1.0",
44
"description": "Pipedream CalendarHero Components",
5-
"main": "dist/app/calendarhero.app.mjs",
5+
"main": "calendarhero.app.mjs",
66
"keywords": [
77
"pipedream",
88
"calendarhero"
99
],
10-
"files": [
11-
"dist"
12-
],
1310
"homepage": "https://pipedream.com/apps/calendarhero",
1411
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1512
"publishConfig": {
1613
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1717
}
1818
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import app from "../../calendarhero.app.mjs";
2+
import { WEBHOOK_EVENT_TYPE_OPTIONS } from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "calendarhero-new-event-instant",
6+
name: "New Event (Instant)",
7+
description:
8+
"Emit new event when a selected type of CalendarHero event occurs. [See the documentation](https://api.calendarhero.com/documentation#/webhook/postWebhookEvent)",
9+
type: "source",
10+
version: "0.0.1",
11+
dedupe: "unique",
12+
props: {
13+
app,
14+
http: "$.interface.http",
15+
event: {
16+
type: "string",
17+
label: "Event Type",
18+
description: "Select the type of event that will trigger this source",
19+
options: WEBHOOK_EVENT_TYPE_OPTIONS,
20+
},
21+
},
22+
hooks: {
23+
async activate() {
24+
const {
25+
app,
26+
event,
27+
http: { endpoint: hookUrl },
28+
} = this;
29+
await app.createWebhook({
30+
event,
31+
data: {
32+
hookUrl,
33+
},
34+
});
35+
},
36+
async deactivate() {
37+
const {
38+
app,
39+
event,
40+
http: { endpoint: hookUrl },
41+
} = this;
42+
await app.deleteWebhook({
43+
event,
44+
data: {
45+
hookUrl,
46+
},
47+
});
48+
},
49+
},
50+
async run({ body }) {
51+
const ts = Date.now();
52+
const id = body.id ?? ts;
53+
this.$emit(body, {
54+
id,
55+
summary: `New event${id
56+
? ` (ID ${id})`
57+
: ""}`,
58+
ts,
59+
});
60+
},
61+
};

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)