totalum-api-sdk 1.0.4 → 1.0.5

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/README.MD +20 -0
  2. package/index.ts +25 -5
  3. package/package.json +1 -1
package/README.MD CHANGED
@@ -9,18 +9,28 @@ 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.
12
13
 
13
14
  ```javascript
14
15
  // IN TYPESCRIPT
15
16
 
16
17
  import {AuthOptions, TotalumApiSdk} from 'totalum-api-sdk';
17
18
 
19
+ // the auth using token
18
20
  const options: AuthOptions = {
19
21
  token:{
20
22
  accessToken: 'YOUR TOKEN'
21
23
  }
22
24
  }
23
25
 
26
+ // the auth using api key
27
+ const options: AuthOptions = {
28
+ apiKey:{
29
+ 'api-key': 'your_api_key',
30
+ 'api-key-name': 'your_api_key_name',
31
+ 'organization-id': 'your_organization_id'
32
+ }
33
+ }
24
34
 
25
35
  const totalumClient = new TotalumApiSdk(options);
26
36
 
@@ -34,12 +44,22 @@ const result = await totalumClient.getItems('your_item', {});
34
44
 
35
45
  const totalum = require('totalum-api-sdk');
36
46
 
47
+ // the auth using token
37
48
  const options = {
38
49
  token:{
39
50
  accessToken: 'YOUR TOKEN'
40
51
  }
41
52
  }
42
53
 
54
+ // the auth using api key
55
+ const options: AuthOptions = {
56
+ apiKey:{
57
+ 'api-key': 'your_api_key',
58
+ 'api-key-name': 'your_api_key_name',
59
+ 'organization-id': 'your_organization_id'
60
+ }
61
+ }
62
+
43
63
  const totalumClient = new totalum.TotalumApiSdk(options);
44
64
 
45
65
  const result = await totalumClient.getItems('your_item', {});
package/index.ts CHANGED
@@ -99,12 +99,13 @@ export interface AuthOptions {
99
99
  },
100
100
  apiKey?: {
101
101
  apiKey:string,
102
- organizationId:string
102
+ apiKeyName:string,
103
+ organizationId:string,
103
104
  }
104
105
  }
105
106
 
106
107
  export class TotalumApiSdk {
107
- private baseUrl= 'https://api.totalum.app/';
108
+ public baseUrl= 'https://api.totalum.app/';
108
109
  private authOptions: AuthOptions;
109
110
  private headers: {[key:string]: string};
110
111
 
@@ -116,13 +117,18 @@ export class TotalumApiSdk {
116
117
  }
117
118
  } else if(this.authOptions.apiKey?.apiKey && this.authOptions.apiKey?.organizationId) {
118
119
  this.headers = {
119
- apiKey: this.authOptions.apiKey.apiKey,
120
- organizationId: this.authOptions.apiKey.organizationId
120
+ 'api-key': this.authOptions.apiKey.apiKey,
121
+ 'organization-id': this.authOptions.apiKey.organizationId,
122
+ 'api-key-name': this.authOptions.apiKey.apiKeyName
121
123
  }
122
124
  } else {
123
125
  throw new Error('Error: invalid auth options')
124
126
  }
125
- }
127
+ }
128
+
129
+ public changeBaseUrl(newBaseUrl:string){
130
+ this.baseUrl = newBaseUrl;
131
+ }
126
132
 
127
133
  private getUrl(pattern: string, params?: any): string {
128
134
  let url = this.baseUrl + pattern;
@@ -152,4 +158,18 @@ export class TotalumApiSdk {
152
158
  const url = this.getUrl(endpoints.crud.createObject, {typeId: itemType});
153
159
  return axios.post(url, item, {headers: this.headers});
154
160
  }
161
+
162
+ /**
163
+ *
164
+ * @param customMongoFilter an string with the mongo filter query
165
+ * @param rootTypeId an string with the id of the element that we make the aggregation query
166
+ * @param typeIdToGet the id of the type that we want to get
167
+ * @param options
168
+ * @param returnCount
169
+ */
170
+ public async customMongoFilter(customMongoFilter: string,rootTypeId:string, typeIdToGet:string, options?: {variables: any, pagination?: any, sort: any}, returnCount?:boolean){
171
+
172
+ }
173
+
174
+
155
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totalum-api-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Totalum sdk wraper of totalum api",
5
5
  "main": "index.js",
6
6
  "scripts": {