From 9d75d2b3b4aafcdeca276de93301ddf8c5e2276f Mon Sep 17 00:00:00 2001 From: BhaskarM Date: Thu, 24 May 2018 11:12:55 +0530 Subject: [PATCH 1/3] Adding calendar event delete functionality in gapi.calendar wrapper --- types/gapi.calendar/index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/gapi.calendar/index.d.ts b/types/gapi.calendar/index.d.ts index b13106b9e3..a6a0385661 100644 --- a/types/gapi.calendar/index.d.ts +++ b/types/gapi.calendar/index.d.ts @@ -271,6 +271,7 @@ declare namespace gapi.client.calendar { static insert(parameters: EventsInsertParameters): HttpRequest; static update(parameters: EventsUpdateParameters): HttpRequest; static get(parameters: EventsGetParameters): HttpRequest; + static delete(parameters: EventsDeleteParameters): HttpRequest; } interface EventsGetParameters { @@ -306,6 +307,13 @@ declare namespace gapi.client.calendar { resource: EventInput; } + interface EventsDeleteParameters { + calendarId: string; + eventId: string; + + sendNotifications?: boolean; + } + interface EventInput { // Required Properties attachments?: { From 0abb7f4199f9fcf27d5944e850821530226812c1 Mon Sep 17 00:00:00 2001 From: BhaskarM Date: Mon, 28 May 2018 16:22:03 +0530 Subject: [PATCH 2/3] adding documentation and tests --- types/gapi.calendar/gapi.calendar-tests.ts | 25 ++++++++++++++++++++++ types/gapi.calendar/index.d.ts | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/types/gapi.calendar/gapi.calendar-tests.ts b/types/gapi.calendar/gapi.calendar-tests.ts index bd42483df5..0b40d30792 100644 --- a/types/gapi.calendar/gapi.calendar-tests.ts +++ b/types/gapi.calendar/gapi.calendar-tests.ts @@ -149,4 +149,29 @@ request.execute(function(event) { appendPre('Event created: ' + event.htmlLink); }); + + + /* + * deleting existing event from calendar https://developers.google.com/calendar/v3/reference/events/delete + * pass the Event.id from the existing events list response + * refer to https://developers.google.com/calendar/v3/reference/events#resource-representations + * input @param {string} calendarEventId that needs to be deleted from the calendar + * */ + function deleteEvent(calendarEventId: any) { + var request = gapi.client.calendar.events.delete({ + calendarId: 'primary', + eventId: calendarEventId, + sendNotifications: true + }); + + request.then( + (response) => { + appendPre('Successfully deleted event ' + calendarEventId); + }, + (error) => { + appendPre('Unable to delete event from your calendar' + calendarEventId); + } + ); + } + } diff --git a/types/gapi.calendar/index.d.ts b/types/gapi.calendar/index.d.ts index a6a0385661..62016a4c33 100644 --- a/types/gapi.calendar/index.d.ts +++ b/types/gapi.calendar/index.d.ts @@ -271,6 +271,8 @@ declare namespace gapi.client.calendar { static insert(parameters: EventsInsertParameters): HttpRequest; static update(parameters: EventsUpdateParameters): HttpRequest; static get(parameters: EventsGetParameters): HttpRequest; + + // delete the existing event from calendar static delete(parameters: EventsDeleteParameters): HttpRequest; } @@ -307,6 +309,8 @@ declare namespace gapi.client.calendar { resource: EventInput; } + // calendarId: 'primary' or the calendar from which the event to be deleted + // eventId: the event that need to be deleted from calendar (Event.id from the list/insert response) interface EventsDeleteParameters { calendarId: string; eventId: string; From 66efd2dfcae34e30069ae285f6b2723208db2e46 Mon Sep 17 00:00:00 2001 From: BhaskarM Date: Mon, 28 May 2018 23:06:20 +0530 Subject: [PATCH 3/3] removing documentation from tests --- types/gapi.calendar/gapi.calendar-tests.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/types/gapi.calendar/gapi.calendar-tests.ts b/types/gapi.calendar/gapi.calendar-tests.ts index 0b40d30792..f2d5058ad2 100644 --- a/types/gapi.calendar/gapi.calendar-tests.ts +++ b/types/gapi.calendar/gapi.calendar-tests.ts @@ -151,12 +151,7 @@ }); - /* - * deleting existing event from calendar https://developers.google.com/calendar/v3/reference/events/delete - * pass the Event.id from the existing events list response - * refer to https://developers.google.com/calendar/v3/reference/events#resource-representations - * input @param {string} calendarEventId that needs to be deleted from the calendar - * */ + function deleteEvent(calendarEventId: any) { var request = gapi.client.calendar.events.delete({ calendarId: 'primary',