assets

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: AGPL-3.0 Imports: 6 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupReferenceValidation added in v0.15.1

func GroupReferenceValidation(sl validator.StructLevel)

GroupReferenceValidation validates that the given group reference is either a concrete reference or a name matcher

func LabelReferenceValidation added in v0.15.1

func LabelReferenceValidation(sl validator.StructLevel)

LabelReferenceValidation validates that the given label reference is either a concrete reference or a name matcher

Types

type Channel added in v0.15.0

type Channel interface {
	UUID() ChannelUUID
	Name() string
	Address() string
	Schemes() []string
	Roles() []ChannelRole
	Parent() *ChannelReference
	Country() string
	MatchPrefixes() []string
}

Channel is something that can send/receive messages.

{
  "uuid": "14782905-81a6-4910-bc9f-93ad287b23c3",
  "name": "My Android",
  "address": "+593979011111",
  "schemes": ["tel"],
  "roles": ["send", "receive"],
  "country": "EC"
}

@asset channel

type ChannelReference added in v0.15.1

type ChannelReference struct {
	UUID ChannelUUID `json:"uuid" validate:"required,uuid"`
	Name string      `json:"name"`
}

ChannelReference is used to reference a channel

func NewChannelReference added in v0.15.1

func NewChannelReference(uuid ChannelUUID, name string) *ChannelReference

NewChannelReference creates a new channel reference with the given UUID and name

func (*ChannelReference) GenericUUID added in v0.39.4

func (r *ChannelReference) GenericUUID() uuids.UUID

GenericUUID returns the untyped UUID

func (*ChannelReference) Identity added in v0.26.0

func (r *ChannelReference) Identity() string

Identity returns the unique identity of the asset

func (*ChannelReference) String added in v0.26.0

func (r *ChannelReference) String() string

func (*ChannelReference) Type added in v0.26.0

func (r *ChannelReference) Type() string

Type returns the name of the asset type

func (*ChannelReference) Variable added in v0.29.0

func (r *ChannelReference) Variable() bool

Variable returns whether this a variable (vs concrete) reference

type ChannelRole added in v0.15.0

type ChannelRole string

ChannelRole is a role that a channel can perform

const (
	ChannelRoleSend    ChannelRole = "send"
	ChannelRoleReceive ChannelRole = "receive"
	ChannelRoleCall    ChannelRole = "call"
	ChannelRoleAnswer  ChannelRole = "answer"
	ChannelRoleUSSD    ChannelRole = "ussd"
)

different roles that channels can perform

type ChannelUUID added in v0.15.0

type ChannelUUID uuids.UUID

ChannelUUID is the UUID of a channel

type Field added in v0.15.0

type Field interface {
	UUID() FieldUUID
	Key() string
	Name() string
	Type() FieldType
}

Field is a custom contact property.

{
  "uuid": "d66a7823-eada-40e5-9a3a-57239d4690bf",
  "key": "gender",
  "name": "Gender",
  "type": "text"
}

@asset field

type FieldReference added in v0.15.1

type FieldReference struct {
	Key  string `json:"key" validate:"required"`
	Name string `json:"name"`
}

FieldReference is a reference to field

func NewFieldReference added in v0.15.1

func NewFieldReference(key string, name string) *FieldReference

NewFieldReference creates a new field reference with the given key and label

func (*FieldReference) Identity added in v0.26.0

func (r *FieldReference) Identity() string

Identity returns the unique identity of the asset

func (*FieldReference) String added in v0.26.0

func (r *FieldReference) String() string

func (*FieldReference) Type added in v0.26.0

func (r *FieldReference) Type() string

Type returns the name of the asset type

func (*FieldReference) Variable added in v0.29.0

func (r *FieldReference) Variable() bool

Variable returns whether this a variable (vs concrete) reference

type FieldType added in v0.15.0

type FieldType string

FieldType is the data type of values for each field

const (
	FieldTypeText     FieldType = "text"
	FieldTypeNumber   FieldType = "number"
	FieldTypeDatetime FieldType = "datetime"
	FieldTypeWard     FieldType = "ward"
	FieldTypeDistrict FieldType = "district"
	FieldTypeState    FieldType = "state"
)

field value types

type FieldUUID added in v0.46.0

type FieldUUID uuids.UUID

FieldUUID is the UUID of a field

type Flow added in v0.15.0

type Flow interface {
	UUID() FlowUUID
	Name() string
	Definition() json.RawMessage
}

Flow is graph of nodes with actions and routers.

{
  "uuid": "14782905-81a6-4910-bc9f-93ad287b23c3",
  "name": "Registration",
  "definition": {
    "nodes": []
  }
}

@asset flow

type FlowReference added in v0.15.1

type FlowReference struct {
	UUID FlowUUID `json:"uuid" validate:"required,uuid4"`
	Name string   `json:"name"`
}

FlowReference is used to reference a flow from another flow

func NewFlowReference added in v0.15.1

func NewFlowReference(uuid FlowUUID, name string) *FlowReference

NewFlowReference creates a new flow reference with the given UUID and name

func (*FlowReference) GenericUUID added in v0.39.4

func (r *FlowReference) GenericUUID() uuids.UUID

GenericUUID returns the untyped UUID

func (*FlowReference) Identity added in v0.26.0

func (r *FlowReference) Identity() string

Identity returns the unique identity of the asset

func (*FlowReference) String added in v0.26.0

func (r *FlowReference) String() string

func (*FlowReference) Type added in v0.26.0

func (r *FlowReference) Type() string

Type returns the name of the asset type

func (*FlowReference) Variable added in v0.29.0

func (r *FlowReference) Variable() bool

Variable returns whether this a variable (vs concrete) reference

type FlowUUID added in v0.15.0

type FlowUUID uuids.UUID

FlowUUID is the UUID of a flow

type Group added in v0.15.0

type Group interface {
	UUID() GroupUUID
	Name() string
	Query() string
}

Group is a set of contacts which can be static or dynamic (i.e. based on a query).

{
  "uuid": "14782905-81a6-4910-bc9f-93ad287b23c3",
  "name": "Youth",
  "query": "age <= 18"
}

@asset group

type GroupReference added in v0.15.1

type GroupReference struct {
	UUID      GroupUUID `json:"uuid,omitempty" validate:"omitempty,uuid4"`
	Name      string    `json:"name,omitempty"`
	NameMatch string    `json:"name_match,omitempty" engine:"evaluated"`
}

GroupReference is used to reference a group

func NewGroupReference added in v0.15.1

func NewGroupReference(uuid GroupUUID, name string) *GroupReference

NewGroupReference creates a new group reference with the given UUID and name

func NewVariableGroupReference added in v0.15.1

func NewVariableGroupReference(nameMatch string) *GroupReference

NewVariableGroupReference creates a new group reference from the given templatized name match

func (*GroupReference) GenericUUID added in v0.39.4

func (r *GroupReference) GenericUUID() uuids.UUID

GenericUUID returns the untyped UUID

func (*GroupReference) Identity added in v0.26.0

func (r *GroupReference) Identity() string

Identity returns the unique identity of the asset

func (*GroupReference) String added in v0.26.0

func (r *GroupReference) String() string

func (*GroupReference) Type added in v0.26.0

func (r *GroupReference) Type() string

Type returns the name of the asset type

func (*GroupReference) Variable added in v0.29.0

func (r *GroupReference) Variable() bool

Variable returns whether this a variable (vs concrete) reference

type GroupUUID added in v0.15.0

type GroupUUID uuids.UUID

GroupUUID is the UUID of a group

type Label added in v0.15.0

type Label interface {
	UUID() LabelUUID
	Name() string
}

Label is an organizational tag that can be applied to a message.

{
  "uuid": "14782905-81a6-4910-bc9f-93ad287b23c3",
  "name": "Spam"
}

@asset label

type LabelReference added in v0.15.1

type LabelReference struct {
	UUID      LabelUUID `json:"uuid,omitempty" validate:"omitempty,uuid4"`
	Name      string    `json:"name,omitempty"`
	NameMatch string    `json:"name_match,omitempty" engine:"evaluated"`
}

LabelReference is used to reference a label

func NewLabelReference added in v0.15.1

func NewLabelReference(uuid LabelUUID, name string) *LabelReference

NewLabelReference creates a new label reference with the given UUID and name

func NewVariableLabelReference added in v0.15.1

func NewVariableLabelReference(nameMatch string) *LabelReference

NewVariableLabelReference creates a new label reference from the given templatized name match

func (*LabelReference) GenericUUID added in v0.39.4

func (r *LabelReference) GenericUUID() uuids.UUID

GenericUUID returns the untyped UUID

func (*LabelReference) Identity added in v0.26.0

func (r *LabelReference) Identity() string

Identity returns the unique identity of the asset

func (*LabelReference) String added in v0.26.0

func (r *LabelReference) String() string

func (*LabelReference) Type added in v0.26.0

func (r *LabelReference) Type() string

Type returns the name of the asset type

func (*LabelReference) Variable added in v0.29.0

func (r *LabelReference) Variable() bool

Variable returns whether this a variable (vs concrete) reference

type LabelUUID added in v0.15.0

type LabelUUID uuids.UUID

LabelUUID is the UUID of a label

type LocationHierarchy added in v0.15.0

type LocationHierarchy interface {
	FindByPath(path utils.LocationPath) *utils.Location
	FindByName(name string, level utils.LocationLevel, parent *utils.Location) []*utils.Location
}

LocationHierarchy is a searchable hierachy of locations.

{
  "name": "Rwanda",
  "aliases": ["Ruanda"],
  "children": [
    {
      "name": "Kigali City",
      "aliases": ["Kigali", "Kigari"],
      "children": [
        {
          "name": "Gasabo",
          "children": [
            {
              "id": "575743222",
              "name": "Gisozi"
            },
            {
              "id": "457378732",
              "name": "Ndera"
            }
          ]
        },
        {
          "name": "Nyarugenge",
          "children": []
        }
      ]
    },
    {
      "name": "Eastern Province"
    }
  ]
}

@asset location

type MissingCallback added in v0.26.0

type MissingCallback func(Reference, error)

MissingCallback is callback to be invoked when an asset is missing

var IgnoreMissing MissingCallback = func(Reference, error) {}

IgnoreMissing does nothing if an asset is reported missing

var PanicOnMissing MissingCallback = func(a Reference, err error) { panic(fmt.Sprintf("missing asset: %s, due to: %s", a, err)) }

PanicOnMissing panics if an asset is reported missing

type Reference added in v0.26.0

type Reference interface {
	fmt.Stringer

	Type() string
	Identity() string
	Variable() bool
}

Reference is interface for all reference types

type Resthook added in v0.15.0

type Resthook interface {
	Slug() string
	Subscribers() []string
}

Resthook is a set of URLs which are subscribed to the named event.

{
  "slug": "new-registration",
  "subscribers": [
    "http://example.com/record.php?@contact.uuid"
  ]
}

@asset resthook

type Source added in v0.48.1

type Source interface {
	Channels() ([]Channel, error)
	Fields() ([]Field, error)
	Flow(FlowUUID) (Flow, error)
	Groups() ([]Group, error)
	Labels() ([]Label, error)
	Locations() ([]LocationHierarchy, error)
	Resthooks() ([]Resthook, error)
	Templates() ([]Template, error)
}

Source is a source of assets

type Template added in v0.32.0

type Template interface {
	UUID() TemplateUUID
	Name() string
	Translations() []TemplateTranslation
}

Template is a message template, currently only used by WhatsApp channels

{
  "name": "revive-issue",
  "uuid": "14782905-81a6-4910-bc9f-93ad287b23c3",
  "translations": [
    {
       "language": "eng",
       "content": "Hi {{1}}, are you still experiencing your issue?",
       "channel": {
         "uuid": "cf26be4c-875f-4094-9e08-162c3c9dcb5b",
         "name": "Twilio Channel"
       }
    },
    {
       "language": "fra",
       "content": "Bonjour {{1}}",
       "channel": {
         "uuid": "cf26be4c-875f-4094-9e08-162c3c9dcb5b",
         "name": "Twilio Channel"
       }
    }
  ]
}

@asset template

type TemplateReference added in v0.32.0

type TemplateReference struct {
	UUID TemplateUUID `json:"uuid" validate:"required,uuid"`
	Name string       `json:"name"`
}

TemplateReference is used to reference a Template

func NewTemplateReference added in v0.38.1

func NewTemplateReference(uuid TemplateUUID, name string) *TemplateReference

NewTemplateReference creates a new template reference with the given UUID and name

func (*TemplateReference) GenericUUID added in v0.39.4

func (r *TemplateReference) GenericUUID() uuids.UUID

GenericUUID returns the untyped UUID

func (*TemplateReference) Identity added in v0.32.0

func (r *TemplateReference) Identity() string

Identity returns the unique identity of the asset

func (*TemplateReference) String added in v0.32.0

func (r *TemplateReference) String() string

func (*TemplateReference) Type added in v0.32.0

func (r *TemplateReference) Type() string

Type returns the name of the asset type

func (*TemplateReference) Variable added in v0.32.0

func (r *TemplateReference) Variable() bool

Variable returns whether this a variable (vs concrete) reference

type TemplateTranslation added in v0.32.0

type TemplateTranslation interface {
	Content() string
	Language() envs.Language
	VariableCount() int
	Channel() ChannelReference
}

TemplateTranslation represents a single translation for a specific template and channel

type TemplateUUID added in v0.32.0

type TemplateUUID uuids.UUID

type UUIDReference added in v0.39.4

type UUIDReference interface {
	Reference
	GenericUUID() uuids.UUID
}

UUIDReference is interface for all reference types that contain a UUID

Directories

Path Synopsis
Package static is an implementation of Source which loads assets from a static JSON file.
Package static is an implementation of Source which loads assets from a static JSON file.

Jump to

Keyboard shortcuts

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