rapidpro

package
v1.2.160 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 40 Imported by: 2

Documentation

Index

Constants

View Source
const NilChannelEventID = ChannelEventID(0)
View Source
const NilContactURNID = ContactURNID(0)

NilContactURNID is our constant for a nil contact URN id

Variables

View Source
var NilContactID = ContactID(0)

NilContactID represents our nil value for ContactID

View Source
var NilOrgID = OrgID(0)

NilOrgID is our nil value for OrgID

Functions

This section is empty.

Types

type ChannelEventID added in v0.8.0

type ChannelEventID null.Int

ChannelEventID is the type of our channel event ids

func (ChannelEventID) MarshalJSON added in v1.2.151

func (i ChannelEventID) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON. 0 values will become null

func (*ChannelEventID) Scan added in v1.2.151

func (i *ChannelEventID) Scan(value interface{}) error

Scan scans from the db value. null values become 0

func (ChannelEventID) String added in v0.8.0

func (i ChannelEventID) String() string

String satisfies the Stringer interface

func (*ChannelEventID) UnmarshalJSON added in v1.2.151

func (i *ChannelEventID) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals from JSON. null values become 0

func (ChannelEventID) Value added in v1.2.151

func (i ChannelEventID) Value() (driver.Value, error)

Value returns the db value, null is returned for 0

type ChannelLog added in v1.2.151

type ChannelLog struct {
	ChannelID      courier.ChannelID `db:"channel_id"`
	MsgID          courier.MsgID     `db:"msg_id"`
	Description    string            `db:"description"`
	IsError        bool              `db:"is_error"`
	Method         string            `db:"method"`
	URL            string            `db:"url"`
	Request        string            `db:"request"`
	Response       string            `db:"response"`
	ResponseStatus int               `db:"response_status"`
	CreatedOn      time.Time         `db:"created_on"`
	RequestTime    int               `db:"request_time"`
}

ChannelLog is our DB specific struct for logs

func (*ChannelLog) RowID added in v1.2.151

func (l *ChannelLog) RowID() string

RowID satisfies our batch.Value interface, we are always inserting logs so we have no row id

type ContactID

type ContactID null.Int

ContactID is our representation of our database contact id

func (ContactID) MarshalJSON added in v1.2.151

func (i ContactID) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON. 0 values will become null

func (*ContactID) Scan added in v1.2.151

func (i *ContactID) Scan(value interface{}) error

Scan scans from the db value. null values become 0

func (ContactID) String added in v1.0.9

func (i ContactID) String() string

String returns a string representation of the id

func (*ContactID) UnmarshalJSON added in v1.2.151

func (i *ContactID) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals from JSON. null values become 0

func (ContactID) Value added in v1.2.151

func (i ContactID) Value() (driver.Value, error)

Value returns the db value, null is returned for 0

type ContactURNID

type ContactURNID null.Int

ContactURNID represents a contact urn's id

func (ContactURNID) MarshalJSON added in v1.2.151

func (i ContactURNID) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON. 0 values will become null

func (*ContactURNID) Scan added in v1.2.151

func (i *ContactURNID) Scan(value interface{}) error

Scan scans from the db value. null values become 0

func (*ContactURNID) UnmarshalJSON added in v1.2.151

func (i *ContactURNID) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals from JSON. null values become 0

func (ContactURNID) Value added in v1.2.151

func (i ContactURNID) Value() (driver.Value, error)

Value returns the db value, null is returned for 0

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"`
	OrgIsAnon_            bool          `db:"org_is_anon"`
	OrgFlowServerEnabled_ bool          `db:"org_flow_server_enabled"`
	// 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) BoolConfigForKey added in v1.2.159

func (c *DBChannel) BoolConfigForKey(key string, defaultValue bool) bool

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

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) IntConfigForKey added in v1.2.98

func (c *DBChannel) IntConfigForKey(key string, defaultValue int) int

IntConfigForKey returns the config value for the passed in key

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) OrgFlowServerEnabled added in v1.2.107

func (c *DBChannel) OrgFlowServerEnabled() bool

OrgFlowServerEnabled returns whether the org for this channel is using the flow server

func (*DBChannel) OrgID

func (c *DBChannel) OrgID() OrgID

OrgID returns the id of the org this channel is for

func (*DBChannel) OrgIsAnon added in v1.1.3

func (c *DBChannel) OrgIsAnon() bool

OrgIsAnon returns the org for this channel is anonymous

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) Channel added in v1.2.107

func (e *DBChannelEvent) Channel() *DBChannel

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) EventID added in v1.0.28

func (e *DBChannelEvent) EventID() int64

func (*DBChannelEvent) EventType added in v0.8.0

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

func (*DBChannelEvent) Extra added in v1.1.3

func (e *DBChannelEvent) Extra() map[string]interface{}

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) 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_  courier.ContactUUID `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

func (*DBContact) UUID

func (c *DBContact) UUID() courier.ContactUUID

UUID returns the UUID for this contact

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"`
	Auth          null.String       `db:"auth"`
	Priority      int               `db:"priority"`
	ChannelID     courier.ChannelID `db:"channel_id"`
	ContactID     ContactID         `db:"contact_id"`
	PrevContactID ContactID
}

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"            db:"uuid"`
	Direction_            MsgDirection           `json:"direction"       db:"direction"`
	Status_               courier.MsgStatusValue `json:"status"          db:"status"`
	Visibility_           MsgVisibility          `json:"visibility"      db:"visibility"`
	HighPriority_         bool                   `json:"high_priority"   db:"high_priority"`
	URN_                  urns.URN               `json:"urn"`
	URNAuth_              string                 `json:"urn_auth"`
	Text_                 string                 `json:"text"            db:"text"`
	Attachments_          pq.StringArray         `json:"attachments"     db:"attachments"`
	ExternalID_           null.String            `json:"external_id"     db:"external_id"`
	ResponseToID_         courier.MsgID          `json:"response_to_id"  db:"response_to_id"`
	ResponseToExternalID_ string                 `json:"response_to_external_id"`
	Metadata_             json.RawMessage        `json:"metadata"        db:"metadata"`

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

	// fields used only for mailroom enabled orgs.. these allow courier to update a session's timeout when
	// a message is sent for correct and efficient timeout behavior
	SessionID_            SessionID  `json:"session_id,omitempty"`
	SessionTimeout_       int        `json:"session_timeout,omitempty"`
	SessionWaitStartedOn_ *time.Time `json:"session_wait_started_on,omitempty"`
	// contains filtered or unexported fields
}

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) EventID added in v1.0.28

func (m *DBMsg) EventID() int64

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) Metadata added in v1.2.149

func (m *DBMsg) Metadata() json.RawMessage

Metadata returns the metadata for this message

func (*DBMsg) QuickReplies added in v1.0.28

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

func (*DBMsg) ReceivedOn added in v0.2.0

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

func (*DBMsg) ResponseToExternalID added in v1.2.98

func (m *DBMsg) ResponseToExternalID() string

func (*DBMsg) ResponseToID added in v1.1.6

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

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) URNAuth added in v1.2.45

func (m *DBMsg) URNAuth() string

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) WithMetadata added in v1.2.149

func (m *DBMsg) WithMetadata(metadata json.RawMessage) courier.Msg

WithMetadata can be used to add metadata to a Msg

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) WithURNAuth added in v1.2.45

func (m *DBMsg) WithURNAuth(auth string) courier.Msg

WithURNAuth can be used to add a URN auth setting to a message

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"`
	ChannelID_   courier.ChannelID      `json:"channel_id"               db:"channel_id"`
	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) EventID added in v1.0.28

func (s *DBMsgStatus) EventID() int64

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) RowID added in v1.2.151

func (s *DBMsgStatus) RowID() string

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 null.Int

OrgID is our type for database Org ids

func (OrgID) MarshalJSON added in v1.2.151

func (i OrgID) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON. 0 values will become null

func (*OrgID) Scan added in v1.2.151

func (i *OrgID) Scan(value interface{}) error

Scan scans from the db value. null values become 0

func (*OrgID) UnmarshalJSON added in v1.2.151

func (i *OrgID) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals from JSON. null values become 0

func (OrgID) Value added in v1.2.151

func (i OrgID) Value() (driver.Value, error)

Value returns the db value, null is returned for 0

type SessionID added in v1.2.123

type SessionID int64

SessionID is our type for RapidPro session ids

Jump to

Keyboard shortcuts

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