plenna_utilities 1.13.2 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/google/index.d.ts +11 -0
- package/dist/src/google/index.js +24 -2
- package/package.json +1 -1
|
@@ -18,14 +18,17 @@ interface deleteDocumentResponse {
|
|
|
18
18
|
interface createCalendarEventResponse {
|
|
19
19
|
success: boolean;
|
|
20
20
|
event?: calendar_v3.Schema$Event;
|
|
21
|
+
message?: string;
|
|
21
22
|
}
|
|
22
23
|
interface deleteCalendarEventResponse {
|
|
23
24
|
success: boolean;
|
|
24
25
|
eventId?: string;
|
|
26
|
+
message?: string;
|
|
25
27
|
}
|
|
26
28
|
interface updateCalendarEventResponse {
|
|
27
29
|
success: boolean;
|
|
28
30
|
event?: calendar_v3.Schema$Event;
|
|
31
|
+
message?: string;
|
|
29
32
|
}
|
|
30
33
|
export interface IRescheduleEvent {
|
|
31
34
|
start: {
|
|
@@ -57,6 +60,13 @@ export interface ICalendarEventPatchParameters {
|
|
|
57
60
|
sendUpdates?: 'all' | 'externalOnly' | 'none';
|
|
58
61
|
supportsAttachments?: boolean;
|
|
59
62
|
}
|
|
63
|
+
export interface ICalendarEventGetParameters {
|
|
64
|
+
calendarId: string;
|
|
65
|
+
eventId: string;
|
|
66
|
+
alwaysIncludeEmail?: boolean;
|
|
67
|
+
maxAttendees?: number;
|
|
68
|
+
timeZone?: string;
|
|
69
|
+
}
|
|
60
70
|
export interface ICalendarEvent extends calendar_v3.Schema$Event {
|
|
61
71
|
}
|
|
62
72
|
export interface ISchemaRequest extends docs_v1.Schema$Request {
|
|
@@ -84,6 +94,7 @@ export declare class PlennaGoogleService {
|
|
|
84
94
|
exportDocumentAsFile(fileId: string): Promise<ArrayBuffer | undefined>;
|
|
85
95
|
deleteDocument(fileId: string): Promise<deleteDocumentResponse>;
|
|
86
96
|
createCalendarEvent(parameterOptions: ICalendarEventInsertParameters, event: ICalendarEvent): Promise<createCalendarEventResponse>;
|
|
97
|
+
getCalendarEvent(parameterOptions: ICalendarEventGetParameters): Promise<ICalendarEvent | undefined>;
|
|
87
98
|
deleteCalendarEvent(eventId: string, calendarId?: string): Promise<deleteCalendarEventResponse>;
|
|
88
99
|
updateCalendarEvent(parameterOptions: ICalendarEventPatchParameters, updates: Partial<ICalendarEvent>): Promise<updateCalendarEventResponse>;
|
|
89
100
|
}
|
package/dist/src/google/index.js
CHANGED
|
@@ -146,6 +146,17 @@ class PlennaGoogleService {
|
|
|
146
146
|
return { success: false };
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
+
async getCalendarEvent(parameterOptions) {
|
|
150
|
+
const authClient = this.calendarAuthorization();
|
|
151
|
+
const calendar = new calendar_1.calendar_v3.Calendar({ auth: authClient });
|
|
152
|
+
try {
|
|
153
|
+
const response = await calendar.events.get({ ...parameterOptions }, { headers: await authClient.getRequestHeaders() });
|
|
154
|
+
return response.data;
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
console.log(error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
149
160
|
async deleteCalendarEvent(eventId, calendarId = 'primary') {
|
|
150
161
|
const authClient = this.calendarAuthorization();
|
|
151
162
|
const calendar = new calendar_1.calendar_v3.Calendar({ auth: authClient });
|
|
@@ -168,9 +179,20 @@ class PlennaGoogleService {
|
|
|
168
179
|
const authClient = this.calendarAuthorization();
|
|
169
180
|
const calendar = new calendar_1.calendar_v3.Calendar({ auth: authClient });
|
|
170
181
|
try {
|
|
171
|
-
const
|
|
182
|
+
const currentEvent = await this.getCalendarEvent({
|
|
183
|
+
calendarId: parameterOptions.calendarId,
|
|
184
|
+
eventId: parameterOptions.eventId
|
|
185
|
+
});
|
|
186
|
+
if (currentEvent === undefined) {
|
|
187
|
+
return { success: false, message: 'Event not found' };
|
|
188
|
+
}
|
|
189
|
+
const updatedEvent = {
|
|
190
|
+
...currentEvent,
|
|
191
|
+
...updates
|
|
192
|
+
};
|
|
193
|
+
const response = await calendar.events.update({
|
|
172
194
|
...parameterOptions,
|
|
173
|
-
requestBody:
|
|
195
|
+
requestBody: updatedEvent
|
|
174
196
|
}, { headers: await authClient.getRequestHeaders() });
|
|
175
197
|
return {
|
|
176
198
|
success: true,
|