webhook

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingSignature = errors.New("missing signature headers")
	ErrInvalidSignature = errors.New("invalid signature")
	ErrTimestampExpired = errors.New("timestamp too old")
	ErrUnknownEventType = errors.New("unknown event type")
)

Functions

This section is empty.

Types

type Event

type Event interface {
	GetUserID() int64
	GetTraceID() string
	GetAction() storage.Action
	GetEntityType() storage.EntityType
	GetEntityID() string
	// contains filtered or unexported methods
}

func ParseEvent

func ParseEvent(data []byte) (Event, error)

ParseEvent parses a raw webhook payload into a typed event. Returns ErrUnknownEventType for unknown entity types or actions.

type ProcessRequest

type ProcessRequest struct {
	Body      []byte
	Signature string
	Timestamp string
}

type Processor

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

func NewProcessor

func NewProcessor(clientSecret string, notificationStore storage.NotificationStore) *Processor

func (*Processor) ProcessWebhook

func (p *Processor) ProcessWebhook(ctx context.Context, req ProcessRequest) error

type RecoveryEvent

type RecoveryEvent struct {
	SleepID string `json:"id"`
	// contains filtered or unexported fields
}

func (RecoveryEvent) GetAction

func (e RecoveryEvent) GetAction() storage.Action

func (RecoveryEvent) GetEntityID

func (e RecoveryEvent) GetEntityID() string

func (RecoveryEvent) GetEntityType

func (e RecoveryEvent) GetEntityType() storage.EntityType

func (RecoveryEvent) GetTraceID

func (e RecoveryEvent) GetTraceID() string

func (RecoveryEvent) GetUserID

func (e RecoveryEvent) GetUserID() int64

type Service

type Service interface {
	// ProcessWebhook verifies the webhook signature, parses the event,
	// and stores/publishes the resulting notification.
	// Returns ErrMissingSignature if signature headers are empty.
	// Returns ErrInvalidSignature if the signature doesn't match.
	// Returns ErrTimestampExpired if the timestamp is too old.
	// Returns ErrUnknownEventType for unknown event types (caller may treat as success).
	ProcessWebhook(ctx context.Context, req ProcessRequest) error
}

type SleepEvent

type SleepEvent struct {
	SleepID string `json:"id"`
	// contains filtered or unexported fields
}

func (SleepEvent) GetAction

func (e SleepEvent) GetAction() storage.Action

func (SleepEvent) GetEntityID

func (e SleepEvent) GetEntityID() string

func (SleepEvent) GetEntityType

func (e SleepEvent) GetEntityType() storage.EntityType

func (SleepEvent) GetTraceID

func (e SleepEvent) GetTraceID() string

func (SleepEvent) GetUserID

func (e SleepEvent) GetUserID() int64

type WorkoutEvent

type WorkoutEvent struct {
	WorkoutID string `json:"id"`
	// contains filtered or unexported fields
}

func (WorkoutEvent) GetAction

func (e WorkoutEvent) GetAction() storage.Action

func (WorkoutEvent) GetEntityID

func (e WorkoutEvent) GetEntityID() string

func (WorkoutEvent) GetEntityType

func (e WorkoutEvent) GetEntityType() storage.EntityType

func (WorkoutEvent) GetTraceID

func (e WorkoutEvent) GetTraceID() string

func (WorkoutEvent) GetUserID

func (e WorkoutEvent) GetUserID() int64

Jump to

Keyboard shortcuts

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