11import addToCalendarPro from "../../add_to_calendar_pro.app.mjs" ;
2+ import { ConfigurationError } from "@pipedream/platform" ;
23
34export default {
45 key : "add_to_calendar_pro-create-event" ,
@@ -13,53 +14,79 @@ export default {
1314 addToCalendarPro ,
1415 "groupProKey" ,
1516 ] ,
17+ description : "The pro key of the group to add the event to. Either this or newEventGroupName is required." ,
18+ optional : true ,
19+ } ,
20+ newEventGroupName : {
21+ type : "string" ,
22+ label : "New Event Group Name" ,
23+ description : "Create a new group for the event with the name provided. Either this or groupProKey is required." ,
24+ optional : true ,
25+ } ,
26+ titleEventSeries : {
27+ propDefinition : [
28+ addToCalendarPro ,
29+ "titleEventSeries" ,
30+ ] ,
31+ } ,
32+ simplifiedRecurrence : {
33+ propDefinition : [
34+ addToCalendarPro ,
35+ "simplifiedRecurrence" ,
36+ ] ,
37+ } ,
38+ recurrence : {
39+ propDefinition : [
40+ addToCalendarPro ,
41+ "recurrence" ,
42+ ] ,
1643 } ,
17- name : {
44+ recurrenceSimpleType : {
1845 propDefinition : [
1946 addToCalendarPro ,
20- "eventName " ,
47+ "recurrenceSimpleType " ,
2148 ] ,
2249 } ,
23- startDate : {
50+ recurrenceInterval : {
2451 propDefinition : [
2552 addToCalendarPro ,
26- "startDate " ,
53+ "recurrenceInterval " ,
2754 ] ,
2855 } ,
29- startTime : {
56+ recurrenceByDay : {
3057 propDefinition : [
3158 addToCalendarPro ,
32- "startTime " ,
59+ "recurrenceByDay " ,
3360 ] ,
3461 } ,
35- endDate : {
62+ recurrenceByMonth : {
3663 propDefinition : [
3764 addToCalendarPro ,
38- "endDate " ,
65+ "recurrenceByMonth " ,
3966 ] ,
4067 } ,
41- endTime : {
68+ recurrenceByMonthDay : {
4269 propDefinition : [
4370 addToCalendarPro ,
44- "endTime " ,
71+ "recurrenceByMonthDay " ,
4572 ] ,
4673 } ,
47- timeZone : {
74+ recurrenceCount : {
4875 propDefinition : [
4976 addToCalendarPro ,
50- "timeZone " ,
77+ "recurrenceCount " ,
5178 ] ,
5279 } ,
53- description : {
80+ recurrenceWeekStart : {
5481 propDefinition : [
5582 addToCalendarPro ,
56- "description " ,
83+ "recurrenceWeekStart " ,
5784 ] ,
5885 } ,
59- location : {
86+ iCalFileName : {
6087 propDefinition : [
6188 addToCalendarPro ,
62- "location " ,
89+ "iCalFileName " ,
6390 ] ,
6491 } ,
6592 rsvp : {
@@ -99,28 +126,164 @@ export default {
99126 ] ,
100127 optional : true ,
101128 } ,
129+ rsvpTemplateId : {
130+ propDefinition : [
131+ addToCalendarPro ,
132+ "rsvpTemplateId" ,
133+ ] ,
134+ optional : true ,
135+ } ,
136+ ctaTemplateId : {
137+ propDefinition : [
138+ addToCalendarPro ,
139+ "ctaTemplateId" ,
140+ ] ,
141+ optional : true ,
142+ } ,
143+ numberOfDates : {
144+ type : "integer" ,
145+ label : "Number of Dates" ,
146+ description : "The number of dates to create for the event" ,
147+ reloadProps : true ,
148+ } ,
149+ } ,
150+ additionalProps ( ) {
151+ const props = { } ;
152+ if ( ! this . numberOfDates ) {
153+ return props ;
154+ }
155+ for ( let i = 0 ; i < this . numberOfDates ; i ++ ) {
156+ props [ `name${ i } ` ] = {
157+ type : "string" ,
158+ label : `Title of Date ${ i + 1 } ` ,
159+ description : `The title of Date ${ i + 1 } ` ,
160+ } ;
161+ props [ `startDate${ i } ` ] = {
162+ type : "string" ,
163+ label : `Start Date of Date ${ i + 1 } ` ,
164+ description : `The start date of Date ${ i + 1 } in format YYYY-MM-DD` ,
165+ } ;
166+ props [ `startTime${ i } ` ] = {
167+ type : "string" ,
168+ label : `Start Time of Date ${ i + 1 } ` ,
169+ description : `The start time of Date ${ i + 1 } in format HH:MM` ,
170+ optional : true ,
171+ } ;
172+ props [ `endDate${ i } ` ] = {
173+ type : "string" ,
174+ label : `End Date of Date ${ i + 1 } ` ,
175+ description : `The end date of Date ${ i + 1 } in format YYYY-MM-DD` ,
176+ optional : true ,
177+ } ;
178+ props [ `endTime${ i } ` ] = {
179+ type : "string" ,
180+ label : `End Time of Date ${ i + 1 } ` ,
181+ description : `The end time of Date ${ i + 1 } in format HH:MM` ,
182+ optional : true ,
183+ } ;
184+ props [ `timeZone${ i } ` ] = {
185+ type : "string" ,
186+ label : `Time Zone of Date ${ i + 1 } ` ,
187+ description : `The time zone of Date ${ i + 1 } . Example: "America/Los_Angeles"` ,
188+ optional : true ,
189+ } ;
190+ props [ `description${ i } ` ] = {
191+ type : "string" ,
192+ label : `Description of Date ${ i + 1 } ` ,
193+ description : `The description of Date ${ i + 1 } ` ,
194+ optional : true ,
195+ } ;
196+ props [ `location${ i } ` ] = {
197+ type : "string" ,
198+ label : `Location of Date ${ i + 1 } ` ,
199+ description : `The location of Date ${ i + 1 } ` ,
200+ optional : true ,
201+ } ;
202+ props [ `availability${ i } ` ] = {
203+ type : "string" ,
204+ label : `Availability of Date ${ i + 1 } ` ,
205+ description : `The availability of Date ${ i + 1 } ` ,
206+ options : [
207+ "free" ,
208+ "busy" ,
209+ ] ,
210+ optional : true ,
211+ } ;
212+ props [ `organizerName${ i } ` ] = {
213+ type : "string" ,
214+ label : `Organizer Name of Date ${ i + 1 } ` ,
215+ description : `The organizer name of Date ${ i + 1 } ` ,
216+ optional : true ,
217+ } ;
218+ props [ `organizerEmail${ i } ` ] = {
219+ type : "string" ,
220+ label : `Organizer Email of Date ${ i + 1 } ` ,
221+ description : `The organizer email of Date ${ i + 1 } ` ,
222+ optional : true ,
223+ } ;
224+ props [ `attendeeName${ i } ` ] = {
225+ type : "string" ,
226+ label : `Attendee Name of Date ${ i + 1 } ` ,
227+ description : `The attendee name of Date ${ i + 1 } ` ,
228+ optional : true ,
229+ } ;
230+ props [ `attendeeEmail${ i } ` ] = {
231+ type : "string" ,
232+ label : `Attendee Email of Date ${ i + 1 } ` ,
233+ description : `The attendee email of Date ${ i + 1 } ` ,
234+ optional : true ,
235+ } ;
236+ }
237+ return props ;
102238 } ,
103239 async run ( { $ } ) {
240+ if ( ! this . groupProKey && ! this . newEventGroupName ) {
241+ throw new ConfigurationError ( "Either `groupProKey` or `newEventGroupName` is required." ) ;
242+ }
243+ if ( this . groupProKey && this . newEventGroupName ) {
244+ throw new ConfigurationError ( "Only one of `groupProKey` or `newEventGroupName` can be provided." ) ;
245+ }
246+ const dates = [ ] ;
247+ for ( let i = 0 ; i < this . numberOfDates ; i ++ ) {
248+ dates . push ( {
249+ name : this [ `name${ i } ` ] ,
250+ startDate : this [ `startDate${ i } ` ] ,
251+ startTime : this [ `startTime${ i } ` ] ,
252+ endDate : this [ `endDate${ i } ` ] ,
253+ endTime : this [ `endTime${ i } ` ] ,
254+ timeZone : this [ `timeZone${ i } ` ] ,
255+ description : this [ `description${ i } ` ] ,
256+ location : this [ `location${ i } ` ] ,
257+ availability : this [ `availability${ i } ` ] ,
258+ organizerName : this [ `organizerName${ i } ` ] ,
259+ organizerEmail : this [ `organizerEmail${ i } ` ] ,
260+ attendeeName : this [ `attendeeName${ i } ` ] ,
261+ attendeeEmail : this [ `attendeeEmail${ i } ` ] ,
262+ } ) ;
263+ }
104264 const event = await this . addToCalendarPro . createEvent ( {
105265 $,
106266 data : {
107267 event_group : this . groupProKey ,
108- dates : [
109- {
110- name : this . name ,
111- startDate : this . startDate ,
112- startTime : this . startTime ,
113- endDate : this . endDate ,
114- endTime : this . endTime ,
115- timeZone : this . timeZone ,
116- description : this . description ,
117- location : this . location ,
118- } ,
119- ] ,
268+ new_event_group_name : this . newEventGroupName ,
269+ dates,
270+ title_event_series : this . titleEventSeries ,
271+ simplified_recurrence : this . simplifiedRecurrence ,
272+ recurrence : this . recurrence ,
273+ recurrence_simple_type : this . recurrenceSimpleType ,
274+ recurrence_interval : this . recurrenceInterval ,
275+ recurrence_byDay : this . recurrenceByDay ,
276+ recurrence_byMonth : this . recurrenceByMonth ,
277+ recurrence_byMonthDay : this . recurrenceByMonthDay ,
278+ recurrence_count : this . recurrenceCount ,
279+ recurrence_weekstart : this . recurrenceWeekStart ,
280+ iCalFileName : this . iCalFileName ,
120281 rsvp : this . rsvp ,
282+ rsvp_block : this . rsvpTemplateId ,
121283 distribution : this . distribution ,
122284 hideButton : this . hideButton ,
123285 cta : this . cta ,
286+ cta_block : this . ctaTemplateId ,
124287 layout : this . styleId ,
125288 landingpage : this . landingPageTemplateId ,
126289 } ,
0 commit comments