@in.pulse-crm/sdk 2.4.5 → 2.4.6

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.
@@ -8,6 +8,7 @@ export default class WhatsappClient extends ApiClient {
8
8
  markContactMessagesAsRead(contactId: number): Promise<WppMessage[]>;
9
9
  sendMessage(to: string, data: SendMessageData): Promise<WppMessage>;
10
10
  finishChatById(id: number, resultId: number): Promise<void>;
11
+ startChatByContactId(contactId: number): Promise<WppChatWithDetailsAndMessages>;
11
12
  getResults(): Promise<{
12
13
  id: number;
13
14
  name: string;
@@ -17,5 +18,9 @@ export default class WhatsappClient extends ApiClient {
17
18
  createContact(name: string, phone: string, customerId: number): Promise<WppContact>;
18
19
  updateContact(contactId: number, name: string): Promise<WppContact>;
19
20
  deleteContact(contactId: number): Promise<void>;
21
+ getSectors(): Promise<{
22
+ id: number;
23
+ name: string;
24
+ }[]>;
20
25
  setAuth(token: string): void;
21
26
  }
@@ -58,6 +58,12 @@ class WhatsappClient extends api_client_1.default {
58
58
  const body = { resultId };
59
59
  await this.httpClient.post(url, body);
60
60
  }
61
+ async startChatByContactId(contactId) {
62
+ const url = `/api/whatsapp/chats`;
63
+ const body = { contactId };
64
+ const { data: res } = await this.httpClient.post(url, body);
65
+ return res.data;
66
+ }
61
67
  async getResults() {
62
68
  const url = `/api/whatsapp/results`;
63
69
  const { data: res } = await this.httpClient.get(url);
@@ -89,6 +95,11 @@ class WhatsappClient extends api_client_1.default {
89
95
  const url = `/api/whatsapp/contacts/${contactId}`;
90
96
  await this.httpClient.delete(url);
91
97
  }
98
+ async getSectors() {
99
+ const url = `/api/whatsapp/sectors`;
100
+ const { data: res } = await this.httpClient.get(url);
101
+ return res.data;
102
+ }
92
103
  setAuth(token) {
93
104
  this.httpClient.defaults.headers.common["Authorization"] =
94
105
  `Bearer ${token}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.4.5",
3
+ "version": "2.4.6",
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",
@@ -59,7 +59,8 @@ class CustomersClient extends ApiClient {
59
59
  baseUrl += `?${params.toString()}`;
60
60
  }
61
61
 
62
- const response = await this.httpClient.get<PaginatedResponse<Customer>>(baseUrl);
62
+ const response =
63
+ await this.httpClient.get<PaginatedResponse<Customer>>(baseUrl);
63
64
 
64
65
  return response.data;
65
66
  }
@@ -99,6 +99,17 @@ export default class WhatsappClient extends ApiClient {
99
99
  await this.httpClient.post<MessageResponse>(url, body);
100
100
  }
101
101
 
102
+ public async startChatByContactId(contactId: number) {
103
+ const url = `/api/whatsapp/chats`;
104
+ const body = { contactId };
105
+
106
+ const { data: res } = await this.httpClient.post<
107
+ DataResponse<WppChatWithDetailsAndMessages>
108
+ >(url, body);
109
+
110
+ return res.data;
111
+ }
112
+
102
113
  public async getResults() {
103
114
  const url = `/api/whatsapp/results`;
104
115
  const { data: res } =
@@ -120,7 +131,9 @@ export default class WhatsappClient extends ApiClient {
120
131
  public async getContactsWithCustomer() {
121
132
  const url = `/api/whatsapp/contacts`;
122
133
  const { data: res } =
123
- await this.httpClient.get<DataResponse<WppContactWithCustomer[]>>(url);
134
+ await this.httpClient.get<DataResponse<WppContactWithCustomer[]>>(
135
+ url,
136
+ );
124
137
 
125
138
  return res.data;
126
139
  }
@@ -157,6 +170,16 @@ export default class WhatsappClient extends ApiClient {
157
170
  await this.httpClient.delete<MessageResponse>(url);
158
171
  }
159
172
 
173
+ public async getSectors() {
174
+ const url = `/api/whatsapp/sectors`;
175
+ const { data: res } =
176
+ await this.httpClient.get<
177
+ DataResponse<{ id: number; name: string }[]>
178
+ >(url);
179
+
180
+ return res.data;
181
+ }
182
+
160
183
  public setAuth(token: string) {
161
184
  this.httpClient.defaults.headers.common["Authorization"] =
162
185
  `Bearer ${token}`;