totalum-api-sdk 1.0.7 → 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.
Files changed (3) hide show
  1. package/index.js +1 -26
  2. package/index.ts +131 -2
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -37,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
14
  Object.defineProperty(exports, "__esModule", { value: true });
38
15
  exports.TotalumApiSdk = void 0;
39
16
  const axios_1 = __importDefault(require("axios"));
40
- const qs = __importStar(require("qs"));
41
17
  // ENDPOINTS
42
18
  const endpoints = {
43
19
  crud: {
@@ -95,9 +71,8 @@ class TotalumApiSdk {
95
71
  }
96
72
  getItems(itemType, query) {
97
73
  return __awaiter(this, void 0, void 0, function* () {
98
- const queryString = qs.stringify(query);
99
74
  const url = this.getUrl(endpoints.crud.getObjects, { typeId: itemType });
100
- return axios_1.default.get(url, { params: queryString, headers: this.headers });
75
+ return axios_1.default.get(url, { params: query, headers: this.headers });
101
76
  });
102
77
  }
103
78
  deleteItemById(itemType, id) {
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 {
@@ -151,9 +255,8 @@ export class TotalumApiSdk {
151
255
  }
152
256
 
153
257
  public async getItems(itemType: string, query?: FilterSearchQueryI) {
154
- const queryString = qs.stringify(query);
155
258
  const url = this.getUrl(endpoints.crud.getObjects, { typeId: itemType });
156
- return axios.get(url, { params: queryString, headers: this.headers });
259
+ return axios.get(url, { params: query, headers: this.headers });
157
260
  }
158
261
 
159
262
  public async deleteItemById(itemType: string, id: string) {
@@ -193,6 +296,30 @@ export class TotalumApiSdk {
193
296
  return axios.post(url, body, { params: params, headers: this.headers });
194
297
  }
195
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
+
196
323
  public async lookUpFilter(idPage: string, query: FilterLookupSearchQueryI, idsOfMultipleNodesToSearch?: string[], returnCount?: boolean) {
197
324
  const url = this.getUrl(endpoints.filter.lookUpFilter, { idPage });
198
325
  const params = {
@@ -203,4 +330,6 @@ export class TotalumApiSdk {
203
330
  return axios.get(url, { params: params, headers: this.headers });
204
331
  }
205
332
 
333
+
334
+
206
335
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totalum-api-sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Totalum sdk wraper of totalum api",
5
5
  "main": "index.js",
6
6
  "scripts": {