@in.pulse-crm/sdk 2.14.0 → 2.14.2
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.
|
@@ -38,7 +38,7 @@ export interface EmitSocketEventFn {
|
|
|
38
38
|
(type: SocketEventType.InternalMessage, room: SocketServerInternalChatRoom, data: InternalMessageEventData): Promise<MessageResponse>;
|
|
39
39
|
(type: SocketEventType.InternalMessageEdit, room: SocketServerInternalChatRoom, data: InternalMessageEditEventData): Promise<MessageResponse>;
|
|
40
40
|
(type: SocketEventType.InternalMessageDelete, room: SocketServerInternalChatRoom, data: InternalMessageDeleteEventData): Promise<MessageResponse>;
|
|
41
|
-
(type: SocketEventType.InternalMessageStatus, room: SocketServerInternalChatRoom, data:
|
|
41
|
+
(type: SocketEventType.InternalMessageStatus, room: SocketServerInternalChatRoom, data: InternalMessageStatusEventData): Promise<MessageResponse>;
|
|
42
42
|
(type: SocketEventType.InternalChatStarted, room: SocketServerRoom, data: InternalChatStartedEventData): Promise<MessageResponse>;
|
|
43
43
|
(type: SocketEventType.InternalChatFinished, room: SocketServerRoom, data: InternalChatFinishedEventData): Promise<MessageResponse>;
|
|
44
44
|
}
|
package/package.json
CHANGED
|
@@ -113,7 +113,7 @@ export interface EmitSocketEventFn {
|
|
|
113
113
|
(
|
|
114
114
|
type: SocketEventType.InternalMessageStatus,
|
|
115
115
|
room: SocketServerInternalChatRoom,
|
|
116
|
-
data:
|
|
116
|
+
data: InternalMessageStatusEventData,
|
|
117
117
|
): Promise<MessageResponse>;
|
|
118
118
|
(
|
|
119
119
|
type: SocketEventType.InternalChatStarted,
|
|
@@ -155,15 +155,19 @@ export type WppChatWithDetailsAndMessages = WppChatWithDetails & {
|
|
|
155
155
|
|
|
156
156
|
export interface SendMessageData {
|
|
157
157
|
sendAsChatOwner?: boolean;
|
|
158
|
-
sendAsAudio?: boolean;
|
|
159
|
-
sendAsDocument?: boolean;
|
|
160
158
|
contactId: number;
|
|
159
|
+
text: string;
|
|
161
160
|
quotedId?: number | null;
|
|
162
161
|
chatId?: number | null;
|
|
163
|
-
text?: string | null;
|
|
164
|
-
file?: File;
|
|
165
|
-
fileId?: number;
|
|
166
162
|
}
|
|
163
|
+
|
|
164
|
+
export interface SendFileMessageData extends SendMessageData {
|
|
165
|
+
fileId: number;
|
|
166
|
+
publicFileId: string;
|
|
167
|
+
sendAsDocument?: boolean;
|
|
168
|
+
sendAsAudio?: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
167
171
|
export interface MonitorChat {
|
|
168
172
|
id: string;
|
|
169
173
|
erpCode: string;
|
package/src/whatsapp.client.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ForwardMessagesData,
|
|
11
11
|
PaginatedContactsResponse,
|
|
12
12
|
PaginatedNotificationsResponse,
|
|
13
|
+
SendFileMessageData,
|
|
13
14
|
SendMessageData,
|
|
14
15
|
WppChatsAndMessages,
|
|
15
16
|
WppChatWithDetailsAndMessages,
|
|
@@ -80,21 +81,21 @@ export default class WhatsappClient extends ApiClient {
|
|
|
80
81
|
public async sendMessage(
|
|
81
82
|
clientId: string,
|
|
82
83
|
to: string,
|
|
83
|
-
data: SendMessageData,
|
|
84
|
+
data: SendMessageData | SendFileMessageData,
|
|
84
85
|
) {
|
|
85
86
|
const url = `/api/whatsapp/${clientId}/messages`;
|
|
86
87
|
const formData = new FormData();
|
|
87
88
|
formData.append("to", to);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
data.quotedId && formData.append("quotedId", String(data.quotedId));
|
|
92
|
-
data.chatId && formData.append("chatId", String(data.chatId));
|
|
93
|
-
data.
|
|
94
|
-
data.sendAsAudio && formData.append("sendAsAudio", "true");
|
|
95
|
-
data.sendAsDocument && formData.append("sendAsDocument", "true");
|
|
96
|
-
data.sendAsChatOwner &&
|
|
97
|
-
|
|
89
|
+
formData.append("text", data.text);
|
|
90
|
+
formData.append("contactId", String(data.contactId));
|
|
91
|
+
|
|
92
|
+
("quotedId" in data) && data.quotedId && formData.append("quotedId", String(data.quotedId));
|
|
93
|
+
("chatId" in data) && data.chatId && formData.append("chatId", String(data.chatId));
|
|
94
|
+
("fileId" in data) && data.fileId && formData.append("fileId", String(data.fileId));
|
|
95
|
+
("sendAsAudio" in data) && data.sendAsAudio && formData.append("sendAsAudio", "true");
|
|
96
|
+
("sendAsDocument" in data) && data.sendAsDocument && formData.append("sendAsDocument", "true");
|
|
97
|
+
("sendAsChatOwner" in data) && data.sendAsChatOwner && formData.append("sendAsChatOwner", String(data.sendAsChatOwner));
|
|
98
|
+
|
|
98
99
|
const { data: res } = await this.ax.post<DataResponse<WppMessage>>(
|
|
99
100
|
url,
|
|
100
101
|
formData,
|