@in.pulse-crm/sdk 2.4.3 → 2.4.4

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.
@@ -7,5 +7,10 @@ export default class WhatsappClient extends ApiClient {
7
7
  getUserWallets(instance: string, userId: number): Promise<WppWallet[]>;
8
8
  markContactMessagesAsRead(contactId: number): Promise<WppMessage[]>;
9
9
  sendMessage(to: string, data: SendMessageData): Promise<WppMessage>;
10
+ finishChatById(id: number, resultId: number): Promise<void>;
11
+ getResults(): Promise<{
12
+ id: number;
13
+ name: string;
14
+ }[]>;
10
15
  setAuth(token: string): void;
11
16
  }
@@ -53,6 +53,16 @@ class WhatsappClient extends api_client_1.default {
53
53
  });
54
54
  return res.data;
55
55
  }
56
+ async finishChatById(id, resultId) {
57
+ const url = `/api/whatsapp/chats/${id}/finish`;
58
+ const body = { resultId };
59
+ await this.httpClient.post(url, body);
60
+ }
61
+ async getResults() {
62
+ const url = `/api/whatsapp/results`;
63
+ const { data: res } = await this.httpClient.get(url);
64
+ return res.data;
65
+ }
56
66
  setAuth(token) {
57
67
  this.httpClient.defaults.headers.common["Authorization"] =
58
68
  `Bearer ${token}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
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",
@@ -1,5 +1,5 @@
1
1
  import ApiClient from "./api-client";
2
- import { DataResponse } from "./types/response.types";
2
+ import { DataResponse, MessageResponse } from "./types/response.types";
3
3
  import {
4
4
  SendMessageData,
5
5
  WppChatsAndMessages,
@@ -90,6 +90,20 @@ export default class WhatsappClient extends ApiClient {
90
90
  return res.data;
91
91
  }
92
92
 
93
+ public async finishChatById(id: number, resultId: number) {
94
+ const url = `/api/whatsapp/chats/${id}/finish`;
95
+ const body = { resultId };
96
+
97
+ await this.httpClient.post<MessageResponse>(url, body);
98
+ }
99
+
100
+ public async getResults() {
101
+ const url = `/api/whatsapp/results`;
102
+ const { data: res } = await this.httpClient.get<DataResponse<{ id: number, name: string }[]>>(url);
103
+
104
+ return res.data;
105
+ }
106
+
93
107
  public setAuth(token: string) {
94
108
  this.httpClient.defaults.headers.common["Authorization"] =
95
109
  `Bearer ${token}`;