@in.pulse-crm/sdk 2.12.6 → 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 +17 -4
- package/package.json +1 -1
- package/src/whatsapp.client.ts +19 -4
|
@@ -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
|
@@ -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
|
@@ -201,12 +201,14 @@ export default class WhatsappClient extends ApiClient {
|
|
|
201
201
|
name: string,
|
|
202
202
|
phone: string,
|
|
203
203
|
customerId?: number,
|
|
204
|
+
sectorIds?: number[],
|
|
204
205
|
) {
|
|
205
206
|
const baseUrl = `/api/whatsapp`;
|
|
206
207
|
const url = customerId
|
|
207
208
|
? `${baseUrl}/customers/${customerId}/contacts`
|
|
208
209
|
: `${baseUrl}/contacts`;
|
|
209
|
-
const body = { name, phone };
|
|
210
|
+
const body: Record<string, any> = { name, phone };
|
|
211
|
+
if (sectorIds !== undefined) body['sectorIds'] = sectorIds;
|
|
210
212
|
const { data: res } = await this.ax.post<DataResponse<WppContact>>(
|
|
211
213
|
url,
|
|
212
214
|
body,
|
|
@@ -222,12 +224,15 @@ export default class WhatsappClient extends ApiClient {
|
|
|
222
224
|
|
|
223
225
|
public async updateContact(
|
|
224
226
|
contactId: number,
|
|
225
|
-
name
|
|
227
|
+
name?: string,
|
|
226
228
|
customerId?: number | null,
|
|
229
|
+
sectorIds?: number[] | null,
|
|
227
230
|
) {
|
|
228
231
|
const url = `/api/whatsapp/contacts/${contactId}`;
|
|
229
|
-
const body: Record<string, any> = {
|
|
230
|
-
|
|
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;
|
|
231
236
|
const { data: res } = await this.ax.put<DataResponse<WppContact>>(
|
|
232
237
|
url,
|
|
233
238
|
body,
|
|
@@ -235,6 +240,16 @@ export default class WhatsappClient extends ApiClient {
|
|
|
235
240
|
return res.data;
|
|
236
241
|
}
|
|
237
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
|
+
|
|
238
253
|
public async deleteContact(contactId: number) {
|
|
239
254
|
const url = `/api/whatsapp/contacts/${contactId}`;
|
|
240
255
|
await this.ax.delete<MessageResponse>(url);
|