rapidpro

package
v0.0.0-...-3b4f3c3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: AGPL-3.0 Imports: 39 Imported by: 0

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

type ChannelEventID null.Int

ChannelEventID is the type of our channel event ids

func (ChannelEventID) MarshalJSON

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

MarshalJSON marshals into JSON. 0 values will become null

func (*ChannelEventID) Scan

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

Scan scans from the db value. null values become 0

func (ChannelEventID) String

func (i ChannelEventID) String() string

String satisfies the Stringer interface

func (*ChannelEventID) UnmarshalJSON

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

UnmarshalJSON unmarshals from JSON. null values become 0

func (ChannelEventID) Value

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

Value returns the db value, null is returned for 0

type ChannelLog

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

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

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

MarshalJSON marshals into JSON. 0 values will become null

func (*ContactID) Scan

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

Scan scans from the db value. null values become 0

func (ContactID) String

func (i ContactID) String() string

String returns a string representation of the id

func (*ContactID) UnmarshalJSON

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

UnmarshalJSON unmarshals from JSON. null values become 0

func (ContactID) Value

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

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

MarshalJSON marshals into JSON. 0 values will become null

func (*ContactURNID) Scan

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

Scan scans from the db value. null values become 0

func (*ContactURNID) UnmarshalJSON

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

UnmarshalJSON unmarshals from JSON. null values become 0

func (ContactURNID) Value

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

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

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

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

IntConfigForKey returns the config value for the passed in key

func (*DBChannel) IsScheme

func (c *DBChannel) IsScheme(scheme string) bool

IsScheme returns whether this channel serves only the passed in scheme

func (*DBChannel) Name

func (c *DBChannel) Name() string

Name returns the name of this channel

func (*DBChannel) OrgConfigForKey

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) OrgIsAnon

func (c *DBChannel) OrgIsAnon() bool

OrgIsAnon returns the org for this channel is anonymous

func (*DBChannel) Schemes

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

Schemes returns the schemes this channels supports

func (*DBChannel) StringConfigForKey

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

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

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

func (*DBChannelEvent) Channel

func (e *DBChannelEvent) Channel() *DBChannel

func (*DBChannelEvent) ChannelID

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

func (*DBChannelEvent) ChannelUUID

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

func (*DBChannelEvent) ContactName

func (e *DBChannelEvent) ContactName() string

func (*DBChannelEvent) CreatedOn

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

func (*DBChannelEvent) EventID

func (e *DBChannelEvent) EventID() int64

func (*DBChannelEvent) EventType

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

func (*DBChannelEvent) Extra

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

func (*DBChannelEvent) Logs

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

func (*DBChannelEvent) OccurredOn

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

func (*DBChannelEvent) URN

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

func (*DBChannelEvent) WithContactName

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

func (*DBChannelEvent) WithExtra

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

func (*DBChannelEvent) WithOccurredOn

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

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

func (*DBMsg) ContactName

func (m *DBMsg) ContactName() string

func (*DBMsg) EventID

func (m *DBMsg) EventID() int64

func (*DBMsg) ExternalID

func (m *DBMsg) ExternalID() string

func (*DBMsg) HighPriority

func (m *DBMsg) HighPriority() bool

func (*DBMsg) ID

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

func (*DBMsg) Metadata

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

Metadata returns the metadata for this message

func (*DBMsg) QuickReplies

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

func (*DBMsg) ReceivedOn

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

func (*DBMsg) ResponseToExternalID

func (m *DBMsg) ResponseToExternalID() string

func (*DBMsg) ResponseToID

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

func (m *DBMsg) URNAuth() string

func (*DBMsg) UUID

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

func (*DBMsg) WithAttachment

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

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

func (*DBMsg) WithContactName

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

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

func (*DBMsg) WithExternalID

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

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

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

WithMetadata can be used to add metadata to a Msg

func (*DBMsg) WithReceivedOn

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

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

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

func (*DBMsg) WithUUID

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

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

func (*DBMsgStatus) ChannelUUID

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

func (*DBMsgStatus) EventID

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

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

func (*DBMsgStatus) RowID

func (s *DBMsgStatus) RowID() string

func (*DBMsgStatus) SetExternalID

func (s *DBMsgStatus) SetExternalID(id string)

func (*DBMsgStatus) SetStatus

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

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

MarshalJSON marshals into JSON. 0 values will become null

func (*OrgID) Scan

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

Scan scans from the db value. null values become 0

func (*OrgID) UnmarshalJSON

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

UnmarshalJSON unmarshals from JSON. null values become 0

func (OrgID) Value

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

Value returns the db value, null is returned for 0

type SessionID

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