rapidpro

package
v0.7.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NilContactID = ContactID{null.NewInt(0, false)}

NilContactID represents our nil value for ContactID

View Source
var NilContactURNID = ContactURNID{null.NewInt(0, false)}

NilContactURNID is our nil value for ContactURNID

View Source
var NilOrgID = OrgID{null.NewInt(0, false)}

NilOrgID is our nil value for OrgID

Functions

This section is empty.

Types

type ContactID

type ContactID struct {
	null.Int
}

ContactID is our representation of our database contact id

type ContactURNID

type ContactURNID struct {
	null.Int
}

ContactURNID represents a contact urn's id

type DBChannel

type DBChannel struct {
	OrgID_       OrgID               `db:"org_id"`
	ID_          courier.ChannelID   `db:"id"`
	ChannelType_ courier.ChannelType `db:"channel_type"`
	Schemes_     pq.StringArray      `db:"schemes"`
	UUID_        courier.ChannelUUID `db:"uuid"`
	Address_     sql.NullString      `db:"address"`
	Country_     sql.NullString      `db:"country"`
	Config_      utils.NullMap       `db:"config"`
	// contains filtered or unexported fields
}

DBChannel is the RapidPro specific concrete type satisfying the courier.Channel interface

func (*DBChannel) Address

func (c *DBChannel) Address() string

Address returns the address of this channel

func (*DBChannel) ChannelType

func (c *DBChannel) ChannelType() courier.ChannelType

ChannelType returns the type of this channel

func (*DBChannel) ConfigForKey

func (c *DBChannel) ConfigForKey(key string, defaultValue interface{}) interface{}

ConfigForKey returns the config value for the passed in key, or defaultValue if it isn't found

func (*DBChannel) Country

func (c *DBChannel) Country() string

Country returns the country code for this channel if any

func (*DBChannel) ID

func (c *DBChannel) ID() courier.ChannelID

ID returns the id of this channel

func (*DBChannel) OrgID

func (c *DBChannel) OrgID() OrgID

OrgID returns the id of the org this channel is for

func (*DBChannel) Schemes added in v0.3.0

func (c *DBChannel) Schemes() []string

Schemes returns the schemes this channels supports

func (*DBChannel) StringConfigForKey added in v0.2.0

func (c *DBChannel) StringConfigForKey(key string, defaultValue string) string

StringConfigForKey returns the config value for the passed in key, or defaultValue if it isn't found

func (*DBChannel) UUID

func (c *DBChannel) UUID() courier.ChannelUUID

UUID returns the UUID of this channel

type DBContact

type DBContact struct {
	OrgID OrgID       `db:"org_id"`
	ID    ContactID   `db:"id"`
	UUID  string      `db:"uuid"`
	Name  null.String `db:"name"`

	URNID 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"`

	IsNew bool
}

DBContact is our struct for a contact in the database

type DBContactURN

type DBContactURN struct {
	OrgID     OrgID             `db:"org_id"`
	ID        ContactURNID      `db:"id"`
	Identity  string            `db:"identity"`
	Scheme    string            `db:"scheme"`
	Path      string            `db:"path"`
	Display   null.String       `db:"display"`
	Priority  int               `db:"priority"`
	ChannelID courier.ChannelID `db:"channel_id"`
	ContactID ContactID         `db:"contact_id"`
}

DBContactURN is our struct to map to database level URNs

type DBMsg

type DBMsg struct {
	OrgID_       OrgID                  `json:"org_id"       db:"org_id"`
	ID_          courier.MsgID          `json:"id"           db:"id"`
	UUID_        courier.MsgUUID        `json:"uuid"`
	Direction_   MsgDirection           `json:"direction"    db:"direction"`
	Status_      courier.MsgStatusValue `json:"status"       db:"status"`
	Visibility_  MsgVisibility          `json:"visibility"   db:"visibility"`
	Priority_    courier.MsgPriority    `json:"priority"     db:"priority"`
	URN_         courier.URN            `json:"urn"`
	Text_        string                 `json:"text"         db:"text"`
	Attachments_ pq.StringArray         `json:"attachments"  db:"attachments"`
	ExternalID_  null.String            `json:"external_id"  db:"external_id"`

	ChannelID_    courier.ChannelID `json:"channel_id"      db:"channel_id"`
	ContactID_    ContactID         `json:"contact_id"      db:"contact_id"`
	ContactURNID_ ContactURNID      `json:"contact_urn_id"  db:"contact_urn_id"`

	MessageCount_ int `json:"msg_count"    db:"msg_count"`
	ErrorCount_   int `json:"error_count"  db:"error_count"`

	ChannelUUID_ courier.ChannelUUID `json:"channel_uuid"`
	ContactName_ string              `json:"contact_name"`

	NextAttempt_ time.Time `json:"next_attempt"  db:"next_attempt"`
	CreatedOn_   time.Time `json:"created_on"    db:"created_on"`
	ModifiedOn_  time.Time `json:"modified_on"   db:"modified_on"`
	QueuedOn_    time.Time `json:"queued_on"     db:"queued_on"`
	SentOn_      time.Time `json:"sent_on"       db:"sent_on"`

	Channel_        courier.Channel   `json:"-"`
	WorkerToken_    queue.WorkerToken `json:"-"`
	AlreadyWritten_ bool              `json:"-"`
}

DBMsg is our base struct to represent msgs both in our JSON and db representations

func (*DBMsg) Attachments

func (m *DBMsg) Attachments() []string

func (*DBMsg) Channel added in v0.2.0

func (m *DBMsg) Channel() courier.Channel

func (*DBMsg) ContactName

func (m *DBMsg) ContactName() string

func (*DBMsg) ExternalID

func (m *DBMsg) ExternalID() string

func (*DBMsg) ID

func (m *DBMsg) ID() courier.MsgID

func (*DBMsg) Priority

func (m *DBMsg) Priority() courier.MsgPriority

func (*DBMsg) ReceivedOn added in v0.2.0

func (m *DBMsg) ReceivedOn() *time.Time

func (*DBMsg) SentOn

func (m *DBMsg) SentOn() *time.Time

func (*DBMsg) Text

func (m *DBMsg) Text() string

func (*DBMsg) URN

func (m *DBMsg) URN() courier.URN

func (*DBMsg) UUID

func (m *DBMsg) UUID() courier.MsgUUID

func (*DBMsg) WithAttachment added in v0.2.0

func (m *DBMsg) WithAttachment(url string) courier.Msg

WithAttachment can be used to append to the media urls for a message

func (*DBMsg) WithContactName added in v0.2.0

func (m *DBMsg) WithContactName(name string) courier.Msg

WithContactName can be used to set the contact name on a msg

func (*DBMsg) WithExternalID added in v0.2.0

func (m *DBMsg) WithExternalID(id string) courier.Msg

WithExternalID can be used to set the external id on a msg in a chained call

func (*DBMsg) WithID added in v0.2.0

func (m *DBMsg) WithID(id courier.MsgID) courier.Msg

WithID can be used to set the id on a msg in a chained call

func (*DBMsg) WithReceivedOn added in v0.2.0

func (m *DBMsg) WithReceivedOn(date time.Time) courier.Msg

WithReceivedOn can be used to set sent_on on a msg in a chained call

func (*DBMsg) WithUUID added in v0.2.0

func (m *DBMsg) WithUUID(uuid courier.MsgUUID) courier.Msg

WithUUID can be used to set the id on a msg in a chained call

type DBMsgStatus

type DBMsgStatus struct {
	ChannelUUID_ courier.ChannelUUID    `json:"channel_uuid"             db:"channel_uuid"`
	ID_          courier.MsgID          `json:"msg_id,omitempty"         db:"msg_id"`
	ExternalID_  string                 `json:"external_id,omitempty"    db:"external_id"`
	Status_      courier.MsgStatusValue `json:"status"                   db:"status"`
	ModifiedOn_  time.Time              `json:"modified_on"              db:"modified_on"`
	// contains filtered or unexported fields
}

DBMsgStatus represents a status update on a message

func (*DBMsgStatus) AddLog added in v0.2.0

func (s *DBMsgStatus) AddLog(log *courier.ChannelLog)

func (*DBMsgStatus) ChannelUUID

func (s *DBMsgStatus) ChannelUUID() courier.ChannelUUID

func (*DBMsgStatus) ExternalID

func (s *DBMsgStatus) ExternalID() string

func (*DBMsgStatus) ID

func (s *DBMsgStatus) ID() courier.MsgID

func (*DBMsgStatus) Logs added in v0.2.0

func (s *DBMsgStatus) Logs() []*courier.ChannelLog

func (*DBMsgStatus) SetExternalID added in v0.2.0

func (s *DBMsgStatus) SetExternalID(id string)

func (*DBMsgStatus) SetStatus added in v0.2.0

func (s *DBMsgStatus) SetStatus(status courier.MsgStatusValue)

func (*DBMsgStatus) Status

func (s *DBMsgStatus) Status() courier.MsgStatusValue

type MsgDirection

type MsgDirection string

MsgDirection is the direction of a message

const (
	MsgIncoming     MsgDirection = "I"
	MsgOutgoing     MsgDirection = "O"
	NilMsgDirection MsgDirection = ""
)

Possible values for MsgDirection

type MsgVisibility

type MsgVisibility string

MsgVisibility is the visibility of a message

const (
	MsgVisible  MsgVisibility = "V"
	MsgDeleted  MsgVisibility = "D"
	MsgArchived MsgVisibility = "A"
)

Possible values for MsgVisibility

type OrgID

type OrgID struct {
	null.Int
}

OrgID is our type for database Org ids

Jump to

Keyboard shortcuts

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