@in.pulse-crm/sdk 2.7.8 → 2.8.0

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.
@@ -16,7 +16,8 @@ export default class WhatsappClient extends ApiClient {
16
16
  }[]>;
17
17
  getCustomerContacts(customerId: number): Promise<WppContact[]>;
18
18
  getContactsWithCustomer(): Promise<WppContactWithCustomer[]>;
19
- createContact(name: string, phone: string, customerId: number): Promise<WppContact>;
19
+ getContacts(): Promise<WppContact[]>;
20
+ createContact(name: string, phone: string, customerId?: number): Promise<WppContact>;
20
21
  updateContact(contactId: number, name: string): Promise<WppContact>;
21
22
  deleteContact(contactId: number): Promise<void>;
22
23
  getSectors(): Promise<{
@@ -76,12 +76,20 @@ class WhatsappClient extends api_client_1.default {
76
76
  return res.data;
77
77
  }
78
78
  async getContactsWithCustomer() {
79
+ const url = `/api/whatsapp/contacts/customer`;
80
+ const { data: res } = await this.httpClient.get(url);
81
+ return res.data;
82
+ }
83
+ async getContacts() {
79
84
  const url = `/api/whatsapp/contacts`;
80
85
  const { data: res } = await this.httpClient.get(url);
81
86
  return res.data;
82
87
  }
83
88
  async createContact(name, phone, customerId) {
84
- const url = `/api/whatsapp/customers/${customerId}/contacts`;
89
+ const baseUrl = `/api/whatsapp`;
90
+ const url = customerId
91
+ ? `${baseUrl}/customers/${customerId}/contacts`
92
+ : `${baseUrl}/contacts`;
85
93
  const body = { name, phone };
86
94
  const { data: res } = await this.httpClient.post(url, body);
87
95
  return res.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.7.8",
3
+ "version": "2.8.0",
4
4
  "description": "SDKs for abstraction of api consumption of in.pulse-crm application",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -133,7 +133,7 @@ export default class WhatsappClient extends ApiClient {
133
133
  }
134
134
 
135
135
  public async getContactsWithCustomer() {
136
- const url = `/api/whatsapp/contacts`;
136
+ const url = `/api/whatsapp/contacts/customer`;
137
137
  const { data: res } =
138
138
  await this.httpClient.get<DataResponse<WppContactWithCustomer[]>>(
139
139
  url,
@@ -141,13 +141,25 @@ export default class WhatsappClient extends ApiClient {
141
141
 
142
142
  return res.data;
143
143
  }
144
+ public async getContacts() {
145
+ const url = `/api/whatsapp/contacts`;
146
+ const { data: res } =
147
+ await this.httpClient.get<DataResponse<WppContact[]>>(
148
+ url,
149
+ );
144
150
 
151
+ return res.data;
152
+ }
145
153
  public async createContact(
146
154
  name: string,
147
155
  phone: string,
148
- customerId: number,
156
+ customerId?: number,
149
157
  ) {
150
- const url = `/api/whatsapp/customers/${customerId}/contacts`;
158
+ const baseUrl = `/api/whatsapp`;
159
+ const url = customerId
160
+ ? `${baseUrl}/customers/${customerId}/contacts`
161
+ : `${baseUrl}/contacts`;
162
+
151
163
  const body = { name, phone };
152
164
 
153
165
  const { data: res } = await this.httpClient.post<