@in.pulse-crm/sdk 2.8.2 → 2.8.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/.prettierrc +4 -4
- package/dist/api-client.d.ts +1 -1
- package/dist/api-client.js +3 -3
- package/dist/auth.client.js +5 -5
- package/dist/customers.client.js +5 -5
- package/dist/files.client.d.ts +2 -0
- package/dist/files.client.js +5 -5
- package/dist/instance.client.js +1 -1
- package/dist/internal.client.js +10 -13
- package/dist/ready-message.client.js +5 -5
- package/dist/reports.client.js +8 -8
- package/dist/socket-server.client.js +1 -1
- package/dist/types/files.types.d.ts +2 -0
- package/dist/types/internal.types.d.ts +0 -1
- package/dist/users.client.js +5 -5
- package/dist/wallets.client.js +11 -11
- package/dist/whatsapp.client.js +23 -24
- package/package.json +1 -1
- package/src/api-client.ts +3 -3
- package/src/auth.client.ts +5 -5
- package/src/customers.client.ts +5 -5
- package/src/files.client.ts +5 -5
- package/src/instance.client.ts +1 -1
- package/src/internal.client.ts +11 -13
- package/src/ready-message.client.ts +5 -5
- package/src/reports.client.ts +8 -8
- package/src/socket-server.client.ts +1 -1
- package/src/types/internal.types.ts +0 -1
- package/src/users.client.ts +5 -5
- package/src/wallets.client.ts +11 -11
- package/src/whatsapp.client.ts +46 -49
- package/tsconfig.json +16 -16
package/.prettierrc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tabWidth": 4,
|
|
3
|
-
"useTabs": true
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tabWidth": 4,
|
|
3
|
+
"useTabs": true
|
|
4
|
+
}
|
package/dist/api-client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosError } from 'axios';
|
|
2
2
|
import { ErrorResponse } from './types/response.types';
|
|
3
3
|
export default class ApiClient {
|
|
4
|
-
|
|
4
|
+
readonly ax: AxiosInstance;
|
|
5
5
|
private baseUrl;
|
|
6
6
|
constructor(baseUrl: string);
|
|
7
7
|
private initializeResponseInterceptor;
|
package/dist/api-client.js
CHANGED
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
class ApiClient {
|
|
8
|
-
|
|
8
|
+
ax;
|
|
9
9
|
baseUrl;
|
|
10
10
|
constructor(baseUrl) {
|
|
11
11
|
this.baseUrl = baseUrl;
|
|
12
|
-
this.
|
|
12
|
+
this.ax = axios_1.default.create({
|
|
13
13
|
baseURL: `${this.baseUrl}`,
|
|
14
14
|
timeout: 60000,
|
|
15
15
|
headers: {
|
|
@@ -19,7 +19,7 @@ class ApiClient {
|
|
|
19
19
|
this.initializeResponseInterceptor();
|
|
20
20
|
}
|
|
21
21
|
initializeResponseInterceptor() {
|
|
22
|
-
this.
|
|
22
|
+
this.ax.interceptors.response.use(null, this.handleError);
|
|
23
23
|
}
|
|
24
24
|
handleError = (error) => {
|
|
25
25
|
const errorMessage = error.response?.data?.message || error.message;
|
package/dist/auth.client.js
CHANGED
|
@@ -17,7 +17,7 @@ class AuthClient extends api_client_1.default {
|
|
|
17
17
|
* @returns Dados de login.
|
|
18
18
|
*/
|
|
19
19
|
async login(instance, username, password) {
|
|
20
|
-
const { data: res } = await this.
|
|
20
|
+
const { data: res } = await this.ax.post(`/api/auth/login`, { LOGIN: username, SENHA: password, instance });
|
|
21
21
|
return res.data;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
@@ -26,7 +26,7 @@ class AuthClient extends api_client_1.default {
|
|
|
26
26
|
* @returns Dados da sessão.
|
|
27
27
|
*/
|
|
28
28
|
async fetchSessionData(authToken) {
|
|
29
|
-
const { data: res } = await this.
|
|
29
|
+
const { data: res } = await this.ax
|
|
30
30
|
.get(`/api/auth/session`, {
|
|
31
31
|
headers: {
|
|
32
32
|
authorization: authToken,
|
|
@@ -71,7 +71,7 @@ class AuthClient extends api_client_1.default {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
async getOnlineSessions(instance) {
|
|
74
|
-
const { data: res } = await this.
|
|
74
|
+
const { data: res } = await this.ax.get("/api/online-sessions", {
|
|
75
75
|
params: {
|
|
76
76
|
instance,
|
|
77
77
|
},
|
|
@@ -79,14 +79,14 @@ class AuthClient extends api_client_1.default {
|
|
|
79
79
|
return res.data;
|
|
80
80
|
}
|
|
81
81
|
async initOnlineSession(authToken) {
|
|
82
|
-
await this.
|
|
82
|
+
await this.ax.post("/api/online-sessions", {}, {
|
|
83
83
|
headers: {
|
|
84
84
|
Authorization: authToken,
|
|
85
85
|
},
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
async finishOnlineSession(authToken) {
|
|
89
|
-
await this.
|
|
89
|
+
await this.ax.delete("/api/online-sessions", {
|
|
90
90
|
headers: {
|
|
91
91
|
Authorization: authToken,
|
|
92
92
|
},
|
package/dist/customers.client.js
CHANGED
|
@@ -11,7 +11,7 @@ class CustomersClient extends api_client_1.default {
|
|
|
11
11
|
* @returns Uma Promise que resolve para o cliente criado.
|
|
12
12
|
*/
|
|
13
13
|
async createCustomer(data) {
|
|
14
|
-
const response = await this.
|
|
14
|
+
const response = await this.ax.post(`/api/customers`, data);
|
|
15
15
|
return response.data;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -20,7 +20,7 @@ class CustomersClient extends api_client_1.default {
|
|
|
20
20
|
* @returns Uma Promise que resolve para o cliente obtido.
|
|
21
21
|
*/
|
|
22
22
|
async getCustomerById(customerId) {
|
|
23
|
-
const response = await this.
|
|
23
|
+
const response = await this.ax.get(`/api/customers/${customerId}`);
|
|
24
24
|
return response.data;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -30,7 +30,7 @@ class CustomersClient extends api_client_1.default {
|
|
|
30
30
|
* @returns Uma Promise que resolve para o cliente atualizado.
|
|
31
31
|
*/
|
|
32
32
|
async updateCustomer(customerId, data) {
|
|
33
|
-
const response = await this.
|
|
33
|
+
const response = await this.ax.patch(`/api/customers/${customerId}`, data);
|
|
34
34
|
return response.data;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -46,7 +46,7 @@ class CustomersClient extends api_client_1.default {
|
|
|
46
46
|
const params = new URLSearchParams(filters);
|
|
47
47
|
baseUrl += `?${params.toString()}`;
|
|
48
48
|
}
|
|
49
|
-
const response = await this.
|
|
49
|
+
const response = await this.ax.get(baseUrl);
|
|
50
50
|
return response.data;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
@@ -54,7 +54,7 @@ class CustomersClient extends api_client_1.default {
|
|
|
54
54
|
* @param token - O token de autenticação a ser definido.
|
|
55
55
|
*/
|
|
56
56
|
setAuth(token) {
|
|
57
|
-
this.
|
|
57
|
+
this.ax.defaults.headers.common["Authorization"] =
|
|
58
58
|
`Bearer ${token}`;
|
|
59
59
|
}
|
|
60
60
|
}
|
package/dist/files.client.d.ts
CHANGED
package/dist/files.client.js
CHANGED
|
@@ -11,7 +11,7 @@ class FilesClient extends api_client_1.default {
|
|
|
11
11
|
* @returns {Promise<Buffer>} Um buffer contendo os dados do arquivo.
|
|
12
12
|
*/
|
|
13
13
|
async fetchFile(id) {
|
|
14
|
-
const response = await this.
|
|
14
|
+
const response = await this.ax.get(`/api/files/${id}`, {
|
|
15
15
|
responseType: "arraybuffer",
|
|
16
16
|
});
|
|
17
17
|
const buffer = Buffer.from(response.data, "binary");
|
|
@@ -25,7 +25,7 @@ class FilesClient extends api_client_1.default {
|
|
|
25
25
|
* @throws Will throw an error if the HTTP request fails.
|
|
26
26
|
*/
|
|
27
27
|
async fetchFileMetadata(id) {
|
|
28
|
-
const { data: res } = await this.
|
|
28
|
+
const { data: res } = await this.ax.get(`/api/files/${id}/metadata`);
|
|
29
29
|
return res.data;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -34,7 +34,7 @@ class FilesClient extends api_client_1.default {
|
|
|
34
34
|
* @returns {string} URL de download do arquivo.
|
|
35
35
|
*/
|
|
36
36
|
getFileDownloadUrl(id) {
|
|
37
|
-
return this.
|
|
37
|
+
return this.ax.defaults.baseURL + `/api/files/${id}`;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Faz o upload de um arquivo.
|
|
@@ -46,7 +46,7 @@ class FilesClient extends api_client_1.default {
|
|
|
46
46
|
form.append("instance", props.instance);
|
|
47
47
|
form.append("dirType", props.dirType);
|
|
48
48
|
form.append("file", new Blob([props.buffer], { type: props.mimeType }), props.fileName);
|
|
49
|
-
const response = await this.
|
|
49
|
+
const response = await this.ax.post("/api/files", form, {
|
|
50
50
|
headers: { "Content-Type": "multipart/form-data" },
|
|
51
51
|
});
|
|
52
52
|
return response.data.data;
|
|
@@ -57,7 +57,7 @@ class FilesClient extends api_client_1.default {
|
|
|
57
57
|
* @returns {Promise<void>}
|
|
58
58
|
*/
|
|
59
59
|
async deleteFile(id) {
|
|
60
|
-
await this.
|
|
60
|
+
await this.ax.delete(`/api/files/${id}`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
exports.default = FilesClient;
|
package/dist/instance.client.js
CHANGED
|
@@ -16,7 +16,7 @@ class InstancesClient extends api_client_1.default {
|
|
|
16
16
|
* @returns {Promise<T>} Resultado da consulta.
|
|
17
17
|
*/
|
|
18
18
|
async executeQuery(instance, query, parameters) {
|
|
19
|
-
const response = await this.
|
|
19
|
+
const response = await this.ax
|
|
20
20
|
.post(`/api/instances/${instance}/query`, { query, parameters })
|
|
21
21
|
.catch((error) => {
|
|
22
22
|
if (error.response?.data?.message) {
|
package/dist/internal.client.js
CHANGED
|
@@ -12,7 +12,7 @@ class InternalChatClient extends api_client_1.default {
|
|
|
12
12
|
form.append("file", groupImage);
|
|
13
13
|
}
|
|
14
14
|
form.append("data", JSON.stringify({ participants, isGroup, groupName, groupId }));
|
|
15
|
-
const { data: res } = await this.
|
|
15
|
+
const { data: res } = await this.ax.post(`/api/internal/chats`, form, {
|
|
16
16
|
headers: {
|
|
17
17
|
"Content-Type": "multipart/form-data",
|
|
18
18
|
},
|
|
@@ -21,21 +21,21 @@ class InternalChatClient extends api_client_1.default {
|
|
|
21
21
|
}
|
|
22
22
|
async deleteInternalChat(chatId) {
|
|
23
23
|
const url = `/api/internal/chats/${chatId}`;
|
|
24
|
-
await this.
|
|
24
|
+
await this.ax.delete(url);
|
|
25
25
|
}
|
|
26
26
|
async getInternalChatsBySession(token = null) {
|
|
27
27
|
const url = `/api/internal/session/chats`;
|
|
28
28
|
const headers = token
|
|
29
29
|
? { Authorization: `Bearer ${token}` }
|
|
30
30
|
: undefined;
|
|
31
|
-
const { data: res } = await this.
|
|
31
|
+
const { data: res } = await this.ax.get(url, {
|
|
32
32
|
headers,
|
|
33
33
|
});
|
|
34
34
|
return res.data;
|
|
35
35
|
}
|
|
36
36
|
async getInternalGroups() {
|
|
37
37
|
const url = `/api/internal/groups`;
|
|
38
|
-
const { data: res } = await this.
|
|
38
|
+
const { data: res } = await this.ax.get(url);
|
|
39
39
|
return res.data;
|
|
40
40
|
}
|
|
41
41
|
async sendMessageToInternalChat(data) {
|
|
@@ -48,23 +48,20 @@ class InternalChatClient extends api_client_1.default {
|
|
|
48
48
|
data.sendAsDocument && formData.append("sendAsDocument", "true");
|
|
49
49
|
data.file && formData.append("file", data.file);
|
|
50
50
|
data.fileId && formData.append("fileId", data.fileId.toString());
|
|
51
|
-
|
|
52
|
-
formData.append("mentions", JSON.stringify(data.mentions));
|
|
53
|
-
}
|
|
54
|
-
await this.httpClient.post(url, formData, {
|
|
51
|
+
await this.ax.post(url, formData, {
|
|
55
52
|
headers: {
|
|
56
53
|
"Content-Type": "multipart/form-data",
|
|
57
54
|
},
|
|
58
55
|
});
|
|
59
56
|
}
|
|
60
57
|
async updateInternalGroup(groupId, data) {
|
|
61
|
-
const { data: res } = await this.
|
|
58
|
+
const { data: res } = await this.ax.put(`/api/internal/groups/${groupId}`, data);
|
|
62
59
|
return res.data;
|
|
63
60
|
}
|
|
64
61
|
async updateInternalGroupImage(groupId, file) {
|
|
65
62
|
const formData = new form_data_1.default();
|
|
66
63
|
formData.append("file", file);
|
|
67
|
-
const { data: res } = await this.
|
|
64
|
+
const { data: res } = await this.ax.put(`/api/internal/groups/${groupId}/image`, formData, {
|
|
68
65
|
headers: {
|
|
69
66
|
"Content-Type": "multipart/form-data",
|
|
70
67
|
},
|
|
@@ -73,15 +70,15 @@ class InternalChatClient extends api_client_1.default {
|
|
|
73
70
|
}
|
|
74
71
|
async markChatMessagesAsRead(chatId) {
|
|
75
72
|
const url = `/api/internal/chat/${chatId}/mark-as-read`;
|
|
76
|
-
await this.
|
|
73
|
+
await this.ax.patch(url);
|
|
77
74
|
}
|
|
78
75
|
async getInternalChatsMonitor() {
|
|
79
76
|
const url = `/api/internal/monitor/chats`;
|
|
80
|
-
const { data: res } = await this.
|
|
77
|
+
const { data: res } = await this.ax.get(url);
|
|
81
78
|
return res.data;
|
|
82
79
|
}
|
|
83
80
|
setAuth(token) {
|
|
84
|
-
this.
|
|
81
|
+
this.ax.defaults.headers.common["Authorization"] =
|
|
85
82
|
`Bearer ${token}`;
|
|
86
83
|
}
|
|
87
84
|
}
|
|
@@ -12,7 +12,7 @@ class ReadyMessageClient extends api_client_1.default {
|
|
|
12
12
|
form.append("file", File);
|
|
13
13
|
}
|
|
14
14
|
form.append("data", JSON.stringify({ TITULO, TEXTO_MENSAGEM, SETOR }));
|
|
15
|
-
const { data: res } = await this.
|
|
15
|
+
const { data: res } = await this.ax.post(`/api/ready-messages`, form, {
|
|
16
16
|
headers: {
|
|
17
17
|
"Content-Type": "multipart/form-data",
|
|
18
18
|
},
|
|
@@ -21,18 +21,18 @@ class ReadyMessageClient extends api_client_1.default {
|
|
|
21
21
|
}
|
|
22
22
|
async deleteReadyMessage(chatId) {
|
|
23
23
|
const url = `/api/ready-messages/${chatId}`;
|
|
24
|
-
await this.
|
|
24
|
+
await this.ax.delete(url);
|
|
25
25
|
}
|
|
26
26
|
async getReadyMessages() {
|
|
27
27
|
const url = `/api/ready-messages`;
|
|
28
|
-
const { data: res } = await this.
|
|
28
|
+
const { data: res } = await this.ax.get(url);
|
|
29
29
|
return res.data;
|
|
30
30
|
}
|
|
31
31
|
async updateReadyMessage(id, ReadyMessage, file) {
|
|
32
32
|
const formData = new form_data_1.default();
|
|
33
33
|
formData.append("file", file);
|
|
34
34
|
formData.append("data", JSON.stringify(ReadyMessage));
|
|
35
|
-
const { data: res } = await this.
|
|
35
|
+
const { data: res } = await this.ax.put(`/api/ready-messages/${id}`, formData, {
|
|
36
36
|
headers: {
|
|
37
37
|
"Content-Type": "multipart/form-data",
|
|
38
38
|
},
|
|
@@ -40,7 +40,7 @@ class ReadyMessageClient extends api_client_1.default {
|
|
|
40
40
|
return res.data;
|
|
41
41
|
}
|
|
42
42
|
setAuth(token) {
|
|
43
|
-
this.
|
|
43
|
+
this.ax.defaults.headers.common["Authorization"] =
|
|
44
44
|
`Bearer ${token}`;
|
|
45
45
|
}
|
|
46
46
|
}
|
package/dist/reports.client.js
CHANGED
|
@@ -18,7 +18,7 @@ class ReportsClient extends api_client_1.default {
|
|
|
18
18
|
*/
|
|
19
19
|
async getChatsReports() {
|
|
20
20
|
const url = `/api/reports/chats`;
|
|
21
|
-
const { data: res } = await this.
|
|
21
|
+
const { data: res } = await this.ax.get(url);
|
|
22
22
|
return res.data;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
@@ -29,7 +29,7 @@ class ReportsClient extends api_client_1.default {
|
|
|
29
29
|
*/
|
|
30
30
|
async generateChatsReport(body) {
|
|
31
31
|
const url = `/api/reports/chats`;
|
|
32
|
-
const { data: res } = await this.
|
|
32
|
+
const { data: res } = await this.ax.post(url, body);
|
|
33
33
|
return res.data;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
@@ -39,7 +39,7 @@ class ReportsClient extends api_client_1.default {
|
|
|
39
39
|
*/
|
|
40
40
|
async deleteChatsReport(chatsReportId) {
|
|
41
41
|
const url = `/api/reports/chats/${chatsReportId}`;
|
|
42
|
-
await this.
|
|
42
|
+
await this.ax.delete(url);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Desative a report sql by its unique identifier.
|
|
@@ -48,7 +48,7 @@ class ReportsClient extends api_client_1.default {
|
|
|
48
48
|
*/
|
|
49
49
|
async deleteHistoryReport(reportId) {
|
|
50
50
|
const url = `/api/reports-history/${reportId}`;
|
|
51
|
-
await this.
|
|
51
|
+
await this.ax.delete(url);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Execute a report sql interactions based on the provided options.
|
|
@@ -58,7 +58,7 @@ class ReportsClient extends api_client_1.default {
|
|
|
58
58
|
*/
|
|
59
59
|
async executeSqlReport(body) {
|
|
60
60
|
const url = `/api/execute-report-sql`;
|
|
61
|
-
const { data: res } = await this.
|
|
61
|
+
const { data: res } = await this.ax.post(url, body);
|
|
62
62
|
return res.data;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
@@ -68,7 +68,7 @@ class ReportsClient extends api_client_1.default {
|
|
|
68
68
|
*/
|
|
69
69
|
async getSqlReportsHistory() {
|
|
70
70
|
const url = `/api/reports-history`;
|
|
71
|
-
const { data: res } = await this.
|
|
71
|
+
const { data: res } = await this.ax.get(url);
|
|
72
72
|
return res.data;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
@@ -79,7 +79,7 @@ class ReportsClient extends api_client_1.default {
|
|
|
79
79
|
*/
|
|
80
80
|
async exportReportSql(body) {
|
|
81
81
|
const url = `/api/export-report-sql`;
|
|
82
|
-
const response = await this.
|
|
82
|
+
const response = await this.ax.post(url, body, {
|
|
83
83
|
responseType: 'blob',
|
|
84
84
|
});
|
|
85
85
|
return response.data;
|
|
@@ -92,7 +92,7 @@ class ReportsClient extends api_client_1.default {
|
|
|
92
92
|
* of all HTTP requests made by the client.
|
|
93
93
|
*/
|
|
94
94
|
setAuth(token) {
|
|
95
|
-
this.
|
|
95
|
+
this.ax.defaults.headers.common["Authorization"] =
|
|
96
96
|
`Bearer ${token}`;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -27,7 +27,7 @@ class SocketServerApi extends api_client_1.default {
|
|
|
27
27
|
* @returns A promise that resolves with the response from the API call.
|
|
28
28
|
*/
|
|
29
29
|
emit = (event, room, value) => {
|
|
30
|
-
return this.
|
|
30
|
+
return this.ax
|
|
31
31
|
.post(`/api/ws/emit/${room}/${event}`, value)
|
|
32
32
|
.then((res) => res.data);
|
|
33
33
|
};
|
package/dist/users.client.js
CHANGED
|
@@ -19,7 +19,7 @@ class UsersClient extends api_client_1.default {
|
|
|
19
19
|
const params = new URLSearchParams(filters);
|
|
20
20
|
baseUrl += `?${params.toString()}`;
|
|
21
21
|
}
|
|
22
|
-
const response = await this.
|
|
22
|
+
const response = await this.ax.get(baseUrl);
|
|
23
23
|
return response.data;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
@@ -28,7 +28,7 @@ class UsersClient extends api_client_1.default {
|
|
|
28
28
|
* @returns Uma resposta contendo os dados do usuário.
|
|
29
29
|
*/
|
|
30
30
|
async getUserById(userId) {
|
|
31
|
-
const { data: res } = await this.
|
|
31
|
+
const { data: res } = await this.ax.get(`/api/users/${userId}`);
|
|
32
32
|
return res.data;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
@@ -39,7 +39,7 @@ class UsersClient extends api_client_1.default {
|
|
|
39
39
|
*/
|
|
40
40
|
async createUser(data) {
|
|
41
41
|
try {
|
|
42
|
-
const { data: res } = await this.
|
|
42
|
+
const { data: res } = await this.ax.post(`/api/users`, data);
|
|
43
43
|
return res.data;
|
|
44
44
|
}
|
|
45
45
|
catch (error) {
|
|
@@ -55,7 +55,7 @@ class UsersClient extends api_client_1.default {
|
|
|
55
55
|
*/
|
|
56
56
|
async updateUser(userId, data) {
|
|
57
57
|
try {
|
|
58
|
-
const { data: res } = await this.
|
|
58
|
+
const { data: res } = await this.ax.patch(`/api/users/${userId}`, data);
|
|
59
59
|
return res.data;
|
|
60
60
|
}
|
|
61
61
|
catch (error) {
|
|
@@ -68,7 +68,7 @@ class UsersClient extends api_client_1.default {
|
|
|
68
68
|
* @param token - The authentication token to be used in the `Authorization` header.
|
|
69
69
|
*/
|
|
70
70
|
setAuth(token) {
|
|
71
|
-
this.
|
|
71
|
+
this.ax.defaults.headers.common["Authorization"] =
|
|
72
72
|
`Bearer ${token}`;
|
|
73
73
|
}
|
|
74
74
|
}
|
package/dist/wallets.client.js
CHANGED
|
@@ -7,7 +7,7 @@ const api_client_1 = __importDefault(require("./api-client"));
|
|
|
7
7
|
class WalletsClient extends api_client_1.default {
|
|
8
8
|
async createWallet(name) {
|
|
9
9
|
try {
|
|
10
|
-
const response = await this.
|
|
10
|
+
const response = await this.ax.post(`/api/wallets`, { name });
|
|
11
11
|
return response.data.data;
|
|
12
12
|
}
|
|
13
13
|
catch (error) {
|
|
@@ -16,7 +16,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
16
16
|
}
|
|
17
17
|
async deleteWallet(walletId) {
|
|
18
18
|
try {
|
|
19
|
-
const response = await this.
|
|
19
|
+
const response = await this.ax.delete(`/api/wallets/${walletId}`);
|
|
20
20
|
return response.data.data;
|
|
21
21
|
}
|
|
22
22
|
catch (error) {
|
|
@@ -25,7 +25,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
25
25
|
}
|
|
26
26
|
async updateWalletName(id, newName) {
|
|
27
27
|
try {
|
|
28
|
-
const response = await this.
|
|
28
|
+
const response = await this.ax.put(`/api/wallets/${id}/name`, { newName });
|
|
29
29
|
return response.data.data;
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
@@ -34,7 +34,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
34
34
|
}
|
|
35
35
|
async addUserToWallet(walletId, userId) {
|
|
36
36
|
try {
|
|
37
|
-
const response = await this.
|
|
37
|
+
const response = await this.ax.post(`/api/wallets/${walletId}/users`, { userId });
|
|
38
38
|
return response.data.data;
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
@@ -43,7 +43,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
43
43
|
}
|
|
44
44
|
async removeUserFromWallet(walletId, userId) {
|
|
45
45
|
try {
|
|
46
|
-
const response = await this.
|
|
46
|
+
const response = await this.ax.delete(`/api/wallets/${walletId}/users/${userId}`);
|
|
47
47
|
return response.data.data;
|
|
48
48
|
}
|
|
49
49
|
catch (error) {
|
|
@@ -52,7 +52,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
52
52
|
}
|
|
53
53
|
async getWallets() {
|
|
54
54
|
try {
|
|
55
|
-
const response = await this.
|
|
55
|
+
const response = await this.ax.get("/api/wallets");
|
|
56
56
|
return response.data.data;
|
|
57
57
|
}
|
|
58
58
|
catch (error) {
|
|
@@ -61,7 +61,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
61
61
|
}
|
|
62
62
|
async getWalletById(walletId) {
|
|
63
63
|
try {
|
|
64
|
-
const response = await this.
|
|
64
|
+
const response = await this.ax.get(`/api/wallets/${walletId}`);
|
|
65
65
|
return response.data.data;
|
|
66
66
|
}
|
|
67
67
|
catch (error) {
|
|
@@ -70,7 +70,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
70
70
|
}
|
|
71
71
|
async getWalletUsers(walletId) {
|
|
72
72
|
try {
|
|
73
|
-
const response = await this.
|
|
73
|
+
const response = await this.ax.get(`/api/wallets/${walletId}/users`);
|
|
74
74
|
return response.data.data;
|
|
75
75
|
}
|
|
76
76
|
catch (error) {
|
|
@@ -79,7 +79,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
79
79
|
}
|
|
80
80
|
async getUserInWallet(walletId, userId) {
|
|
81
81
|
try {
|
|
82
|
-
const response = await this.
|
|
82
|
+
const response = await this.ax.get(`/api/wallets/${walletId}/users/${userId}`);
|
|
83
83
|
return response.data.data;
|
|
84
84
|
}
|
|
85
85
|
catch (error) {
|
|
@@ -88,7 +88,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
88
88
|
}
|
|
89
89
|
async getUserWallets(instance, userId) {
|
|
90
90
|
try {
|
|
91
|
-
const response = await this.
|
|
91
|
+
const response = await this.ax.get(`/api/users/${userId}/wallets`, { params: { instance } });
|
|
92
92
|
return response.data.data;
|
|
93
93
|
}
|
|
94
94
|
catch (error) {
|
|
@@ -96,7 +96,7 @@ class WalletsClient extends api_client_1.default {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
setAuth(token) {
|
|
99
|
-
this.
|
|
99
|
+
this.ax.defaults.headers.common["Authorization"] =
|
|
100
100
|
`Bearer ${token}`;
|
|
101
101
|
}
|
|
102
102
|
}
|