api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Gin          *gin.Engine
	TwilioClient *twilio.Twilio
	DB           *sql.DB
	// contains filtered or unexported fields
}

API represents a API config object

func NewAPI

func NewAPI(conf Config, router *gin.Engine, db *sql.DB, logger log.Logger) (*API, error)

NewAPI creates a new API instance

func (*API) Register

func (api *API) Register()

Register creates all api endpoints in given instance of gin

type Config

type Config struct {
	TwilioSID             string
	TwilioToken           string
	JWTSecret             []byte
	WhatsAppFrom          string
	WebHookAccount        gin.Accounts
	VerifyTmpl, NotifTmpl *template.Template
}

Config represents a configuration object for this API

type Group

type Group struct {
	ID            int            `json:"id"`
	Name          string         `json:"name"`
	UserID        int            `json:"userID"`
	WhatsAppNodes []WhatsAppNode `json:"whatsappNodes"`
}

Group represents a group of nodes

type Notification

type Notification struct {
	ID        int    `json:"id"`
	UserID    int    `json:"userID"`
	GroupID   int    `json:"groupID"`
	Body      string `json:"body"`
	TimeSt    string `json:"timeSt"`
	GroupName string `json:"groupName"`
}

Notification represent a single message object

type Number

type Number struct {
	ID       int    `json:"id"`
	UserID   int    `json:"userID"`
	Phone    string `json:"phone"`
	Groups   int    `json:"groups"`
	Verified bool   `json:"verified"`
}

Number models the numbers table in database

type User

type User struct {
	ID       int
	Name     string
	Phone    string
	Hash     string
	Verified bool
}

User models a user in database

type VerifyUser

type VerifyUser struct {
	ID       int
	UserID   int
	NumberID int
	Code     string
}

VerifyUser Models the verifyUser table

type WhatsAppNode

type WhatsAppNode struct {
	ID              int    `json:"id"`
	GroupID         int    `json:"groupID"`
	NumberID        int    `json:"numberID"`
	Phone           string `json:"phone"`
	LastMsgReceived string `json:"lastMsgReceived"`
}

WhatsAppNode represents table whatsappNodes' schema

Jump to

Keyboard shortcuts

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