rapidpro

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2017 License: AGPL-3.0 Imports: 34 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 ChannelEventID added in v0.8.0

type ChannelEventID struct {
	null.Int
}

ChannelEventID is the type of our channel event ids

func (ChannelEventID) String added in v0.8.0

func (i ChannelEventID) String() string

String satisfies the Stringer interface

type ContactID

type ContactID struct {
	null.Int
}

ContactID is our representation of our database contact id

func (*ContactID) String added in v1.0.9

func (c *ContactID) String() string

String returns a string representation of this ContactID

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"`
	Name_        sql.NullString      `db:"name"`
	Address_     sql.NullString      `db:"address"`
	Country_     sql.NullString      `db:"country"`
	Config_      utils.NullMap       `db:"config"`

	OrgConfig_ utils.NullMap `db:"org_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) CallbackDomain added in v1.0.21

func (c *DBChannel) CallbackDomain(fallbackDomain string) string

CallbackDomain returns the callback domain to use for 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) Name added in v1.0.9

func (c *DBChannel) Name() string

Name returns the name of this channel

func (*DBChannel) OrgConfigForKey added in v1.0.9

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

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

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 DBChannelEvent added in v0.8.0

type DBChannelEvent struct {
	ID_          ChannelEventID           `                               db:"id"`
	OrgID_       OrgID                    `json:"org_id"                  db:"org_id"`
	ChannelUUID_ courier.ChannelUUID      `json:"channel_uuid"            db:"channel_uuid"`
	ChannelID_   courier.ChannelID        `json:"channel_id"              db:"channel_id"`
	URN_         urns.URN                 `json:"urn"                     db:"urn"`
	EventType_   courier.ChannelEventType `json:"event_type"              db:"event_type"`
	Extra_       *utils.NullMap           `json:"extra"                   db:"extra"`
	OccurredOn_  time.Time                `json:"occurred_on"             db:"occurred_on"`
	CreatedOn_   time.Time                `json:"created_on"              db:"created_on"`

	ContactName_  string       `json:"contact_name"`
	ContactID_    ContactID    `json:"-"               db:"contact_id"`
	ContactURNID_ ContactURNID `json:"-"               db:"contact_urn_id"`
	// contains filtered or unexported fields
}

DBChannelEvent represents an event on a channel

func (*DBChannelEvent) AddLog added in v0.8.0

func (e *DBChannelEvent) AddLog(log *courier.ChannelLog)

func (*DBChannelEvent) ChannelID added in v0.8.0

func (e *DBChannelEvent) ChannelID() courier.ChannelID

func (*DBChannelEvent) ChannelUUID added in v0.8.0

func (e *DBChannelEvent) ChannelUUID() courier.ChannelUUID

func (*DBChannelEvent) ContactName added in v0.8.0

func (e *DBChannelEvent) ContactName() string

func (*DBChannelEvent) CreatedOn added in v0.8.0

func (e *DBChannelEvent) CreatedOn() time.Time

func (*DBChannelEvent) EventType added in v0.8.0

func (e *DBChannelEvent) EventType() courier.ChannelEventType

func (*DBChannelEvent) Logs added in v0.8.0

func (e *DBChannelEvent) Logs() []*courier.ChannelLog

func (*DBChannelEvent) OccurredOn added in v0.8.0

func (e *DBChannelEvent) OccurredOn() time.Time

func (*DBChannelEvent) ReceiveID added in v0.8.0

func (e *DBChannelEvent) ReceiveID() int64

func (*DBChannelEvent) URN added in v0.8.0

func (e *DBChannelEvent) URN() urns.URN

func (*DBChannelEvent) WithContactName added in v0.8.0

func (e *DBChannelEvent) WithContactName(name string) courier.ChannelEvent

func (*DBChannelEvent) WithExtra added in v0.8.0

func (e *DBChannelEvent) WithExtra(extra map[string]interface{}) courier.ChannelEvent

func (*DBChannelEvent) WithOccurredOn added in v0.8.0

func (e *DBChannelEvent) WithOccurredOn(time time.Time) courier.ChannelEvent

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"`
	HighPriority_ null.Bool              `json:"high_priority" db:"high_priority"`
	URN_          urns.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) HighPriority added in v1.0.6

func (m *DBMsg) HighPriority() bool

func (*DBMsg) ID

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

func (*DBMsg) ReceiveID added in v0.8.0

func (m *DBMsg) ReceiveID() int64

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() urns.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