Skip to content

Commit

Permalink
✨ feat: exemple
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvserafim committed Jun 1, 2024
1 parent e8314b5 commit dab15af
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/raphaelvserafim/gerar-pix-sicredi.git"
"url": "https://github.com/raphaelvserafim/client-api-whatsapp.git"
},
"dependencies": {
"axios": "^1.6.8",
Expand Down
4 changes: 2 additions & 2 deletions src/WhatsApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export class WhatsApp {
location?: Location,
name?: string,
options?: string[],
sections: Section,
sections?: Section,
footer?: string,
description?: string,
title?: string,
buttonText?: string,
}
}, reply: boolean = false): Promise<any> {
}, reply: boolean = false ): Promise<any> {
if (reply) {
this.route = Routes.MESSAGES + "/" + data.body.msgId + "/" + data.type;
} else {
Expand Down
159 changes: 159 additions & 0 deletions src/exemple.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import WhatsApp from "./WhatsApp";
import { StatusPresence, TypeMessage } from "./model";

const whatsapp = new WhatsApp({ server: "", key: "" });

const to = "559999999999" // If you want to send it to the group = 123456789@us

whatsapp.info().then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.connect().then((response) => {
console.log(response)
}).catch(console.error);


whatsapp.logout().then((response) => {
console.log(response)
}).catch(console.error);


whatsapp.contacts().then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.sendMessage({
type: TypeMessage.PRESENCE,
body: {
to: to,
status: StatusPresence.COMPOSING
}
}).then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.sendMessage({
type: TypeMessage.TEXT,
body: {
to: to,
text: "Hey"
}
}).then((response) => {
console.log(response)

}).catch(console.error)


whatsapp.sendMessage({
type: TypeMessage.TEXT,
body: {
msgId: "SKJH455AJKJ",
to: to,
text: "Hey"
}
}, true).then((response) => {
console.log(response)
}).catch(console.error)



whatsapp.sendMessage({
type: TypeMessage.AUDIO,
body: {
to: to,
url: ""
}
}).then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.sendMessage({
type: TypeMessage.IMAGE,
body: {
to: to,
url: ""
}
}).then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.sendMessage({
type: TypeMessage.VIDEO,
body: {
to: to,
url: ""
}
}).then((response) => {
console.log(response)
}).catch(console.error)



whatsapp.sendMessage({
type: TypeMessage.DOCUMENT,
body: {
to: to,
url: "",
mimetype: "",
fileName: ""
}
}).then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.sendMessage({
type: TypeMessage.CONTACT,
body: {
to: to,
contact: {
fullName: "Raphael",
phoneNumber: to,
organization: "api-wa.me"
}
}
}).then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.sendMessage({
type: TypeMessage.REACTION,
body: {
to: to,
msgId: "ASDDF872AHDURBSG",
text: "🤖"
}
}).then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.groups().then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.infoGroup("123456789@us").then((response) => {
console.log(response)
}).catch(console.error)



whatsapp.createGroup("Devs", [to]).then((response) => {
console.log(response)
}).catch(console.error)


whatsapp.updateGroup("123456789@us", "Devs", "Only developers !").then((response) => {
console.log(response)
}).catch(console.error)



2 changes: 1 addition & 1 deletion src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface WebhookBody {
export interface Contact {
fullName: string;
phoneNumber: string;
organization: string;
organization?: string;
}


Expand Down

0 comments on commit dab15af

Please sign in to comment.