webhooks

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package webhooks provides webhook event types and payload definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType              `json:"event_type"`
	Timestamp time.Time              `json:"timestamp"`
	Data      map[string]interface{} `json:"data"`
	UserID    int                    `json:"user_id,omitempty"`
	Source    string                 `json:"source"`
}

Event represents an event that can trigger webhooks.

type EventType

type EventType string

EventType represents the type of event that triggers a webhook.

const (
	// Ticket events.
	EventTicketCreated   EventType = "ticket.created"
	EventTicketUpdated   EventType = "ticket.updated"
	EventTicketClosed    EventType = "ticket.closed"
	EventTicketReopened  EventType = "ticket.reopened"
	EventTicketAssigned  EventType = "ticket.assigned"
	EventTicketEscalated EventType = "ticket.escalated"

	// Article events.
	EventArticleCreated EventType = "article.created"
	EventArticleUpdated EventType = "article.updated"
	EventArticleDeleted EventType = "article.deleted"

	// Customer events.
	EventCustomerCreated EventType = "customer.created"
	EventCustomerUpdated EventType = "customer.updated"

	// SLA events.
	EventSLABreached EventType = "sla.breached"
	EventSLAWarning  EventType = "sla.warning"

	// Queue events.
	EventQueueThreshold EventType = "queue.threshold"
)

func AllEventTypes

func AllEventTypes() []EventType

AllEventTypes returns all available event types.

type Webhook

type Webhook struct {
	ID             int               `json:"id"`
	Name           string            `json:"name"`
	URL            string            `json:"url"`
	Secret         string            `json:"secret,omitempty"`
	Events         []string          `json:"events"`
	Active         bool              `json:"active"`
	RetryCount     int               `json:"retry_count"`
	TimeoutSeconds int               `json:"timeout_seconds"`
	Headers        map[string]string `json:"headers,omitempty"`
	CreateTime     time.Time         `json:"create_time"`
	CreateBy       int               `json:"create_by"`
	ChangeTime     time.Time         `json:"change_time"`
	ChangeBy       int               `json:"change_by"`
}

Webhook represents a configured webhook endpoint.

type WebhookDelivery

type WebhookDelivery struct {
	ID          int        `json:"id"`
	WebhookID   int        `json:"webhook_id"`
	EventType   string     `json:"event_type"`
	Payload     string     `json:"payload"`
	StatusCode  int        `json:"status_code"`
	Response    string     `json:"response,omitempty"`
	Attempts    int        `json:"attempts"`
	DeliveredAt *time.Time `json:"delivered_at,omitempty"`
	NextRetry   *time.Time `json:"next_retry,omitempty"`
	CreatedAt   time.Time  `json:"created_at"`
	Success     bool       `json:"success"`
}

WebhookDelivery represents a webhook delivery attempt.

type WebhookPayload

type WebhookPayload struct {
	Event     EventType              `json:"event"`
	Timestamp time.Time              `json:"timestamp"`
	Data      map[string]interface{} `json:"data"`
	Signature string                 `json:"signature,omitempty"`
}

WebhookPayload represents the payload sent to webhook endpoints.

Jump to

Keyboard shortcuts

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