@in.pulse-crm/sdk 2.10.1 → 2.10.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.
|
@@ -4,20 +4,24 @@ export interface WppContact {
|
|
|
4
4
|
name: string;
|
|
5
5
|
phone: string;
|
|
6
6
|
customerId?: number;
|
|
7
|
+
avatarUrl?: string;
|
|
7
8
|
instance: string;
|
|
8
9
|
isBlocked: boolean;
|
|
9
10
|
isOnlyAdmin: boolean;
|
|
11
|
+
lastOutOfHoursReplySentAt?: Date | null;
|
|
10
12
|
}
|
|
11
13
|
export interface WppContactWithCustomer {
|
|
12
14
|
id: number;
|
|
13
15
|
name: string;
|
|
14
16
|
phone: string;
|
|
15
17
|
customerId?: number;
|
|
18
|
+
avatarUrl?: string;
|
|
16
19
|
instance: string;
|
|
17
20
|
isBlocked: boolean;
|
|
18
21
|
isOnlyAdmin: boolean;
|
|
19
22
|
customer: Customer | null;
|
|
20
23
|
chatingWith: string | null;
|
|
24
|
+
lastOutOfHoursReplySentAt?: Date | null;
|
|
21
25
|
}
|
|
22
26
|
export interface WppMessage {
|
|
23
27
|
id: number;
|
|
@@ -29,6 +33,7 @@ export interface WppMessage {
|
|
|
29
33
|
type: string;
|
|
30
34
|
quotedId?: number | null;
|
|
31
35
|
chatId?: number | null;
|
|
36
|
+
userName?: string;
|
|
32
37
|
contactId?: number | null;
|
|
33
38
|
body: string;
|
|
34
39
|
timestamp: string;
|
|
@@ -55,6 +60,7 @@ export interface WppChat {
|
|
|
55
60
|
instance: string;
|
|
56
61
|
contactId?: number;
|
|
57
62
|
userId?: number;
|
|
63
|
+
userName?: string;
|
|
58
64
|
walletId?: number;
|
|
59
65
|
botId?: number;
|
|
60
66
|
resultId?: number;
|
|
@@ -164,3 +170,32 @@ export interface PaginatedNotificationsResponse {
|
|
|
164
170
|
notifications: AppNotification[];
|
|
165
171
|
totalCount: number;
|
|
166
172
|
}
|
|
173
|
+
export interface AutomaticResponseSchedule {
|
|
174
|
+
id?: number;
|
|
175
|
+
dayOfWeek: number;
|
|
176
|
+
startTime: string;
|
|
177
|
+
endTime: string;
|
|
178
|
+
}
|
|
179
|
+
export interface AutomaticResponseRule {
|
|
180
|
+
id: number;
|
|
181
|
+
name: string;
|
|
182
|
+
message: string;
|
|
183
|
+
isEnabled: boolean;
|
|
184
|
+
isGlobal: boolean;
|
|
185
|
+
cooldownSeconds: number;
|
|
186
|
+
fileId: number | null;
|
|
187
|
+
schedules: AutomaticResponseSchedule[];
|
|
188
|
+
userAssignments: {
|
|
189
|
+
userId: number;
|
|
190
|
+
}[];
|
|
191
|
+
}
|
|
192
|
+
export interface AutomaticResponseRuleDTO {
|
|
193
|
+
name: string;
|
|
194
|
+
message: string;
|
|
195
|
+
isEnabled: boolean;
|
|
196
|
+
isGlobal: boolean;
|
|
197
|
+
cooldownSeconds: number;
|
|
198
|
+
fileId?: number | null;
|
|
199
|
+
userIds: number[];
|
|
200
|
+
schedules: Omit<AutomaticResponseSchedule, 'id'>[];
|
|
201
|
+
}
|
|
@@ -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, CreateScheduleDTO, ForwardMessagesData, PaginatedNotificationsResponse, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppContactWithCustomer, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
|
|
4
|
+
import { AppNotification, AutomaticResponseRule, AutomaticResponseRuleDTO, CreateScheduleDTO, ForwardMessagesData, PaginatedNotificationsResponse, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppContactWithCustomer, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
|
|
5
5
|
interface FetchMessagesFilters {
|
|
6
6
|
minDate: string;
|
|
7
7
|
maxDate: string;
|
|
@@ -79,5 +79,9 @@ export default class WhatsappClient extends ApiClient {
|
|
|
79
79
|
getMessages(token: string, filters: FetchMessagesFilters): Promise<(WppMessage & {
|
|
80
80
|
WppContact: WppContact | null;
|
|
81
81
|
})[]>;
|
|
82
|
+
getAutoResponseRules(): Promise<AutomaticResponseRule[]>;
|
|
83
|
+
createAutoResponseRule(ruleData: AutomaticResponseRuleDTO): Promise<AutomaticResponseRule>;
|
|
84
|
+
updateAutoResponseRule(id: number, ruleData: Omit<AutomaticResponseRuleDTO, 'instance'>): Promise<AutomaticResponseRule>;
|
|
85
|
+
deleteAutoResponseRule(id: number): Promise<void>;
|
|
82
86
|
}
|
|
83
87
|
export {};
|
package/dist/whatsapp.client.js
CHANGED
|
@@ -237,5 +237,24 @@ class WhatsappClient extends api_client_1.default {
|
|
|
237
237
|
});
|
|
238
238
|
return res.data;
|
|
239
239
|
}
|
|
240
|
+
async getAutoResponseRules() {
|
|
241
|
+
const url = `/api/auto-response-rules`;
|
|
242
|
+
const { data: res } = await this.ax.get(url);
|
|
243
|
+
return res.data;
|
|
244
|
+
}
|
|
245
|
+
async createAutoResponseRule(ruleData) {
|
|
246
|
+
const url = `/api/auto-response-rules`;
|
|
247
|
+
const { data: res } = await this.ax.post(url, ruleData);
|
|
248
|
+
return res.data;
|
|
249
|
+
}
|
|
250
|
+
async updateAutoResponseRule(id, ruleData) {
|
|
251
|
+
const url = `/api/auto-response-rules/${id}`;
|
|
252
|
+
const { data: res } = await this.ax.put(url, ruleData);
|
|
253
|
+
return res.data;
|
|
254
|
+
}
|
|
255
|
+
async deleteAutoResponseRule(id) {
|
|
256
|
+
const url = `/api/auto-response-rules/${id}`;
|
|
257
|
+
await this.ax.delete(url);
|
|
258
|
+
}
|
|
240
259
|
}
|
|
241
260
|
exports.default = WhatsappClient;
|
package/package.json
CHANGED
|
@@ -5,9 +5,11 @@ export interface WppContact {
|
|
|
5
5
|
name: string;
|
|
6
6
|
phone: string;
|
|
7
7
|
customerId?: number;
|
|
8
|
+
avatarUrl?: string;
|
|
8
9
|
instance: string;
|
|
9
10
|
isBlocked: boolean;
|
|
10
11
|
isOnlyAdmin: boolean;
|
|
12
|
+
lastOutOfHoursReplySentAt?: Date | null;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface WppContactWithCustomer {
|
|
@@ -15,11 +17,13 @@ export interface WppContactWithCustomer {
|
|
|
15
17
|
name: string;
|
|
16
18
|
phone: string;
|
|
17
19
|
customerId?: number;
|
|
20
|
+
avatarUrl?: string;
|
|
18
21
|
instance: string;
|
|
19
22
|
isBlocked: boolean;
|
|
20
23
|
isOnlyAdmin: boolean;
|
|
21
24
|
customer: Customer | null;
|
|
22
25
|
chatingWith: string | null;
|
|
26
|
+
lastOutOfHoursReplySentAt?: Date | null;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
export interface WppMessage {
|
|
@@ -32,6 +36,7 @@ export interface WppMessage {
|
|
|
32
36
|
type: string;
|
|
33
37
|
quotedId?: number | null;
|
|
34
38
|
chatId?: number | null;
|
|
39
|
+
userName?: string;
|
|
35
40
|
contactId?: number | null;
|
|
36
41
|
body: string;
|
|
37
42
|
timestamp: string;
|
|
@@ -54,6 +59,7 @@ export interface WppChat {
|
|
|
54
59
|
instance: string;
|
|
55
60
|
contactId?: number;
|
|
56
61
|
userId?: number;
|
|
62
|
+
userName?: string;
|
|
57
63
|
walletId?: number;
|
|
58
64
|
botId?: number;
|
|
59
65
|
resultId?: number;
|
|
@@ -189,4 +195,34 @@ export interface AppNotification {
|
|
|
189
195
|
export interface PaginatedNotificationsResponse {
|
|
190
196
|
notifications: AppNotification[];
|
|
191
197
|
totalCount: number;
|
|
192
|
-
}
|
|
198
|
+
}
|
|
199
|
+
export interface AutomaticResponseSchedule {
|
|
200
|
+
id?: number;
|
|
201
|
+
dayOfWeek: number;
|
|
202
|
+
startTime: string;
|
|
203
|
+
endTime: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface AutomaticResponseRule {
|
|
207
|
+
id: number;
|
|
208
|
+
name: string;
|
|
209
|
+
message: string;
|
|
210
|
+
isEnabled: boolean;
|
|
211
|
+
isGlobal: boolean;
|
|
212
|
+
cooldownSeconds: number;
|
|
213
|
+
fileId: number | null;
|
|
214
|
+
schedules: AutomaticResponseSchedule[];
|
|
215
|
+
userAssignments: { userId: number }[];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface AutomaticResponseRuleDTO {
|
|
219
|
+
name: string;
|
|
220
|
+
message: string;
|
|
221
|
+
isEnabled: boolean;
|
|
222
|
+
isGlobal: boolean;
|
|
223
|
+
cooldownSeconds: number;
|
|
224
|
+
fileId?: number | null;
|
|
225
|
+
userIds: number[];
|
|
226
|
+
schedules: Omit<AutomaticResponseSchedule, 'id'>[];
|
|
227
|
+
}
|
|
228
|
+
|
package/src/whatsapp.client.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { RequestFilters } from "./types";
|
|
|
3
3
|
import { DataResponse, MessageResponse } from "./types/response.types";
|
|
4
4
|
import {
|
|
5
5
|
AppNotification,
|
|
6
|
+
AutomaticResponseRule,
|
|
7
|
+
AutomaticResponseRuleDTO,
|
|
6
8
|
CreateScheduleDTO,
|
|
7
9
|
ForwardMessagesData,
|
|
8
10
|
PaginatedNotificationsResponse,
|
|
@@ -339,4 +341,26 @@ export default class WhatsappClient extends ApiClient {
|
|
|
339
341
|
});
|
|
340
342
|
return res.data;
|
|
341
343
|
}
|
|
344
|
+
public async getAutoResponseRules() {
|
|
345
|
+
const url = `/api/auto-response-rules`;
|
|
346
|
+
const { data: res } = await this.ax.get<DataResponse<AutomaticResponseRule[]>>(url);
|
|
347
|
+
return res.data;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
public async createAutoResponseRule(ruleData: AutomaticResponseRuleDTO) {
|
|
351
|
+
const url = `/api/auto-response-rules`;
|
|
352
|
+
const { data: res } = await this.ax.post<DataResponse<AutomaticResponseRule>>(url, ruleData);
|
|
353
|
+
return res.data;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
public async updateAutoResponseRule(id: number, ruleData: Omit<AutomaticResponseRuleDTO, 'instance'>) {
|
|
357
|
+
const url = `/api/auto-response-rules/${id}`;
|
|
358
|
+
const { data: res } = await this.ax.put<DataResponse<AutomaticResponseRule>>(url, ruleData);
|
|
359
|
+
return res.data;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
public async deleteAutoResponseRule(id: number) {
|
|
363
|
+
const url = `/api/auto-response-rules/${id}`;
|
|
364
|
+
await this.ax.delete<MessageResponse>(url);
|
|
365
|
+
}
|
|
342
366
|
}
|