@in.pulse-crm/sdk 2.6.13 → 2.7.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
2
|
import { InternalChat, InternalChatMember, InternalGroup, InternalMessage, InternalSendMessageData } from "./types/internal.types";
|
|
3
3
|
export default class InternalChatClient extends ApiClient {
|
|
4
|
-
createInternalChat(participants: number[], isGroup?: boolean, groupName?: string | null, groupId?: string | null): Promise<InternalChat>;
|
|
4
|
+
createInternalChat(participants: number[], isGroup?: boolean, groupName?: string | null, groupId?: string | null, groupImage?: File | null): Promise<InternalChat>;
|
|
5
5
|
deleteInternalChat(chatId: number): Promise<void>;
|
|
6
6
|
getInternalChatsBySession(token?: string | null): Promise<{
|
|
7
7
|
chats: (InternalChat & {
|
|
@@ -16,6 +16,7 @@ export default class InternalChatClient extends ApiClient {
|
|
|
16
16
|
participants: number[];
|
|
17
17
|
wppGroupId: string | null;
|
|
18
18
|
}): Promise<InternalGroup>;
|
|
19
|
+
updateInternalGroupImage(groupId: number, file: File): Promise<InternalGroup>;
|
|
19
20
|
markChatMessagesAsRead(chatId: number): Promise<void>;
|
|
20
21
|
getInternalChatsMonitor(): Promise<{
|
|
21
22
|
chats: (InternalChat & {
|
package/dist/internal.client.js
CHANGED
|
@@ -6,9 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const api_client_1 = __importDefault(require("./api-client"));
|
|
7
7
|
const form_data_1 = __importDefault(require("form-data"));
|
|
8
8
|
class InternalChatClient extends api_client_1.default {
|
|
9
|
-
async createInternalChat(participants, isGroup = false, groupName = null, groupId = null) {
|
|
10
|
-
const
|
|
11
|
-
|
|
9
|
+
async createInternalChat(participants, isGroup = false, groupName = null, groupId = null, groupImage = null) {
|
|
10
|
+
const form = new form_data_1.default();
|
|
11
|
+
if (groupImage) {
|
|
12
|
+
form.append("file", groupImage);
|
|
13
|
+
}
|
|
14
|
+
form.append("data", JSON.stringify({ participants, isGroup, groupName, groupId }));
|
|
15
|
+
const { data: res } = await this.httpClient.post(`/api/internal/chats`, form, {
|
|
16
|
+
headers: {
|
|
17
|
+
"Content-Type": "multipart/form-data",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
12
20
|
return res.data;
|
|
13
21
|
}
|
|
14
22
|
async deleteInternalChat(chatId) {
|
|
@@ -50,6 +58,16 @@ class InternalChatClient extends api_client_1.default {
|
|
|
50
58
|
const { data: res } = await this.httpClient.put(`/api/internal/groups/${groupId}`, data);
|
|
51
59
|
return res.data;
|
|
52
60
|
}
|
|
61
|
+
async updateInternalGroupImage(groupId, file) {
|
|
62
|
+
const formData = new form_data_1.default();
|
|
63
|
+
formData.append("file", file);
|
|
64
|
+
const { data: res } = await this.httpClient.put(`/api/internal/groups/${groupId}/image`, formData, {
|
|
65
|
+
headers: {
|
|
66
|
+
"Content-Type": "multipart/form-data",
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return res.data;
|
|
70
|
+
}
|
|
53
71
|
async markChatMessagesAsRead(chatId) {
|
|
54
72
|
const url = `/api/internal/chat/${chatId}/mark-as-read`;
|
|
55
73
|
await this.httpClient.patch(url);
|
|
@@ -26,6 +26,7 @@ export interface InternalChat {
|
|
|
26
26
|
isGroup: boolean;
|
|
27
27
|
groupName: string | null;
|
|
28
28
|
groupDescription: string | null;
|
|
29
|
+
groupImageFileId: number | null;
|
|
29
30
|
}
|
|
30
31
|
export interface InternalGroup {
|
|
31
32
|
id: number;
|
|
@@ -37,15 +38,16 @@ export interface InternalGroup {
|
|
|
37
38
|
finishedAt: Date | null;
|
|
38
39
|
finishedBy: number | null;
|
|
39
40
|
isGroup: boolean;
|
|
40
|
-
groupId: string | null;
|
|
41
41
|
groupName: string | null;
|
|
42
42
|
groupDescription: string | null;
|
|
43
|
+
groupImageFileId: number | null;
|
|
43
44
|
participants: {
|
|
44
45
|
userId: number;
|
|
45
46
|
joinedAt: Date;
|
|
46
47
|
lastReadAt: Date | null;
|
|
47
48
|
internalChatId: number;
|
|
48
49
|
}[];
|
|
50
|
+
wppGroupId: string | null;
|
|
49
51
|
}
|
|
50
52
|
export interface InternalChatMember {
|
|
51
53
|
internalChatId: number;
|
package/package.json
CHANGED
package/src/internal.client.ts
CHANGED
|
@@ -19,12 +19,26 @@ export default class InternalChatClient extends ApiClient {
|
|
|
19
19
|
isGroup: boolean = false,
|
|
20
20
|
groupName: string | null = null,
|
|
21
21
|
groupId: string | null = null,
|
|
22
|
+
groupImage: File | null = null,
|
|
22
23
|
) {
|
|
23
|
-
const
|
|
24
|
+
const form = new FormData();
|
|
25
|
+
|
|
26
|
+
if (groupImage) {
|
|
27
|
+
form.append("file", groupImage);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
form.append(
|
|
31
|
+
"data",
|
|
32
|
+
JSON.stringify({ participants, isGroup, groupName, groupId }),
|
|
33
|
+
);
|
|
24
34
|
|
|
25
35
|
const { data: res } = await this.httpClient.post<
|
|
26
36
|
DataResponse<InternalChat>
|
|
27
|
-
>(`/api/internal/chats`,
|
|
37
|
+
>(`/api/internal/chats`, form, {
|
|
38
|
+
headers: {
|
|
39
|
+
"Content-Type": "multipart/form-data",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
28
42
|
|
|
29
43
|
return res.data;
|
|
30
44
|
}
|
|
@@ -93,6 +107,20 @@ export default class InternalChatClient extends ApiClient {
|
|
|
93
107
|
return res.data;
|
|
94
108
|
}
|
|
95
109
|
|
|
110
|
+
public async updateInternalGroupImage(groupId: number, file: File) {
|
|
111
|
+
const formData = new FormData();
|
|
112
|
+
formData.append("file", file);
|
|
113
|
+
|
|
114
|
+
const { data: res } = await this.httpClient.put<
|
|
115
|
+
DataResponse<InternalGroup>
|
|
116
|
+
>(`/api/internal/groups/${groupId}/image`, formData, {
|
|
117
|
+
headers: {
|
|
118
|
+
"Content-Type": "multipart/form-data",
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
return res.data;
|
|
122
|
+
}
|
|
123
|
+
|
|
96
124
|
public async markChatMessagesAsRead(chatId: number) {
|
|
97
125
|
const url = `/api/internal/chat/${chatId}/mark-as-read`;
|
|
98
126
|
await this.httpClient.patch(url);
|
|
@@ -28,6 +28,7 @@ export interface InternalChat {
|
|
|
28
28
|
isGroup: boolean;
|
|
29
29
|
groupName: string | null;
|
|
30
30
|
groupDescription: string | null;
|
|
31
|
+
groupImageFileId: number | null;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export interface InternalGroup {
|
|
@@ -40,15 +41,16 @@ export interface InternalGroup {
|
|
|
40
41
|
finishedAt: Date | null;
|
|
41
42
|
finishedBy: number | null;
|
|
42
43
|
isGroup: boolean;
|
|
43
|
-
groupId: string | null;
|
|
44
44
|
groupName: string | null;
|
|
45
45
|
groupDescription: string | null;
|
|
46
|
+
groupImageFileId: number | null;
|
|
46
47
|
participants: {
|
|
47
48
|
userId: number;
|
|
48
49
|
joinedAt: Date;
|
|
49
50
|
lastReadAt: Date | null;
|
|
50
51
|
internalChatId: number;
|
|
51
52
|
}[];
|
|
53
|
+
wppGroupId: string | null;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
export interface InternalChatMember {
|