@raphaelvserafim/client-api-whatsapp 1.0.7 → 1.0.9

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/README.md CHANGED
@@ -98,6 +98,148 @@ whatsapp.sendMessage({
98
98
  }).catch(console.error)
99
99
  ```
100
100
 
101
+
102
+ ### Cobrança Pix
103
+ ```js
104
+ whatsapp.sendMessage({
105
+ type: TypeMessage.BUTTON_PIX,
106
+ body: {
107
+ to: "14375223417",
108
+ title: "Pizza",
109
+ text: "Pizza ",
110
+ referenceId: "apiwame",
111
+ code: "0020",
112
+ key: "23711695000115",
113
+ merchantName: "CACHE SISTEMAS WEB",
114
+ keyType: "CNPJ",
115
+ items: [
116
+ {
117
+ id: "123",
118
+ name: "Pizza G",
119
+ price: 10,
120
+ quantity: 10
121
+ },
122
+ ],
123
+ subtotal: "90",
124
+ totalAmount: "100"
125
+ }
126
+ }).then((response) => {
127
+ console.log(response)
128
+ }).catch(console.error)
129
+ ```
130
+
131
+
132
+ ### Buttons Reply
133
+ ```js
134
+ whatsapp.sendMessage({
135
+ type: TypeMessage.BUTTON_REPLY,
136
+ body: {
137
+ to: "14375223417",
138
+ header: {
139
+ title: "Example Header",
140
+ },
141
+ text: "This is a test",
142
+ footer: "choose an option",
143
+ buttons: [
144
+ {
145
+ type: "quick_reply",
146
+ id: "uniqId1",
147
+ text: "Yes"
148
+ },
149
+ {
150
+ type: "quick_reply",
151
+ id: "uniqId2",
152
+ text: "No"
153
+ }
154
+ ]
155
+ }
156
+ }).then((response) => {
157
+ console.log(response)
158
+ }).catch(console.error)
159
+ ```
160
+
161
+
162
+ ### Buttons ACTION
163
+ ```js
164
+ whatsapp.sendMessage({
165
+ type: TypeMessage.BUTTON_ACTION,
166
+ body: {
167
+ to: "14375223417",
168
+ header: {
169
+ title: "Example Header",
170
+ },
171
+ text: "This is a test",
172
+ footer: "choose an option",
173
+ buttons: [
174
+ {
175
+ type: "cta_copy",
176
+ copy_code: "1234567890",
177
+ text: "Copy barcode"
178
+ },
179
+ {
180
+ type: "cta_url",
181
+ url: "https://api-wa.me",
182
+ text: "Access the website"
183
+ },
184
+ {
185
+ type: "cta_call",
186
+ phone_number: "+5566996852025",
187
+ text: "Call us"
188
+ }
189
+ ]
190
+ }
191
+ }).then((response) => {
192
+ console.log(response)
193
+ }).catch(console.error)
194
+ ```
195
+
196
+
197
+ ### List Menu
198
+ ```js
199
+ whatsapp.sendMessage({
200
+ type: TypeMessage.MENU,
201
+ body: {
202
+ to: "14375223417",
203
+ buttonText: "Menu",
204
+ text: "string",
205
+ title: "Menu",
206
+ description: "Description",
207
+ footer: "footer",
208
+ sections: [
209
+ {
210
+ title: "Pizza",
211
+ rows: [
212
+ {
213
+ title: "Pizza 01",
214
+ description: "Example pizza 01",
215
+ rowId: "1"
216
+ }
217
+ ]
218
+ }
219
+ ]
220
+ }
221
+ }).then((response) => {
222
+ console.log(response)
223
+ }).catch(console.error)
224
+ ```
225
+
226
+ ### POLL
227
+ ```js
228
+ whatsapp.sendMessage({
229
+ type: TypeMessage.POLL,
230
+ body: {
231
+ to: "14375223417",
232
+ name: "Do you like PHP?",
233
+ options: [
234
+ "Yes",
235
+ "No"
236
+ ],
237
+ }
238
+ }).then((response) => {
239
+ console.log(response)
240
+ }).catch(console.error)
241
+ ```
242
+
101
243
  ### Link
102
244
  ```js
103
245
  whatsapp.sendMessage({
@@ -1,4 +1,4 @@
1
- import { Init, WebhookBody, TypeMessage, StatusPresence, Contact, Section, InfoInstance, SendMessageRoot } from './model';
1
+ import { Init, WebhookBody, TypeMessage, StatusPresence, Contact, Section, InfoInstance, SendMessageRoot, Connect, Location, Buttons, Items } from './types';
2
2
  export declare class WhatsApp {
3
3
  private readonly server;
4
4
  private readonly key;
@@ -7,16 +7,27 @@ export declare class WhatsApp {
7
7
  private body;
8
8
  constructor(data: Init);
9
9
  private request;
10
- connect(): Promise<any>;
10
+ connect(): Promise<Connect>;
11
11
  info(): Promise<InfoInstance>;
12
12
  logout(): Promise<any>;
13
- setting(markMessageRead: boolean, saveMedia: boolean, receiveStatusMessage: boolean): Promise<any>;
13
+ setting({ markMessageRead, saveMedia, receiveStatusMessage, receivePresence }: {
14
+ markMessageRead: boolean;
15
+ receiveStatusMessage: boolean;
16
+ receivePresence: boolean;
17
+ saveMedia: boolean;
18
+ }): Promise<{
19
+ status: number;
20
+ message: string;
21
+ }>;
14
22
  updateWebhook(body: WebhookBody): Promise<any>;
15
23
  sendMessage(data: {
16
24
  type: TypeMessage;
17
25
  body: {
18
26
  to: string;
19
27
  msgId?: string;
28
+ header?: {
29
+ title?: string;
30
+ };
20
31
  status?: StatusPresence;
21
32
  text?: string;
22
33
  url?: string;
@@ -27,13 +38,22 @@ export declare class WhatsApp {
27
38
  location?: Location;
28
39
  name?: string;
29
40
  options?: string[];
30
- sections?: Section;
41
+ sections?: Section[];
42
+ buttons?: Buttons[];
31
43
  footer?: string;
32
44
  description?: string;
33
45
  title?: string;
34
46
  buttonText?: string;
35
47
  thumbnailUrl?: string;
36
48
  sourceUrl?: string;
49
+ referenceId?: string;
50
+ code?: string;
51
+ key?: string;
52
+ merchantName?: string;
53
+ keyType?: "CNPJ" | "CPF" | "EMAIL" | "PHONE";
54
+ subtotal?: string;
55
+ totalAmount?: string;
56
+ items?: Items[];
37
57
  };
38
58
  }, reply?: boolean): Promise<SendMessageRoot>;
39
59
  forwardingMessage(to: string, msgId: string): Promise<any>;
package/dist/WhatsApp.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WhatsApp = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const axios_1 = tslib_1.__importDefault(require("axios"));
6
- const model_1 = require("./model");
6
+ const types_1 = require("./types");
7
7
  class WhatsApp {
8
8
  server;
9
9
  key;
@@ -37,96 +37,102 @@ class WhatsApp {
37
37
  }
38
38
  }
39
39
  async connect() {
40
- this.route = model_1.Routes.INSTANCES;
41
- this.method = model_1.HttpMethod.POST;
40
+ this.route = types_1.Routes.INSTANCES;
41
+ this.method = types_1.HttpMethod.POST;
42
42
  return await this.request();
43
43
  }
44
44
  async info() {
45
- this.route = model_1.Routes.INSTANCES;
46
- this.method = model_1.HttpMethod.GET;
45
+ this.route = types_1.Routes.INSTANCES;
46
+ this.method = types_1.HttpMethod.GET;
47
47
  return await this.request();
48
48
  }
49
49
  async logout() {
50
- this.route = model_1.Routes.INSTANCES;
51
- this.method = model_1.HttpMethod.DELETE;
50
+ this.route = types_1.Routes.INSTANCES;
51
+ this.method = types_1.HttpMethod.DELETE;
52
52
  return await this.request();
53
53
  }
54
- async setting(markMessageRead, saveMedia, receiveStatusMessage) {
55
- this.route = model_1.Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}&receiveStatusMessage=${receiveStatusMessage}`;
56
- this.method = model_1.HttpMethod.PATCH;
54
+ async setting({ markMessageRead, saveMedia, receiveStatusMessage, receivePresence }) {
55
+ this.route = types_1.Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}&receiveStatusMessage=${receiveStatusMessage}&receivePresence=${receivePresence}`;
56
+ this.method = types_1.HttpMethod.PATCH;
57
57
  return await this.request();
58
58
  }
59
59
  async updateWebhook(body) {
60
- this.route = model_1.Routes.INSTANCES;
61
- this.method = model_1.HttpMethod.PUT;
60
+ this.route = types_1.Routes.INSTANCES;
61
+ this.method = types_1.HttpMethod.PUT;
62
62
  this.body = body;
63
63
  return await this.request();
64
64
  }
65
65
  async sendMessage(data, reply = false) {
66
+ if (data.type === types_1.TypeMessage.BUTTON_PIX) {
67
+ const { key, keyType, merchantName, subtotal, totalAmount, items } = data.body;
68
+ if (!key || !keyType || !merchantName || !subtotal || !totalAmount || !items || items.length === 0) {
69
+ throw new Error("Campos obrigatórios para pagamento via PIX estão ausentes.");
70
+ }
71
+ }
66
72
  if (reply) {
67
- this.route = model_1.Routes.MESSAGES + "/" + data.body.msgId + "/" + data.type;
73
+ this.route = types_1.Routes.MESSAGES + "/" + data.body.msgId + "/" + data.type;
68
74
  }
69
75
  else {
70
- this.route = model_1.Routes.MESSAGES + "/" + data.type;
76
+ this.route = types_1.Routes.MESSAGES + "/" + data.type;
71
77
  }
72
- this.method = model_1.HttpMethod.POST;
78
+ this.method = types_1.HttpMethod.POST;
73
79
  this.body = data.body;
74
80
  return await this.request();
75
81
  }
76
82
  async forwardingMessage(to, msgId) {
77
- this.route = model_1.Routes.MESSAGES + "/" + msgId + "/forwarding";
78
- this.method = model_1.HttpMethod.POST;
83
+ this.route = types_1.Routes.MESSAGES + "/" + msgId + "/forwarding";
84
+ this.method = types_1.HttpMethod.POST;
79
85
  this.body = {
80
86
  to,
81
87
  };
82
88
  return await this.request();
83
89
  }
84
90
  async rejectCall(id, from) {
85
- this.route = model_1.Routes.CALL + `/${id}/${from}`;
86
- this.method = model_1.HttpMethod.DELETE;
91
+ this.route = types_1.Routes.CALL + `/${id}/${from}`;
92
+ this.method = types_1.HttpMethod.DELETE;
87
93
  return await this.request();
88
94
  }
89
95
  async pairingCode(phoneNumber) {
90
- this.route = model_1.Routes.INSTANCES + "/pairing-code";
96
+ this.route = types_1.Routes.INSTANCES + "/pairing-code";
91
97
  this.body = {
92
98
  phoneNumber,
93
99
  };
94
- this.method = model_1.HttpMethod.POST;
100
+ this.method = types_1.HttpMethod.POST;
95
101
  return await this.request();
96
102
  }
97
103
  async checkRegisteredWhatsapp(number) {
98
- this.route = model_1.Routes.ACTIONS + "/registered?number=" + number;
99
- this.method = model_1.HttpMethod.GET;
104
+ this.route = types_1.Routes.ACTIONS + "/registered?number=" + number;
105
+ this.method = types_1.HttpMethod.GET;
100
106
  return await this.request();
101
107
  }
102
108
  async contacts() {
103
- this.route = model_1.Routes.CONTACTS;
104
- this.method = model_1.HttpMethod.GET;
109
+ this.route = types_1.Routes.CONTACTS;
110
+ this.method = types_1.HttpMethod.GET;
105
111
  return await this.request();
106
112
  }
107
113
  async contactProfile(id) {
108
- this.route = model_1.Routes.CONTACTS + "/" + id;
109
- this.method = model_1.HttpMethod.GET;
114
+ this.route = types_1.Routes.CONTACTS + "/" + id;
115
+ this.method = types_1.HttpMethod.GET;
110
116
  return await this.request();
111
117
  }
112
118
  async groups() {
113
- this.route = model_1.Routes.GROUPS;
114
- this.method = model_1.HttpMethod.GET;
119
+ this.route = types_1.Routes.GROUPS;
120
+ this.method = types_1.HttpMethod.GET;
115
121
  return await this.request();
116
122
  }
117
123
  async infoGroup(id) {
118
- this.route = model_1.Routes.GROUPS + "/" + id;
119
- this.method = model_1.HttpMethod.GET;
124
+ this.route = types_1.Routes.GROUPS + "/" + id;
125
+ this.method = types_1.HttpMethod.GET;
120
126
  return await this.request();
121
127
  }
122
128
  async getInviteGroup(id) {
123
- this.route = model_1.Routes.GROUPS + "/" + id + "/invite";
124
- this.method = model_1.HttpMethod.GET;
129
+ this.route = types_1.Routes.GROUPS + "/" + id + "/invite";
130
+ this.method = types_1.HttpMethod.GET;
125
131
  return await this.request();
126
132
  }
127
133
  async updateGroup(id, name, description) {
128
- this.route = model_1.Routes.GROUPS + "/" + id;
129
- this.method = model_1.HttpMethod.PUT;
134
+ this.route = types_1.Routes.GROUPS + "/" + id;
135
+ this.method = types_1.HttpMethod.PUT;
130
136
  this.body = {
131
137
  name,
132
138
  description
@@ -134,21 +140,21 @@ class WhatsApp {
134
140
  return await this.request();
135
141
  }
136
142
  async updateGroupPicture(id, url) {
137
- this.route = model_1.Routes.GROUPS + "/" + id + "/picture";
138
- this.method = model_1.HttpMethod.PUT;
143
+ this.route = types_1.Routes.GROUPS + "/" + id + "/picture";
144
+ this.method = types_1.HttpMethod.PUT;
139
145
  this.body = {
140
146
  url
141
147
  };
142
148
  return await this.request();
143
149
  }
144
150
  async leaveGroup(id) {
145
- this.route = model_1.Routes.GROUPS + "/" + id;
146
- this.method = model_1.HttpMethod.DELETE;
151
+ this.route = types_1.Routes.GROUPS + "/" + id;
152
+ this.method = types_1.HttpMethod.DELETE;
147
153
  return await this.request();
148
154
  }
149
155
  async createGroup(name, participants) {
150
- this.route = model_1.Routes.GROUPS;
151
- this.method = model_1.HttpMethod.POST;
156
+ this.route = types_1.Routes.GROUPS;
157
+ this.method = types_1.HttpMethod.POST;
152
158
  this.body = {
153
159
  name,
154
160
  participants
@@ -156,8 +162,8 @@ class WhatsApp {
156
162
  return await this.request();
157
163
  }
158
164
  async addParticipantsGroup(id, participants) {
159
- this.route = model_1.Routes.GROUPS + "/" + id + "/participants";
160
- this.method = model_1.HttpMethod.POST;
165
+ this.route = types_1.Routes.GROUPS + "/" + id + "/participants";
166
+ this.method = types_1.HttpMethod.POST;
161
167
  this.body = {
162
168
  participants
163
169
  };
@@ -1 +1 @@
1
- {"version":3,"file":"WhatsApp.js","sourceRoot":"","sources":["../src/WhatsApp.ts"],"names":[],"mappings":";;;;AAAA,0DAAiE;AACjE,mCAA8I;AAE9I,MAAa,QAAQ;IACF,MAAM,CAAS;IACf,GAAG,CAAS;IACrB,KAAK,CAAS;IACd,MAAM,GAAsB,IAAI,CAAC;IACjC,IAAI,GAAQ,IAAI,CAAC;IAEzB,YAAY,IAAU;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,OAAO,GAAuB;YAClC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;YAC/C,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,M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AAC;IAC9B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,IAAI,CAAC,KAAK,GAAG,cAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,kBAAU,CAAC,MAAM,CAAC;QAChC,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,YAAsB;QACpD,IAAI,CAAC,KAAK,GAAG,cAAM,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,kBAAU,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG;YACV,IAAI;YACJ,YAAY;SACb,CAAA;QACD,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAGD,KAAK,CAAC,oBAAoB,CAAC,EAAU,EAAE,YAAsB;QAC3D,IAAI,CAAC,KAAK,GAAG,cAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE,GAAG,eAAe,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,kBAAU,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG;YACV,YAAY;SACb,CAAA;QACD,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAEF;AAxND,4BAwNC;AAGD,kBAAe,QAAQ,CAAC","sourcesContent":["import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';\nimport { Init, HttpMethod, WebhookBody, Routes, TypeMessage, StatusPresence, Contact, Section, InfoInstance, SendMessageRoot } from './model';\n\nexport class WhatsApp {\n private readonly server: string;\n private readonly key: string;\n private route: string;\n private method: HttpMethod | null = null;\n private body: any = null;\n\n constructor(data: Init) {\n this.server = data.server;\n this.key = data.key;\n }\n\n private async request(): Promise<any> {\n if (!this.route || !this.method) {\n throw new Error('Path and method must be defined before making a request.');\n }\n const options: AxiosRequestConfig = {\n url: `${this.server}/${this.key}/${this.route}`,\n method: this.method,\n headers: {\n 'Content-Type': 'application/json'\n }\n };\n if ((this.method === 'POST' || this.method === 'PUT') && this.body) {\n options.data = JSON.stringify(this.body);\n }\n try {\n const response = await axios(options);\n return response.data;\n } catch (error: any) {\n throw new Error(`HTTP Request Error: ${error.message} (status: ${error.response?.status})`);\n }\n }\n\n\n async connect(): Promise<any> {\n this.route = Routes.INSTANCES;\n this.method = HttpMethod.POST;\n return await this.request();\n }\n\n async info(): Promise<InfoInstance> {\n this.route = Routes.INSTANCES;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n async logout(): Promise<any> {\n this.route = Routes.INSTANCES;\n this.method = HttpMethod.DELETE;\n return await this.request();\n }\n\n\n async setting(markMessageRead: boolean, saveMedia: boolean, receiveStatusMessage: boolean): Promise<any> {\n this.route = Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}&receiveStatusMessage=${receiveStatusMessage}`;\n this.method = HttpMethod.PATCH;\n return await this.request();\n }\n\n\n async updateWebhook(body: WebhookBody): Promise<any> {\n this.route = Routes.INSTANCES;\n this.method = HttpMethod.PUT;\n this.body = body;\n return await this.request();\n }\n\n\n async sendMessage(\n data: {\n type: TypeMessage,\n body: {\n to: string,\n msgId?: string,\n status?: StatusPresence,\n text?: string,\n url?: string,\n caption?: string,\n mimetype?: string,\n fileName?: string,\n contact?: Contact,\n location?: Location,\n name?: string,\n options?: string[],\n sections?: Section,\n footer?: string,\n description?: string,\n title?: string,\n buttonText?: string,\n thumbnailUrl?: string,\n sourceUrl?: string,\n }\n }, reply: boolean = false): Promise<SendMessageRoot> {\n if (reply) {\n this.route = Routes.MESSAGES + \"/\" + data.body.msgId + \"/\" + data.type;\n } else {\n this.route = Routes.MESSAGES + \"/\" + data.type;\n }\n\n this.method = HttpMethod.POST;\n this.body = data.body;\n return await this.request();\n }\n\n\n async forwardingMessage(to: string, msgId: string) {\n this.route = Routes.MESSAGES + \"/\" + msgId + \"/forwarding\";\n this.method = HttpMethod.POST;\n this.body = {\n to,\n }\n return await this.request();\n }\n\n async rejectCall(id: string, from: string) {\n this.route = Routes.CALL + `/${id}/${from}`;\n this.method = HttpMethod.DELETE;\n return await this.request();\n }\n\n async pairingCode(phoneNumber: string) {\n this.route = Routes.INSTANCES + \"/pairing-code\";\n this.body = {\n phoneNumber,\n }\n this.method = HttpMethod.POST;\n return await this.request();\n }\n\n async checkRegisteredWhatsapp(number: string) {\n this.route = Routes.ACTIONS + \"/registered?number=\" + number;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n\n async contacts() {\n this.route = Routes.CONTACTS;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n async contactProfile(id: string) {\n this.route = Routes.CONTACTS + \"/\" + id;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n\n async groups() {\n this.route = Routes.GROUPS;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n\n async infoGroup(id: string) {\n this.route = Routes.GROUPS + \"/\" + id;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n async getInviteGroup(id: string) {\n this.route = Routes.GROUPS + \"/\" + id + \"/invite\";\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n\n\n async updateGroup(id: string, name: string, description: string) {\n this.route = Routes.GROUPS + \"/\" + id;\n this.method = HttpMethod.PUT;\n this.body = {\n name,\n description\n }\n return await this.request();\n }\n\n async updateGroupPicture(id: string, url: string) {\n this.route = Routes.GROUPS + \"/\" + id + \"/picture\";\n this.method = HttpMethod.PUT;\n this.body = {\n url\n }\n return await this.request();\n }\n\n async leaveGroup(id: string) {\n this.route = Routes.GROUPS + \"/\" + id;\n this.method = HttpMethod.DELETE;\n return await this.request();\n }\n\n async createGroup(name: string, participants: string[]) {\n this.route = Routes.GROUPS;\n this.method = HttpMethod.POST;\n this.body = {\n name,\n participants\n }\n return await this.request();\n }\n\n\n async addParticipantsGroup(id: string, participants: string[]) {\n this.route = Routes.GROUPS + \"/\" + id + \"/participants\";\n this.method = HttpMethod.POST;\n this.body = {\n participants\n }\n return await this.request();\n }\n\n}\n\n\nexport default WhatsApp;\n\n\n"]}
1
+ {"version":3,"file":"WhatsApp.js","sourceRoot":"","sources":["../src/WhatsApp.ts"],"names":[],"mappings":";;;;AAAA,0DAAiE;AACjE,mCAAiL;AAEjL,MAAa,QAAQ;IACF,MAAM,CAAS;IACf,GAAG,CAAS;IACrB,KAAK,CAAS;IACd,MAAM,GAAsB,IAAI,CAAC;IACjC,IAAI,GAAQ,IAAI,CAAC;IAEzB,YAAY,IAAU;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,OAAO,GAAuB;YAClC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;YAC/C,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACnE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAA,eAAK,EAAC,OAAO,CAAC,CAAC;YACtC,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAU,EAAE,CAA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AAG,kBAAU,CAAC,GAAG,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG;YACV,GAAG;SACJ,CAAA;QACD,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,IAAI,CAAC,KAAK,GAAG,cAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,kBAAU,CAAC,MAAM,CAAC;QAChC,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,YAAsB;QACpD,IAAI,CAAC,KAAK,GAAG,cAAM,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,kBAAU,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG;YACV,IAAI;YACJ,YAAY;SACb,CAAA;QACD,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAGD,KAAK,CAAC,oBAAoB,CAAC,EAAU,EAAE,YAAsB;QAC3D,IAAI,CAAC,KAAK,GAAG,cAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE,GAAG,eAAe,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,kBAAU,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG;YACV,YAAY;SACb,CAAA;QACD,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAEF;AA5OD,4BA4OC;AAGD,kBAAe,QAAQ,CAAC","sourcesContent":["import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';\nimport { Init, HttpMethod, WebhookBody, Routes, TypeMessage, StatusPresence, Contact, Section, InfoInstance, SendMessageRoot, Connect, Location, Buttons, Items } from './types';\n\nexport class WhatsApp {\n private readonly server: string;\n private readonly key: string;\n private route: string;\n private method: HttpMethod | null = null;\n private body: any = null;\n\n constructor(data: Init) {\n this.server = data.server;\n this.key = data.key;\n }\n\n private async request(): Promise<any> {\n if (!this.route || !this.method) {\n throw new Error('Path and method must be defined before making a request.');\n }\n const options: AxiosRequestConfig = {\n url: `${this.server}/${this.key}/${this.route}`,\n method: this.method,\n headers: {\n 'Content-Type': 'application/json'\n }\n };\n if ((this.method === 'POST' || this.method === 'PUT') && this.body) {\n options.data = JSON.stringify(this.body);\n }\n try {\n const response = await axios(options);\n return response.data;\n } catch (error: any) {\n throw new Error(`HTTP Request Error: ${error.message} (status: ${error.response?.status})`);\n }\n }\n\n\n async connect(): Promise<Connect> {\n this.route = Routes.INSTANCES;\n this.method = HttpMethod.POST;\n return await this.request();\n }\n\n async info(): Promise<InfoInstance> {\n this.route = Routes.INSTANCES;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n async logout(): Promise<any> {\n this.route = Routes.INSTANCES;\n this.method = HttpMethod.DELETE;\n return await this.request();\n }\n\n\n async setting({ markMessageRead, saveMedia, receiveStatusMessage, receivePresence }: { markMessageRead: boolean, receiveStatusMessage: boolean, receivePresence: boolean; saveMedia: boolean, }): Promise<{ status: number, message: string }> {\n this.route = Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}&receiveStatusMessage=${receiveStatusMessage}&receivePresence=${receivePresence}`;\n this.method = HttpMethod.PATCH;\n return await this.request();\n }\n\n\n async updateWebhook(body: WebhookBody): Promise<any> {\n this.route = Routes.INSTANCES;\n this.method = HttpMethod.PUT;\n this.body = body;\n return await this.request();\n }\n\n\n async sendMessage(\n data: {\n type: TypeMessage,\n body: {\n to: string,\n msgId?: string,\n header?: {\n title?: string,\n },\n status?: StatusPresence,\n text?: string,\n url?: string,\n caption?: string,\n mimetype?: string,\n fileName?: string,\n contact?: Contact,\n location?: Location,\n name?: string,\n options?: string[],\n sections?: Section[],\n buttons?: Buttons[],\n footer?: string,\n description?: string,\n title?: string,\n buttonText?: string,\n thumbnailUrl?: string,\n sourceUrl?: string,\n referenceId?: string,\n code?: string,\n key?: string,\n merchantName?: string,\n keyType?: \"CNPJ\" | \"CPF\" | \"EMAIL\" | \"PHONE\",\n subtotal?: string,\n totalAmount?: string,\n items?: Items[],\n }\n }, reply: boolean = false): Promise<SendMessageRoot> {\n\n if (data.type === TypeMessage.BUTTON_PIX) {\n const { key, keyType, merchantName, subtotal, totalAmount, items } = data.body;\n if (!key || !keyType || !merchantName || !subtotal || !totalAmount || !items || items.length === 0) {\n throw new Error(\"Campos obrigatórios para pagamento via PIX estão ausentes.\");\n }\n }\n\n if (reply) {\n this.route = Routes.MESSAGES + \"/\" + data.body.msgId + \"/\" + data.type;\n } else {\n this.route = Routes.MESSAGES + \"/\" + data.type;\n }\n\n this.method = HttpMethod.POST;\n this.body = data.body;\n return await this.request();\n }\n\n\n async forwardingMessage(to: string, msgId: string) {\n this.route = Routes.MESSAGES + \"/\" + msgId + \"/forwarding\";\n this.method = HttpMethod.POST;\n this.body = {\n to,\n }\n return await this.request();\n }\n\n async rejectCall(id: string, from: string) {\n this.route = Routes.CALL + `/${id}/${from}`;\n this.method = HttpMethod.DELETE;\n return await this.request();\n }\n\n async pairingCode(phoneNumber: string) {\n this.route = Routes.INSTANCES + \"/pairing-code\";\n this.body = {\n phoneNumber,\n }\n this.method = HttpMethod.POST;\n return await this.request();\n }\n\n async checkRegisteredWhatsapp(number: string) {\n this.route = Routes.ACTIONS + \"/registered?number=\" + number;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n\n async contacts() {\n this.route = Routes.CONTACTS;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n async contactProfile(id: string) {\n this.route = Routes.CONTACTS + \"/\" + id;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n\n async groups() {\n this.route = Routes.GROUPS;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n\n async infoGroup(id: string) {\n this.route = Routes.GROUPS + \"/\" + id;\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n async getInviteGroup(id: string) {\n this.route = Routes.GROUPS + \"/\" + id + \"/invite\";\n this.method = HttpMethod.GET;\n return await this.request();\n }\n\n\n\n async updateGroup(id: string, name: string, description: string) {\n this.route = Routes.GROUPS + \"/\" + id;\n this.method = HttpMethod.PUT;\n this.body = {\n name,\n description\n }\n return await this.request();\n }\n\n async updateGroupPicture(id: string, url: string) {\n this.route = Routes.GROUPS + \"/\" + id + \"/picture\";\n this.method = HttpMethod.PUT;\n this.body = {\n url\n }\n return await this.request();\n }\n\n async leaveGroup(id: string) {\n this.route = Routes.GROUPS + \"/\" + id;\n this.method = HttpMethod.DELETE;\n return await this.request();\n }\n\n async createGroup(name: string, participants: string[]) {\n this.route = Routes.GROUPS;\n this.method = HttpMethod.POST;\n this.body = {\n name,\n participants\n }\n return await this.request();\n }\n\n\n async addParticipantsGroup(id: string, participants: string[]) {\n this.route = Routes.GROUPS + \"/\" + id + \"/participants\";\n this.method = HttpMethod.POST;\n this.body = {\n participants\n }\n return await this.request();\n }\n\n}\n\n\nexport default WhatsApp;\n\n\n"]}
package/dist/exemple.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const WhatsApp_1 = tslib_1.__importDefault(require("./WhatsApp"));
5
- const model_1 = require("./model");
5
+ const types_1 = require("./types");
6
6
  const whatsapp = new WhatsApp_1.default({ server: "", key: "" });
7
7
  const to = "559999999999"; // If you want to send it to the group = 123456789@us
8
8
  whatsapp.info().then((response) => {
@@ -18,16 +18,16 @@ whatsapp.contacts().then((response) => {
18
18
  console.log(response);
19
19
  }).catch(console.error);
20
20
  whatsapp.sendMessage({
21
- type: model_1.TypeMessage.PRESENCE,
21
+ type: types_1.TypeMessage.PRESENCE,
22
22
  body: {
23
23
  to: to,
24
- status: model_1.StatusPresence.COMPOSING
24
+ status: types_1.StatusPresence.COMPOSING
25
25
  }
26
26
  }).then((response) => {
27
27
  console.log(response);
28
28
  }).catch(console.error);
29
29
  whatsapp.sendMessage({
30
- type: model_1.TypeMessage.TEXT,
30
+ type: types_1.TypeMessage.TEXT,
31
31
  body: {
32
32
  to: to,
33
33
  text: "Hey"
@@ -36,7 +36,150 @@ whatsapp.sendMessage({
36
36
  console.log(response);
37
37
  }).catch(console.error);
38
38
  whatsapp.sendMessage({
39
- type: model_1.TypeMessage.TEXT,
39
+ type: types_1.TypeMessage.BUTTON_PIX,
40
+ body: {
41
+ to: "14375223417",
42
+ title: "Pizza",
43
+ text: "Pizza ",
44
+ referenceId: "apiwame",
45
+ code: "0020",
46
+ key: "23711695000115",
47
+ merchantName: "CACHE SISTEMAS WEB",
48
+ keyType: "CNPJ",
49
+ items: [
50
+ {
51
+ id: "123",
52
+ name: "Pizza G",
53
+ price: 10,
54
+ quantity: 10
55
+ },
56
+ ],
57
+ subtotal: "90",
58
+ totalAmount: "100"
59
+ }
60
+ }).then((response) => {
61
+ console.log(response);
62
+ }).catch(console.error);
63
+ whatsapp.sendMessage({
64
+ type: types_1.TypeMessage.BUTTON_PIX,
65
+ body: {
66
+ to: "14375223417",
67
+ title: "Pizza",
68
+ text: "Pizza ",
69
+ referenceId: "apiwame",
70
+ code: "0020",
71
+ key: "23711695000115",
72
+ merchantName: "CACHE SISTEMAS WEB",
73
+ keyType: "CNPJ",
74
+ items: [
75
+ {
76
+ id: "123",
77
+ name: "Pizza G",
78
+ price: 10,
79
+ quantity: 10
80
+ },
81
+ ],
82
+ subtotal: "90",
83
+ totalAmount: "100"
84
+ }
85
+ }).then((response) => {
86
+ console.log(response);
87
+ }).catch(console.error);
88
+ whatsapp.sendMessage({
89
+ type: types_1.TypeMessage.BUTTON_REPLY,
90
+ body: {
91
+ to: "14375223417",
92
+ header: {
93
+ title: "Example Header",
94
+ },
95
+ text: "This is a test",
96
+ footer: "choose an option",
97
+ buttons: [
98
+ {
99
+ type: "quick_reply",
100
+ id: "uniqId1",
101
+ text: "Yes"
102
+ },
103
+ {
104
+ type: "quick_reply",
105
+ id: "uniqId2",
106
+ text: "No"
107
+ }
108
+ ]
109
+ }
110
+ }).then((response) => {
111
+ console.log(response);
112
+ }).catch(console.error);
113
+ whatsapp.sendMessage({
114
+ type: types_1.TypeMessage.BUTTON_ACTION,
115
+ body: {
116
+ to: "14375223417",
117
+ header: {
118
+ title: "Example Header",
119
+ },
120
+ text: "This is a test",
121
+ footer: "choose an option",
122
+ buttons: [
123
+ {
124
+ type: "cta_copy",
125
+ copy_code: "1234567890",
126
+ text: "Copy barcode"
127
+ },
128
+ {
129
+ type: "cta_url",
130
+ url: "https://api-wa.me",
131
+ text: "Access the website"
132
+ },
133
+ {
134
+ type: "cta_call",
135
+ phone_number: "+5566996852025",
136
+ text: "Call us"
137
+ }
138
+ ]
139
+ }
140
+ }).then((response) => {
141
+ console.log(response);
142
+ }).catch(console.error);
143
+ whatsapp.sendMessage({
144
+ type: types_1.TypeMessage.MENU,
145
+ body: {
146
+ to: "14375223417",
147
+ buttonText: "Menu",
148
+ text: "string",
149
+ title: "Menu",
150
+ description: "Description",
151
+ footer: "footer",
152
+ sections: [
153
+ {
154
+ title: "Pizza",
155
+ rows: [
156
+ {
157
+ title: "Pizza 01",
158
+ description: "Example pizza 01",
159
+ rowId: "1"
160
+ }
161
+ ]
162
+ }
163
+ ]
164
+ }
165
+ }).then((response) => {
166
+ console.log(response);
167
+ }).catch(console.error);
168
+ whatsapp.sendMessage({
169
+ type: types_1.TypeMessage.POLL,
170
+ body: {
171
+ to: "14375223417",
172
+ name: "Do you like PHP?",
173
+ options: [
174
+ "Yes",
175
+ "No"
176
+ ],
177
+ }
178
+ }).then((response) => {
179
+ console.log(response);
180
+ }).catch(console.error);
181
+ whatsapp.sendMessage({
182
+ type: types_1.TypeMessage.TEXT,
40
183
  body: {
41
184
  msgId: "SKJH455AJKJ",
42
185
  to: to,
@@ -46,7 +189,7 @@ whatsapp.sendMessage({
46
189
  console.log(response);
47
190
  }).catch(console.error);
48
191
  whatsapp.sendMessage({
49
- type: model_1.TypeMessage.AUDIO,
192
+ type: types_1.TypeMessage.AUDIO,
50
193
  body: {
51
194
  to: to,
52
195
  url: ""
@@ -55,7 +198,7 @@ whatsapp.sendMessage({
55
198
  console.log(response);
56
199
  }).catch(console.error);
57
200
  whatsapp.sendMessage({
58
- type: model_1.TypeMessage.IMAGE,
201
+ type: types_1.TypeMessage.IMAGE,
59
202
  body: {
60
203
  to: to,
61
204
  url: ""
@@ -64,7 +207,7 @@ whatsapp.sendMessage({
64
207
  console.log(response);
65
208
  }).catch(console.error);
66
209
  whatsapp.sendMessage({
67
- type: model_1.TypeMessage.VIDEO,
210
+ type: types_1.TypeMessage.VIDEO,
68
211
  body: {
69
212
  to: to,
70
213
  url: ""
@@ -73,7 +216,7 @@ whatsapp.sendMessage({
73
216
  console.log(response);
74
217
  }).catch(console.error);
75
218
  whatsapp.sendMessage({
76
- type: model_1.TypeMessage.DOCUMENT,
219
+ type: types_1.TypeMessage.DOCUMENT,
77
220
  body: {
78
221
  to: to,
79
222
  url: "",
@@ -84,7 +227,7 @@ whatsapp.sendMessage({
84
227
  console.log(response);
85
228
  }).catch(console.error);
86
229
  whatsapp.sendMessage({
87
- type: model_1.TypeMessage.CONTACT,
230
+ type: types_1.TypeMessage.CONTACT,
88
231
  body: {
89
232
  to: to,
90
233
  contact: {
@@ -97,7 +240,7 @@ whatsapp.sendMessage({
97
240
  console.log(response);
98
241
  }).catch(console.error);
99
242
  whatsapp.sendMessage({
100
- type: model_1.TypeMessage.REACTION,
243
+ type: types_1.TypeMessage.REACTION,
101
244
  body: {
102
245
  to: to,
103
246
  msgId: "ASDDF872AHDURBSG",
@@ -1 +1 @@
1
- {"version":3,"file":"exemple.js","sourceRoot":"","sources":["../src/exemple.ts"],"names":[],"mappings":";;;AAAA,kEAAkC;AAClC,mCAAsD;AAEtD,MAAM,QAAQ,GAAG,IAAI,kBAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;AAEvD,MAAM,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AC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAGvB,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IAClC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAGvB,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACnD,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAIvB,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACnD,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAGvB,QAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IAClF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA","sourcesContent":["import WhatsApp from \"./WhatsApp\";\nimport { StatusPresence, TypeMessage } from \"./model\";\n\nconst whatsapp = new WhatsApp({ server: \"\", key: \"\" });\n\nconst to = \"559999999999\" // If you want to send it to the group = 123456789@us\n\nwhatsapp.info().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.connect().then((response) => {\n console.log(response)\n}).catch(console.error);\n\n\nwhatsapp.logout().then((response) => {\n console.log(response)\n}).catch(console.error);\n\n\nwhatsapp.contacts().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.PRESENCE,\n body: {\n to: to,\n status: StatusPresence.COMPOSING\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.TEXT,\n body: {\n to: to,\n text: \"Hey\"\n }\n}).then((response) => {\n console.log(response)\n\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.TEXT,\n body: {\n msgId: \"SKJH455AJKJ\",\n to: to,\n text: \"Hey\"\n }\n}, true).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.AUDIO,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.IMAGE,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.VIDEO,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.DOCUMENT,\n body: {\n to: to,\n url: \"\",\n mimetype: \"\",\n fileName: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.CONTACT,\n body: {\n to: to,\n contact: {\n fullName: \"Raphael\",\n phoneNumber: to,\n organization: \"api-wa.me\"\n }\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.REACTION,\n body: {\n to: to,\n msgId: \"ASDDF872AHDURBSG\",\n text: \"🤖\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.groups().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.infoGroup(\"123456789@us\").then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.createGroup(\"Devs\", [to]).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.updateGroup(\"123456789@us\", \"Devs\", \"Only developers !\").then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\n"]}
1
+ {"version":3,"file":"exemple.js","sourceRoot":"","sources":["../src/exemple.ts"],"names":[],"mappings":";;;AAAA,kEAAkC;AAClC,mCAAsD;AAEtD,MAAM,QAAQ,GAAG,IAAI,kBAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;AAEvD,MAAM,EAAE,GAAG,cAAc,CAAA,CAAC,sDAAsD;AAEhF,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAGvB,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAGxB,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IAClC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAGxB,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACvB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAA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= new WhatsApp({ server: \"\", key: \"\" });\n\nconst to = \"559999999999\" // If you want to send it to the group = 123456789@us\n\nwhatsapp.info().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.connect().then((response) => {\n console.log(response)\n}).catch(console.error);\n\n\nwhatsapp.logout().then((response) => {\n console.log(response)\n}).catch(console.error);\n\n\nwhatsapp.contacts().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.PRESENCE,\n body: {\n to: to,\n status: StatusPresence.COMPOSING\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.TEXT,\n body: {\n to: to,\n text: \"Hey\"\n }\n}).then((response) => {\n console.log(response)\n\n}).catch(console.error)\n\nwhatsapp.sendMessage({\n type: TypeMessage.BUTTON_PIX,\n body: {\n to: \"14375223417\",\n title: \"Pizza\",\n text: \"Pizza \",\n referenceId: \"apiwame\",\n code: \"0020\",\n key: \"23711695000115\",\n merchantName: \"CACHE SISTEMAS WEB\",\n keyType: \"CNPJ\",\n items: [\n {\n id: \"123\",\n name: \"Pizza G\",\n price: 10,\n quantity: 10\n },\n ],\n subtotal: \"90\",\n totalAmount: \"100\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\nwhatsapp.sendMessage({\n type: TypeMessage.BUTTON_PIX,\n body: {\n to: \"14375223417\",\n title: \"Pizza\",\n text: \"Pizza \",\n referenceId: \"apiwame\",\n code: \"0020\",\n key: \"23711695000115\",\n merchantName: \"CACHE SISTEMAS WEB\",\n keyType: \"CNPJ\",\n items: [\n {\n id: \"123\",\n name: \"Pizza G\",\n price: 10,\n quantity: 10\n },\n ],\n subtotal: \"90\",\n totalAmount: \"100\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.BUTTON_REPLY,\n body: {\n to: \"14375223417\",\n header: {\n title: \"Example Header\",\n },\n text: \"This is a test\",\n footer: \"choose an option\",\n buttons: [\n {\n type: \"quick_reply\",\n id: \"uniqId1\",\n text: \"Yes\"\n },\n {\n type: \"quick_reply\",\n id: \"uniqId2\",\n text: \"No\"\n }\n ]\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.BUTTON_ACTION,\n body: {\n to: \"14375223417\",\n header: {\n title: \"Example Header\",\n },\n text: \"This is a test\",\n footer: \"choose an option\",\n buttons: [\n {\n type: \"cta_copy\",\n copy_code: \"1234567890\",\n text: \"Copy barcode\"\n },\n {\n type: \"cta_url\",\n url: \"https://api-wa.me\",\n text: \"Access the website\"\n },\n {\n type: \"cta_call\",\n phone_number: \"+5566996852025\",\n text: \"Call us\"\n }\n ]\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.MENU,\n body: {\n to: \"14375223417\",\n buttonText: \"Menu\",\n text: \"string\",\n title: \"Menu\",\n description: \"Description\",\n footer: \"footer\",\n sections: [\n {\n title: \"Pizza\",\n rows: [\n {\n title: \"Pizza 01\",\n description: \"Example pizza 01\",\n rowId: \"1\"\n }\n ]\n }\n ]\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.POLL,\n body: {\n to: \"14375223417\",\n name: \"Do you like PHP?\",\n options: [\n \"Yes\",\n \"No\"\n ],\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.TEXT,\n body: {\n msgId: \"SKJH455AJKJ\",\n to: to,\n text: \"Hey\"\n }\n}, true).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.AUDIO,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.IMAGE,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.VIDEO,\n body: {\n to: to,\n url: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.DOCUMENT,\n body: {\n to: to,\n url: \"\",\n mimetype: \"\",\n fileName: \"\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.CONTACT,\n body: {\n to: to,\n contact: {\n fullName: \"Raphael\",\n phoneNumber: to,\n organization: \"api-wa.me\"\n }\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.sendMessage({\n type: TypeMessage.REACTION,\n body: {\n to: to,\n msgId: \"ASDDF872AHDURBSG\",\n text: \"🤖\"\n }\n}).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.groups().then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.infoGroup(\"123456789@us\").then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\nwhatsapp.createGroup(\"Devs\", [to]).then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\nwhatsapp.updateGroup(\"123456789@us\", \"Devs\", \"Only developers !\").then((response) => {\n console.log(response)\n}).catch(console.error)\n\n\n\n"]}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { TypeMessage, Init, StatusPresence, Contact, Location } from './model';
1
+ export { TypeMessage, Init, StatusPresence, Contact, Location } from './types';
2
2
  export { WhatsApp } from './WhatsApp';
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WhatsApp = exports.StatusPresence = exports.TypeMessage = void 0;
4
- var model_1 = require("./model");
5
- Object.defineProperty(exports, "TypeMessage", { enumerable: true, get: function () { return model_1.TypeMessage; } });
6
- Object.defineProperty(exports, "StatusPresence", { enumerable: true, get: function () { return model_1.StatusPresence; } });
4
+ var types_1 = require("./types");
5
+ Object.defineProperty(exports, "TypeMessage", { enumerable: true, get: function () { return types_1.TypeMessage; } });
6
+ Object.defineProperty(exports, "StatusPresence", { enumerable: true, get: function () { return types_1.StatusPresence; } });
7
7
  var WhatsApp_1 = require("./WhatsApp");
8
8
  Object.defineProperty(exports, "WhatsApp", { enumerable: true, get: function () { return WhatsApp_1.WhatsApp; } });
9
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+E;AAAtE,oGAAA,WAAW,OAAA;AAAQ,uGAAA,cAAc,OAAA;AAC1C,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA","sourcesContent":["export { TypeMessage, Init, StatusPresence, Contact, Location } from './model';\nexport { WhatsApp } from './WhatsApp';"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+E;AAAtE,oGAAA,WAAW,OAAA;AAAQ,uGAAA,cAAc,OAAA;AAC1C,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA","sourcesContent":["export { TypeMessage, Init, StatusPresence, Contact, Location } from './types';\nexport { WhatsApp } from './WhatsApp';"]}
@@ -28,7 +28,12 @@ export declare enum TypeMessage {
28
28
  LOCATION = "location",
29
29
  REACTION = "reaction",
30
30
  LINK = "link",
31
- TITLE = "title"
31
+ TITLE = "title",
32
+ BUTTON_REPLY = "button_reply",
33
+ BUTTON_ACTION = "button_action",
34
+ BUTTON_PIX = "pix",
35
+ POLL = "survey",
36
+ MENU = "list"
32
37
  }
33
38
  export declare enum StatusPresence {
34
39
  UNAVAILABLE = "unavailable",
@@ -72,15 +77,20 @@ export interface InfoInstance {
72
77
  export interface Instance {
73
78
  receive_status_message: boolean;
74
79
  save_media: boolean;
80
+ receive_presence: boolean;
81
+ permission: number;
75
82
  mark_messages: boolean;
76
83
  blocked: boolean;
77
- user: User;
84
+ user?: User;
78
85
  phoneConnected: boolean;
79
86
  webhook: Webhook;
87
+ businessProfile?: BusinessProfile;
80
88
  }
81
89
  export interface User {
82
- id: string;
83
- lid: string;
90
+ id?: string;
91
+ lid?: string;
92
+ name?: string;
93
+ imageProfile?: string;
84
94
  }
85
95
  export interface Webhook {
86
96
  allowWebhook: boolean;
@@ -112,3 +122,31 @@ export interface Message {
112
122
  export interface ExtendedTextMessage {
113
123
  text: string;
114
124
  }
125
+ export interface Connect {
126
+ status: number;
127
+ phoneConnected: boolean;
128
+ qrcode: string;
129
+ image: string;
130
+ user?: User;
131
+ }
132
+ export interface BusinessProfile {
133
+ wid: string;
134
+ description: string;
135
+ website: any[];
136
+ category: string;
137
+ business_hours: {};
138
+ }
139
+ export interface Buttons {
140
+ type: "quick_reply" | "cta_copy" | "cta_url" | "cta_call";
141
+ copy_code?: string;
142
+ phone_number?: string;
143
+ url?: string;
144
+ id?: string;
145
+ text: string;
146
+ }
147
+ export interface Items {
148
+ id: string;
149
+ name: string;
150
+ price: number;
151
+ quantity: number;
152
+ }
@@ -31,6 +31,11 @@ var TypeMessage;
31
31
  TypeMessage["REACTION"] = "reaction";
32
32
  TypeMessage["LINK"] = "link";
33
33
  TypeMessage["TITLE"] = "title";
34
+ TypeMessage["BUTTON_REPLY"] = "button_reply";
35
+ TypeMessage["BUTTON_ACTION"] = "button_action";
36
+ TypeMessage["BUTTON_PIX"] = "pix";
37
+ TypeMessage["POLL"] = "survey";
38
+ TypeMessage["MENU"] = "list";
34
39
  })(TypeMessage || (exports.TypeMessage = TypeMessage = {}));
35
40
  var StatusPresence;
36
41
  (function (StatusPresence) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAKA,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,6BAAe,CAAA;AACjB,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB;AAGD,IAAY,MAOX;AAPD,WAAY,MAAM;IAChB,gCAAsB,CAAA;IACtB,8BAAoB,CAAA;IACpB,+BAAqB,CAAA;IACrB,2BAAiB,CAAA;IACjB,6BAAmB,CAAA;IACnB,uBAAa,CAAA;AACf,CAAC,EAPW,MAAM,sBAAN,MAAM,QAOjB;AAGD,IAAY,WAiBX;AAjBD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,8BAAe,CAAA;IACf,8BAAe,CAAA;IACf,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;IACrB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,4CAA6B,CAAA;IAC7B,8CAA+B,CAAA;IAC/B,iCAAkB,CAAA;IAClB,8BAAe,CAAA;IACf,4BAAa,CAAA;AACf,CAAC,EAjBW,WAAW,2BAAX,WAAW,QAiBtB;AAGD,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,6CAA2B,CAAA;IAC3B,yCAAuB,CAAA;IACvB,yCAAuB,CAAA;IACvB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB","sourcesContent":["export interface Init {\n server: string;\n key: string;\n}\n\nexport enum HttpMethod {\n GET = 'GET',\n POST = 'POST',\n PUT = 'PUT',\n DELETE = 'DELETE',\n PATCH = 'PATCH',\n}\n\n\nexport enum Routes {\n INSTANCES = 'instance',\n MESSAGES = 'message',\n CONTACTS = 'contacts',\n GROUPS = 'groups',\n ACTIONS = 'actions',\n CALL = 'call',\n}\n\n\nexport enum TypeMessage {\n PRESENCE = 'presence',\n TEXT = 'text',\n AUDIO = 'audio',\n IMAGE = 'image',\n VIDEO = 'video',\n DOCUMENT = 'document',\n CONTACT = 'contact',\n LOCATION = 'location',\n REACTION = 'reaction',\n LINK = 'link',\n TITLE = 'title',\n BUTTON_REPLY = 'button_reply',\n BUTTON_ACTION = 'button_action',\n BUTTON_PIX = 'pix',\n POLL = 'survey',\n MENU = 'list',\n}\n\n\nexport enum StatusPresence {\n UNAVAILABLE = 'unavailable',\n AVAILABLE = 'available',\n COMPOSING = 'composing',\n RECORDING = 'recording',\n PAUSED = 'paused',\n}\n\n\n\nexport interface WebhookBody {\n allowWebhook: boolean;\n webhookMessage: string;\n webhookGroup: string;\n webhookConnection: string;\n webhookQrCode: string;\n webhookMessageFromMe: string;\n webhookHistory: string;\n}\n\nexport interface Contact {\n fullName: string;\n phoneNumber: string;\n organization?: string;\n}\n\n\nexport interface Location {\n latitude: number;\n longitude: number;\n address: string;\n}\n\nexport interface Row {\n title: string;\n description: string;\n rowId: string;\n}\n\nexport interface Section {\n title: string;\n rows: Row[];\n}\n\n\n\nexport interface InfoInstance {\n status: number\n instance: Instance\n}\n\nexport interface Instance {\n receive_status_message: boolean\n save_media: boolean\n receive_presence: boolean\n permission: number\n mark_messages: boolean\n blocked: boolean\n user?: User\n phoneConnected: boolean\n webhook: Webhook;\n businessProfile?: BusinessProfile;\n}\n\nexport interface User {\n id?: string;\n lid?: string;\n name?: string;\n imageProfile?: string;\n\n}\n\nexport interface Webhook {\n allowWebhook: boolean\n webhookMessage: string\n webhookGroup: string\n webhookConnection: string\n webhookQrCode: string\n webhookMessageFromMe: string\n webhookHistory: string\n}\n\n\n\nexport interface SendMessageRoot {\n status: number\n data: Data\n}\n\nexport interface Data {\n key: Key\n message: Message\n messageTimestamp: string\n status: string\n}\n\nexport interface Key {\n remoteJid: string\n fromMe: boolean\n id: string\n}\n\nexport interface Message {\n extendedTextMessage: ExtendedTextMessage\n}\n\nexport interface ExtendedTextMessage {\n text: string\n}\n\nexport interface Connect {\n status: number;\n phoneConnected: boolean;\n qrcode: string;\n image: string;\n user?: User;\n}\n\n\n\nexport interface BusinessProfile {\n wid: string\n description: string\n website: any[]\n category: string\n business_hours: {}\n}\n\n\n\nexport interface Buttons {\n type: \"quick_reply\" | \"cta_copy\" | \"cta_url\" | \"cta_call\",\n copy_code?: string,\n phone_number?: string,\n url?: string,\n id?: string,\n text: string;\n}\n\n\nexport interface Items {\n id: string,\n name: string,\n price: number,\n quantity: number\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raphaelvserafim/client-api-whatsapp",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "With our API, you can send text, audio, video, and image messages quickly and easily. Adapt to your business communication needs comprehensively.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/WhatsApp.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
2
- import { Init, HttpMethod, WebhookBody, Routes, TypeMessage, StatusPresence, Contact, Section, InfoInstance, SendMessageRoot } from './model';
2
+ import { Init, HttpMethod, WebhookBody, Routes, TypeMessage, StatusPresence, Contact, Section, InfoInstance, SendMessageRoot, Connect, Location, Buttons, Items } from './types';
3
3
 
4
4
  export class WhatsApp {
5
5
  private readonly server: string;
@@ -36,7 +36,7 @@ export class WhatsApp {
36
36
  }
37
37
 
38
38
 
39
- async connect(): Promise<any> {
39
+ async connect(): Promise<Connect> {
40
40
  this.route = Routes.INSTANCES;
41
41
  this.method = HttpMethod.POST;
42
42
  return await this.request();
@@ -55,8 +55,8 @@ export class WhatsApp {
55
55
  }
56
56
 
57
57
 
58
- async setting(markMessageRead: boolean, saveMedia: boolean, receiveStatusMessage: boolean): Promise<any> {
59
- this.route = Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}&receiveStatusMessage=${receiveStatusMessage}`;
58
+ async setting({ markMessageRead, saveMedia, receiveStatusMessage, receivePresence }: { markMessageRead: boolean, receiveStatusMessage: boolean, receivePresence: boolean; saveMedia: boolean, }): Promise<{ status: number, message: string }> {
59
+ this.route = Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}&receiveStatusMessage=${receiveStatusMessage}&receivePresence=${receivePresence}`;
60
60
  this.method = HttpMethod.PATCH;
61
61
  return await this.request();
62
62
  }
@@ -76,6 +76,9 @@ export class WhatsApp {
76
76
  body: {
77
77
  to: string,
78
78
  msgId?: string,
79
+ header?: {
80
+ title?: string,
81
+ },
79
82
  status?: StatusPresence,
80
83
  text?: string,
81
84
  url?: string,
@@ -86,15 +89,32 @@ export class WhatsApp {
86
89
  location?: Location,
87
90
  name?: string,
88
91
  options?: string[],
89
- sections?: Section,
92
+ sections?: Section[],
93
+ buttons?: Buttons[],
90
94
  footer?: string,
91
95
  description?: string,
92
96
  title?: string,
93
97
  buttonText?: string,
94
98
  thumbnailUrl?: string,
95
99
  sourceUrl?: string,
100
+ referenceId?: string,
101
+ code?: string,
102
+ key?: string,
103
+ merchantName?: string,
104
+ keyType?: "CNPJ" | "CPF" | "EMAIL" | "PHONE",
105
+ subtotal?: string,
106
+ totalAmount?: string,
107
+ items?: Items[],
96
108
  }
97
109
  }, reply: boolean = false): Promise<SendMessageRoot> {
110
+
111
+ if (data.type === TypeMessage.BUTTON_PIX) {
112
+ const { key, keyType, merchantName, subtotal, totalAmount, items } = data.body;
113
+ if (!key || !keyType || !merchantName || !subtotal || !totalAmount || !items || items.length === 0) {
114
+ throw new Error("Campos obrigatórios para pagamento via PIX estão ausentes.");
115
+ }
116
+ }
117
+
98
118
  if (reply) {
99
119
  this.route = Routes.MESSAGES + "/" + data.body.msgId + "/" + data.type;
100
120
  } else {
package/src/exemple.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import WhatsApp from "./WhatsApp";
2
- import { StatusPresence, TypeMessage } from "./model";
2
+ import { StatusPresence, TypeMessage } from "./types";
3
3
 
4
4
  const whatsapp = new WhatsApp({ server: "", key: "" });
5
5
 
@@ -47,6 +47,159 @@ whatsapp.sendMessage({
47
47
 
48
48
  }).catch(console.error)
49
49
 
50
+ whatsapp.sendMessage({
51
+ type: TypeMessage.BUTTON_PIX,
52
+ body: {
53
+ to: "14375223417",
54
+ title: "Pizza",
55
+ text: "Pizza ",
56
+ referenceId: "apiwame",
57
+ code: "0020",
58
+ key: "23711695000115",
59
+ merchantName: "CACHE SISTEMAS WEB",
60
+ keyType: "CNPJ",
61
+ items: [
62
+ {
63
+ id: "123",
64
+ name: "Pizza G",
65
+ price: 10,
66
+ quantity: 10
67
+ },
68
+ ],
69
+ subtotal: "90",
70
+ totalAmount: "100"
71
+ }
72
+ }).then((response) => {
73
+ console.log(response)
74
+ }).catch(console.error)
75
+
76
+ whatsapp.sendMessage({
77
+ type: TypeMessage.BUTTON_PIX,
78
+ body: {
79
+ to: "14375223417",
80
+ title: "Pizza",
81
+ text: "Pizza ",
82
+ referenceId: "apiwame",
83
+ code: "0020",
84
+ key: "23711695000115",
85
+ merchantName: "CACHE SISTEMAS WEB",
86
+ keyType: "CNPJ",
87
+ items: [
88
+ {
89
+ id: "123",
90
+ name: "Pizza G",
91
+ price: 10,
92
+ quantity: 10
93
+ },
94
+ ],
95
+ subtotal: "90",
96
+ totalAmount: "100"
97
+ }
98
+ }).then((response) => {
99
+ console.log(response)
100
+ }).catch(console.error)
101
+
102
+
103
+ whatsapp.sendMessage({
104
+ type: TypeMessage.BUTTON_REPLY,
105
+ body: {
106
+ to: "14375223417",
107
+ header: {
108
+ title: "Example Header",
109
+ },
110
+ text: "This is a test",
111
+ footer: "choose an option",
112
+ buttons: [
113
+ {
114
+ type: "quick_reply",
115
+ id: "uniqId1",
116
+ text: "Yes"
117
+ },
118
+ {
119
+ type: "quick_reply",
120
+ id: "uniqId2",
121
+ text: "No"
122
+ }
123
+ ]
124
+ }
125
+ }).then((response) => {
126
+ console.log(response)
127
+ }).catch(console.error)
128
+
129
+
130
+ whatsapp.sendMessage({
131
+ type: TypeMessage.BUTTON_ACTION,
132
+ body: {
133
+ to: "14375223417",
134
+ header: {
135
+ title: "Example Header",
136
+ },
137
+ text: "This is a test",
138
+ footer: "choose an option",
139
+ buttons: [
140
+ {
141
+ type: "cta_copy",
142
+ copy_code: "1234567890",
143
+ text: "Copy barcode"
144
+ },
145
+ {
146
+ type: "cta_url",
147
+ url: "https://api-wa.me",
148
+ text: "Access the website"
149
+ },
150
+ {
151
+ type: "cta_call",
152
+ phone_number: "+5566996852025",
153
+ text: "Call us"
154
+ }
155
+ ]
156
+ }
157
+ }).then((response) => {
158
+ console.log(response)
159
+ }).catch(console.error)
160
+
161
+
162
+ whatsapp.sendMessage({
163
+ type: TypeMessage.MENU,
164
+ body: {
165
+ to: "14375223417",
166
+ buttonText: "Menu",
167
+ text: "string",
168
+ title: "Menu",
169
+ description: "Description",
170
+ footer: "footer",
171
+ sections: [
172
+ {
173
+ title: "Pizza",
174
+ rows: [
175
+ {
176
+ title: "Pizza 01",
177
+ description: "Example pizza 01",
178
+ rowId: "1"
179
+ }
180
+ ]
181
+ }
182
+ ]
183
+ }
184
+ }).then((response) => {
185
+ console.log(response)
186
+ }).catch(console.error)
187
+
188
+
189
+ whatsapp.sendMessage({
190
+ type: TypeMessage.POLL,
191
+ body: {
192
+ to: "14375223417",
193
+ name: "Do you like PHP?",
194
+ options: [
195
+ "Yes",
196
+ "No"
197
+ ],
198
+ }
199
+ }).then((response) => {
200
+ console.log(response)
201
+ }).catch(console.error)
202
+
50
203
 
51
204
  whatsapp.sendMessage({
52
205
  type: TypeMessage.TEXT,
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { TypeMessage, Init, StatusPresence, Contact, Location } from './model';
1
+ export { TypeMessage, Init, StatusPresence, Contact, Location } from './types';
2
2
  export { WhatsApp } from './WhatsApp';
@@ -34,6 +34,11 @@ export enum TypeMessage {
34
34
  REACTION = 'reaction',
35
35
  LINK = 'link',
36
36
  TITLE = 'title',
37
+ BUTTON_REPLY = 'button_reply',
38
+ BUTTON_ACTION = 'button_action',
39
+ BUTTON_PIX = 'pix',
40
+ POLL = 'survey',
41
+ MENU = 'list',
37
42
  }
38
43
 
39
44
 
@@ -83,8 +88,6 @@ export interface Section {
83
88
 
84
89
 
85
90
 
86
-
87
-
88
91
  export interface InfoInstance {
89
92
  status: number
90
93
  instance: Instance
@@ -93,16 +96,22 @@ export interface InfoInstance {
93
96
  export interface Instance {
94
97
  receive_status_message: boolean
95
98
  save_media: boolean
99
+ receive_presence: boolean
100
+ permission: number
96
101
  mark_messages: boolean
97
102
  blocked: boolean
98
- user: User
103
+ user?: User
99
104
  phoneConnected: boolean
100
- webhook: Webhook
105
+ webhook: Webhook;
106
+ businessProfile?: BusinessProfile;
101
107
  }
102
108
 
103
109
  export interface User {
104
- id: string
105
- lid: string
110
+ id?: string;
111
+ lid?: string;
112
+ name?: string;
113
+ imageProfile?: string;
114
+
106
115
  }
107
116
 
108
117
  export interface Webhook {
@@ -142,3 +151,40 @@ export interface Message {
142
151
  export interface ExtendedTextMessage {
143
152
  text: string
144
153
  }
154
+
155
+ export interface Connect {
156
+ status: number;
157
+ phoneConnected: boolean;
158
+ qrcode: string;
159
+ image: string;
160
+ user?: User;
161
+ }
162
+
163
+
164
+
165
+ export interface BusinessProfile {
166
+ wid: string
167
+ description: string
168
+ website: any[]
169
+ category: string
170
+ business_hours: {}
171
+ }
172
+
173
+
174
+
175
+ export interface Buttons {
176
+ type: "quick_reply" | "cta_copy" | "cta_url" | "cta_call",
177
+ copy_code?: string,
178
+ phone_number?: string,
179
+ url?: string,
180
+ id?: string,
181
+ text: string;
182
+ }
183
+
184
+
185
+ export interface Items {
186
+ id: string,
187
+ name: string,
188
+ price: number,
189
+ quantity: number
190
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":";;;AAKA,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,6BAAe,CAAA;AACjB,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB;AAGD,IAAY,MAOX;AAPD,WAAY,MAAM;IAChB,gCAAsB,CAAA;IACtB,8BAAoB,CAAA;IACpB,+BAAqB,CAAA;IACrB,2BAAiB,CAAA;IACjB,6BAAmB,CAAA;IACnB,uBAAa,CAAA;AACf,CAAC,EAPW,MAAM,sBAAN,MAAM,QAOjB;AAGD,IAAY,WAYX;AAZD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,8BAAe,CAAA;IACf,8BAAe,CAAA;IACf,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;IACrB,4BAAa,CAAA;IACb,8BAAe,CAAA;AACjB,CAAC,EAZW,WAAW,2BAAX,WAAW,QAYtB;AAGD,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,6CAA2B,CAAA;IAC3B,yCAAuB,CAAA;IACvB,yCAAuB,CAAA;IACvB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB","sourcesContent":["export interface Init {\n server: string;\n key: string;\n}\n\nexport enum HttpMethod {\n GET = 'GET',\n POST = 'POST',\n PUT = 'PUT',\n DELETE = 'DELETE',\n PATCH = 'PATCH',\n}\n\n\nexport enum Routes {\n INSTANCES = 'instance',\n MESSAGES = 'message',\n CONTACTS = 'contacts',\n GROUPS = 'groups',\n ACTIONS = 'actions',\n CALL = 'call',\n}\n\n\nexport enum TypeMessage {\n PRESENCE = 'presence',\n TEXT = 'text',\n AUDIO = 'audio',\n IMAGE = 'image',\n VIDEO = 'video',\n DOCUMENT = 'document',\n CONTACT = 'contact',\n LOCATION = 'location',\n REACTION = 'reaction',\n LINK = 'link',\n TITLE = 'title',\n}\n\n\nexport enum StatusPresence {\n UNAVAILABLE = 'unavailable',\n AVAILABLE = 'available',\n COMPOSING = 'composing',\n RECORDING = 'recording',\n PAUSED = 'paused',\n}\n\n\n\nexport interface WebhookBody {\n allowWebhook: boolean;\n webhookMessage: string;\n webhookGroup: string;\n webhookConnection: string;\n webhookQrCode: string;\n webhookMessageFromMe: string;\n webhookHistory: string;\n}\n\nexport interface Contact {\n fullName: string;\n phoneNumber: string;\n organization?: string;\n}\n\n\nexport interface Location {\n latitude: number;\n longitude: number;\n address: string;\n}\n\nexport interface Row {\n title: string;\n description: string;\n rowId: string;\n}\n\nexport interface Section {\n title: string;\n rows: Row[];\n}\n\n\n\n\n\nexport interface InfoInstance {\n status: number\n instance: Instance\n}\n\nexport interface Instance {\n receive_status_message: boolean\n save_media: boolean\n mark_messages: boolean\n blocked: boolean\n user: User\n phoneConnected: boolean\n webhook: Webhook\n}\n\nexport interface User {\n id: string\n lid: string\n}\n\nexport interface Webhook {\n allowWebhook: boolean\n webhookMessage: string\n webhookGroup: string\n webhookConnection: string\n webhookQrCode: string\n webhookMessageFromMe: string\n webhookHistory: string\n}\n\n\n\nexport interface SendMessageRoot {\n status: number\n data: Data\n}\n\nexport interface Data {\n key: Key\n message: Message\n messageTimestamp: string\n status: string\n}\n\nexport interface Key {\n remoteJid: string\n fromMe: boolean\n id: string\n}\n\nexport interface Message {\n extendedTextMessage: ExtendedTextMessage\n}\n\nexport interface ExtendedTextMessage {\n text: string\n}\n"]}