@raphaelvserafim/client-api-whatsapp 1.0.6 → 1.0.8

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.
@@ -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,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,CAAA;AAGvB,QAAQ,CAAC,WAAW,CAAC;IACnB,IAAI,EAAE,mBAAW,CAAC,QA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Q,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,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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 \"./types\";\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\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';"]}
@@ -0,0 +1,152 @@
1
+ export interface Init {
2
+ server: string;
3
+ key: string;
4
+ }
5
+ export declare enum HttpMethod {
6
+ GET = "GET",
7
+ POST = "POST",
8
+ PUT = "PUT",
9
+ DELETE = "DELETE",
10
+ PATCH = "PATCH"
11
+ }
12
+ export declare enum Routes {
13
+ INSTANCES = "instance",
14
+ MESSAGES = "message",
15
+ CONTACTS = "contacts",
16
+ GROUPS = "groups",
17
+ ACTIONS = "actions",
18
+ CALL = "call"
19
+ }
20
+ export declare enum TypeMessage {
21
+ PRESENCE = "presence",
22
+ TEXT = "text",
23
+ AUDIO = "audio",
24
+ IMAGE = "image",
25
+ VIDEO = "video",
26
+ DOCUMENT = "document",
27
+ CONTACT = "contact",
28
+ LOCATION = "location",
29
+ REACTION = "reaction",
30
+ LINK = "link",
31
+ TITLE = "title",
32
+ BUTTON_REPLY = "button_reply",
33
+ BUTTON_ACTION = "button_action",
34
+ BUTTON_PIX = "pix",
35
+ POLL = "survey",
36
+ MENU = "list"
37
+ }
38
+ export declare enum StatusPresence {
39
+ UNAVAILABLE = "unavailable",
40
+ AVAILABLE = "available",
41
+ COMPOSING = "composing",
42
+ RECORDING = "recording",
43
+ PAUSED = "paused"
44
+ }
45
+ export interface WebhookBody {
46
+ allowWebhook: boolean;
47
+ webhookMessage: string;
48
+ webhookGroup: string;
49
+ webhookConnection: string;
50
+ webhookQrCode: string;
51
+ webhookMessageFromMe: string;
52
+ webhookHistory: string;
53
+ }
54
+ export interface Contact {
55
+ fullName: string;
56
+ phoneNumber: string;
57
+ organization?: string;
58
+ }
59
+ export interface Location {
60
+ latitude: number;
61
+ longitude: number;
62
+ address: string;
63
+ }
64
+ export interface Row {
65
+ title: string;
66
+ description: string;
67
+ rowId: string;
68
+ }
69
+ export interface Section {
70
+ title: string;
71
+ rows: Row[];
72
+ }
73
+ export interface InfoInstance {
74
+ status: number;
75
+ instance: Instance;
76
+ }
77
+ export interface Instance {
78
+ receive_status_message: boolean;
79
+ save_media: boolean;
80
+ receive_presence: boolean;
81
+ permission: number;
82
+ mark_messages: boolean;
83
+ blocked: boolean;
84
+ user?: User;
85
+ phoneConnected: boolean;
86
+ webhook: Webhook;
87
+ businessProfile?: BusinessProfile;
88
+ }
89
+ export interface User {
90
+ id?: string;
91
+ lid?: string;
92
+ name?: string;
93
+ imageProfile?: string;
94
+ }
95
+ export interface Webhook {
96
+ allowWebhook: boolean;
97
+ webhookMessage: string;
98
+ webhookGroup: string;
99
+ webhookConnection: string;
100
+ webhookQrCode: string;
101
+ webhookMessageFromMe: string;
102
+ webhookHistory: string;
103
+ }
104
+ export interface SendMessageRoot {
105
+ status: number;
106
+ data: Data;
107
+ }
108
+ export interface Data {
109
+ key: Key;
110
+ message: Message;
111
+ messageTimestamp: string;
112
+ status: string;
113
+ }
114
+ export interface Key {
115
+ remoteJid: string;
116
+ fromMe: boolean;
117
+ id: string;
118
+ }
119
+ export interface Message {
120
+ extendedTextMessage: ExtendedTextMessage;
121
+ }
122
+ export interface ExtendedTextMessage {
123
+ text: string;
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
+ }
@@ -16,6 +16,7 @@ var Routes;
16
16
  Routes["CONTACTS"] = "contacts";
17
17
  Routes["GROUPS"] = "groups";
18
18
  Routes["ACTIONS"] = "actions";
19
+ Routes["CALL"] = "call";
19
20
  })(Routes || (exports.Routes = Routes = {}));
20
21
  var TypeMessage;
21
22
  (function (TypeMessage) {
@@ -29,6 +30,12 @@ var TypeMessage;
29
30
  TypeMessage["LOCATION"] = "location";
30
31
  TypeMessage["REACTION"] = "reaction";
31
32
  TypeMessage["LINK"] = "link";
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";
32
39
  })(TypeMessage || (exports.TypeMessage = TypeMessage = {}));
33
40
  var StatusPresence;
34
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.6",
3
+ "version": "1.0.8",
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 } 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,13 +36,13 @@ 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();
43
43
  }
44
44
 
45
- async info(): Promise<any> {
45
+ async info(): Promise<InfoInstance> {
46
46
  this.route = Routes.INSTANCES;
47
47
  this.method = HttpMethod.GET;
48
48
  return await this.request();
@@ -54,14 +54,14 @@ export class WhatsApp {
54
54
  return await this.request();
55
55
  }
56
56
 
57
- async setting(markMessageRead: boolean, saveMedia: boolean): Promise<any> {
58
- this.route = Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}`;
57
+
58
+ async setting(markMessageRead: boolean, saveMedia: boolean, receiveStatusMessage: boolean, receivePresence: boolean): Promise<{ status: number, message: string }> {
59
+ this.route = Routes.INSTANCES + `/?markMessageRead=${markMessageRead}&saveMedia=${saveMedia}&receiveStatusMessage=${receiveStatusMessage}&receivePresence=${receivePresence}`;
59
60
  this.method = HttpMethod.PATCH;
60
61
  return await this.request();
61
62
  }
62
63
 
63
64
 
64
-
65
65
  async updateWebhook(body: WebhookBody): Promise<any> {
66
66
  this.route = Routes.INSTANCES;
67
67
  this.method = HttpMethod.PUT;
@@ -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[],
108
+ }
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.");
96
115
  }
97
- }, reply: boolean = false): Promise<any> {
116
+ }
117
+
98
118
  if (reply) {
99
119
  this.route = Routes.MESSAGES + "/" + data.body.msgId + "/" + data.type;
100
120
  } else {
@@ -106,6 +126,31 @@ export class WhatsApp {
106
126
  return await this.request();
107
127
  }
108
128
 
129
+
130
+ async forwardingMessage(to: string, msgId: string) {
131
+ this.route = Routes.MESSAGES + "/" + msgId + "/forwarding";
132
+ this.method = HttpMethod.POST;
133
+ this.body = {
134
+ to,
135
+ }
136
+ return await this.request();
137
+ }
138
+
139
+ async rejectCall(id: string, from: string) {
140
+ this.route = Routes.CALL + `/${id}/${from}`;
141
+ this.method = HttpMethod.DELETE;
142
+ return await this.request();
143
+ }
144
+
145
+ async pairingCode(phoneNumber: string) {
146
+ this.route = Routes.INSTANCES + "/pairing-code";
147
+ this.body = {
148
+ phoneNumber,
149
+ }
150
+ this.method = HttpMethod.POST;
151
+ return await this.request();
152
+ }
153
+
109
154
  async checkRegisteredWhatsapp(number: string) {
110
155
  this.route = Routes.ACTIONS + "/registered?number=" + number;
111
156
  this.method = HttpMethod.GET;
@@ -139,6 +184,14 @@ export class WhatsApp {
139
184
  return await this.request();
140
185
  }
141
186
 
187
+ async getInviteGroup(id: string) {
188
+ this.route = Routes.GROUPS + "/" + id + "/invite";
189
+ this.method = HttpMethod.GET;
190
+ return await this.request();
191
+ }
192
+
193
+
194
+
142
195
  async updateGroup(id: string, name: string, description: string) {
143
196
  this.route = Routes.GROUPS + "/" + id;
144
197
  this.method = HttpMethod.PUT;
@@ -149,6 +202,15 @@ export class WhatsApp {
149
202
  return await this.request();
150
203
  }
151
204
 
205
+ async updateGroupPicture(id: string, url: string) {
206
+ this.route = Routes.GROUPS + "/" + id + "/picture";
207
+ this.method = HttpMethod.PUT;
208
+ this.body = {
209
+ url
210
+ }
211
+ return await this.request();
212
+ }
213
+
152
214
  async leaveGroup(id: string) {
153
215
  this.route = Routes.GROUPS + "/" + id;
154
216
  this.method = HttpMethod.DELETE;
@@ -165,6 +227,16 @@ export class WhatsApp {
165
227
  return await this.request();
166
228
  }
167
229
 
230
+
231
+ async addParticipantsGroup(id: string, participants: string[]) {
232
+ this.route = Routes.GROUPS + "/" + id + "/participants";
233
+ this.method = HttpMethod.POST;
234
+ this.body = {
235
+ participants
236
+ }
237
+ return await this.request();
238
+ }
239
+
168
240
  }
169
241
 
170
242
 
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';