wsp

package module
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 8 Imported by: 0

README

go_whatsapp_api

Go module to interact with Whatsapp Business API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBModels added in v0.5.2

func DBModels() []any

Get migration models

func NewMessageCallback

func NewMessageCallback(callback func(msg Message))

Set function to be called when a new message arrived

func RegisterWebhook

func RegisterWebhook(s *conn.Server) *conn.Server

Register webhooks to Echo server

func StatusChangeCallback added in v0.5.2

func StatusChangeCallback(callback func(msg Message))

Set function to be called when a message status changed

Types

type Credentials

type Credentials struct {
	BusinessID string
	Token      string
	PhoneID    string
	Version    string
}

func (Credentials) Request

func (cd Credentials) Request(req conn.Request) conn.Response

Make a Request with the Instance

func (Credentials) Save

func (cd Credentials) Save()

Save credentials to be used globally

func (Credentials) Validate

func (cd Credentials) Validate() *Credentials

Validate credentials

type Message

type Message struct {
	ID        string
	From      string
	Text      string
	Status    string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Request

type Request struct {
	To string
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(To string) *Request

Create new whatsapp request

func (Request) Send

func (r Request) Send() conn.Response

Make whatsapp request

func (*Request) Template

func (r *Request) Template(name string, lang string, bodyVars ...string) *Request

Set template content for request

func (*Request) Text

func (r *Request) Text(text string) *Request

Set text content for request

func (*Request) WithCredentials

func (r *Request) WithCredentials(cd *Credentials) *Request

Set custom credentials for a request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL