Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateGroup(sl validator.StructLevel)
- type Action
- type ActionUUID
- type Channel
- func (c *Channel) Default() interface{}
- func (c *Channel) MarshalJSON() ([]byte, error)
- func (c *Channel) Name() string
- func (c *Channel) Resolve(key string) interface{}
- func (c *Channel) String() string
- func (c *Channel) Type() ChannelType
- func (c *Channel) UUID() ChannelUUID
- func (c *Channel) UnmarshalJSON(data []byte) error
- type ChannelType
- type ChannelUUID
- type Contact
- func (c *Contact) AddGroup(uuid GroupUUID, name string)
- func (c *Contact) Default() interface{}
- func (c *Contact) Fields() *Fields
- func (c *Contact) Groups() GroupList
- func (c *Contact) Language() utils.Language
- func (c *Contact) MarshalJSON() ([]byte, error)
- func (c *Contact) Name() string
- func (c *Contact) RemoveGroup(uuid GroupUUID) bool
- func (c *Contact) Resolve(key string) interface{}
- func (c *Contact) SetLanguage(lang utils.Language)
- func (c *Contact) SetName(name string)
- func (c *Contact) SetTimezone(tz *time.Location)
- func (c *Contact) String() string
- func (c *Contact) Timezone() *time.Location
- func (c *Contact) URNs() URNList
- func (c *Contact) UUID() ContactUUID
- func (c *Contact) UnmarshalJSON(data []byte) error
- type ContactReference
- type ContactUUID
- type Context
- type Event
- type Exit
- type ExitUUID
- type Field
- type FieldUUID
- type Fields
- type Flow
- type FlowEnvironment
- type FlowRun
- type FlowRunReference
- type FlowTranslations
- type FlowUUID
- type Group
- type GroupList
- type GroupUUID
- type Input
- type Label
- type LabelUUID
- type MsgDirection
- type Node
- type NodeUUID
- type Result
- type Results
- func (r *Results) Default() interface{}
- func (r *Results) MarshalJSON() ([]byte, error)
- func (r *Results) Resolve(key string) interface{}
- func (r *Results) Save(node NodeUUID, name string, value string, category string, ...)
- func (r *Results) String() string
- func (r *Results) UnmarshalJSON(data []byte) error
- type Route
- type Router
- type RunStatus
- type RunUUID
- type Session
- type Step
- type StepUUID
- type Translations
- type URN
- type URNList
- type URNPath
- type URNScheme
- type UUID
- type Wait
Constants ¶
const ( TelScheme = "tel" FacebookScheme = "facebook" TwitterScheme = "twitter" ViberScheme = "viber" TelegramScheme = "telegram" EmailScheme = "email" )
List of schemes we support for URNs
Variables ¶
var NoRoute = Route{}
Functions ¶
func ValidateGroup ¶
func ValidateGroup(sl validator.StructLevel)
ValidateGroup is our global validator for our group struct
Types ¶
type ActionUUID ¶
type ActionUUID UUID
func (ActionUUID) String ¶
func (u ActionUUID) String() string
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel represents a channel in the system. Channels have a UUID, name, type and configuration
func ReadChannel ¶
func ReadChannel(data json.RawMessage) (*Channel, error)
ReadChannel decodes a channel from the passed in JSON
func (*Channel) Default ¶
func (c *Channel) Default() interface{}
Default returns the default value for a channel, which is itself
func (*Channel) MarshalJSON ¶
MarshalJSON is our custom marshalling of a channel
func (*Channel) UnmarshalJSON ¶
UnmarshalJSON is our custom unmarshalling of a channel
type ChannelType ¶
type ChannelType string
ChannelType represents the type of a Channel
func (ChannelType) String ¶
func (ct ChannelType) String() string
type ChannelUUID ¶
type ChannelUUID UUID
func (ChannelUUID) String ¶
func (u ChannelUUID) String() string
type Contact ¶
type Contact struct {
// contains filtered or unexported fields
}
Contact represents a single contact
func ReadContact ¶
func ReadContact(data json.RawMessage) (*Contact, error)
ReadContact decodes a contact from the passed in JSON
func (*Contact) Default ¶
func (c *Contact) Default() interface{}
Default returns our default value in the context
func (*Contact) MarshalJSON ¶
func (*Contact) RemoveGroup ¶
func (*Contact) SetLanguage ¶
func (*Contact) SetTimezone ¶
func (*Contact) UUID ¶
func (c *Contact) UUID() ContactUUID
func (*Contact) UnmarshalJSON ¶
type ContactReference ¶
type ContactReference struct { UUID ContactUUID `json:"uuid" validate:"required,uuid4"` Name string `json:"name"` }
type ContactUUID ¶
type ContactUUID UUID
func (ContactUUID) String ¶
func (u ContactUUID) String() string
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field represents a contact field and value for a contact
func (*Field) Default ¶
func (f *Field) Default() interface{}
Default returns the default value for a Field, which is the field itself
func (*Field) MarshalJSON ¶
MarshalJSON is our custom unmarshalling for Field
func (*Field) UnmarshalJSON ¶
UnmarshalJSON is our custom unmarshalling for Field
type Fields ¶
type Fields struct {
// contains filtered or unexported fields
}
Fields represents a set of fields keyed by snakified field names
func (*Fields) Default ¶
func (f *Fields) Default() interface{}
Default returns the default value for Fields, which is ourselves
func (*Fields) MarshalJSON ¶
MarshalJSON is our custom marshalling of a Fields object, we build a map with the full names and then marshal that with snakified keys
func (*Fields) String ¶
String returns the string representation of these Fields, which is our JSON representation
func (*Fields) UnmarshalJSON ¶
UnmarshalJSON is our custom unmarshalling of a Fields object, we validate our keys against snaked names
type FlowEnvironment ¶
type FlowRun ¶
type FlowRun interface { UUID() RunUUID FlowUUID() FlowUUID Flow() Flow Hydrate(FlowEnvironment) error ContactUUID() ContactUUID Contact() *Contact ChannelUUID() ChannelUUID Channel() *Channel SetChannel(*Channel) Context() Context Results() *Results Environment() FlowEnvironment SetExtra(json.RawMessage) Extra() utils.JSONFragment Session() Session SetSession(Session) ResetSession() Status() RunStatus Exit(RunStatus) IsComplete() bool Wait() Wait SetWait(Wait) Input() Input SetInput(Input) AddEvent(Step, Event) AddError(Step, error) CreateStep(Node) Step Path() []Step SetLanguage(utils.Language) SetFlowTranslations(FlowTranslations) GetText(uuid UUID, key string, backdown string) string GetTranslations(uuid UUID, key string, backdown []string) []string Webhook() *utils.RequestResponse SetWebhook(*utils.RequestResponse) Child() FlowRunReference Parent() FlowRunReference CreatedOn() time.Time ModifiedOn() time.Time ExpiresOn() *time.Time TimesOutOn() *time.Time ExitedOn() *time.Time }
FlowRun represents a single run on a flow by a single contact
type FlowRunReference ¶
type FlowRunReference interface { UUID() RunUUID FlowUUID() FlowUUID ContactUUID() ContactUUID ChannelUUID() ChannelUUID Results() *Results Status() RunStatus CreatedOn() time.Time ModifiedOn() time.Time ExpiresOn() *time.Time TimesOutOn() *time.Time ExitedOn() *time.Time }
FlowRunReference represents a flow run reference within a flow
type FlowTranslations ¶
type FlowTranslations interface {
GetTranslations(utils.Language) Translations
}
FlowTranslations provide a way to get the Translations for a flow for a specific language
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a grouping of contacts. From an engine perspective the only piece that matter is the UUID of the group and its name
func (*Group) Default ¶
func (g *Group) Default() interface{}
Default returns the default value for this group
func (*Group) MarshalJSON ¶
MarshalJSON marshals the Group into json
func (*Group) UnmarshalJSON ¶
UnmarshalJSON unmarshals the group from the passed in json
type GroupList ¶
type GroupList []*Group
GroupList defines a list of groups
func (GroupList) Default ¶
func (l GroupList) Default() interface{}
Default returns the default value for this group, which is our entire list
func (GroupList) FindGroup ¶
FindGroup returns the group with the passed in UUID or nil if not found
type Input ¶
type Input interface { Event utils.VariableResolver }
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label represents a msg label
func (*Label) MarshalJSON ¶
func (*Label) UnmarshalJSON ¶
type MsgDirection ¶
type MsgDirection string
MsgDirection is the direction of a Msg (either in or out)
const ( // MsgOut represents an outgoing message MsgOut MsgDirection = "O" // MsgIn represents an incoming message MsgIn MsgDirection = "I" )
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result represents a result value in our flow run. Results have a name for which they are the result for, the value itself of the result, optional category and the date and node the result was collected on
func (*Result) Default ¶
func (r *Result) Default() interface{}
Default returns the default value for a result, which is our value
func (*Result) MarshalJSON ¶
MarshalJSON is our custom marshalling of a Result object
func (*Result) Resolve ¶
Resolve resolves the passed in key to a value. Result values have a name, value, category, node and created_on
func (*Result) UnmarshalJSON ¶
UnmarshalJSON is our custom unmarshalling of a Result object
type Results ¶
type Results struct {
// contains filtered or unexported fields
}
Results is our wrapper around a map of snakified result names to result objects
func (*Results) Default ¶
func (r *Results) Default() interface{}
Default returns the default value for our Results, which is the entire map
func (*Results) MarshalJSON ¶
MarshalJSON is our custom marshalling of a Results object, we build a map with the full names and then marshal that with snakified keys
func (*Results) Save ¶
func (r *Results) Save(node NodeUUID, name string, value string, category string, categoryLocalized string, createdOn time.Time)
Save saves a new result in our map. The key is saved in a snakified format
func (*Results) String ¶
String returns the string representation of our Results, which is a key/value pairing of our fields
func (*Results) UnmarshalJSON ¶
UnmarshalJSON is our custom unmarshalling of a Results object, we build our map only with with snakified keys
type RunStatus ¶
type RunStatus string
RunStatus represents the current status of the flow run
const ( // StatusActive represents an active flow run that is awaiting input StatusActive RunStatus = "A" // StatusCompleted represents a flow run that has run to completion StatusCompleted RunStatus = "C" // StatusErrored represents a flow run that encountered an error StatusErrored RunStatus = "E" // StatusExpired represents a flow run that expired due to inactivity StatusExpired RunStatus = "X" // StatusInterrupted represents a flow run that was interrupted by another flow StatusInterrupted RunStatus = "I" )
type Session ¶
type Session interface { Runs() []FlowRun AddRun(FlowRun) ActiveRun() FlowRun Events() []Event AddEvent(Event) ClearEvents() }
Session represents the session of a flow run which may contain many runs
type Translations ¶
type Translations interface { GetText(uuid UUID, key string, backdown string) string GetTranslations(uuid UUID, key string, backdown []string) []string }
Translations provide a way to get the translation for a specific language for a uuid/key pair