totalum-api-sdk 1.0.8 → 1.0.9
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/index.ts +130 -0
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -2,6 +2,104 @@ import axios from 'axios';
|
|
|
2
2
|
import * as qs from 'qs';
|
|
3
3
|
|
|
4
4
|
//INTERFACES
|
|
5
|
+
|
|
6
|
+
export interface GoogleCalendarI {
|
|
7
|
+
summary: string;
|
|
8
|
+
location?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
start: {
|
|
11
|
+
dateTime: string;
|
|
12
|
+
timeZone?: string;
|
|
13
|
+
};
|
|
14
|
+
end: {
|
|
15
|
+
dateTime: string;
|
|
16
|
+
timeZone?: string;
|
|
17
|
+
};
|
|
18
|
+
attendees?: {email: string}[];
|
|
19
|
+
reminders?: Reminders;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Reminders {
|
|
23
|
+
useDefault: boolean;
|
|
24
|
+
overrides?: {
|
|
25
|
+
method: string;
|
|
26
|
+
minutes: number;
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface GoogleCalendarEventsResponseI {
|
|
31
|
+
accessRole: string;
|
|
32
|
+
defaultReminders: { method: string; minutes: number }[];
|
|
33
|
+
etag: string;
|
|
34
|
+
items: {
|
|
35
|
+
kind: string;
|
|
36
|
+
etag: string;
|
|
37
|
+
id: string;
|
|
38
|
+
attendees?: {
|
|
39
|
+
email: string;
|
|
40
|
+
responseStatus: string;
|
|
41
|
+
}[];
|
|
42
|
+
created: string;
|
|
43
|
+
creator: {
|
|
44
|
+
email: string;
|
|
45
|
+
self?: boolean;
|
|
46
|
+
};
|
|
47
|
+
description: string;
|
|
48
|
+
end: {
|
|
49
|
+
dateTime: string;
|
|
50
|
+
timeZone: string;
|
|
51
|
+
};
|
|
52
|
+
eventType: string;
|
|
53
|
+
htmlLink: string;
|
|
54
|
+
iCalUID: string;
|
|
55
|
+
location: string;
|
|
56
|
+
organizer: {
|
|
57
|
+
email: string;
|
|
58
|
+
self?: boolean;
|
|
59
|
+
};
|
|
60
|
+
reminders: { useDefault: boolean };
|
|
61
|
+
sequence: number;
|
|
62
|
+
start: {
|
|
63
|
+
dateTime: string;
|
|
64
|
+
timeZone: string;
|
|
65
|
+
};
|
|
66
|
+
status: string;
|
|
67
|
+
summary: string;
|
|
68
|
+
// Additional fields can be added here
|
|
69
|
+
}[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface GoogleEmailI {
|
|
73
|
+
to: string;
|
|
74
|
+
subject: string;
|
|
75
|
+
message: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface GoogleEmailResponseI {
|
|
79
|
+
id: string;
|
|
80
|
+
threadId: string;
|
|
81
|
+
labelIds: string[];
|
|
82
|
+
snippet: string;
|
|
83
|
+
payload: {
|
|
84
|
+
partId: string;
|
|
85
|
+
mimeType: string;
|
|
86
|
+
filename: string;
|
|
87
|
+
headers: {
|
|
88
|
+
name: string;
|
|
89
|
+
value: string;
|
|
90
|
+
}[];
|
|
91
|
+
body: {
|
|
92
|
+
size: number;
|
|
93
|
+
data: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
sizeEstimate: number;
|
|
97
|
+
historyId: string;
|
|
98
|
+
internalDate: string;
|
|
99
|
+
fullText: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
5
103
|
export interface StructureLevels {
|
|
6
104
|
id: string, // the id of the node
|
|
7
105
|
typeId: string,
|
|
@@ -103,6 +201,12 @@ const endpoints = {
|
|
|
103
201
|
pdfTemplate: {
|
|
104
202
|
generatePdfByTemplate: 'api/v1/pdf-template/generatePdfByTemplate/:id'
|
|
105
203
|
},
|
|
204
|
+
googleIntegration: {
|
|
205
|
+
getEmails: 'api/v1/google-integration/get-emails',
|
|
206
|
+
sendEmail: 'api/v1/google-integration/send-email',
|
|
207
|
+
getCalendarEvents: 'api/v1/google-integration/get-calendar-events',
|
|
208
|
+
createCalendarEvent: 'api/v1/google-integration/create-calendar-event',
|
|
209
|
+
}
|
|
106
210
|
}
|
|
107
211
|
|
|
108
212
|
export interface AuthOptions {
|
|
@@ -192,6 +296,30 @@ export class TotalumApiSdk {
|
|
|
192
296
|
return axios.post(url, body, { params: params, headers: this.headers });
|
|
193
297
|
}
|
|
194
298
|
|
|
299
|
+
public async getGoogleAccountEmails(accountEmail: string) {
|
|
300
|
+
const url = this.getUrl(endpoints.googleIntegration.getEmails, {});
|
|
301
|
+
const params = { userEmail: accountEmail };
|
|
302
|
+
return axios.get(url, { params: params, headers: this.headers });
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
public async googleAccountSendEmail(accountEmail: string, body: {to: string, subject: string, message: string}) {
|
|
306
|
+
const url = this.getUrl(endpoints.googleIntegration.sendEmail, {});
|
|
307
|
+
const params = { userEmail: accountEmail };
|
|
308
|
+
return axios.post(url, body, { params: params, headers: this.headers });
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
public async getGoogleCalendarEvents(accountEmail: string) {
|
|
312
|
+
const url = this.getUrl(endpoints.googleIntegration.getCalendarEvents, {});
|
|
313
|
+
const params = { userEmail: accountEmail };
|
|
314
|
+
return axios.get(url, { params: params, headers: this.headers });
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
public async createCalendarEvent(accountEmail: string, body: GoogleCalendarI) {
|
|
318
|
+
const url = this.getUrl(endpoints.googleIntegration.createCalendarEvent, {});
|
|
319
|
+
const params = { userEmail: accountEmail };
|
|
320
|
+
return axios.post(url, body, { params: params, headers: this.headers });
|
|
321
|
+
}
|
|
322
|
+
|
|
195
323
|
public async lookUpFilter(idPage: string, query: FilterLookupSearchQueryI, idsOfMultipleNodesToSearch?: string[], returnCount?: boolean) {
|
|
196
324
|
const url = this.getUrl(endpoints.filter.lookUpFilter, { idPage });
|
|
197
325
|
const params = {
|
|
@@ -202,4 +330,6 @@ export class TotalumApiSdk {
|
|
|
202
330
|
return axios.get(url, { params: params, headers: this.headers });
|
|
203
331
|
}
|
|
204
332
|
|
|
333
|
+
|
|
334
|
+
|
|
205
335
|
}
|