Documentation ¶
Index ¶
- Constants
- Variables
- func Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, ...) bool
- func ReadModifier(assets flows.SessionAssets, data json.RawMessage, ...) (flows.Modifier, error)
- func ReevaluateGroups(env envs.Environment, contact *flows.Contact, log flows.EventCallback)
- type ChannelModifier
- type FieldModifier
- type GroupsModification
- type GroupsModifier
- type LanguageModifier
- type NameModifier
- type StatusModifier
- type TicketModifier
- type TimezoneModifier
- type URNModification
- type URNModifier
- type URNsModification
- type URNsModifier
Constants ¶
const TypeChannel string = "channel"
TypeChannel is the type of our channel modifier
const TypeField string = "field"
TypeField is the type of our field modifier
const TypeGroups string = "groups"
TypeGroups is the type of our groups modifier
const TypeLanguage string = "language"
TypeLanguage is the type of our language modifier
const TypeName string = "name"
TypeName is the type of our name modifier
const TypeStatus string = "status"
TypeStatus is the type of our status modifier
const TypeTicket string = "ticket"
TypeTicket is the type of our ticket modifier
const TypeTimezone string = "timezone"
TypeTimezone is the type of our timezone modifier
const TypeURN string = "urn"
TypeURN is the type of our URN modifier
const TypeURNs string = "urns"
TypeURNs is the type of our URNs modifier
Variables ¶
var ErrNoModifier = errors.New("no modifier to return because of missing assets")
ErrNoModifier is the error instance returned when a modifier is read but due to missing assets can't be returned
var RegisteredTypes = map[string]readFunc{}
RegisteredTypes is the registered modifier types
Functions ¶
func Apply ¶ added in v0.164.3
func Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, c *flows.Contact, mod flows.Modifier, logEvent flows.EventCallback) bool
Apply applies the given modifier to the given contact and re-evaluates query based groups if necessary
func ReadModifier ¶
func ReadModifier(assets flows.SessionAssets, data json.RawMessage, missing assets.MissingCallback) (flows.Modifier, error)
ReadModifier reads a modifier from the given JSON
func ReevaluateGroups ¶ added in v0.134.1
func ReevaluateGroups(env envs.Environment, contact *flows.Contact, log flows.EventCallback)
ReevaluateGroups is a helper to re-evaluate groups and log any changes to membership
Types ¶
type ChannelModifier ¶
type ChannelModifier struct {
// contains filtered or unexported fields
}
ChannelModifier modifies the preferred channel of a contact
func NewChannel ¶
func NewChannel(channel *flows.Channel) *ChannelModifier
NewChannel creates a new channel modifier
func (*ChannelModifier) Apply ¶
func (m *ChannelModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
func (*ChannelModifier) MarshalJSON ¶
func (m *ChannelModifier) MarshalJSON() ([]byte, error)
type FieldModifier ¶
type FieldModifier struct {
// contains filtered or unexported fields
}
FieldModifier modifies a field value on the contact
func NewField ¶
func NewField(field *flows.Field, value string) *FieldModifier
NewField creates a new field modifier
func (*FieldModifier) Apply ¶
func (m *FieldModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
func (*FieldModifier) MarshalJSON ¶
func (m *FieldModifier) MarshalJSON() ([]byte, error)
func (*FieldModifier) Type ¶
func (m *FieldModifier) Type() string
Type returns the type of this modifier
func (*FieldModifier) Value ¶
func (m *FieldModifier) Value() string
type GroupsModification ¶
type GroupsModification string
GroupsModification is the type of modification to make
const ( GroupsAdd GroupsModification = "add" GroupsRemove GroupsModification = "remove" )
the supported types of modification
type GroupsModifier ¶
type GroupsModifier struct {
// contains filtered or unexported fields
}
GroupsModifier modifies the group membership of the contact
func NewGroups ¶
func NewGroups(groups []*flows.Group, modification GroupsModification) *GroupsModifier
NewGroups creates a new groups modifier
func (*GroupsModifier) Apply ¶
func (m *GroupsModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
func (*GroupsModifier) MarshalJSON ¶
func (m *GroupsModifier) MarshalJSON() ([]byte, error)
type LanguageModifier ¶
type LanguageModifier struct { Language envs.Language `json:"language"` // contains filtered or unexported fields }
LanguageModifier modifies the language of a contact
func NewLanguage ¶
func NewLanguage(language envs.Language) *LanguageModifier
NewLanguage creates a new language modifier
func (*LanguageModifier) Apply ¶
func (m *LanguageModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
type NameModifier ¶
type NameModifier struct { Name string `json:"name"` // contains filtered or unexported fields }
NameModifier modifies the name of a contact
func (*NameModifier) Apply ¶
func (m *NameModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
type StatusModifier ¶
type StatusModifier struct { Status flows.ContactStatus `json:"status" validate:"contact_status"` // contains filtered or unexported fields }
StatusModifier modifies the status of a contact
func NewStatus ¶
func NewStatus(status flows.ContactStatus) *StatusModifier
NewStatus creates a new status modifier
func (*StatusModifier) Apply ¶
func (m *StatusModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
type TicketModifier ¶ added in v0.165.0
type TicketModifier struct {
// contains filtered or unexported fields
}
TicketModifier opens a ticket for the contact
func NewTicket ¶ added in v0.165.0
func NewTicket(ticketer *flows.Ticketer, topic *flows.Topic, body string, assignee *flows.User) *TicketModifier
NewTicket creates a new ticket modifier
func (*TicketModifier) Apply ¶ added in v0.165.0
func (m *TicketModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
func (*TicketModifier) MarshalJSON ¶ added in v0.165.0
func (m *TicketModifier) MarshalJSON() ([]byte, error)
func (*TicketModifier) Ticketer ¶ added in v0.165.0
func (m *TicketModifier) Ticketer() *flows.Ticketer
type TimezoneModifier ¶
type TimezoneModifier struct {
// contains filtered or unexported fields
}
TimezoneModifier modifies the timezone of a contact
func NewTimezone ¶
func NewTimezone(timezone *time.Location) *TimezoneModifier
NewTimezone creates a new timezone modifier
func (*TimezoneModifier) Apply ¶
func (m *TimezoneModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
func (*TimezoneModifier) MarshalJSON ¶
func (m *TimezoneModifier) MarshalJSON() ([]byte, error)
type URNModification ¶
type URNModification string
URNModification is the type of modification to make
const ( URNAppend URNModification = "append" URNRemove URNModification = "remove" )
the supported types of modification
type URNModifier ¶
type URNModifier struct { URN urns.URN `json:"urn" validate:"required"` Modification URNModification `json:"modification" validate:"required,eq=append|eq=remove"` // contains filtered or unexported fields }
URNModifier modifies a URN on a contact. This has been replaced by URNsModifier but is kept here for now to support processing of old Surveyor submissions.
func NewURN ¶
func NewURN(urn urns.URN, modification URNModification) *URNModifier
NewURN creates a new name modifier
func (*URNModifier) Apply ¶
func (m *URNModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact
type URNsModification ¶
type URNsModification string
URNsModification is the type of modification to make
const ( URNsAppend URNsModification = "append" URNsRemove URNsModification = "remove" URNsSet URNsModification = "set" )
the supported types of modification
type URNsModifier ¶
type URNsModifier struct { URNs []urns.URN `json:"urns" validate:"required"` Modification URNsModification `json:"modification" validate:"required,eq=append|eq=remove|eq=set"` // contains filtered or unexported fields }
URNsModifier modifies the URNs on a contact
func NewURNs ¶
func NewURNs(urnz []urns.URN, modification URNsModification) *URNsModifier
NewURNs creates a new URNs modifier
func (*URNsModifier) Apply ¶
func (m *URNsModifier) Apply(eng flows.Engine, env envs.Environment, sa flows.SessionAssets, contact *flows.Contact, log flows.EventCallback) bool
Apply applies this modification to the given contact