@in.pulse-crm/sdk 2.12.3 → 2.12.5
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.
|
@@ -14,14 +14,29 @@ export interface WppContactWithCustomer {
|
|
|
14
14
|
id: number;
|
|
15
15
|
name: string;
|
|
16
16
|
phone: string;
|
|
17
|
-
customerId
|
|
18
|
-
avatarUrl
|
|
17
|
+
customerId: number | null;
|
|
18
|
+
avatarUrl: string | null;
|
|
19
19
|
instance: string;
|
|
20
20
|
isBlocked: boolean;
|
|
21
21
|
isOnlyAdmin: boolean;
|
|
22
|
+
isDeleted: boolean;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
updatedAt: Date | null;
|
|
25
|
+
conversationExpiration: string | null;
|
|
22
26
|
customer: Customer | null;
|
|
23
27
|
chatingWith: string | null;
|
|
24
|
-
lastOutOfHoursReplySentAt
|
|
28
|
+
lastOutOfHoursReplySentAt: Date | null;
|
|
29
|
+
}
|
|
30
|
+
export interface PaginatedContactsResponse {
|
|
31
|
+
data: WppContactWithCustomer[];
|
|
32
|
+
pagination: {
|
|
33
|
+
page: number;
|
|
34
|
+
perPage: number;
|
|
35
|
+
total: number;
|
|
36
|
+
totalPages: number;
|
|
37
|
+
hasNext: boolean;
|
|
38
|
+
hasPrev: boolean;
|
|
39
|
+
};
|
|
25
40
|
}
|
|
26
41
|
export interface WppMessage {
|
|
27
42
|
id: number;
|
|
@@ -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, PaginatedNotificationsResponse, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact,
|
|
4
|
+
import { AppNotification, AutomaticResponseRule, AutomaticResponseRuleDTO, CreateScheduleDTO, ForwardMessagesData, PaginatedContactsResponse, PaginatedNotificationsResponse, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
|
|
5
5
|
interface FetchMessagesFilters {
|
|
6
6
|
minDate: string;
|
|
7
7
|
maxDate: string;
|
|
@@ -22,7 +22,17 @@ export default class WhatsappClient extends ApiClient {
|
|
|
22
22
|
name: string;
|
|
23
23
|
}[]>;
|
|
24
24
|
getCustomerContacts(customerId: number): Promise<WppContact[]>;
|
|
25
|
-
getContactsWithCustomer(
|
|
25
|
+
getContactsWithCustomer(filters?: {
|
|
26
|
+
name?: string;
|
|
27
|
+
phone?: string;
|
|
28
|
+
customerId?: number;
|
|
29
|
+
customerErp?: string;
|
|
30
|
+
customerCnpj?: string;
|
|
31
|
+
customerName?: string;
|
|
32
|
+
hasCustomer?: boolean;
|
|
33
|
+
page?: number;
|
|
34
|
+
perPage?: number;
|
|
35
|
+
}): Promise<PaginatedContactsResponse>;
|
|
26
36
|
getContacts(): Promise<WppContact[]>;
|
|
27
37
|
createContact(name: string, phone: string, customerId?: number): Promise<WppContact>;
|
|
28
38
|
forwardMessages(data: ForwardMessagesData): Promise<void>;
|
package/dist/whatsapp.client.js
CHANGED
|
@@ -81,8 +81,32 @@ class WhatsappClient extends api_client_1.default {
|
|
|
81
81
|
const { data: res } = await this.ax.get(url);
|
|
82
82
|
return res.data;
|
|
83
83
|
}
|
|
84
|
-
async getContactsWithCustomer() {
|
|
85
|
-
|
|
84
|
+
async getContactsWithCustomer(filters) {
|
|
85
|
+
let url = `/api/whatsapp/contacts/customer`;
|
|
86
|
+
if (filters) {
|
|
87
|
+
const params = new URLSearchParams();
|
|
88
|
+
if (filters.name)
|
|
89
|
+
params.append('name', filters.name);
|
|
90
|
+
if (filters.phone)
|
|
91
|
+
params.append('phone', filters.phone);
|
|
92
|
+
if (filters.customerId !== undefined)
|
|
93
|
+
params.append('customerId', String(filters.customerId));
|
|
94
|
+
if (filters.customerErp)
|
|
95
|
+
params.append('customerErp', filters.customerErp);
|
|
96
|
+
if (filters.customerCnpj)
|
|
97
|
+
params.append('customerCnpj', filters.customerCnpj);
|
|
98
|
+
if (filters.customerName)
|
|
99
|
+
params.append('customerName', filters.customerName);
|
|
100
|
+
if (filters.hasCustomer !== undefined)
|
|
101
|
+
params.append('hasCustomer', String(filters.hasCustomer));
|
|
102
|
+
if (filters.page !== undefined)
|
|
103
|
+
params.append('page', String(filters.page));
|
|
104
|
+
if (filters.perPage !== undefined)
|
|
105
|
+
params.append('perPage', String(filters.perPage));
|
|
106
|
+
const queryString = params.toString();
|
|
107
|
+
if (queryString)
|
|
108
|
+
url += `?${queryString}`;
|
|
109
|
+
}
|
|
86
110
|
const { data: res } = await this.ax.get(url);
|
|
87
111
|
return res.data;
|
|
88
112
|
}
|
package/package.json
CHANGED
|
@@ -16,14 +16,30 @@ export interface WppContactWithCustomer {
|
|
|
16
16
|
id: number;
|
|
17
17
|
name: string;
|
|
18
18
|
phone: string;
|
|
19
|
-
customerId
|
|
20
|
-
avatarUrl
|
|
19
|
+
customerId: number | null;
|
|
20
|
+
avatarUrl: string | null;
|
|
21
21
|
instance: string;
|
|
22
22
|
isBlocked: boolean;
|
|
23
23
|
isOnlyAdmin: boolean;
|
|
24
|
+
isDeleted: boolean;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date | null;
|
|
27
|
+
conversationExpiration: string | null;
|
|
24
28
|
customer: Customer | null;
|
|
25
29
|
chatingWith: string | null;
|
|
26
|
-
lastOutOfHoursReplySentAt
|
|
30
|
+
lastOutOfHoursReplySentAt: Date | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface PaginatedContactsResponse {
|
|
34
|
+
data: WppContactWithCustomer[];
|
|
35
|
+
pagination: {
|
|
36
|
+
page: number;
|
|
37
|
+
perPage: number;
|
|
38
|
+
total: number;
|
|
39
|
+
totalPages: number;
|
|
40
|
+
hasNext: boolean;
|
|
41
|
+
hasPrev: boolean;
|
|
42
|
+
};
|
|
27
43
|
}
|
|
28
44
|
|
|
29
45
|
export interface WppMessage {
|
package/src/whatsapp.client.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
AutomaticResponseRuleDTO,
|
|
8
8
|
CreateScheduleDTO,
|
|
9
9
|
ForwardMessagesData,
|
|
10
|
+
PaginatedContactsResponse,
|
|
10
11
|
PaginatedNotificationsResponse,
|
|
11
12
|
SendMessageData,
|
|
12
13
|
WppChatsAndMessages,
|
|
@@ -151,10 +152,34 @@ export default class WhatsappClient extends ApiClient {
|
|
|
151
152
|
return res.data;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
public async getContactsWithCustomer(
|
|
155
|
-
|
|
155
|
+
public async getContactsWithCustomer(filters?: {
|
|
156
|
+
name?: string;
|
|
157
|
+
phone?: string;
|
|
158
|
+
customerId?: number;
|
|
159
|
+
customerErp?: string;
|
|
160
|
+
customerCnpj?: string;
|
|
161
|
+
customerName?: string;
|
|
162
|
+
hasCustomer?: boolean;
|
|
163
|
+
page?: number;
|
|
164
|
+
perPage?: number;
|
|
165
|
+
}) {
|
|
166
|
+
let url = `/api/whatsapp/contacts/customer`;
|
|
167
|
+
if (filters) {
|
|
168
|
+
const params = new URLSearchParams();
|
|
169
|
+
if (filters.name) params.append('name', filters.name);
|
|
170
|
+
if (filters.phone) params.append('phone', filters.phone);
|
|
171
|
+
if (filters.customerId !== undefined) params.append('customerId', String(filters.customerId));
|
|
172
|
+
if (filters.customerErp) params.append('customerErp', filters.customerErp);
|
|
173
|
+
if (filters.customerCnpj) params.append('customerCnpj', filters.customerCnpj);
|
|
174
|
+
if (filters.customerName) params.append('customerName', filters.customerName);
|
|
175
|
+
if (filters.hasCustomer !== undefined) params.append('hasCustomer', String(filters.hasCustomer));
|
|
176
|
+
if (filters.page !== undefined) params.append('page', String(filters.page));
|
|
177
|
+
if (filters.perPage !== undefined) params.append('perPage', String(filters.perPage));
|
|
178
|
+
const queryString = params.toString();
|
|
179
|
+
if (queryString) url += `?${queryString}`;
|
|
180
|
+
}
|
|
156
181
|
const { data: res } =
|
|
157
|
-
await this.ax.get<DataResponse<
|
|
182
|
+
await this.ax.get<DataResponse<PaginatedContactsResponse>>(url);
|
|
158
183
|
return res.data;
|
|
159
184
|
}
|
|
160
185
|
|