@in.pulse-crm/sdk 2.9.7 → 2.10.0
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/files.client.d.ts +3 -1
- package/dist/files.client.js +2 -2
- package/dist/types/files.types.d.ts +2 -0
- package/dist/whatsapp.client.d.ts +9 -0
- package/dist/whatsapp.client.js +15 -0
- package/package.json +1 -1
- package/src/files.client.ts +2 -2
- package/src/whatsapp.client.ts +40 -8
- 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/files.client.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import ApiClient from "./api-client";
|
|
2
4
|
import { File, UploadFileOptions } from "./types/files.types";
|
|
3
5
|
declare class FilesClient extends ApiClient {
|
|
@@ -20,7 +22,7 @@ declare class FilesClient extends ApiClient {
|
|
|
20
22
|
* @param {number} id - ID do arquivo.
|
|
21
23
|
* @returns {string} URL de download do arquivo.
|
|
22
24
|
*/
|
|
23
|
-
getFileDownloadUrl(id: number): string;
|
|
25
|
+
getFileDownloadUrl(id: number, baseUrl?: string): string;
|
|
24
26
|
/**
|
|
25
27
|
* Faz o upload de um arquivo.
|
|
26
28
|
* @param {UploadFileOptions} props - Opções para o upload do arquivo.
|
package/dist/files.client.js
CHANGED
|
@@ -33,8 +33,8 @@ class FilesClient extends api_client_1.default {
|
|
|
33
33
|
* @param {number} id - ID do arquivo.
|
|
34
34
|
* @returns {string} URL de download do arquivo.
|
|
35
35
|
*/
|
|
36
|
-
getFileDownloadUrl(id) {
|
|
37
|
-
return this.ax.defaults.baseURL + `/api/files/${id}`;
|
|
36
|
+
getFileDownloadUrl(id, baseUrl) {
|
|
37
|
+
return (baseUrl || this.ax.defaults.baseURL) + `/api/files/${id}`;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Faz o upload de um arquivo.
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
2
|
import { RequestFilters } from "./types";
|
|
3
3
|
import { CreateScheduleDTO, ForwardMessagesData, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppContactWithCustomer, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
|
|
4
|
+
interface FetchMessagesFilters {
|
|
5
|
+
minDate: string;
|
|
6
|
+
maxDate: string;
|
|
7
|
+
userId?: number | null;
|
|
8
|
+
}
|
|
4
9
|
export default class WhatsappClient extends ApiClient {
|
|
5
10
|
getChatsBySession(messages?: boolean, contact?: boolean, token?: string | null): Promise<WppChatsAndMessages>;
|
|
6
11
|
getChatById(id: number): Promise<WppChatWithDetailsAndMessages>;
|
|
@@ -56,4 +61,8 @@ export default class WhatsappClient extends ApiClient {
|
|
|
56
61
|
* @returns Uma Promise que resolve para um objeto wppSchedule.
|
|
57
62
|
*/
|
|
58
63
|
deleteSchedule(scheduleId: number): Promise<any>;
|
|
64
|
+
getMessages(token: string, filters: FetchMessagesFilters): Promise<(WppMessage & {
|
|
65
|
+
WppContact: WppContact | null;
|
|
66
|
+
})[]>;
|
|
59
67
|
}
|
|
68
|
+
export {};
|
package/dist/whatsapp.client.js
CHANGED
|
@@ -203,5 +203,20 @@ class WhatsappClient extends api_client_1.default {
|
|
|
203
203
|
const response = await this.ax.delete(`/api/whatsapp/schedules/${scheduleId}`);
|
|
204
204
|
return response.data;
|
|
205
205
|
}
|
|
206
|
+
async getMessages(token, filters) {
|
|
207
|
+
const params = new URLSearchParams(Object.entries(filters)
|
|
208
|
+
.filter(([_, v]) => v !== undefined && v !== null)
|
|
209
|
+
.reduce((acc, [k, v]) => {
|
|
210
|
+
acc[k] = String(v);
|
|
211
|
+
return acc;
|
|
212
|
+
}, {}));
|
|
213
|
+
const url = `/api/whatsapp/messages?${params.toString()}`;
|
|
214
|
+
const { data: res } = await this.ax.get(url, {
|
|
215
|
+
headers: {
|
|
216
|
+
Authorization: `Bearer ${token}`,
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
return res.data;
|
|
220
|
+
}
|
|
206
221
|
}
|
|
207
222
|
exports.default = WhatsappClient;
|
package/package.json
CHANGED
package/src/files.client.ts
CHANGED
|
@@ -37,8 +37,8 @@ class FilesClient extends ApiClient {
|
|
|
37
37
|
* @param {number} id - ID do arquivo.
|
|
38
38
|
* @returns {string} URL de download do arquivo.
|
|
39
39
|
*/
|
|
40
|
-
public getFileDownloadUrl(id: number): string {
|
|
41
|
-
return this.ax.defaults.baseURL + `/api/files/${id}`;
|
|
40
|
+
public getFileDownloadUrl(id: number, baseUrl?: string): string {
|
|
41
|
+
return (baseUrl || this.ax.defaults.baseURL) + `/api/files/${id}`;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
package/src/whatsapp.client.ts
CHANGED
|
@@ -20,6 +20,12 @@ type GetChatResponse = DataResponse<WppChatWithDetailsAndMessages>;
|
|
|
20
20
|
type GetMessageResponse = DataResponse<WppMessage>;
|
|
21
21
|
type MarkChatAsReadResponse = DataResponse<WppMessage[]>;
|
|
22
22
|
|
|
23
|
+
interface FetchMessagesFilters {
|
|
24
|
+
minDate: string;
|
|
25
|
+
maxDate: string;
|
|
26
|
+
userId?: number | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
export default class WhatsappClient extends ApiClient {
|
|
24
30
|
public async getChatsBySession(
|
|
25
31
|
messages = false,
|
|
@@ -170,14 +176,18 @@ export default class WhatsappClient extends ApiClient {
|
|
|
170
176
|
|
|
171
177
|
return res.data;
|
|
172
178
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
public async updateContact(
|
|
179
|
+
public async forwardMessages(data: ForwardMessagesData) {
|
|
180
|
+
const url = "/api/whatsapp/messages/forward";
|
|
181
|
+
|
|
182
|
+
const body = data;
|
|
183
|
+
|
|
184
|
+
await this.ax.post<MessageResponse>(url, body);
|
|
185
|
+
}
|
|
186
|
+
public async updateContact(
|
|
187
|
+
contactId: number,
|
|
188
|
+
name: string,
|
|
189
|
+
customerId?: number | null,
|
|
190
|
+
) {
|
|
181
191
|
const url = `/api/whatsapp/contacts/${contactId}`;
|
|
182
192
|
const body: Record<string, any> = { name };
|
|
183
193
|
|
|
@@ -313,4 +323,26 @@ export default class WhatsappClient extends ApiClient {
|
|
|
313
323
|
);
|
|
314
324
|
return response.data;
|
|
315
325
|
}
|
|
326
|
+
|
|
327
|
+
public async getMessages(token: string, filters: FetchMessagesFilters) {
|
|
328
|
+
const params = new URLSearchParams(
|
|
329
|
+
Object.entries(filters)
|
|
330
|
+
.filter(([_, v]) => v !== undefined && v !== null)
|
|
331
|
+
.reduce<Record<string, string>>((acc, [k, v]) => {
|
|
332
|
+
acc[k] = String(v);
|
|
333
|
+
return acc;
|
|
334
|
+
}, {}),
|
|
335
|
+
);
|
|
336
|
+
const url = `/api/whatsapp/messages?${params.toString()}`;
|
|
337
|
+
|
|
338
|
+
const { data: res } = await this.ax.get<
|
|
339
|
+
DataResponse<(WppMessage & { WppContact: WppContact | null })[]>
|
|
340
|
+
>(url, {
|
|
341
|
+
headers: {
|
|
342
|
+
Authorization: `Bearer ${token}`,
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
return res.data;
|
|
347
|
+
}
|
|
316
348
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
4
|
-
"module": "commonjs" /* Specify what module code is generated. */,
|
|
5
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
6
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
7
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
8
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
9
|
-
"noUnusedLocals": false,
|
|
10
|
-
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
11
|
-
"declaration": true
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"src/index.ts",
|
|
15
|
-
"src/**/*.{ts}"
|
|
16
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
4
|
+
"module": "commonjs" /* Specify what module code is generated. */,
|
|
5
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
6
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
7
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
8
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
9
|
+
"noUnusedLocals": false,
|
|
10
|
+
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"src/index.ts",
|
|
15
|
+
"src/**/*.{ts}"
|
|
16
|
+
]
|
|
17
17
|
}
|