@raphaelvserafim/client-api-whatsapp 1.0.9 → 1.2.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.
Files changed (60) hide show
  1. package/README.md +512 -297
  2. package/dist/WhatsApp.d.ts +139 -33
  3. package/dist/WhatsApp.js +111 -167
  4. package/dist/WhatsApp.js.map +1 -1
  5. package/dist/client/HttpClient.d.ts +6 -0
  6. package/dist/client/HttpClient.js +29 -0
  7. package/dist/client/HttpClient.js.map +1 -0
  8. package/dist/client/IHttpClient.d.ts +9 -0
  9. package/dist/client/IHttpClient.js +3 -0
  10. package/dist/client/IHttpClient.js.map +1 -0
  11. package/dist/errors.d.ts +5 -0
  12. package/dist/errors.js +13 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/index.d.ts +14 -1
  15. package/dist/index.js +33 -3
  16. package/dist/index.js.map +1 -1
  17. package/dist/services/ActionService.d.ts +9 -0
  18. package/dist/services/ActionService.js +32 -0
  19. package/dist/services/ActionService.js.map +1 -0
  20. package/dist/services/BusinessService.d.ts +10 -0
  21. package/dist/services/BusinessService.js +43 -0
  22. package/dist/services/BusinessService.js.map +1 -0
  23. package/dist/services/CallService.d.ts +8 -0
  24. package/dist/services/CallService.js +24 -0
  25. package/dist/services/CallService.js.map +1 -0
  26. package/dist/services/ChatService.d.ts +16 -0
  27. package/dist/services/ChatService.js +38 -0
  28. package/dist/services/ChatService.js.map +1 -0
  29. package/dist/services/CommunityService.d.ts +28 -0
  30. package/dist/services/CommunityService.js +76 -0
  31. package/dist/services/CommunityService.js.map +1 -0
  32. package/dist/services/ContactService.d.ts +15 -0
  33. package/dist/services/ContactService.js +30 -0
  34. package/dist/services/ContactService.js.map +1 -0
  35. package/dist/services/GroupService.d.ts +32 -0
  36. package/dist/services/GroupService.js +104 -0
  37. package/dist/services/GroupService.js.map +1 -0
  38. package/dist/services/InstanceService.d.ts +28 -0
  39. package/dist/services/InstanceService.js +124 -0
  40. package/dist/services/InstanceService.js.map +1 -0
  41. package/dist/services/LabelService.d.ts +17 -0
  42. package/dist/services/LabelService.js +43 -0
  43. package/dist/services/LabelService.js.map +1 -0
  44. package/dist/services/MessageService.d.ts +51 -0
  45. package/dist/services/MessageService.js +106 -0
  46. package/dist/services/MessageService.js.map +1 -0
  47. package/dist/types/index.d.ts +155 -11
  48. package/dist/types/index.js +10 -0
  49. package/dist/types/index.js.map +1 -1
  50. package/package.json +6 -11
  51. package/.babelrc +0 -3
  52. package/dist/exemple.d.ts +0 -1
  53. package/dist/exemple.js +0 -264
  54. package/dist/exemple.js.map +0 -1
  55. package/src/WhatsApp.ts +0 -245
  56. package/src/exemple.ts +0 -312
  57. package/src/index.ts +0 -2
  58. package/src/types/index.ts +0 -190
  59. package/tsconfig.compile.json +0 -15
  60. package/tsconfig.json +0 -35
package/src/exemple.ts DELETED
@@ -1,312 +0,0 @@
1
- import WhatsApp from "./WhatsApp";
2
- import { StatusPresence, TypeMessage } from "./types";
3
-
4
- const whatsapp = new WhatsApp({ server: "", key: "" });
5
-
6
- const to = "559999999999" // If you want to send it to the group = 123456789@us
7
-
8
- whatsapp.info().then((response) => {
9
- console.log(response)
10
- }).catch(console.error)
11
-
12
-
13
- whatsapp.connect().then((response) => {
14
- console.log(response)
15
- }).catch(console.error);
16
-
17
-
18
- whatsapp.logout().then((response) => {
19
- console.log(response)
20
- }).catch(console.error);
21
-
22
-
23
- whatsapp.contacts().then((response) => {
24
- console.log(response)
25
- }).catch(console.error)
26
-
27
-
28
- whatsapp.sendMessage({
29
- type: TypeMessage.PRESENCE,
30
- body: {
31
- to: to,
32
- status: StatusPresence.COMPOSING
33
- }
34
- }).then((response) => {
35
- console.log(response)
36
- }).catch(console.error)
37
-
38
-
39
- whatsapp.sendMessage({
40
- type: TypeMessage.TEXT,
41
- body: {
42
- to: to,
43
- text: "Hey"
44
- }
45
- }).then((response) => {
46
- console.log(response)
47
-
48
- }).catch(console.error)
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
-
203
-
204
- whatsapp.sendMessage({
205
- type: TypeMessage.TEXT,
206
- body: {
207
- msgId: "SKJH455AJKJ",
208
- to: to,
209
- text: "Hey"
210
- }
211
- }, true).then((response) => {
212
- console.log(response)
213
- }).catch(console.error)
214
-
215
-
216
-
217
- whatsapp.sendMessage({
218
- type: TypeMessage.AUDIO,
219
- body: {
220
- to: to,
221
- url: ""
222
- }
223
- }).then((response) => {
224
- console.log(response)
225
- }).catch(console.error)
226
-
227
-
228
- whatsapp.sendMessage({
229
- type: TypeMessage.IMAGE,
230
- body: {
231
- to: to,
232
- url: ""
233
- }
234
- }).then((response) => {
235
- console.log(response)
236
- }).catch(console.error)
237
-
238
-
239
- whatsapp.sendMessage({
240
- type: TypeMessage.VIDEO,
241
- body: {
242
- to: to,
243
- url: ""
244
- }
245
- }).then((response) => {
246
- console.log(response)
247
- }).catch(console.error)
248
-
249
-
250
-
251
- whatsapp.sendMessage({
252
- type: TypeMessage.DOCUMENT,
253
- body: {
254
- to: to,
255
- url: "",
256
- mimetype: "",
257
- fileName: ""
258
- }
259
- }).then((response) => {
260
- console.log(response)
261
- }).catch(console.error)
262
-
263
-
264
- whatsapp.sendMessage({
265
- type: TypeMessage.CONTACT,
266
- body: {
267
- to: to,
268
- contact: {
269
- fullName: "Raphael",
270
- phoneNumber: to,
271
- organization: "api-wa.me"
272
- }
273
- }
274
- }).then((response) => {
275
- console.log(response)
276
- }).catch(console.error)
277
-
278
-
279
- whatsapp.sendMessage({
280
- type: TypeMessage.REACTION,
281
- body: {
282
- to: to,
283
- msgId: "ASDDF872AHDURBSG",
284
- text: "🤖"
285
- }
286
- }).then((response) => {
287
- console.log(response)
288
- }).catch(console.error)
289
-
290
-
291
- whatsapp.groups().then((response) => {
292
- console.log(response)
293
- }).catch(console.error)
294
-
295
-
296
- whatsapp.infoGroup("123456789@us").then((response) => {
297
- console.log(response)
298
- }).catch(console.error)
299
-
300
-
301
-
302
- whatsapp.createGroup("Devs", [to]).then((response) => {
303
- console.log(response)
304
- }).catch(console.error)
305
-
306
-
307
- whatsapp.updateGroup("123456789@us", "Devs", "Only developers !").then((response) => {
308
- console.log(response)
309
- }).catch(console.error)
310
-
311
-
312
-
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { TypeMessage, Init, StatusPresence, Contact, Location } from './types';
2
- export { WhatsApp } from './WhatsApp';
@@ -1,190 +0,0 @@
1
- export interface Init {
2
- server: string;
3
- key: string;
4
- }
5
-
6
- export enum HttpMethod {
7
- GET = 'GET',
8
- POST = 'POST',
9
- PUT = 'PUT',
10
- DELETE = 'DELETE',
11
- PATCH = 'PATCH',
12
- }
13
-
14
-
15
- export enum Routes {
16
- INSTANCES = 'instance',
17
- MESSAGES = 'message',
18
- CONTACTS = 'contacts',
19
- GROUPS = 'groups',
20
- ACTIONS = 'actions',
21
- CALL = 'call',
22
- }
23
-
24
-
25
- export enum TypeMessage {
26
- PRESENCE = 'presence',
27
- TEXT = 'text',
28
- AUDIO = 'audio',
29
- IMAGE = 'image',
30
- VIDEO = 'video',
31
- DOCUMENT = 'document',
32
- CONTACT = 'contact',
33
- LOCATION = 'location',
34
- REACTION = 'reaction',
35
- LINK = 'link',
36
- TITLE = 'title',
37
- BUTTON_REPLY = 'button_reply',
38
- BUTTON_ACTION = 'button_action',
39
- BUTTON_PIX = 'pix',
40
- POLL = 'survey',
41
- MENU = 'list',
42
- }
43
-
44
-
45
- export enum StatusPresence {
46
- UNAVAILABLE = 'unavailable',
47
- AVAILABLE = 'available',
48
- COMPOSING = 'composing',
49
- RECORDING = 'recording',
50
- PAUSED = 'paused',
51
- }
52
-
53
-
54
-
55
- export interface WebhookBody {
56
- allowWebhook: boolean;
57
- webhookMessage: string;
58
- webhookGroup: string;
59
- webhookConnection: string;
60
- webhookQrCode: string;
61
- webhookMessageFromMe: string;
62
- webhookHistory: string;
63
- }
64
-
65
- export interface Contact {
66
- fullName: string;
67
- phoneNumber: string;
68
- organization?: string;
69
- }
70
-
71
-
72
- export interface Location {
73
- latitude: number;
74
- longitude: number;
75
- address: string;
76
- }
77
-
78
- export interface Row {
79
- title: string;
80
- description: string;
81
- rowId: string;
82
- }
83
-
84
- export interface Section {
85
- title: string;
86
- rows: Row[];
87
- }
88
-
89
-
90
-
91
- export interface InfoInstance {
92
- status: number
93
- instance: Instance
94
- }
95
-
96
- export interface Instance {
97
- receive_status_message: boolean
98
- save_media: boolean
99
- receive_presence: boolean
100
- permission: number
101
- mark_messages: boolean
102
- blocked: boolean
103
- user?: User
104
- phoneConnected: boolean
105
- webhook: Webhook;
106
- businessProfile?: BusinessProfile;
107
- }
108
-
109
- export interface User {
110
- id?: string;
111
- lid?: string;
112
- name?: string;
113
- imageProfile?: string;
114
-
115
- }
116
-
117
- export interface Webhook {
118
- allowWebhook: boolean
119
- webhookMessage: string
120
- webhookGroup: string
121
- webhookConnection: string
122
- webhookQrCode: string
123
- webhookMessageFromMe: string
124
- webhookHistory: string
125
- }
126
-
127
-
128
-
129
- export interface SendMessageRoot {
130
- status: number
131
- data: Data
132
- }
133
-
134
- export interface Data {
135
- key: Key
136
- message: Message
137
- messageTimestamp: string
138
- status: string
139
- }
140
-
141
- export interface Key {
142
- remoteJid: string
143
- fromMe: boolean
144
- id: string
145
- }
146
-
147
- export interface Message {
148
- extendedTextMessage: ExtendedTextMessage
149
- }
150
-
151
- export interface ExtendedTextMessage {
152
- text: string
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,15 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "outDir": "./dist",
6
- "moduleResolution": "node",
7
- "declaration": true,
8
- "noResolve": false,
9
- "preserveConstEnums": true,
10
- "sourceMap": true,
11
- "noEmit": false,
12
- "emitDeclarationOnly": false,
13
- "inlineSources": true
14
- }
15
- }
package/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "esnext",
5
- "sourceMap": true,
6
- "declaration": false,
7
- "experimentalDecorators": true,
8
- "emitDecoratorMetadata": true,
9
- "moduleResolution": "node",
10
- "isolatedModules": false,
11
- "suppressImplicitAnyIndexErrors": false,
12
- "noImplicitAny": true,
13
- "strictNullChecks": true,
14
- "noUnusedLocals": false,
15
- "noUnusedParameters": false,
16
- "allowSyntheticDefaultImports": true,
17
- "importHelpers": true,
18
- "newLine": "LF",
19
- "noEmit": true,
20
- "esModuleInterop": true,
21
- "resolveJsonModule": true,
22
- "lib": [
23
- "es7",
24
- "dom",
25
- "ESNext.AsyncIterable"
26
- ],
27
- "typeRoots": [
28
- "./node_modules/@types"
29
- ]
30
- },
31
- "include": ["src/**/*.ts"],
32
- "linterOptions": {
33
- "exclude": []
34
- }
35
- }