@@ -91,6 +91,54 @@ Function _deleteEvent($inParameters : Object) : Object // For test purposes onl
9191 // ----------------------------------------------------
9292
9393
94+ Function _insertAttachment ($inParameters : Object; $inAttachement : Object) : Object // For test purposes only (subject to changes, use at your own risk)
95+
96+ /*
97+ POST /me/events/{id}/attachments
98+ POST /users/{id | userPrincipalName}/events/{id}/attachments
99+
100+ POST /me/calendar/events/{id}/attachments
101+ POST /users/{id | userPrincipalName}/calendar/events/{id}/attachments
102+
103+ POST /me/calendars/{id}/events/{id}/attachments
104+ POST /users/{id | userPrincipalName}/calendars/{id}/events/{id}/attachments
105+ */
106+ Case of
107+ : (Value type ($inParameters .eventId )# Is text)
108+ Super ._throwError (10 ; {which: "\" eventId\" " ; function: "office365.calendar._insertAttachment" })
109+
110+ : (Length (String ($inParameters .eventId ))= 0)
111+ Super ._throwError (9 ; {which: "\" eventId\" " ; function: "office365.calendar._insertAttachment" })
112+
113+ Else
114+ var $headers : Object:= {Accept: "application/json" }
115+ var $urlParams : Text:= ""
116+
117+ If (Length (String (This .userId ))> 0)
118+ $urlParams := "users/" + This .userId
119+ Else
120+ $urlParams := "me"
121+ End if
122+
123+ If (Length (String ($inParameters .calendarId ))> 0)
124+ $urlParams + = "/calendars/" + cs .Tools .me .urlEncode ($inParameters .calendarId)
125+ Else
126+ $urlParams + = "/calendar"
127+ End if
128+ $urlParams + = "/events/" + cs .Tools .me .urlEncode ($inParameters .eventId)+ "/attachments"
129+
130+ var $URL : Text:= This ._getURL ()+ $urlParams
131+ var $response : Object:= Super ._sendRequestAndWaitResponse ("POST" ; $URL ; $headers ; $inAttachement )
132+
133+ return This ._returnStatus ($response )
134+ End case
135+
136+ return This ._returnStatus ()
137+
138+
139+ // ----------------------------------------------------
140+
141+
94142Function _insertEvent ($inParameters : Object; $inEvent : Object) : Object // For test purposes only (subject to changes, use at your own risk)
95143
96144/*
@@ -120,7 +168,29 @@ Function _insertEvent($inParameters : Object; $inEvent : Object) : Object // Fo
120168 $urlParams + = "/events"
121169
122170 var $URL : Text:= This ._getURL ()+ $urlParams
123- var $response : Object:= Super ._sendRequestAndWaitResponse ("POST" ; $URL ; $headers ; $inEvent )
171+ var $event : Object:= Super ._cleanGraphObject ($inEvent )
172+ var $attachments : Collection:= Null
173+
174+ If (Value type ($event .attachments )= Is collection) && ($event .attachments .length > 0)
175+ $attachments := $event .attachments
176+ OB REMOVE ($event ; "attachments" )
177+ End if
178+
179+ var $response : Object:= Super ._sendRequestAndWaitResponse ("POST" ; $URL ; $headers ; $event )
180+
181+ If ((Value type ($attachments )= Is collection) && ($attachments .length > 0))
182+
183+ var $params : Object:= {eventId: $response .id ; calendarId: String ($inParameters .calendarId )}
184+ var $attachment : Object
185+
186+ For each ($attachment; $attachments)
187+
188+ var $status : Object:= This ._insertAttachment ($params ; $attachment )
189+ If ($status .success = False)
190+ return This ._returnStatus ($status )
191+ End if
192+ End for each
193+ End if
124194
125195 return This ._returnStatus ($response )
126196
@@ -338,7 +408,7 @@ Function getEvents($inParameters : Object) : Object
338408 return $result
339409
340410 End case
341-
411+
342412 Super ._throwErrors (True )
343-
413+
344414 return This ._returnStatus ()
0 commit comments