@in.pulse-crm/sdk 2.12.5 → 2.12.7
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.
- package/dist/whatsapp.client.d.ts +3 -2
- package/dist/whatsapp.client.js +27 -14
- package/package.json +1 -1
- package/src/whatsapp.client.ts +38 -16
|
@@ -34,9 +34,10 @@ export default class WhatsappClient extends ApiClient {
|
|
|
34
34
|
perPage?: number;
|
|
35
35
|
}): Promise<PaginatedContactsResponse>;
|
|
36
36
|
getContacts(): Promise<WppContact[]>;
|
|
37
|
-
createContact(name: string, phone: string, customerId?: number): Promise<WppContact>;
|
|
37
|
+
createContact(name: string, phone: string, customerId?: number, sectorIds?: number[]): Promise<WppContact>;
|
|
38
38
|
forwardMessages(data: ForwardMessagesData): Promise<void>;
|
|
39
|
-
updateContact(contactId: number, name
|
|
39
|
+
updateContact(contactId: number, name?: string, customerId?: number | null, sectorIds?: number[] | null): Promise<WppContact>;
|
|
40
|
+
addSectorToContact(contactId: number, sectorId: number): Promise<WppContact>;
|
|
40
41
|
deleteContact(contactId: number): Promise<void>;
|
|
41
42
|
getSectors(): Promise<{
|
|
42
43
|
id: number;
|
package/dist/whatsapp.client.js
CHANGED
|
@@ -86,28 +86,28 @@ class WhatsappClient extends api_client_1.default {
|
|
|
86
86
|
if (filters) {
|
|
87
87
|
const params = new URLSearchParams();
|
|
88
88
|
if (filters.name)
|
|
89
|
-
params.append(
|
|
89
|
+
params.append("name", filters.name);
|
|
90
90
|
if (filters.phone)
|
|
91
|
-
params.append(
|
|
91
|
+
params.append("phone", filters.phone);
|
|
92
92
|
if (filters.customerId !== undefined)
|
|
93
|
-
params.append(
|
|
93
|
+
params.append("customerId", String(filters.customerId));
|
|
94
94
|
if (filters.customerErp)
|
|
95
|
-
params.append(
|
|
95
|
+
params.append("customerErp", filters.customerErp);
|
|
96
96
|
if (filters.customerCnpj)
|
|
97
|
-
params.append(
|
|
97
|
+
params.append("customerCnpj", filters.customerCnpj);
|
|
98
98
|
if (filters.customerName)
|
|
99
|
-
params.append(
|
|
99
|
+
params.append("customerName", filters.customerName);
|
|
100
100
|
if (filters.hasCustomer !== undefined)
|
|
101
|
-
params.append(
|
|
101
|
+
params.append("hasCustomer", String(filters.hasCustomer));
|
|
102
102
|
if (filters.page !== undefined)
|
|
103
|
-
params.append(
|
|
103
|
+
params.append("page", String(filters.page));
|
|
104
104
|
if (filters.perPage !== undefined)
|
|
105
|
-
params.append(
|
|
105
|
+
params.append("perPage", String(filters.perPage));
|
|
106
106
|
const queryString = params.toString();
|
|
107
107
|
if (queryString)
|
|
108
108
|
url += `?${queryString}`;
|
|
109
109
|
}
|
|
110
|
-
const
|
|
110
|
+
const res = await this.ax.get(url);
|
|
111
111
|
return res.data;
|
|
112
112
|
}
|
|
113
113
|
async getContacts() {
|
|
@@ -115,12 +115,14 @@ class WhatsappClient extends api_client_1.default {
|
|
|
115
115
|
const { data: res } = await this.ax.get(url);
|
|
116
116
|
return res.data;
|
|
117
117
|
}
|
|
118
|
-
async createContact(name, phone, customerId) {
|
|
118
|
+
async createContact(name, phone, customerId, sectorIds) {
|
|
119
119
|
const baseUrl = `/api/whatsapp`;
|
|
120
120
|
const url = customerId
|
|
121
121
|
? `${baseUrl}/customers/${customerId}/contacts`
|
|
122
122
|
: `${baseUrl}/contacts`;
|
|
123
123
|
const body = { name, phone };
|
|
124
|
+
if (sectorIds !== undefined)
|
|
125
|
+
body['sectorIds'] = sectorIds;
|
|
124
126
|
const { data: res } = await this.ax.post(url, body);
|
|
125
127
|
return res.data;
|
|
126
128
|
}
|
|
@@ -129,13 +131,24 @@ class WhatsappClient extends api_client_1.default {
|
|
|
129
131
|
const body = data;
|
|
130
132
|
await this.ax.post(url, body);
|
|
131
133
|
}
|
|
132
|
-
async updateContact(contactId, name, customerId) {
|
|
134
|
+
async updateContact(contactId, name, customerId, sectorIds) {
|
|
133
135
|
const url = `/api/whatsapp/contacts/${contactId}`;
|
|
134
|
-
const body = {
|
|
135
|
-
|
|
136
|
+
const body = {};
|
|
137
|
+
if (name !== undefined)
|
|
138
|
+
body["name"] = name;
|
|
139
|
+
if (customerId !== undefined)
|
|
140
|
+
body["customerId"] = customerId;
|
|
141
|
+
if (sectorIds !== undefined)
|
|
142
|
+
body["sectorIds"] = sectorIds;
|
|
136
143
|
const { data: res } = await this.ax.put(url, body);
|
|
137
144
|
return res.data;
|
|
138
145
|
}
|
|
146
|
+
async addSectorToContact(contactId, sectorId) {
|
|
147
|
+
const url = `/api/whatsapp/contacts/${contactId}/sectors`;
|
|
148
|
+
const body = { sectorId };
|
|
149
|
+
const { data: res } = await this.ax.post(url, body);
|
|
150
|
+
return res.data;
|
|
151
|
+
}
|
|
139
152
|
async deleteContact(contactId) {
|
|
140
153
|
const url = `/api/whatsapp/contacts/${contactId}`;
|
|
141
154
|
await this.ax.delete(url);
|
package/package.json
CHANGED
package/src/whatsapp.client.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
WppChatsAndMessages,
|
|
14
14
|
WppChatWithDetailsAndMessages,
|
|
15
15
|
WppContact,
|
|
16
|
-
WppContactWithCustomer,
|
|
17
16
|
WppMessage,
|
|
18
17
|
WppSchedule,
|
|
19
18
|
WppWallet,
|
|
@@ -166,20 +165,28 @@ export default class WhatsappClient extends ApiClient {
|
|
|
166
165
|
let url = `/api/whatsapp/contacts/customer`;
|
|
167
166
|
if (filters) {
|
|
168
167
|
const params = new URLSearchParams();
|
|
169
|
-
if (filters.name) params.append(
|
|
170
|
-
if (filters.phone) params.append(
|
|
171
|
-
if (filters.customerId !== undefined)
|
|
172
|
-
|
|
173
|
-
if (filters.
|
|
174
|
-
|
|
175
|
-
if (filters.
|
|
176
|
-
|
|
177
|
-
if (filters.
|
|
168
|
+
if (filters.name) params.append("name", filters.name);
|
|
169
|
+
if (filters.phone) params.append("phone", filters.phone);
|
|
170
|
+
if (filters.customerId !== undefined)
|
|
171
|
+
params.append("customerId", String(filters.customerId));
|
|
172
|
+
if (filters.customerErp)
|
|
173
|
+
params.append("customerErp", filters.customerErp);
|
|
174
|
+
if (filters.customerCnpj)
|
|
175
|
+
params.append("customerCnpj", filters.customerCnpj);
|
|
176
|
+
if (filters.customerName)
|
|
177
|
+
params.append("customerName", filters.customerName);
|
|
178
|
+
if (filters.hasCustomer !== undefined)
|
|
179
|
+
params.append("hasCustomer", String(filters.hasCustomer));
|
|
180
|
+
if (filters.page !== undefined)
|
|
181
|
+
params.append("page", String(filters.page));
|
|
182
|
+
if (filters.perPage !== undefined)
|
|
183
|
+
params.append("perPage", String(filters.perPage));
|
|
178
184
|
const queryString = params.toString();
|
|
179
185
|
if (queryString) url += `?${queryString}`;
|
|
180
186
|
}
|
|
181
|
-
|
|
182
|
-
|
|
187
|
+
|
|
188
|
+
const res = await this.ax.get<PaginatedContactsResponse>(url);
|
|
189
|
+
|
|
183
190
|
return res.data;
|
|
184
191
|
}
|
|
185
192
|
|
|
@@ -194,12 +201,14 @@ export default class WhatsappClient extends ApiClient {
|
|
|
194
201
|
name: string,
|
|
195
202
|
phone: string,
|
|
196
203
|
customerId?: number,
|
|
204
|
+
sectorIds?: number[],
|
|
197
205
|
) {
|
|
198
206
|
const baseUrl = `/api/whatsapp`;
|
|
199
207
|
const url = customerId
|
|
200
208
|
? `${baseUrl}/customers/${customerId}/contacts`
|
|
201
209
|
: `${baseUrl}/contacts`;
|
|
202
|
-
const body = { name, phone };
|
|
210
|
+
const body: Record<string, any> = { name, phone };
|
|
211
|
+
if (sectorIds !== undefined) body['sectorIds'] = sectorIds;
|
|
203
212
|
const { data: res } = await this.ax.post<DataResponse<WppContact>>(
|
|
204
213
|
url,
|
|
205
214
|
body,
|
|
@@ -215,12 +224,15 @@ export default class WhatsappClient extends ApiClient {
|
|
|
215
224
|
|
|
216
225
|
public async updateContact(
|
|
217
226
|
contactId: number,
|
|
218
|
-
name
|
|
227
|
+
name?: string,
|
|
219
228
|
customerId?: number | null,
|
|
229
|
+
sectorIds?: number[] | null,
|
|
220
230
|
) {
|
|
221
231
|
const url = `/api/whatsapp/contacts/${contactId}`;
|
|
222
|
-
const body: Record<string, any> = {
|
|
223
|
-
|
|
232
|
+
const body: Record<string, any> = {};
|
|
233
|
+
if (name !== undefined) body["name"] = name;
|
|
234
|
+
if (customerId !== undefined) body["customerId"] = customerId;
|
|
235
|
+
if (sectorIds !== undefined) body["sectorIds"] = sectorIds;
|
|
224
236
|
const { data: res } = await this.ax.put<DataResponse<WppContact>>(
|
|
225
237
|
url,
|
|
226
238
|
body,
|
|
@@ -228,6 +240,16 @@ export default class WhatsappClient extends ApiClient {
|
|
|
228
240
|
return res.data;
|
|
229
241
|
}
|
|
230
242
|
|
|
243
|
+
public async addSectorToContact(contactId: number, sectorId: number) {
|
|
244
|
+
const url = `/api/whatsapp/contacts/${contactId}/sectors`;
|
|
245
|
+
const body = { sectorId };
|
|
246
|
+
const { data: res } = await this.ax.post<DataResponse<WppContact>>(
|
|
247
|
+
url,
|
|
248
|
+
body,
|
|
249
|
+
);
|
|
250
|
+
return res.data;
|
|
251
|
+
}
|
|
252
|
+
|
|
231
253
|
public async deleteContact(contactId: number) {
|
|
232
254
|
const url = `/api/whatsapp/contacts/${contactId}`;
|
|
233
255
|
await this.ax.delete<MessageResponse>(url);
|