webhook

package
v1.0.0-beta.220 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntitlementsEventGroupName = "entitlements"

	EntitlementsBalanceThresholdType        = "entitlements.balance.threshold"
	EntitlementsBalanceThresholdDescription = "Notification event for entitlements balance threshold violations"

	EntitlementResetType        = "entitlements.reset"
	EntitlementResetDescription = "Notification event for entitlement reset events."
)
View Source
const (
	InvoiceEventGroupName = "invoice"

	InvoiceCreatedType        = "invoice.created"
	InvoiceCreatedDescription = "Notification event for new invoice created."

	InvoiceUpdatedType        = "invoice.updated"
	InvoiceUpdatedDescription = "Notification event for new invoice updated."
)
View Source
const (
	DefaultRegistrationTimeout = 30 * time.Second
)
View Source
const DefaultSigningSecretSize = 32
View Source
const (
	SigningSecretPrefix = "whsec_"
)

Variables

View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var EventTypeEntitlementsBalanceThreshold = EventType{
	Name:        EntitlementsBalanceThresholdType,
	Description: EntitlementsBalanceThresholdDescription,
	GroupName:   EntitlementsEventGroupName,
}
View Source
var EventTypeEntitlementsReset = EventType{
	Name:        EntitlementResetType,
	Description: EntitlementResetDescription,
	GroupName:   EntitlementsEventGroupName,
}
View Source
var EventTypeInvoiceCreated = EventType{
	Name:        InvoiceCreatedType,
	Description: InvoiceCreatedDescription,
	GroupName:   InvoiceEventGroupName,
}
View Source
var EventTypeInvoiceUpdated = EventType{
	Name:        InvoiceUpdatedType,
	Description: InvoiceUpdatedDescription,
	GroupName:   InvoiceEventGroupName,
}

FIXME: add JSON schema for events FIXME: refactor notifications to keep these in one place

Functions

func IgnoreNotImplemented

func IgnoreNotImplemented(err error) error

func IsNotFoundError

func IsNotFoundError(err error) bool

func IsNotImplemented

func IsNotImplemented(err error) bool

func IsValidationError

func IsValidationError(err error) bool

func NewNotFoundError

func NewNotFoundError(err error) error

func NewSigningSecret

func NewSigningSecret(size int) (string, error)

func NewSigningSecretWithDefaultSize

func NewSigningSecretWithDefaultSize() (string, error)

func NewValidationError

func NewValidationError(err error) error

func ValidateSigningSecret

func ValidateSigningSecret(secret string) error

Types

type CreateWebhookInput

type CreateWebhookInput struct {
	Namespace string

	ID            *string
	URL           string
	CustomHeaders map[string]string
	Disabled      bool
	Secret        *string
	RateLimit     *uint16
	Description   *string
	EventTypes    []string
	Channels      []string
	Metadata      map[string]string
}

func (CreateWebhookInput) Validate

func (i CreateWebhookInput) Validate() error

type DeleteWebhookInput

type DeleteWebhookInput = GetWebhookInput

type EvenTypeSchemaVersion

type EvenTypeSchemaVersion = string

type EventType

type EventType struct {
	Name        string
	Description string
	GroupName   string
	// Schemas defines the list of schemas for each event type version
	Schemas    map[EvenTypeSchemaVersion]EventTypeSchema
	Deprecated bool
}

type EventTypeHandler

type EventTypeHandler interface {
	RegisterEventTypes(ctx context.Context, params RegisterEventTypesInputs) error
}

type EventTypeSchema

type EventTypeSchema = interface{}

type GetWebhookInput

type GetWebhookInput struct {
	Namespace string

	ID string
}

func (GetWebhookInput) Validate

func (i GetWebhookInput) Validate() error

type Handler

type Handler interface {
	WebhookHandler
	MessageHandler
	EventTypeHandler
}

type ListWebhooksInput

type ListWebhooksInput struct {
	Namespace string

	IDs        []string
	EventTypes []string
	Channels   []string
}

func (ListWebhooksInput) Validate

func (i ListWebhooksInput) Validate() error

type Message

type Message struct {
	Namespace string

	ID        string
	EventID   string
	EventType string
	Channels  []string
	Payload   map[string]interface{}
}

type MessageHandler

type MessageHandler interface {
	SendMessage(ctx context.Context, params SendMessageInput) (*Message, error)
}

type NotFoundError

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

func (NotFoundError) Error

func (e NotFoundError) Error() string

func (NotFoundError) Unwrap

func (e NotFoundError) Unwrap() error

type RegisterEventTypesInputs

type RegisterEventTypesInputs struct {
	EventTypes  []EventType
	AllowUpdate bool
}

type SendMessageInput

type SendMessageInput struct {
	Namespace string

	EventID   string
	EventType string
	Channels  []string
	Payload   map[string]interface{}
}

func (SendMessageInput) Validate

func (i SendMessageInput) Validate() error

type UpdateWebhookChannelsInput

type UpdateWebhookChannelsInput struct {
	Namespace string

	ID             string
	AddChannels    []string
	RemoveChannels []string
}

func (UpdateWebhookChannelsInput) Validate

func (i UpdateWebhookChannelsInput) Validate() error

type UpdateWebhookInput

type UpdateWebhookInput struct {
	Namespace string

	ID            string
	URL           string
	CustomHeaders map[string]string
	Disabled      bool
	Secret        *string
	RateLimit     *uint16
	Description   *string
	EventTypes    []string
	Channels      []string
	Metadata      map[string]string
}

func (UpdateWebhookInput) Validate

func (i UpdateWebhookInput) Validate() error

type ValidationError

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

func (ValidationError) Error

func (e ValidationError) Error() string

func (ValidationError) Unwrap

func (e ValidationError) Unwrap() error

type Webhook

type Webhook struct {
	Namespace string

	ID            string
	URL           string
	Secret        string
	CustomHeaders map[string]string
	Disabled      bool
	RateLimit     *uint16
	Description   string
	EventTypes    []string
	Channels      []string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

type WebhookHandler

type WebhookHandler interface {
	ListWebhooks(ctx context.Context, params ListWebhooksInput) ([]Webhook, error)
	CreateWebhook(ctx context.Context, params CreateWebhookInput) (*Webhook, error)
	UpdateWebhook(ctx context.Context, params UpdateWebhookInput) (*Webhook, error)
	UpdateWebhookChannels(ctx context.Context, params UpdateWebhookChannelsInput) (*Webhook, error)
	GetWebhook(ctx context.Context, params GetWebhookInput) (*Webhook, error)
	DeleteWebhook(ctx context.Context, params DeleteWebhookInput) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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