@in.pulse-crm/sdk 2.3.5 → 2.3.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.
@@ -77,3 +77,14 @@ export type WppChatsAndMessages = {
77
77
  export type WppChatWithDetailsAndMessages = WppChatWithDetails & {
78
78
  messages: WppMessage[];
79
79
  };
80
+ export interface SendMessageData {
81
+ sendAsChatOwner?: boolean;
82
+ sendAsAudio?: boolean;
83
+ sendAsDocument?: boolean;
84
+ contactId: number;
85
+ quotedId?: number | null;
86
+ chatId?: number | null;
87
+ text?: string | null;
88
+ file?: File;
89
+ fileId?: number;
90
+ }
@@ -1,10 +1,11 @@
1
1
  import ApiClient from "./api-client";
2
- import { WppChatsAndMessages, WppChatWithDetailsAndMessages, WppMessage, WppWallet } from "./types/whatsapp.types";
2
+ import { SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppMessage, WppWallet } from "./types/whatsapp.types";
3
3
  export default class WhatsappClient extends ApiClient {
4
4
  getChatsBySession(token: string, messages?: boolean, contact?: boolean): Promise<WppChatsAndMessages>;
5
5
  getChatById(id: number): Promise<WppChatWithDetailsAndMessages>;
6
6
  getMessageById(id: string): Promise<WppMessage>;
7
7
  getUserWallets(instance: string, userId: number): Promise<WppWallet[]>;
8
8
  markContactMessagesAsRead(contactId: number): Promise<WppMessage[]>;
9
+ sendMessage(data: SendMessageData): Promise<void>;
9
10
  setAuth(token: string): void;
10
11
  }
@@ -32,6 +32,10 @@ class WhatsappClient extends api_client_1.default {
32
32
  const { data: res } = await this.httpClient.patch(url, body);
33
33
  return res.data;
34
34
  }
35
+ async sendMessage(data) {
36
+ const url = "/api/whatsapp/messages";
37
+ await this.httpClient.post(url, data);
38
+ }
35
39
  setAuth(token) {
36
40
  this.httpClient.defaults.headers.common["Authorization"] =
37
41
  `Bearer ${token}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.3.5",
3
+ "version": "2.3.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",
@@ -93,3 +93,15 @@ export type WppChatsAndMessages = {
93
93
  export type WppChatWithDetailsAndMessages = WppChatWithDetails & {
94
94
  messages: WppMessage[];
95
95
  };
96
+
97
+ export interface SendMessageData {
98
+ sendAsChatOwner?: boolean;
99
+ sendAsAudio?: boolean;
100
+ sendAsDocument?: boolean;
101
+ contactId: number;
102
+ quotedId?: number | null;
103
+ chatId?: number | null;
104
+ text?: string | null;
105
+ file?: File;
106
+ fileId?: number;
107
+ }
@@ -1,6 +1,7 @@
1
1
  import ApiClient from "./api-client";
2
2
  import { DataResponse } from "./types/response.types";
3
3
  import {
4
+ SendMessageData,
4
5
  WppChatsAndMessages,
5
6
  WppChatWithDetailsAndMessages,
6
7
  WppMessage,
@@ -62,6 +63,11 @@ export default class WhatsappClient extends ApiClient {
62
63
  return res.data;
63
64
  }
64
65
 
66
+ public async sendMessage(data: SendMessageData): Promise<void> {
67
+ const url = "/api/whatsapp/messages";
68
+ await this.httpClient.post<DataResponse<WppMessage>>(url, data);
69
+ }
70
+
65
71
  public setAuth(token: string) {
66
72
  this.httpClient.defaults.headers.common["Authorization"] =
67
73
  `Bearer ${token}`;