whatsapp

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TwilioHTTPClientTimeoutSeconds determines how long to wait (in seconds) before giving up on a
	// request to the Twilio API
	TwilioHTTPClientTimeoutSeconds = 30
	TwilioWhatsappSIDEnvVarName    = "TWILIO_WHATSAPP_SID"

	// gosec false positive
	TwilioWhatsappAuthTokenEnvVarName = "TWILIO_WHATSAPP_AUTH_TOKEN" /* #nosec */

	TwilioWhatsappSenderEnvVarName = "TWILIO_WHATSAPP_SENDER"
)

Twilio Whatsapp API contants

Variables

This section is empty.

Functions

This section is empty.

Types

type ServiceWhatsapp

type ServiceWhatsapp interface {
	PhoneNumberVerificationCode(
		ctx context.Context,
		to string,
		code string,
		marketingMessage string,
	) (bool, error)

	// TODO: Remove db implementation
	SaveTwilioCallbackResponse(
		ctx context.Context,
		data dto.Message,
	) error

	TemporaryPIN(
		ctx context.Context,
		to string,
		message string,
	) (bool, error)
}

ServiceWhatsapp defines the interactions with the whatsapp service

type ServiceWhatsappImpl

type ServiceWhatsappImpl struct {
	BaseURL          string
	AccountSID       string
	AccountAuthToken string
	Sender           string
	HTTPClient       *http.Client
	Repository       database.Repository
}

ServiceWhatsappImpl is a WhatsApp service. The receivers implement the query and mutation resolvers.

func NewService

func NewService() *ServiceWhatsappImpl

NewService initializes a properly set up WhatsApp service

func (ServiceWhatsappImpl) CheckPreconditions

func (s ServiceWhatsappImpl) CheckPreconditions()

CheckPreconditions ...

func (ServiceWhatsappImpl) MakeTwilioRequest

func (s ServiceWhatsappImpl) MakeTwilioRequest(
	ctx context.Context,
	method string,
	urlPath string,
	content url.Values,
	target interface{},
) error

MakeTwilioRequest makes a twilio request

func (ServiceWhatsappImpl) PhoneNumberVerificationCode

func (s ServiceWhatsappImpl) PhoneNumberVerificationCode(
	ctx context.Context,
	to string,
	code string,
	marketingMessage string,
) (bool, error)

PhoneNumberVerificationCode sends Phone Number verification codes via WhatsApp

func (ServiceWhatsappImpl) SaveTwilioCallbackResponse

func (s ServiceWhatsappImpl) SaveTwilioCallbackResponse(
	ctx context.Context,
	data dto.Message,
) error

SaveTwilioCallbackResponse saves the twilio callback response for future analysis

func (ServiceWhatsappImpl) TemporaryPIN

func (s ServiceWhatsappImpl) TemporaryPIN(
	ctx context.Context,
	to string,
	message string,
) (bool, error)

TemporaryPIN send PIN via whatsapp to user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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