models

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateVriableRegex = regexp.MustCompile(`\{\{\s*\d+\s*\}\}`)

Functions

func ReplaceVariables

func ReplaceVariables(input string, varValues []string) string

func Variables

func Variables(input string) []int

Variables returns all the variables in the template

Types

type Conversation

type Conversation struct {
	gorm.Model
	PhoneNumberId string    `json:"phoneNumberId"`
	PhoneNumber   string    `json:"phoneNumber"`
	Messages      []Message `json:"messages"`
}

type Direction

type Direction string
const (
	DirectionIn  Direction = "in"
	DirectionOut Direction = "out"
)

type Message

type Message struct {
	gorm.Model
	ConversationID uint            `json:"conversationId"`
	WhatsappID     string          `json:"whatsappID"`
	Direction      Direction       `json:"direction"`
	HeaderMessage  *string         `json:"headerMessage"`
	Message        string          `json:"message"`
	FooterMessage  *string         `json:"footerMessage"`
	Timestamp      int64           `json:"timestamp"`
	Buttons        []MessageButton `json:"buttons"`
}

func (*Message) CreateOrAppend

func (m *Message) CreateOrAppend(number string) error

type MessageButton added in v1.0.1

type MessageButton struct {
	gorm.Model
	ConversationID uint    `json:"conversationId"`
	MessageID      uint    `json:"messageId"`
	Text           string  `json:"text"`
	Payload        *string `json:"payload"`
}

type Template

type Template struct {
	gorm.Model
	Name string `json:"name"`
	// FIXME different types of headers
	Header                *string                `json:"header"`
	Body                  string                 `json:"body"`
	Footer                *string                `json:"footer"`
	TemplateCustomButtons []TemplateCustomButton `json:"templateCustomButtons"`
}

func (*Template) CreateCustomButton

func (t *Template) CreateCustomButton(text string) error

func (*Template) Validate

func (t *Template) Validate() error

type TemplateCustomButton

type TemplateCustomButton struct {
	gorm.Model
	TemplateID uint   `json:"templateId"`
	Text       string `json:"text"`
}

Jump to

Keyboard shortcuts

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