modifiers

package
v0.96.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TypeChannel string = "channel"

TypeChannel is the type of our channel modifier

View Source
const TypeField string = "field"

TypeField is the type of our field modifier

View Source
const TypeGroups string = "groups"

TypeGroups is the type of our groups modifier

View Source
const TypeLanguage string = "language"

TypeLanguage is the type of our language modifier

View Source
const TypeName string = "name"

TypeName is the type of our name modifier

View Source
const TypeStatus string = "status"

TypeStatus is the type of our status modifier

View Source
const TypeTimezone string = "timezone"

TypeTimezone is the type of our timezone modifier

View Source
const TypeURN string = "urn"

TypeURN is the type of our URN modifier

View Source
const TypeURNs string = "urns"

TypeURNs is the type of our URNs modifier

Variables

View Source
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

View Source
var RegisteredTypes = map[string]readFunc{}

RegisteredTypes is the registered modifier types

Functions

func ReadModifier

func ReadModifier(assets flows.SessionAssets, data json.RawMessage, missing assets.MissingCallback) (flows.Modifier, error)

ReadModifier reads a modifier from the given JSON

Types

type ChannelModifier

type ChannelModifier struct {
	// contains filtered or unexported fields
}

ChannelModifier modifies the preferred channel of a contact

func NewChannel added in v0.48.0

func NewChannel(channel *flows.Channel) *ChannelModifier

NewChannel creates a new channel modifier

func (*ChannelModifier) Apply

func (m *ChannelModifier) Apply(env envs.Environment, assets flows.SessionAssets, contact *flows.Contact, log flows.EventCallback)

Apply applies this modification to the given contact

func (*ChannelModifier) MarshalJSON

func (m *ChannelModifier) MarshalJSON() ([]byte, error)

func (*ChannelModifier) Type

func (m *ChannelModifier) Type() string

Type returns the type of this modifier

type FieldModifier

type FieldModifier struct {
	// contains filtered or unexported fields
}

FieldModifier modifies a field value on the contact

func NewField added in v0.48.0

func NewField(field *flows.Field, value string) *FieldModifier

NewField creates a new field modifier

func (*FieldModifier) Apply

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

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

func NewGroups(groups []*flows.Group, modification GroupsModification) *GroupsModifier

NewGroups creates a new groups modifier

func (*GroupsModifier) Apply

func (m *GroupsModifier) Apply(env envs.Environment, assets flows.SessionAssets, contact *flows.Contact, log flows.EventCallback)

Apply applies this modification to the given contact

func (*GroupsModifier) MarshalJSON

func (m *GroupsModifier) MarshalJSON() ([]byte, error)

func (*GroupsModifier) Type

func (m *GroupsModifier) Type() string

Type returns the type of this modifier

type LanguageModifier

type LanguageModifier struct {
	Language envs.Language `json:"language"`
	// contains filtered or unexported fields
}

LanguageModifier modifies the language of a contact

func NewLanguage added in v0.48.0

func NewLanguage(language envs.Language) *LanguageModifier

NewLanguage creates a new language modifier

func (*LanguageModifier) Apply

func (m *LanguageModifier) Apply(env envs.Environment, assets flows.SessionAssets, contact *flows.Contact, log flows.EventCallback)

Apply applies this modification to the given contact

func (*LanguageModifier) Type

func (m *LanguageModifier) Type() string

Type returns the type of this modifier

type NameModifier

type NameModifier struct {
	Name string `json:"name"`
	// contains filtered or unexported fields
}

NameModifier modifies the name of a contact

func NewName added in v0.48.0

func NewName(name string) *NameModifier

NewName creates a new name modifier

func (*NameModifier) Apply

func (m *NameModifier) Apply(env envs.Environment, assets flows.SessionAssets, contact *flows.Contact, log flows.EventCallback)

Apply applies this modification to the given contact

func (*NameModifier) Type

func (m *NameModifier) Type() string

Type returns the type of this modifier

type StatusModifier added in v0.84.0

type StatusModifier struct {
	Status flows.ContactStatus `json:"status" validate:"eq=active|eq=blocked|eq=stopped"`
	// contains filtered or unexported fields
}

StatusModifier modifies the status of a contact

func NewStatus added in v0.84.0

func NewStatus(status flows.ContactStatus) *StatusModifier

NewStatus creates a new status modifier

func (*StatusModifier) Apply added in v0.84.0

func (m *StatusModifier) Apply(env envs.Environment, assets flows.SessionAssets, contact *flows.Contact, log flows.EventCallback)

Apply applies this modification to the given contact

func (*StatusModifier) Type added in v0.84.0

func (m *StatusModifier) Type() string

Type returns the type of this modifier

type TimezoneModifier

type TimezoneModifier struct {
	// contains filtered or unexported fields
}

TimezoneModifier modifies the timezone of a contact

func NewTimezone added in v0.48.0

func NewTimezone(timezone *time.Location) *TimezoneModifier

NewTimezone creates a new timezone modifier

func (*TimezoneModifier) Apply

func (m *TimezoneModifier) Apply(env envs.Environment, assets flows.SessionAssets, contact *flows.Contact, log flows.EventCallback)

Apply applies this modification to the given contact

func (*TimezoneModifier) MarshalJSON

func (m *TimezoneModifier) MarshalJSON() ([]byte, error)

func (*TimezoneModifier) Type

func (m *TimezoneModifier) Type() string

Type returns the type of this modifier

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

func NewURN(urn urns.URN, modification URNModification) *URNModifier

NewURN creates a new name modifier

func (*URNModifier) Apply

func (m *URNModifier) Apply(env envs.Environment, assets flows.SessionAssets, contact *flows.Contact, log flows.EventCallback)

Apply applies this modification to the given contact

func (*URNModifier) Type

func (m *URNModifier) Type() string

Type returns the type of this modifier

type URNsModification added in v0.93.0

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

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

func NewURNs(urnz []urns.URN, modification URNsModification) *URNsModifier

NewURNs creates a new URNs modifier

func (*URNsModifier) Apply added in v0.93.0

func (m *URNsModifier) Apply(env envs.Environment, assets flows.SessionAssets, contact *flows.Contact, log flows.EventCallback)

Apply applies this modification to the given contact

func (*URNsModifier) Type added in v0.93.0

func (m *URNsModifier) Type() string

Type returns the type of this modifier

Jump to

Keyboard shortcuts

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