nfydest

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownType = validation.NewGenericError("unknown destination type")
	ErrUnsupported = errors.New("unsupported operation")
	ErrNotEnabled  = validation.NewGenericError("destination type is not enabled")
)

Functions

This section is empty.

Types

type ActionParamError

type ActionParamError struct {
	ParamID string
	Err     error
}

func (*ActionParamError) ClientError

func (e *ActionParamError) ClientError() bool

func (*ActionParamError) Error

func (e *ActionParamError) Error() string

type ActionValidator

type ActionValidator interface {
	ValidateAction(ctx context.Context, act gadb.UIKActionV1) error
}

type Cursorable

type Cursorable interface {
	Cursor() (string, error)
	Fieldable
}

type DestArgError

type DestArgError struct {
	FieldID string
	Err     error
}

DestArgError is returned when a destination argument is invalid.

func (*DestArgError) ClientError

func (e *DestArgError) ClientError() bool

func (*DestArgError) Error

func (e *DestArgError) Error() string

type DestValidator

type DestValidator interface {
	ValidateDest(ctx context.Context, dest gadb.DestV1) error
}

type DisplayInfo

type DisplayInfo struct {
	Text        string
	IconURL     string
	IconAltText string
	LinkURL     string
}

func (DisplayInfo) IsInlineDisplayInfo

func (DisplayInfo) IsInlineDisplayInfo()

type DynamicParamConfig

type DynamicParamConfig struct {
	ParamID      string
	Label        string
	Hint         string
	HintURL      string
	DefaultValue string
}

type FieldConfig

type FieldConfig struct {
	FieldID            string
	Label              string
	Hint               string
	HintURL            string
	PlaceholderText    string
	Prefix             string
	InputType          string
	SupportsSearch     bool
	SupportsValidation bool
}

type FieldSearcher

type FieldSearcher interface {
	SearchField(ctx context.Context, fieldID string, options SearchOptions) (*SearchResult, error)
	FieldLabel(ctx context.Context, fieldID, value string) (string, error)
}

type FieldValue

type FieldValue struct {
	Value      string
	Label      string
	IsFavorite bool
}

type Fieldable

type Fieldable interface {
	AsField() FieldValue
}

type MessageSender

type MessageSender interface {
	// Send should return nil error if the notification was sent successfully. It should be expected
	// that a returned error means that the notification should be attempted again.
	//
	// If the sent message can have its status tracked, a unique externalID should be returned.
	SendMessage(context.Context, nfymsg.Message) (*nfymsg.SentMessage, error)
}

A MessageSender can send notifications.

type MessageStatuser

type MessageStatuser interface {
	MessageStatus(ctx context.Context, externalID string) (*nfymsg.Status, error)
}

A MessageStatuser is an optional interface a Sender can implement that allows checking the status of a previously sent message by it's externalID.

type OptionFrommer

type OptionFrommer interface {
	FromNotifyOptions(context.Context, SearchOptions) error
}

type ParamValidator

type ParamValidator interface {
	ValidateParam(ctx context.Context, paramID, value string) error
}

type Provider

type Provider interface {
	ID() string
	TypeInfo(ctx context.Context) (*TypeInfo, error)

	ValidateField(ctx context.Context, fieldID, value string) error
	DisplayInfo(ctx context.Context, args map[string]string) (*DisplayInfo, error)
}

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) DisplayInfo

func (r *Registry) DisplayInfo(ctx context.Context, d gadb.DestV1) (*DisplayInfo, error)

func (*Registry) FieldLabel

func (r *Registry) FieldLabel(ctx context.Context, typeID, fieldID, value string) (string, error)

func (*Registry) IsDynamicAction

func (r *Registry) IsDynamicAction(ctx context.Context, typeID string) (bool, error)

func (*Registry) LookupTypeName

func (r *Registry) LookupTypeName(ctx context.Context, typeID string) (string, error)

func (*Registry) MessageStatus

func (r *Registry) MessageStatus(ctx context.Context, destType string, externalID string) (*nfymsg.Status, error)

func (*Registry) Provider

func (r *Registry) Provider(id string) Provider

func (*Registry) RegisterProvider

func (r *Registry) RegisterProvider(ctx context.Context, p Provider)

func (*Registry) SearchField

func (r *Registry) SearchField(ctx context.Context, typeID, fieldID string, options SearchOptions) (*SearchResult, error)

func (*Registry) SendMessage

func (r *Registry) SendMessage(ctx context.Context, msg nfymsg.Message) (*nfymsg.SentMessage, error)

func (*Registry) StubNotifiers

func (r *Registry) StubNotifiers()

StubNotifiers will cause all notifications senders to be stubbed out.

This causes all notifications to be marked as delivered, but not actually sent.

func (*Registry) TypeInfo

func (r *Registry) TypeInfo(ctx context.Context, typeID string) (*TypeInfo, error)

func (*Registry) Types

func (r *Registry) Types(ctx context.Context) ([]TypeInfo, error)

func (*Registry) ValidateAction

func (r *Registry) ValidateAction(ctx context.Context, act gadb.UIKActionV1) error

func (*Registry) ValidateDest

func (r *Registry) ValidateDest(ctx context.Context, dest gadb.DestV1) error

func (*Registry) ValidateField

func (r *Registry) ValidateField(ctx context.Context, typeID, fieldID, value string) error

type SearchOptions

type SearchOptions struct {
	Search string
	Omit   []string
	Cursor string
	Limit  int
}

type SearchResult

type SearchResult struct {
	HasNextPage bool
	Cursor      string
	Values      []FieldValue
}

func SearchByCursorFunc

func SearchByCursorFunc[OptionType any, POptionType interface {
	*OptionType
	OptionFrommer
}, Result Cursorable](ctx context.Context, opts SearchOptions, searchFn func(context.Context, *OptionType) ([]Result, error)) (*SearchResult, error)

func SearchByListFunc

func SearchByListFunc[T Fieldable](ctx context.Context, searchOpts SearchOptions, listFn func(context.Context) ([]T, error)) (*SearchResult, error)

SearchByListFunc allows returning a SearchResult from a function that returns a list of Fieldable items.

type TypeInfo

type TypeInfo struct {
	Type string

	Name        string
	IconURL     string
	IconAltText string
	Enabled     bool

	RequiredFields []FieldConfig
	DynamicParams  []DynamicParamConfig

	UserDisclaimer string

	// Message type info
	SupportsStatusUpdates      bool
	SupportsAlertNotifications bool
	SupportsUserVerification   bool
	SupportsOnCallNotify       bool
	SupportsSignals            bool

	UserVerificationRequired bool
	StatusUpdatesRequired    bool
}

func (TypeInfo) IsContactMethod

func (t TypeInfo) IsContactMethod() bool

func (TypeInfo) IsDynamicAction

func (t TypeInfo) IsDynamicAction() bool

func (TypeInfo) IsEPTarget

func (t TypeInfo) IsEPTarget() bool

func (TypeInfo) IsSchedOnCallNotify

func (t TypeInfo) IsSchedOnCallNotify() bool

Jump to

Keyboard shortcuts

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