totalum-api-sdk 2.0.8 → 2.0.10
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/README.MD +37 -13
- package/dist/common/interfaces.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -0
- package/dist/services/FilesService.d.ts +9 -1
- package/dist/services/FilesService.js +8 -2
- package/package.json +5 -5
package/README.MD
CHANGED
|
@@ -9,59 +9,83 @@ This library wraps the totalum public api, so you can easy call all endpoints.
|
|
|
9
9
|
npm i totalum-api-sdk
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
We recomend you to use the api key instead of the token.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
# Usage of TotalumApiSdk
|
|
14
|
+
|
|
15
|
+
Totalum allows you to use the SDK to perform actions such as creating users, creating items, creating pdfs, etc.
|
|
16
|
+
|
|
17
|
+
Basically the Totalum sdk is a wrapper of the Totalum api, so if you want you can use the api directly if you prefer.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Authentication
|
|
21
|
+
|
|
22
|
+
You can choose to use one of the two authentication methods offered by Totalum Sdk:
|
|
23
|
+
|
|
24
|
+
- **Token**: You can use an access token to authenticate. This token can be obtained from the localStorage of your browser from the web https://web.totalum.app
|
|
25
|
+
|
|
26
|
+
- **ApiKey**: (RECOMMENDED OPTION) You can use an ApiKey to authenticate. This ApiKey can be obtained in the **Api Keys** section of the **Configuration** section of Totalum.
|
|
27
|
+
|
|
28
|
+
**In Typescript:**
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
|
|
15
32
|
// IN TYPESCRIPT
|
|
16
33
|
|
|
17
34
|
import {AuthOptions, TotalumApiSdk} from 'totalum-api-sdk';
|
|
18
35
|
|
|
36
|
+
// CHOISE FROM USE accessToken OR apiKey (API KEY IS RECOMMENDED)
|
|
37
|
+
|
|
19
38
|
// the auth using token
|
|
20
39
|
const options: AuthOptions = {
|
|
21
40
|
token:{
|
|
22
|
-
accessToken: 'YOUR TOKEN'
|
|
41
|
+
accessToken: 'YOUR TOKEN' // get it from totalum project web localStorage
|
|
23
42
|
}
|
|
24
43
|
}
|
|
25
44
|
|
|
26
45
|
// the auth using api key
|
|
27
46
|
const options: AuthOptions = {
|
|
28
47
|
apiKey:{
|
|
29
|
-
'api-key': 'your_api_key',
|
|
30
|
-
'api-key-name': 'your_api_key_name',
|
|
31
|
-
'organization-id': 'your_organization_id'
|
|
48
|
+
'api-key': 'your_api_key', //the api key secret that is shown only once
|
|
49
|
+
'api-key-name': 'your_api_key_name', // the name of the api key that you can see in the api keys section
|
|
50
|
+
'organization-id': 'your_organization_id' // your project name (project id) Get it from Configuration -> Información Proyecto -> Nombre del proyecto (project id)
|
|
32
51
|
}
|
|
33
52
|
}
|
|
34
53
|
|
|
35
54
|
const totalumClient = new TotalumApiSdk(options);
|
|
36
55
|
|
|
37
|
-
// execute some function
|
|
38
|
-
|
|
56
|
+
// execute some TotalumApiSdk function
|
|
39
57
|
const result = await totalumClient.crud.getItems('your_item', {});
|
|
58
|
+
|
|
40
59
|
```
|
|
41
60
|
|
|
61
|
+
**In Javascript:**
|
|
62
|
+
|
|
42
63
|
```javascript
|
|
43
64
|
// IN JAVASCRIPT
|
|
44
65
|
|
|
45
66
|
const totalum = require('totalum-api-sdk');
|
|
46
67
|
|
|
68
|
+
// CHOICE FROM USE accessToken OR apiKey (API KEY IS RECOMMENDED)
|
|
69
|
+
|
|
47
70
|
// the auth using token
|
|
48
71
|
const options = {
|
|
49
72
|
token:{
|
|
50
|
-
accessToken: 'YOUR TOKEN'
|
|
73
|
+
accessToken: 'YOUR TOKEN' // get it from totalum project web localStorage
|
|
51
74
|
}
|
|
52
75
|
}
|
|
53
76
|
|
|
54
77
|
// the auth using api key
|
|
55
78
|
const options: AuthOptions = {
|
|
56
79
|
apiKey:{
|
|
57
|
-
'api-key': 'your_api_key',
|
|
58
|
-
'api-key-name': 'your_api_key_name',
|
|
59
|
-
'organization-id': 'your_organization_id'
|
|
80
|
+
'api-key': 'your_api_key', //the api key secret that is shown only once
|
|
81
|
+
'api-key-name': 'your_api_key_name', // the name of the api key that you can see in the api keys section
|
|
82
|
+
'organization-id': 'your_organization_id' // your project name (project id) Get it from Configuration -> Información Proyecto -> Nombre del proyecto (project id)
|
|
60
83
|
}
|
|
61
84
|
}
|
|
62
85
|
|
|
63
86
|
const totalumClient = new totalum.TotalumApiSdk(options);
|
|
64
87
|
|
|
88
|
+
// execute some TotalumApiSdk function
|
|
65
89
|
const result = await totalumClient.crud.getItems('your_item', {});
|
|
66
|
-
|
|
90
|
+
|
|
67
91
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { GoogleService } from './services/GoogleService';
|
|
|
4
4
|
import { FilterService } from './services/FilterService';
|
|
5
5
|
import { FilesService } from './services/FilesService';
|
|
6
6
|
import { CrudService } from './services/CrudService';
|
|
7
|
+
export * from './common/interfaces';
|
|
7
8
|
export declare class TotalumApiSdk {
|
|
8
9
|
private authOptions;
|
|
9
10
|
private _baseUrl;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.TotalumApiSdk = void 0;
|
|
4
18
|
const OpenaiService_1 = require("./services/OpenaiService");
|
|
@@ -6,6 +20,7 @@ const GoogleService_1 = require("./services/GoogleService");
|
|
|
6
20
|
const FilterService_1 = require("./services/FilterService");
|
|
7
21
|
const FilesService_1 = require("./services/FilesService");
|
|
8
22
|
const CrudService_1 = require("./services/CrudService");
|
|
23
|
+
__exportStar(require("./common/interfaces"), exports);
|
|
9
24
|
class TotalumApiSdk {
|
|
10
25
|
constructor(authOptions) {
|
|
11
26
|
var _a, _b, _c;
|
|
@@ -3,7 +3,15 @@ export declare class FilesService {
|
|
|
3
3
|
private baseUrl;
|
|
4
4
|
constructor(baseUrl: string, headers: any);
|
|
5
5
|
uploadFile(fileFormData: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param fileName
|
|
9
|
+
* @param options options.expirationTime - is the time in milliseconds that the signed URL should be valid for. The default is 128 hours
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
getDownloadUrl(fileName: string, options: {
|
|
13
|
+
expirationTime: number;
|
|
14
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
15
|
generatePdfByTemplate(id: string, variables: {
|
|
8
16
|
[variableName: string]: any;
|
|
9
17
|
}, name: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -27,10 +27,16 @@ class FilesService {
|
|
|
27
27
|
return axios_1.default.post(url, fileFormData, { headers: this.headers });
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param fileName
|
|
33
|
+
* @param options options.expirationTime - is the time in milliseconds that the signed URL should be valid for. The default is 128 hours
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
getDownloadUrl(fileName, options) {
|
|
31
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
38
|
const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.getDownloadUrl, { fileName });
|
|
33
|
-
return axios_1.default.get(url, { headers: this.headers });
|
|
39
|
+
return axios_1.default.get(url, { headers: this.headers, params: options });
|
|
34
40
|
});
|
|
35
41
|
}
|
|
36
42
|
generatePdfByTemplate(id, variables, name) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "totalum-api-sdk",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "Totalum sdk
|
|
3
|
+
"version": "2.0.10",
|
|
4
|
+
"description": "Totalum sdk wrapper and utils of totalum api",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
7
|
"files": ["dist"],
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc"
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/qs": "^6.9.7",
|
|
15
|
-
"typescript": "^5.1.3"
|
|
15
|
+
"typescript": "^5.1.3",
|
|
16
|
+
"openai": "^4.4.0"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"@types/axios": "^0.14.0",
|
|
19
20
|
"axios": "^1.4.0",
|
|
20
|
-
"openai": "^4.4.0",
|
|
21
21
|
"qs": "^6.11.2"
|
|
22
22
|
}
|
|
23
23
|
}
|