@in.pulse-crm/sdk 2.5.4 → 2.5.13
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 +2 -0
- package/dist/internal.client.d.ts +5 -9
- package/dist/internal.client.js +11 -9
- package/dist/types/customers.types.d.ts +1 -1
- package/dist/types/files.types.d.ts +2 -0
- package/dist/types/internal.types.d.ts +19 -0
- package/dist/types/whatsapp.types.d.ts +12 -0
- package/dist/wallets.client.js +1 -1
- package/dist/whatsapp.client.d.ts +2 -2
- package/dist/whatsapp.client.js +3 -8
- package/package.json +1 -1
- package/src/internal.client.ts +18 -18
- package/src/types/customers.types.ts +0 -5
- package/src/types/internal.types.ts +20 -0
- package/src/types/whatsapp.types.ts +12 -0
- package/src/wallets.client.ts +1 -1
- package/src/whatsapp.client.ts +4 -10
- 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,5 +1,5 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
|
-
import { InternalChat, InternalMessage, InternalSendMessageData } from "./types/internal.types";
|
|
2
|
+
import { InternalChat, InternalGroup, InternalMessage, InternalSendMessageData } from "./types/internal.types";
|
|
3
3
|
export default class InternalChatClient extends ApiClient {
|
|
4
4
|
createInternalChat(participants: number[], isGroup?: boolean, groupName?: string): Promise<InternalChat>;
|
|
5
5
|
getInternalChatsBySession(token?: string | null): Promise<{
|
|
@@ -8,15 +8,11 @@ export default class InternalChatClient extends ApiClient {
|
|
|
8
8
|
})[];
|
|
9
9
|
messages: InternalMessage[];
|
|
10
10
|
}>;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
getInternalGroups(): Promise<InternalGroup[]>;
|
|
12
|
+
sendMessageToInternalChat(data: InternalSendMessageData): Promise<void>;
|
|
13
|
+
updateInternalGroup(groupId: number, { name, participants }: {
|
|
13
14
|
name: string;
|
|
14
15
|
participants: number[];
|
|
15
|
-
}): Promise<
|
|
16
|
-
startChatByContactId(contactId: number): Promise<{
|
|
17
|
-
chat: InternalChat & {
|
|
18
|
-
messages: InternalMessage[];
|
|
19
|
-
};
|
|
20
|
-
}>;
|
|
16
|
+
}): Promise<InternalGroup>;
|
|
21
17
|
setAuth(token: string): void;
|
|
22
18
|
}
|
package/dist/internal.client.js
CHANGED
|
@@ -21,7 +21,12 @@ class InternalChatClient extends api_client_1.default {
|
|
|
21
21
|
});
|
|
22
22
|
return res.data;
|
|
23
23
|
}
|
|
24
|
-
async
|
|
24
|
+
async getInternalGroups() {
|
|
25
|
+
const url = `/api/internal/groups`;
|
|
26
|
+
const { data: res } = await this.httpClient.get(url);
|
|
27
|
+
return res.data;
|
|
28
|
+
}
|
|
29
|
+
async sendMessageToInternalChat(data) {
|
|
25
30
|
const url = `/api/internal/chats/${data.chatId}/messages`;
|
|
26
31
|
const formData = new form_data_1.default();
|
|
27
32
|
formData.append("chatId", data.chatId.toString());
|
|
@@ -37,14 +42,11 @@ class InternalChatClient extends api_client_1.default {
|
|
|
37
42
|
},
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
|
-
async
|
|
41
|
-
const { data: res } = await this.httpClient.put(`/api/internal/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const url = `/api/internal/chats`;
|
|
46
|
-
const body = { contactId };
|
|
47
|
-
const { data: res } = await this.httpClient.post(url, body);
|
|
45
|
+
async updateInternalGroup(groupId, { name, participants }) {
|
|
46
|
+
const { data: res } = await this.httpClient.put(`/api/internal/groups/${groupId}`, {
|
|
47
|
+
name,
|
|
48
|
+
participants,
|
|
49
|
+
});
|
|
48
50
|
return res.data;
|
|
49
51
|
}
|
|
50
52
|
setAuth(token) {
|
|
@@ -63,5 +63,5 @@ export interface Customer {
|
|
|
63
63
|
CODIGOPRINCIPAL: number;
|
|
64
64
|
SETOR: number;
|
|
65
65
|
}
|
|
66
|
-
export type CreateCustomerDTO = Pick<Customer, "RAZAO" | "
|
|
66
|
+
export type CreateCustomerDTO = Pick<Customer, "RAZAO" | "CPF_CNPJ">;
|
|
67
67
|
export type UpdateCustomerDTO = Partial<CreateCustomerDTO>;
|
|
@@ -27,6 +27,25 @@ export interface InternalChat {
|
|
|
27
27
|
groupName: string | null;
|
|
28
28
|
groupDescription: string | null;
|
|
29
29
|
}
|
|
30
|
+
export interface InternalGroup {
|
|
31
|
+
id: number;
|
|
32
|
+
instance: string;
|
|
33
|
+
creatorId: number | null;
|
|
34
|
+
sectorId: number | null;
|
|
35
|
+
isFinished: true;
|
|
36
|
+
startedAt: Date;
|
|
37
|
+
finishedAt: Date | null;
|
|
38
|
+
finishedBy: number | null;
|
|
39
|
+
isGroup: boolean;
|
|
40
|
+
groupName: string | null;
|
|
41
|
+
groupDescription: string | null;
|
|
42
|
+
participants: {
|
|
43
|
+
userId: number;
|
|
44
|
+
joinedAt: Date;
|
|
45
|
+
lastReadAt: Date | null;
|
|
46
|
+
internalChatId: number;
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
30
49
|
export interface InternalChatMember {
|
|
31
50
|
internalchatId: number;
|
|
32
51
|
internalcontactId: number;
|
|
@@ -108,3 +108,15 @@ export interface SendMessageData {
|
|
|
108
108
|
file?: File;
|
|
109
109
|
fileId?: number;
|
|
110
110
|
}
|
|
111
|
+
export interface MonitorChat {
|
|
112
|
+
id: string;
|
|
113
|
+
erpCode: string;
|
|
114
|
+
companyName: string;
|
|
115
|
+
contactName: string;
|
|
116
|
+
whatsappNumber: string;
|
|
117
|
+
sectorName: string;
|
|
118
|
+
attendantName: string;
|
|
119
|
+
startDate: string;
|
|
120
|
+
endDate: string;
|
|
121
|
+
result: string;
|
|
122
|
+
}
|
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(instance, name) {
|
|
9
9
|
try {
|
|
10
|
-
const response = await this.httpClient.post(`/api/wallets`, {
|
|
10
|
+
const response = await this.httpClient.post(`/api/wallets`, { instance, name });
|
|
11
11
|
return response.data.data;
|
|
12
12
|
}
|
|
13
13
|
catch (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
|
-
import { SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppContactWithCustomer, WppMessage, WppWallet } from "./types/whatsapp.types";
|
|
2
|
+
import { MonitorChat, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppContactWithCustomer, WppMessage, WppWallet } from "./types/whatsapp.types";
|
|
3
3
|
export default class WhatsappClient extends ApiClient {
|
|
4
4
|
getChatsBySession(messages?: boolean, contact?: boolean, token?: string | null): Promise<WppChatsAndMessages>;
|
|
5
5
|
getChatById(id: number): Promise<WppChatWithDetailsAndMessages>;
|
|
@@ -23,6 +23,6 @@ export default class WhatsappClient extends ApiClient {
|
|
|
23
23
|
name: string;
|
|
24
24
|
}[]>;
|
|
25
25
|
setAuth(token: string): void;
|
|
26
|
-
getChatsMonitor(
|
|
26
|
+
getChatsMonitor(): Promise<MonitorChat[]>;
|
|
27
27
|
transferAttendance(id: number, userId: number): Promise<void>;
|
|
28
28
|
}
|
package/dist/whatsapp.client.js
CHANGED
|
@@ -105,14 +105,9 @@ class WhatsappClient extends api_client_1.default {
|
|
|
105
105
|
this.httpClient.defaults.headers.common["Authorization"] =
|
|
106
106
|
`Bearer ${token}`;
|
|
107
107
|
}
|
|
108
|
-
async getChatsMonitor(
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
: undefined;
|
|
112
|
-
const url = `/api/whatsapp/session/monitor?messages=${messages}&contact=${contact}`;
|
|
113
|
-
const { data: res } = await this.httpClient.get(url, {
|
|
114
|
-
headers,
|
|
115
|
-
});
|
|
108
|
+
async getChatsMonitor() {
|
|
109
|
+
const url = `/api/whatsapp/session/monitor`;
|
|
110
|
+
const { data: res } = await this.httpClient.get(url);
|
|
116
111
|
return res.data;
|
|
117
112
|
}
|
|
118
113
|
async transferAttendance(id, userId) {
|
package/package.json
CHANGED
package/src/internal.client.ts
CHANGED
|
@@ -2,6 +2,7 @@ import ApiClient from "./api-client";
|
|
|
2
2
|
import { DataResponse } from "./types/response.types";
|
|
3
3
|
import {
|
|
4
4
|
InternalChat,
|
|
5
|
+
InternalGroup,
|
|
5
6
|
InternalMessage,
|
|
6
7
|
InternalSendMessageData,
|
|
7
8
|
} from "./types/internal.types";
|
|
@@ -29,6 +30,7 @@ export default class InternalChatClient extends ApiClient {
|
|
|
29
30
|
|
|
30
31
|
return res.data;
|
|
31
32
|
}
|
|
33
|
+
|
|
32
34
|
public async getInternalChatsBySession(token: string | null = null) {
|
|
33
35
|
const url = `/api/internal/session/chats`;
|
|
34
36
|
|
|
@@ -43,7 +45,15 @@ export default class InternalChatClient extends ApiClient {
|
|
|
43
45
|
return res.data;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
public async
|
|
48
|
+
public async getInternalGroups() {
|
|
49
|
+
const url = `/api/internal/groups`;
|
|
50
|
+
const { data: res } =
|
|
51
|
+
await this.httpClient.get<DataResponse<InternalGroup[]>>(url);
|
|
52
|
+
|
|
53
|
+
return res.data;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public async sendMessageToInternalChat(data: InternalSendMessageData) {
|
|
47
57
|
const url = `/api/internal/chats/${data.chatId}/messages`;
|
|
48
58
|
const formData = new FormData();
|
|
49
59
|
|
|
@@ -66,26 +76,16 @@ export default class InternalChatClient extends ApiClient {
|
|
|
66
76
|
);
|
|
67
77
|
}
|
|
68
78
|
|
|
69
|
-
public async
|
|
79
|
+
public async updateInternalGroup(
|
|
70
80
|
groupId: number,
|
|
71
81
|
{ name, participants }: { name: string; participants: number[] },
|
|
72
82
|
) {
|
|
73
|
-
const { data: res } = await this.httpClient.put<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
public async startChatByContactId(contactId: number) {
|
|
81
|
-
const url = `/api/internal/chats`;
|
|
82
|
-
const body = { contactId };
|
|
83
|
-
|
|
84
|
-
const { data: res } = await this.httpClient.post<StartChatResponse>(
|
|
85
|
-
url,
|
|
86
|
-
body,
|
|
87
|
-
);
|
|
88
|
-
|
|
83
|
+
const { data: res } = await this.httpClient.put<
|
|
84
|
+
DataResponse<InternalGroup>
|
|
85
|
+
>(`/api/internal/groups/${groupId}`, {
|
|
86
|
+
name,
|
|
87
|
+
participants,
|
|
88
|
+
});
|
|
89
89
|
return res.data;
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -30,6 +30,26 @@ export interface InternalChat {
|
|
|
30
30
|
groupDescription: string | null;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export interface InternalGroup {
|
|
34
|
+
id: number;
|
|
35
|
+
instance: string;
|
|
36
|
+
creatorId: number | null;
|
|
37
|
+
sectorId: number | null;
|
|
38
|
+
isFinished: true;
|
|
39
|
+
startedAt: Date;
|
|
40
|
+
finishedAt: Date | null;
|
|
41
|
+
finishedBy: number | null;
|
|
42
|
+
isGroup: boolean;
|
|
43
|
+
groupName: string | null;
|
|
44
|
+
groupDescription: string | null;
|
|
45
|
+
participants: {
|
|
46
|
+
userId: number;
|
|
47
|
+
joinedAt: Date;
|
|
48
|
+
lastReadAt: Date | null;
|
|
49
|
+
internalChatId: number;
|
|
50
|
+
}[];
|
|
51
|
+
}
|
|
52
|
+
|
|
33
53
|
export interface InternalChatMember {
|
|
34
54
|
internalchatId: number;
|
|
35
55
|
internalcontactId: number;
|
|
@@ -128,3 +128,15 @@ export interface SendMessageData {
|
|
|
128
128
|
file?: File;
|
|
129
129
|
fileId?: number;
|
|
130
130
|
}
|
|
131
|
+
export interface MonitorChat {
|
|
132
|
+
id: string;
|
|
133
|
+
erpCode: string;
|
|
134
|
+
companyName: string;
|
|
135
|
+
contactName: string;
|
|
136
|
+
whatsappNumber: string;
|
|
137
|
+
sectorName: string;
|
|
138
|
+
attendantName: string;
|
|
139
|
+
startDate: string;
|
|
140
|
+
endDate: string;
|
|
141
|
+
result: string;
|
|
142
|
+
}
|
package/src/wallets.client.ts
CHANGED
package/src/whatsapp.client.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
2
|
import { DataResponse, MessageResponse } from "./types/response.types";
|
|
3
3
|
import {
|
|
4
|
+
MonitorChat,
|
|
4
5
|
SendMessageData,
|
|
5
6
|
WppChatsAndMessages,
|
|
6
7
|
WppChatWithDetailsAndMessages,
|
|
@@ -15,6 +16,7 @@ type GetChatsResponse = DataResponse<WppChatsAndMessages>;
|
|
|
15
16
|
type GetChatResponse = DataResponse<WppChatWithDetailsAndMessages>;
|
|
16
17
|
type GetMessageResponse = DataResponse<WppMessage>;
|
|
17
18
|
type MarkChatAsReadResponse = DataResponse<WppMessage[]>;
|
|
19
|
+
type GetMonitorChatsResponse = DataResponse<MonitorChat[]>;
|
|
18
20
|
|
|
19
21
|
export default class WhatsappClient extends ApiClient {
|
|
20
22
|
public async getChatsBySession(
|
|
@@ -186,18 +188,10 @@ export default class WhatsappClient extends ApiClient {
|
|
|
186
188
|
`Bearer ${token}`;
|
|
187
189
|
}
|
|
188
190
|
public async getChatsMonitor(
|
|
189
|
-
messages = false,
|
|
190
|
-
contact = false,
|
|
191
|
-
token: string | null = null,
|
|
192
191
|
) {
|
|
193
|
-
const
|
|
194
|
-
? { Authorization: `Bearer ${token}` }
|
|
195
|
-
: undefined;
|
|
196
|
-
const url = `/api/whatsapp/session/monitor?messages=${messages}&contact=${contact}`;
|
|
192
|
+
const url = `/api/whatsapp/session/monitor`;
|
|
197
193
|
|
|
198
|
-
const { data: res } = await this.httpClient.get<
|
|
199
|
-
headers,
|
|
200
|
-
});
|
|
194
|
+
const { data: res } = await this.httpClient.get<GetMonitorChatsResponse>(url,);
|
|
201
195
|
|
|
202
196
|
return res.data;
|
|
203
197
|
}
|
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
|
}
|