diff --git a/components/goto_meeting/actions/create-meeting/create-meeting.mjs b/components/goto_meeting/actions/create-meeting/create-meeting.mjs new file mode 100644 index 0000000000000..bc2800704135c --- /dev/null +++ b/components/goto_meeting/actions/create-meeting/create-meeting.mjs @@ -0,0 +1,67 @@ +import { MEETING_TYPE_OPTIONS } from "../../common/constants.mjs"; +import { parseObject } from "../../common/utils.mjs"; +import app from "../../goto_meeting.app.mjs"; + +export default { + key: "goto_meeting-create-meeting", + name: "Create Meeting", + description: "Creates a scheduled meeting in GoTo Meeting. [See the documentation](https://developer.goto.com/GoToMeetingV1#tag/Meetings/operation/createMeeting)", + version: "0.0.1", + type: "action", + props: { + app, + subject: { + type: "string", + label: "Subject", + description: "The subject of the meeting", + }, + startTime: { + type: "string", + label: "Start Time", + description: "The start time of the meeting in ISO 8601 format", + }, + endTime: { + type: "string", + label: "End Time", + description: "The end time of the meeting in ISO 8601 format", + }, + passwordRequired: { + type: "boolean", + label: "Password Required", + description: "Whether a password is required to join the meeting", + }, + conferenceCallInfo: { + type: "string", + label: "Conference Call Info", + description: "Information for the conference call", + }, + meetingType: { + type: "string", + label: "Meeting Type", + description: "The type of the meeting", + options: MEETING_TYPE_OPTIONS, + }, + coorganizerKeys: { + type: "string[]", + label: "Co-Organizer Keys", + description: "Keys of the co-organizers for the meeting", + optional: true, + }, + }, + async run({ $ }) { + const meeting = await this.app.createScheduledMeeting({ + $, + data: { + subject: this.subject, + startTime: this.startTime, + endTime: this.endTime, + passwordRequired: this.passwordRequired, + conferenceCallInfo: this.conferenceCallInfo, + meetingType: this.meetingType, + coorganizerKeys: parseObject(this.coorganizerKeys), + }, + }); + $.export("$summary", `Meeting Created: ${meeting[0].meetingid}`); + return meeting; + }, +}; diff --git a/components/goto_meeting/common/constants.mjs b/components/goto_meeting/common/constants.mjs new file mode 100644 index 0000000000000..0e4cae27b44f7 --- /dev/null +++ b/components/goto_meeting/common/constants.mjs @@ -0,0 +1,14 @@ +export const MEETING_TYPE_OPTIONS = [ + { + label: "Scheduled", + value: "scheduled", + }, + { + label: "Instant", + value: "instant", + }, + { + label: "Recurring", + value: "recurring", + }, +]; diff --git a/components/goto_meeting/common/utils.mjs b/components/goto_meeting/common/utils.mjs new file mode 100644 index 0000000000000..dcc9cc61f6f41 --- /dev/null +++ b/components/goto_meeting/common/utils.mjs @@ -0,0 +1,24 @@ +export const parseObject = (obj) => { + if (!obj) return undefined; + + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === "string") { + try { + return JSON.parse(item); + } catch (e) { + return item; + } + } + return item; + }); + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch (e) { + return obj; + } + } + return obj; +}; diff --git a/components/goto_meeting/goto_meeting.app.mjs b/components/goto_meeting/goto_meeting.app.mjs index aae71d3197a52..a2c6f5c02b711 100644 --- a/components/goto_meeting/goto_meeting.app.mjs +++ b/components/goto_meeting/goto_meeting.app.mjs @@ -1,11 +1,38 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "goto_meeting", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.goto.com/meeting/v1"; + }, + _headers() { + return { + "Authorization": `Bearer ${this.$auth.oauth_access_token}`, + }; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + headers: this._headers(), + ...opts, + }); + }, + createScheduledMeeting(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/meetings", + ...opts, + }); + }, + listUpcomingMeetings(opts = {}) { + return this._makeRequest({ + path: "/upcomingMeetings", + ...opts, + }); }, }, }; diff --git a/components/goto_meeting/package.json b/components/goto_meeting/package.json index a3ecea1b93384..7ea52ea7cb1b6 100644 --- a/components/goto_meeting/package.json +++ b/components/goto_meeting/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/goto_meeting", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream GoTo Meeting Components", "main": "goto_meeting.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/goto_meeting/sources/new-meeting/new-meeting.mjs b/components/goto_meeting/sources/new-meeting/new-meeting.mjs new file mode 100644 index 0000000000000..6f9eec37c1e26 --- /dev/null +++ b/components/goto_meeting/sources/new-meeting/new-meeting.mjs @@ -0,0 +1,42 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import app from "../../goto_meeting.app.mjs"; + +export default { + key: "goto_meeting-new-meeting", + name: "New Meeting Created", + description: "Emit new event when a meeting is created in your GoToMeeting account.", + version: "0.0.1", + type: "source", + dedupe: "unique", + props: { + app, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + async emitEvent() { + const response = await this.app.listUpcomingMeetings(); + + for (const item of response) { + this.$emit(item, { + id: item.meetingId, + summary: `Meeting Created: ${item.meetingId}`, + ts: Date.now(), + }); + } + }, + }, + hooks: { + async deploy() { + await this.emitEvent(); + }, + }, + async run() { + await this.emitEvent(); + }, +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3183cb0fdb21a..713155d3aa882 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4580,7 +4580,11 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/goto_meeting: {} + components/goto_meeting: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/gotowebinar: dependencies: @@ -9279,8 +9283,7 @@ importers: specifier: 3.0.1 version: 3.0.1 - components/seen: - specifiers: {} + components/seen: {} components/segment: dependencies: