Skip to content

Commit f456e6e

Browse files
committed
goto_meeting init
1 parent 4546757 commit f456e6e

File tree

4 files changed

+368
-3
lines changed

4 files changed

+368
-3
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import goto_meeting from "../../goto_meeting.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "goto_meeting-create-meeting",
6+
name: "Create Meeting",
7+
description: "Creates a scheduled meeting in GoTo Meeting. [See the documentation](), ",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
goto_meeting: {
12+
type: "app",
13+
app: "goto_meeting",
14+
},
15+
subject: {
16+
propDefinition: [
17+
goto_meeting,
18+
"subject",
19+
],
20+
},
21+
startTime: {
22+
propDefinition: [
23+
goto_meeting,
24+
"startTime",
25+
],
26+
},
27+
endTime: {
28+
propDefinition: [
29+
goto_meeting,
30+
"endTime",
31+
],
32+
},
33+
passwordRequired: {
34+
propDefinition: [
35+
goto_meeting,
36+
"passwordRequired",
37+
],
38+
},
39+
conferenceCallInfo: {
40+
propDefinition: [
41+
goto_meeting,
42+
"conferenceCallInfo",
43+
],
44+
},
45+
meetingType: {
46+
propDefinition: [
47+
goto_meeting,
48+
"meetingType",
49+
],
50+
},
51+
timezoneKey: {
52+
propDefinition: [
53+
goto_meeting,
54+
"timezoneKey",
55+
],
56+
optional: true,
57+
},
58+
coorganizerKeys: {
59+
propDefinition: [
60+
goto_meeting,
61+
"coorganizerKeys",
62+
],
63+
optional: true,
64+
},
65+
},
66+
async run({ $ }) {
67+
const meeting = await this.goto_meeting.createScheduledMeeting({
68+
subject: this.subject,
69+
startTime: this.startTime,
70+
endTime: this.endTime,
71+
passwordRequired: this.passwordRequired,
72+
conferenceCallInfo: this.conferenceCallInfo,
73+
meetingType: this.meetingType,
74+
timezoneKey: this.timezoneKey,
75+
coorganizerKeys: this.coorganizerKeys,
76+
});
77+
$.export("$summary", `Meeting Created: ${meeting.subject}`);
78+
return meeting;
79+
},
80+
};
Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,157 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "goto_meeting",
4-
propDefinitions: {},
6+
version: "0.0.{{ts}}",
7+
propDefinitions: {
8+
subject: {
9+
type: "string",
10+
label: "Subject",
11+
description: "The subject of the meeting",
12+
},
13+
startTime: {
14+
type: "string",
15+
label: "Start Time",
16+
description: "The start time of the meeting in ISO 8601 format",
17+
},
18+
endTime: {
19+
type: "string",
20+
label: "End Time",
21+
description: "The end time of the meeting in ISO 8601 format",
22+
},
23+
passwordRequired: {
24+
type: "boolean",
25+
label: "Password Required",
26+
description: "Whether a password is required to join the meeting",
27+
},
28+
conferenceCallInfo: {
29+
type: "string",
30+
label: "Conference Call Info",
31+
description: "Information for the conference call",
32+
},
33+
meetingType: {
34+
type: "string",
35+
label: "Meeting Type",
36+
description: "The type of the meeting",
37+
options: [
38+
{
39+
label: "Scheduled",
40+
value: "scheduled",
41+
},
42+
{
43+
label: "Instant",
44+
value: "instant",
45+
},
46+
{
47+
label: "Recurring",
48+
value: "recurring",
49+
},
50+
],
51+
},
52+
timezoneKey: {
53+
type: "string",
54+
label: "Timezone Key",
55+
description: "The timezone key for the meeting time",
56+
optional: true,
57+
},
58+
coorganizerKeys: {
59+
type: "string[]",
60+
label: "Co-Organizer Keys",
61+
description: "Keys of the co-organizers for the meeting",
62+
optional: true,
63+
async options() {
64+
const coorganizers = await this.listCoOrganizers();
65+
return coorganizers.map((coorganizer) => ({
66+
label: coorganizer.name,
67+
value: coorganizer.id,
68+
}));
69+
},
70+
},
71+
},
572
methods: {
6-
// this.$auth contains connected account data
73+
// Existing method
774
authKeys() {
875
console.log(Object.keys(this.$auth));
976
},
77+
_baseUrl() {
78+
return "https://api.goto.com/meeting/v1";
79+
},
80+
async _makeRequest(opts = {}) {
81+
const {
82+
$ = this,
83+
method = "GET",
84+
path = "/",
85+
headers = {},
86+
...otherOpts
87+
} = opts;
88+
return axios($, {
89+
...otherOpts,
90+
method,
91+
url: this._baseUrl() + path,
92+
headers: {
93+
...headers,
94+
"Authorization": `Bearer ${this.$auth.access_token}`,
95+
"Content-Type": "application/json",
96+
},
97+
});
98+
},
99+
async createScheduledMeeting({
100+
subject, startTime, endTime, passwordRequired, conferenceCallInfo, meetingType, timezoneKey, coorganizerKeys,
101+
}) {
102+
const data = {
103+
subject: this.subject,
104+
startTime: this.startTime,
105+
endTime: this.endTime,
106+
passwordRequired: this.passwordRequired,
107+
conferenceCallInfo: this.conferenceCallInfo,
108+
meetingType: this.meetingType,
109+
};
110+
if (this.timezoneKey) {
111+
data.timezoneKey = this.timezoneKey;
112+
}
113+
if (this.coorganizerKeys && this.coorganizerKeys.length > 0) {
114+
data.coorganizerKeys = this.coorganizerKeys;
115+
}
116+
const meeting = await this._makeRequest({
117+
method: "POST",
118+
path: "/meetings",
119+
data,
120+
});
121+
this.emitMeetingCreated(meeting);
122+
return meeting;
123+
},
124+
async listCoOrganizers() {
125+
return this._makeRequest({
126+
method: "GET",
127+
path: "/users/coorganizers",
128+
});
129+
},
130+
emitMeetingCreated(meeting) {
131+
this.$emit(meeting, {
132+
summary: `Meeting Created: ${meeting.subject}`,
133+
id: meeting.id,
134+
});
135+
},
136+
async paginate(fn, ...opts) {
137+
const results = [];
138+
let hasMore = true;
139+
let page = 1;
140+
141+
while (hasMore) {
142+
const response = await fn({
143+
...opts,
144+
page,
145+
});
146+
if (response && response.length > 0) {
147+
results.push(...response);
148+
page += 1;
149+
} else {
150+
hasMore = false;
151+
}
152+
}
153+
154+
return results;
155+
},
10156
},
11157
};

components/goto_meeting/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import goto_meeting from "../../goto_meeting.app.mjs";
2+
import {
3+
axios, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
4+
} from "@pipedream/platform";
5+
6+
export default {
7+
key: "goto_meeting-new-meeting",
8+
name: "New Meeting Created",
9+
description: "Emit a new event when a meeting is created in your GoToMeeting account. [See the documentation]()",
10+
version: "0.0.{{ts}}",
11+
type: "source",
12+
dedupe: "unique",
13+
props: {
14+
goto_meeting: {
15+
type: "app",
16+
app: "goto_meeting",
17+
},
18+
db: "$.service.db",
19+
timer: {
20+
type: "$.interface.timer",
21+
default: {
22+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
23+
},
24+
},
25+
},
26+
hooks: {
27+
async deploy() {
28+
const MAX_EVENTS = 50;
29+
let page = 1;
30+
const fetchedMeetings = [];
31+
32+
while (fetchedMeetings.length < MAX_EVENTS) {
33+
const meetings = await this.goto_meeting._makeRequest({
34+
method: "GET",
35+
path: "/meetings",
36+
params: {
37+
page,
38+
perPage: 50,
39+
orderBy: "created",
40+
order: "desc",
41+
},
42+
});
43+
44+
if (meetings.length === 0) {
45+
break;
46+
}
47+
48+
fetchedMeetings.push(...meetings);
49+
50+
if (meetings.length < 50) {
51+
break;
52+
}
53+
54+
page += 1;
55+
}
56+
57+
const recentMeetings = fetchedMeetings.slice(0, MAX_EVENTS).reverse();
58+
59+
for (const meeting of recentMeetings) {
60+
this.$emit(meeting, {
61+
id: meeting.id || meeting.created,
62+
summary: `Meeting Created: ${meeting.subject}`,
63+
ts: meeting.created
64+
? Date.parse(meeting.created)
65+
: Date.now(),
66+
});
67+
}
68+
69+
const lastMeeting = fetchedMeetings[0];
70+
const lastTimestamp = lastMeeting.created
71+
? Date.parse(lastMeeting.created)
72+
: Date.now();
73+
await this.db.set("lastTimestamp", lastTimestamp);
74+
},
75+
async activate() {
76+
// Add activation logic if needed
77+
},
78+
async deactivate() {
79+
// Add deactivation logic if needed
80+
},
81+
},
82+
async run() {
83+
const lastTimestamp = (await this.db.get("lastTimestamp")) || 0;
84+
let page = 1;
85+
const newMeetings = [];
86+
87+
while (true) {
88+
const meetings = await this.goto_meeting._makeRequest({
89+
method: "GET",
90+
path: "/meetings",
91+
params: {
92+
page,
93+
perPage: 50,
94+
orderBy: "created",
95+
order: "desc",
96+
},
97+
});
98+
99+
if (meetings.length === 0) {
100+
break;
101+
}
102+
103+
for (const meeting of meetings) {
104+
const meetingTimestamp = meeting.created
105+
? Date.parse(meeting.created)
106+
: Date.now();
107+
if (meetingTimestamp > lastTimestamp) {
108+
newMeetings.push(meeting);
109+
} else {
110+
break;
111+
}
112+
}
113+
114+
if (meetings.length < 50) {
115+
break;
116+
}
117+
118+
page += 1;
119+
}
120+
121+
if (newMeetings.length > 0) {
122+
for (const meeting of newMeetings.reverse()) {
123+
this.$emit(meeting, {
124+
id: meeting.id || meeting.created,
125+
summary: `Meeting Created: ${meeting.subject}`,
126+
ts: meeting.created
127+
? Date.parse(meeting.created)
128+
: Date.now(),
129+
});
130+
}
131+
132+
const latestMeeting = newMeetings[0];
133+
const latestTimestamp = latestMeeting.created
134+
? Date.parse(latestMeeting.created)
135+
: Date.now();
136+
await this.db.set("lastTimestamp", latestTimestamp);
137+
}
138+
},
139+
};

0 commit comments

Comments
 (0)