store

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemeTel     = "tel"
	SchemeTwitter = "twitter"
	SchemeEmail   = "email"
)

Variables

This section is empty.

Functions

func InsertContact

func InsertContact(db *sqlx.DB, contact *Contact) error

InsertContact inserts the passed in contact, the id field will be populated with the result on success

func InsertContactURN

func InsertContactURN(db *sqlx.DB, urn *ContactURN) error

InsertContactURN inserts the passed in urn, the id field will be populated with the result on success

func InsertMsg

func InsertMsg(db *sqlx.DB, msg *Msg) error

InsertMsg inserts the passed in msg, the id field will be populated with the result on success

func UpdateContactURN

func UpdateContactURN(db *sqlx.DB, urn *ContactURN) error

UpdateContactURN updates the Channel and Contact on an existing URN

Types

type Channel

type Channel struct {
	Org         OrgID     `db:"org_id"`
	ID          ChannelID `db:"id"`
	UUID        string    `db:"uuid"`
	ChannelType string    `db:"channel_type"`
	Config      string    `db:"config"`
}

func ChannelForUUID

func ChannelForUUID(db *sqlx.DB, channelType string, uuid string) (*Channel, error)

ChannelForUUID attempts to look up the channel with the passed in UUID, returning it

type ChannelID

type ChannelID struct {
	sql.NullInt64
}

type Contact

type Contact struct {
	Org  OrgID     `db:"org_id"`
	ID   ContactID `db:"id"`
	UUID string    `db:"uuid"`
	Name string    `db:"name"`

	URN ContactURNID `db:"urn_id"`

	CreatedOn  time.Time `db:"created_on"`
	ModifiedOn time.Time `db:"modified_on"`

	CreatedBy  int `db:"created_by_id"`
	ModifiedBy int `db:"modified_by_id"`
}

func ContactForURN

func ContactForURN(db *sqlx.DB, org OrgID, channel ChannelID, urn URN, name string) (*Contact, error)

ContactForURN first tries to look up a contact for the passed in URN, if not finding one then creating one

type ContactID

type ContactID struct {
	sql.NullInt64
}

type ContactURN

type ContactURN struct {
	Org      OrgID        `db:"org_id"`
	ID       ContactURNID `db:"id"`
	URN      URN          `db:"urn"`
	Scheme   string       `db:"scheme"`
	Path     string       `db:"path"`
	Priority int          `db:"priority"`
	Channel  ChannelID    `db:"channel_id"`
	Contact  ContactID    `db:"contact_id"`
}

func ContactURNForURN

func ContactURNForURN(db *sqlx.DB, org OrgID, channel ChannelID, contact ContactID, urn URN) (*ContactURN, error)

ContactURNForURN returns the ContactURN for the passed in org and URN, creating and associating

it with the passed in contact if necessary

func NewContactURN

func NewContactURN(org OrgID, channel ChannelID, contact ContactID, urn URN) *ContactURN

NewContactURN returns a new ContactURN object for the passed in org, contact and string urn, this is not saved to the DB yet

type ContactURNID

type ContactURNID struct {
	sql.NullInt64
}

type MessageID

type MessageID int64

type Msg

type Msg struct {
	Org        OrgID     `db:"org_id"`
	ID         MessageID `db:"id"`
	Direction  string    `db:"direction"`
	Text       string    `db:"text"`
	Priority   int       `db:"priority"`
	Status     string    `db:"status"`
	Visibility string    `db:"visibility"`
	ExternalID string    `db:"external_id"`

	MessageCount int `db:"msg_count"`
	ErrorCount   int `db:"error_count"`

	Channel    ChannelID    `db:"channel_id"`
	Contact    ContactID    `db:"contact_id"`
	ContactURN ContactURNID `db:"contact_urn_id"`

	NextAttempt time.Time `db:"next_attempt"`
	CreatedOn   time.Time `db:"created_on"`
	ModifiedOn  time.Time `db:"modified_on"`
	QueuedOn    time.Time `db:"queued_on"`
	SentOn      time.Time `db:"sent_on"`
}

func NewMsg

func NewMsg(org OrgID, channel ChannelID, contact ContactID, urn ContactURNID, direction string, text string, status string, externalID string) *Msg

NewMsg creates a new contact with the passed in parameters

type OrgID

type OrgID struct {
	sql.NullInt64
}

type URN

type URN string

func NewURNFromParts

func NewURNFromParts(scheme string, path string) URN

NewURNFromParts builds a new URN from the passed in string and path

Jump to

Keyboard shortcuts

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