@in.pulse-crm/sdk 2.14.1 → 2.14.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.
|
@@ -142,14 +142,16 @@ export type WppChatWithDetailsAndMessages = WppChatWithDetails & {
|
|
|
142
142
|
};
|
|
143
143
|
export interface SendMessageData {
|
|
144
144
|
sendAsChatOwner?: boolean;
|
|
145
|
-
sendAsAudio?: boolean;
|
|
146
|
-
sendAsDocument?: boolean;
|
|
147
145
|
contactId: number;
|
|
146
|
+
text: string;
|
|
148
147
|
quotedId?: number | null;
|
|
149
148
|
chatId?: number | null;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
fileId
|
|
149
|
+
}
|
|
150
|
+
export interface SendFileMessageData extends SendMessageData {
|
|
151
|
+
fileId: number;
|
|
152
|
+
publicFileId: string;
|
|
153
|
+
sendAsDocument?: boolean;
|
|
154
|
+
sendAsAudio?: boolean;
|
|
153
155
|
}
|
|
154
156
|
export interface MonitorChat {
|
|
155
157
|
id: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
2
|
import { RequestFilters } from "./types";
|
|
3
3
|
import { DataResponse, MessageResponse } from "./types/response.types";
|
|
4
|
-
import { AppNotification, AutomaticResponseRule, AutomaticResponseRuleDTO, CreateScheduleDTO, ForwardMessagesData, PaginatedContactsResponse, PaginatedNotificationsResponse, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
|
|
4
|
+
import { AppNotification, AutomaticResponseRule, AutomaticResponseRuleDTO, CreateScheduleDTO, ForwardMessagesData, PaginatedContactsResponse, PaginatedNotificationsResponse, SendFileMessageData, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
|
|
5
5
|
interface FetchMessagesFilters {
|
|
6
6
|
minDate: string;
|
|
7
7
|
maxDate: string;
|
|
@@ -13,7 +13,7 @@ export default class WhatsappClient extends ApiClient {
|
|
|
13
13
|
getMessageById(id: string): Promise<WppMessage>;
|
|
14
14
|
getUserWallets(instance: string, userId: number): Promise<WppWallet[]>;
|
|
15
15
|
markContactMessagesAsRead(contactId: number): Promise<WppMessage[]>;
|
|
16
|
-
sendMessage(clientId: string, to: string, data: SendMessageData): Promise<WppMessage>;
|
|
16
|
+
sendMessage(clientId: string, to: string, data: SendMessageData | SendFileMessageData): Promise<WppMessage>;
|
|
17
17
|
editMessage(clientId: string, messageId: string, newText: string, isInternal?: boolean): Promise<void>;
|
|
18
18
|
finishChatById(id: number, resultId: number, scheduleDate?: Date | null): Promise<void>;
|
|
19
19
|
startChatByContactId(contactId: number, template?: any): Promise<void>;
|
package/dist/whatsapp.client.js
CHANGED
|
@@ -38,16 +38,14 @@ class WhatsappClient extends api_client_1.default {
|
|
|
38
38
|
const url = `/api/whatsapp/${clientId}/messages`;
|
|
39
39
|
const formData = new form_data_1.default();
|
|
40
40
|
formData.append("to", to);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
data.
|
|
44
|
-
data.
|
|
45
|
-
data.
|
|
46
|
-
data.
|
|
47
|
-
data.
|
|
48
|
-
data.
|
|
49
|
-
data.sendAsChatOwner &&
|
|
50
|
-
formData.append("sendAsChatOwner", String(data.sendAsChatOwner));
|
|
41
|
+
formData.append("text", data.text);
|
|
42
|
+
formData.append("contactId", String(data.contactId));
|
|
43
|
+
("quotedId" in data) && data.quotedId && formData.append("quotedId", String(data.quotedId));
|
|
44
|
+
("chatId" in data) && data.chatId && formData.append("chatId", String(data.chatId));
|
|
45
|
+
("fileId" in data) && data.fileId && formData.append("fileId", String(data.fileId));
|
|
46
|
+
("sendAsAudio" in data) && data.sendAsAudio && formData.append("sendAsAudio", "true");
|
|
47
|
+
("sendAsDocument" in data) && data.sendAsDocument && formData.append("sendAsDocument", "true");
|
|
48
|
+
("sendAsChatOwner" in data) && data.sendAsChatOwner && formData.append("sendAsChatOwner", String(data.sendAsChatOwner));
|
|
51
49
|
const { data: res } = await this.ax.post(url, formData, {
|
|
52
50
|
headers: {
|
|
53
51
|
"Content-Type": "multipart/form-data",
|
package/package.json
CHANGED
|
@@ -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,
|