msgine

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

MsGine Go SDK

Client for the MsGine developer API. Standard library only, Go 1.21 or later.

go get github.com/kasimlyee/msgine-sdk/go

Documentation: https://docs.msgine.net

Quick start

package main

import (
	"context"
	"fmt"
	"log"

	msgine "github.com/kasimlyee/msgine-sdk/go"
)

func main() {
	client, err := msgine.New("msg_<kid>_<secret>")
	if err != nil {
		log.Fatal(err)
	}

	msg, err := client.SMS.Send(context.Background(), msgine.SendSMSParams{
		To:      []string{"+256700000001", "+256700000002"},
		Message: "Your code is 4821",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(msg.ID, msg.Status)
}

Every method takes a context.Context first. Cancelling it aborts the request and any wait between retries.

Options

Option Default
WithSigningSecret(secret) none
WithBaseURL(url) https://api.msgine.net/api/v1
WithHTTPClient(*http.Client) one shared client
WithTimeout(d) 30s, applied to each attempt
WithMaxRetries(n) 2

Channels

ctx := context.Background()

client.SMS.Send(ctx, msgine.SendSMSParams{To: []string{"+256700000001"}, Message: "Hi"})
client.WhatsApp.Send(ctx, msgine.SendWhatsAppParams{To: []string{"+256700000001"}, Message: "Hi"})
client.Email.Send(ctx, msgine.SendEmailParams{
	From: "hello@example.com", To: []string{"user@example.com"}, Subject: "Receipt", HTML: "<p>Thanks</p>",
})
client.Push.Send(ctx, msgine.SendPushParams{Title: "Hello", Body: "World", ExternalUserIDs: []string{"user-1"}})
client.Push.Devices.Register(ctx, msgine.RegisterDeviceParams{Token: "fcm-token", Platform: "android"})

page, err := client.SMS.List(ctx, &msgine.PageOptions{Page: 1, Limit: 20})

Email is transactional only; messageType is always sent as transactional. Lists return *msgine.Page[T] with Items, Total, Page and Pages. Passing nil options uses the API defaults.

Other resources: Messages, Webhooks, Workflows (Runs, Launches, Hooks, Secrets, MessagingPolicy), Events, OptOuts, ContactFields, Analytics, Push.Config.

Messaging policy

Quiet hours and the daily cap accept an explicit null. Fields of UpdateMessagingPolicyParams are msgine.Nullable values: leave a field unset to omit it, use msgine.Value(x) to set it and msgine.Null[T]() to send null.

client.Workflows.MessagingPolicy.Update(ctx, msgine.UpdateMessagingPolicyParams{
	Timezone:        msgine.Value("Africa/Kampala"),
	QuietHoursStart: msgine.Value("21:00"),
	QuietHoursEnd:   msgine.Null[string](),
})

Webhooks

Read the raw request body: the signature covers the exact bytes sent.

http.HandleFunc("/msgine", func(w http.ResponseWriter, r *http.Request) {
	payload, err := io.ReadAll(r.Body)
	if err != nil {
		http.Error(w, "bad request", http.StatusBadRequest)
		return
	}
	event, err := msgine.VerifyWebhook(payload, r.Header.Get("X-MsGine-Signature"), secret, 0)
	if err != nil {
		http.Error(w, "invalid signature", http.StatusBadRequest)
		return
	}
	fmt.Println(event.Event, event.MessageID)
	w.WriteHeader(http.StatusNoContent)
})

The last argument is the timestamp tolerance; 0 means 300 seconds. Failures satisfy errors.Is(err, msgine.ErrWebhookVerification). A header with several v1 signatures is accepted if any matches.

Errors and retries

API failures and connection failures are *msgine.Error:

var apiErr *msgine.Error
if errors.As(err, &apiErr) {
	fmt.Println(apiErr.Status, apiErr.Code, apiErr.Message, apiErr.Details, apiErr.RetryAfter)
}

Connection failures have Status 0 and Code connection_error or timeout; the underlying error is available through errors.Unwrap. Body holds the raw response body.

Up to WithMaxRetries retries happen for:

  • HTTP 429, always.
  • HTTP 408 and 5xx, and network errors, only when the call is safe to repeat: any method other than POST and PATCH, or a send call.

Send calls (SMS, WhatsApp, email, push, events, workflow run start) carry an idempotencyKey. Set IdempotencyKey yourself, or a UUID is generated once per call and reused on every retry. The wait honours Retry-After (between 1 and 60 seconds), otherwise it is 1s, 2s, 4s up to 8s plus up to 250ms of jitter.

Sandbox keys

An API key created with environment: sandbox validates and records requests but sends nothing and charges nothing. Use one in tests.

Request signing

With WithSigningSecret, every attempt sends x-timestamp and x-signature, the hex HMAC-SHA256 of METHOD + path + ?query + timestamp + sha256(body), computed over the exact body bytes sent.

Documentation

Index

Constants

View Source
const (
	Version = "1.0.0"
)

Variables

View Source
var ErrWebhookVerification = errors.New("msgine: webhook verification failed")

Functions

This section is empty.

Types

type APNSOptions

type APNSOptions struct {
	Badge            *int   `json:"badge,omitempty"`
	Sound            string `json:"sound,omitempty"`
	ContentAvailable bool   `json:"contentAvailable,omitempty"`
	MutableContent   bool   `json:"mutableContent,omitempty"`
	Category         string `json:"category,omitempty"`
	ThreadID         string `json:"threadId,omitempty"`
}

type AnalyticsService

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

func (*AnalyticsService) Daily

func (s *AnalyticsService) Daily(ctx context.Context, days int) (map[string]any, error)

func (*AnalyticsService) Developer

func (s *AnalyticsService) Developer(ctx context.Context, r *DateRange) (map[string]any, error)

func (*AnalyticsService) Engagement

func (s *AnalyticsService) Engagement(ctx context.Context, r *DateRange) (map[string]any, error)

func (*AnalyticsService) Messaging

func (s *AnalyticsService) Messaging(ctx context.Context, r *DateRange) (map[string]any, error)

func (*AnalyticsService) Overview

func (s *AnalyticsService) Overview(ctx context.Context, r *DateRange) (map[string]any, error)

func (*AnalyticsService) Summary

func (s *AnalyticsService) Summary(ctx context.Context, r *DateRange) (map[string]any, error)

type AndroidOptions

type AndroidOptions struct {
	ChannelID   string `json:"channelId,omitempty"`
	Sound       string `json:"sound,omitempty"`
	ClickAction string `json:"clickAction,omitempty"`
	Color       string `json:"color,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Priority    string `json:"priority,omitempty"`
}

type Client

type Client struct {
	SMS           *SMSService
	WhatsApp      *WhatsAppService
	Email         *EmailService
	Push          *PushService
	Messages      *MessagesService
	Webhooks      *WebhooksService
	Workflows     *WorkflowsService
	Events        *EventsService
	OptOuts       *OptOutsService
	ContactFields *ContactFieldsService
	Analytics     *AnalyticsService
	// contains filtered or unexported fields
}

func New

func New(apiKey string, opts ...Option) (*Client, error)

type ContactField

type ContactField struct {
	ID        string   `json:"id"`
	Key       string   `json:"key"`
	Label     string   `json:"label"`
	Type      string   `json:"type"`
	Options   []string `json:"options"`
	CreatedAt string   `json:"createdAt"`
	UpdatedAt string   `json:"updatedAt"`
}

type ContactFieldsService

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

func (*ContactFieldsService) Create

func (*ContactFieldsService) Delete

func (s *ContactFieldsService) Delete(ctx context.Context, fieldID string) error

func (*ContactFieldsService) List

func (*ContactFieldsService) Update

type CreateContactFieldParams

type CreateContactFieldParams struct {
	Key     string   `json:"key"`
	Label   string   `json:"label"`
	Type    string   `json:"type"`
	Options []string `json:"options,omitempty"`
}

type CreateOptOutParams

type CreateOptOutParams struct {
	Channel string `json:"channel"`
	Address string `json:"address"`
	Reason  string `json:"reason,omitempty"`
}

type CreateWebhookParams

type CreateWebhookParams struct {
	URL         string   `json:"url"`
	Events      []string `json:"events"`
	Description string   `json:"description,omitempty"`
}

type CreateWorkflowParams

type CreateWorkflowParams struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Definition  map[string]any `json:"definition,omitempty"`
}

type CreatedWebhook

type CreatedWebhook struct {
	Webhook Webhook `json:"webhook"`
	Secret  string  `json:"secret"`
}

type DateRange

type DateRange struct {
	From string
	To   string
}

type Device

type Device struct {
	ID             string  `json:"id"`
	Platform       string  `json:"platform"`
	IsActive       bool    `json:"isActive"`
	ExternalUserID *string `json:"externalUserId,omitempty"`
	Token          string  `json:"token,omitempty"`
	CreatedAt      string  `json:"createdAt"`
	UpdatedAt      string  `json:"updatedAt,omitempty"`
}

type DeviceList

type DeviceList struct {
	Devices []Device `json:"devices"`
	Total   int      `json:"total"`
	Active  int      `json:"active"`
}

type EmailMessage

type EmailMessage struct {
	ID                string   `json:"id"`
	Channel           string   `json:"channel"`
	From              string   `json:"from"`
	To                []string `json:"to"`
	Subject           string   `json:"subject"`
	Status            string   `json:"status"`
	Cost              float64  `json:"cost"`
	Currency          string   `json:"currency"`
	RecipientCount    int      `json:"recipientCount"`
	Sandbox           bool     `json:"sandbox,omitempty"`
	Domain            string   `json:"domain,omitempty"`
	ProviderMessageID *string  `json:"providerMessageId,omitempty"`
	FailureReason     *string  `json:"failureReason,omitempty"`
	ScheduledAt       string   `json:"scheduledAt,omitempty"`
	SentAt            string   `json:"sentAt,omitempty"`
	CreatedAt         string   `json:"createdAt"`
}

type EmailService

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

func (*EmailService) List

func (s *EmailService) List(ctx context.Context, opts *PageOptions) (*Page[EmailMessage], error)

func (*EmailService) Send

type Error

type Error struct {
	Status     int
	Code       string
	Message    string
	Details    []ErrorDetail
	RetryAfter time.Duration
	Body       []byte
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
	Field   string `json:"field,omitempty"`
}

type EventsService

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

func (*EventsService) Send

func (s *EventsService) Send(ctx context.Context, p SendEventParams) (map[string]any, error)

type InboundWhatsAppMessage

type InboundWhatsAppMessage struct {
	ID          string  `json:"id"`
	From        string  `json:"from"`
	ProfileName *string `json:"profileName"`
	ContactID   *string `json:"contactId"`
	Type        string  `json:"type"`
	Text        *string `json:"text"`
	ReplyTo     *string `json:"replyTo"`
	ReceivedAt  string  `json:"receivedAt"`
}

type LaunchParams

type LaunchParams struct {
	At      string `json:"at,omitempty"`
	Sandbox bool   `json:"sandbox,omitempty"`
}

type ListOptOutsOptions

type ListOptOutsOptions struct {
	Page    int
	Limit   int
	Channel string
}

type ListRunsOptions

type ListRunsOptions struct {
	Page   int
	Limit  int
	Status string
}

type ListWorkflowsOptions

type ListWorkflowsOptions struct {
	Page   int
	Limit  int
	Status string
}

type MessagesService

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

func (*MessagesService) Get

func (s *MessagesService) Get(ctx context.Context, messageID string) (map[string]any, error)

type MessagingPolicy

type MessagingPolicy struct {
	Timezone                    string  `json:"timezone,omitempty"`
	QuietHoursStart             *string `json:"quietHoursStart"`
	QuietHoursEnd               *string `json:"quietHoursEnd"`
	DailyMarketingCapPerContact *int    `json:"dailyMarketingCapPerContact"`
}

type MessagingPolicyService

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

func (*MessagingPolicyService) Get

func (*MessagingPolicyService) Update

type Nullable

type Nullable[T any] struct {
	// contains filtered or unexported fields
}

func Null

func Null[T any]() Nullable[T]

func Value

func Value[T any](v T) Nullable[T]

type OptOut

type OptOut struct {
	ID        string  `json:"id"`
	Channel   string  `json:"channel"`
	Address   string  `json:"address"`
	Source    string  `json:"source"`
	Reason    *string `json:"reason"`
	CreatedAt string  `json:"createdAt"`
	UpdatedAt string  `json:"updatedAt"`
}

type OptOutsService

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

func (*OptOutsService) Create

func (*OptOutsService) Delete

func (s *OptOutsService) Delete(ctx context.Context, optOutID string) error

func (*OptOutsService) List

type Option

type Option func(*Client)

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

func WithMaxRetries

func WithMaxRetries(maxRetries int) Option

func WithSigningSecret

func WithSigningSecret(secret string) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Page

type Page[T any] struct {
	Items []T `json:"items"`
	Total int `json:"total"`
	Page  int `json:"page"`
	Pages int `json:"pages"`
}

type PageOptions

type PageOptions struct {
	Page  int
	Limit int
}

type PushConfig

type PushConfig struct {
	ProjectID   string `json:"projectId"`
	ClientEmail string `json:"clientEmail"`
	IsActive    bool   `json:"isActive"`
	CreatedAt   string `json:"createdAt"`
	UpdatedAt   string `json:"updatedAt"`
}

type PushConfigParams

type PushConfigParams struct {
	ProjectID   string `json:"projectId"`
	ClientEmail string `json:"clientEmail"`
	PrivateKey  string `json:"privateKey"`
}

type PushConfigService

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

func (*PushConfigService) Delete

func (s *PushConfigService) Delete(ctx context.Context) error

func (*PushConfigService) Get

func (*PushConfigService) Set

type PushDevicesService

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

func (*PushDevicesService) List

func (*PushDevicesService) Register

func (*PushDevicesService) Remove

func (s *PushDevicesService) Remove(ctx context.Context, token string) error

type PushNotification

type PushNotification struct {
	ID             string            `json:"id"`
	Channel        string            `json:"channel"`
	Title          string            `json:"title"`
	Body           string            `json:"body"`
	Status         string            `json:"status"`
	RecipientCount int               `json:"recipientCount"`
	Sandbox        bool              `json:"sandbox,omitempty"`
	Data           map[string]string `json:"data,omitempty"`
	ScheduledAt    string            `json:"scheduledAt,omitempty"`
	CreatedAt      string            `json:"createdAt"`
}

type PushService

type PushService struct {
	Devices *PushDevicesService
	Config  *PushConfigService
	// contains filtered or unexported fields
}

func (*PushService) Confirm

func (s *PushService) Confirm(ctx context.Context, notificationID, event string) error

func (*PushService) List

func (*PushService) Send

type Recipients

type Recipients []string

func (Recipients) MarshalJSON

func (r Recipients) MarshalJSON() ([]byte, error)

type RegisterDeviceParams

type RegisterDeviceParams struct {
	Token          string `json:"token"`
	Platform       string `json:"platform"`
	ExternalUserID string `json:"externalUserId,omitempty"`
}

type SMSMessage

type SMSMessage struct {
	ID          string       `json:"id"`
	SID         string       `json:"sid,omitempty"`
	Channel     string       `json:"channel"`
	To          []string     `json:"to"`
	From        string       `json:"from"`
	Content     string       `json:"content"`
	Status      string       `json:"status"`
	Cost        float64      `json:"cost"`
	Currency    string       `json:"currency"`
	Sandbox     bool         `json:"sandbox,omitempty"`
	ScheduledAt string       `json:"scheduledAt,omitempty"`
	SentAt      string       `json:"sentAt,omitempty"`
	DeliveredAt string       `json:"deliveredAt,omitempty"`
	CreatedAt   string       `json:"createdAt"`
	Metadata    *SMSMetadata `json:"metadata,omitempty"`
}

type SMSMetadata

type SMSMetadata struct {
	RecipientsProcessed   int      `json:"recipientsProcessed"`
	InvalidNumbersSkipped int      `json:"invalidNumbersSkipped"`
	DuplicatesRemoved     int      `json:"duplicatesRemoved"`
	SMSCount              int      `json:"smsCount"`
	MessageLength         int      `json:"messageLength"`
	CostPerSMS            float64  `json:"costPerSms"`
	InvalidNumbers        []string `json:"invalidNumbers,omitempty"`
	OptedOutSkipped       []string `json:"optedOutSkipped,omitempty"`
}

type SMSService

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

func (*SMSService) List

func (s *SMSService) List(ctx context.Context, opts *PageOptions) (*Page[SMSMessage], error)

func (*SMSService) Send

type SendEmailParams

type SendEmailParams struct {
	From           string     `json:"from"`
	To             Recipients `json:"to"`
	Subject        string     `json:"subject"`
	Text           string     `json:"text,omitempty"`
	HTML           string     `json:"html,omitempty"`
	CC             Recipients `json:"cc,omitempty"`
	BCC            Recipients `json:"bcc,omitempty"`
	ScheduledFor   string     `json:"scheduledFor,omitempty"`
	IdempotencyKey string     `json:"idempotencyKey,omitempty"`
}

type SendEventParams

type SendEventParams struct {
	Name           string         `json:"name"`
	Payload        map[string]any `json:"payload,omitempty"`
	ContactID      string         `json:"contactId,omitempty"`
	Phone          string         `json:"phone,omitempty"`
	IdempotencyKey string         `json:"idempotencyKey,omitempty"`
}

type SendPushParams

type SendPushParams struct {
	Title           string            `json:"title"`
	Body            string            `json:"body"`
	ExternalUserIDs []string          `json:"externalUserIds,omitempty"`
	Topic           string            `json:"topic,omitempty"`
	Type            string            `json:"type,omitempty"`
	Priority        string            `json:"priority,omitempty"`
	TTL             int               `json:"ttl,omitempty"`
	Data            map[string]string `json:"data,omitempty"`
	ImageURL        string            `json:"imageUrl,omitempty"`
	CollapseKey     string            `json:"collapseKey,omitempty"`
	Android         *AndroidOptions   `json:"android,omitempty"`
	APNS            *APNSOptions      `json:"apns,omitempty"`
	WebPush         *WebPushOptions   `json:"webpush,omitempty"`
	ScheduledFor    string            `json:"scheduledFor,omitempty"`
	IdempotencyKey  string            `json:"idempotencyKey,omitempty"`
}

type SendSMSParams

type SendSMSParams struct {
	To             Recipients `json:"to"`
	Message        string     `json:"message"`
	From           string     `json:"from,omitempty"`
	ScheduledFor   string     `json:"scheduledFor,omitempty"`
	IdempotencyKey string     `json:"idempotencyKey,omitempty"`
}

type SendWhatsAppParams

type SendWhatsAppParams struct {
	To               Recipients `json:"to"`
	Message          string     `json:"message,omitempty"`
	From             string     `json:"from,omitempty"`
	MessageType      string     `json:"messageType,omitempty"`
	TemplateID       string     `json:"templateId,omitempty"`
	TemplateLanguage string     `json:"templateLanguage,omitempty"`
	TemplateParams   []string   `json:"templateParams,omitempty"`
	MediaURL         string     `json:"mediaUrl,omitempty"`
	MediaType        string     `json:"mediaType,omitempty"`
	ScheduledFor     string     `json:"scheduledFor,omitempty"`
	IdempotencyKey   string     `json:"idempotencyKey,omitempty"`
}

type StartRunParams

type StartRunParams struct {
	Input          map[string]any `json:"input,omitempty"`
	ContactID      string         `json:"contactId,omitempty"`
	Phone          string         `json:"phone,omitempty"`
	Sandbox        bool           `json:"sandbox,omitempty"`
	IdempotencyKey string         `json:"idempotencyKey,omitempty"`
}

type UpdateContactFieldParams

type UpdateContactFieldParams struct {
	Label   string   `json:"label,omitempty"`
	Options []string `json:"options,omitempty"`
}

type UpdateMessagingPolicyParams

type UpdateMessagingPolicyParams struct {
	Timezone                    Nullable[string]
	QuietHoursStart             Nullable[string]
	QuietHoursEnd               Nullable[string]
	DailyMarketingCapPerContact Nullable[int]
}

func (UpdateMessagingPolicyParams) MarshalJSON

func (p UpdateMessagingPolicyParams) MarshalJSON() ([]byte, error)

type UpdateWebhookParams

type UpdateWebhookParams struct {
	URL         string   `json:"url,omitempty"`
	Events      []string `json:"events,omitempty"`
	IsActive    *bool    `json:"isActive,omitempty"`
	Description string   `json:"description,omitempty"`
	MaxRetries  *int     `json:"maxRetries,omitempty"`
}

type UpdateWorkflowParams

type UpdateWorkflowParams struct {
	Name        string         `json:"name,omitempty"`
	Description string         `json:"description,omitempty"`
	Definition  map[string]any `json:"definition,omitempty"`
}

type ValidationIssue

type ValidationIssue struct {
	NodeID  string `json:"nodeId,omitempty"`
	Message string `json:"message"`
}

type ValidationResult

type ValidationResult struct {
	Valid  bool              `json:"valid"`
	Errors []ValidationIssue `json:"errors"`
}

type WebPushOptions

type WebPushOptions struct {
	Icon               string `json:"icon,omitempty"`
	Link               string `json:"link,omitempty"`
	Badge              string `json:"badge,omitempty"`
	RequireInteraction bool   `json:"requireInteraction,omitempty"`
}

type Webhook

type Webhook struct {
	ID              string   `json:"id"`
	URL             string   `json:"url"`
	Events          []string `json:"events"`
	IsActive        bool     `json:"isActive"`
	Description     *string  `json:"description"`
	MaxRetries      int      `json:"maxRetries"`
	LastTriggeredAt *string  `json:"lastTriggeredAt"`
	SuccessCount    int      `json:"successCount"`
	FailureCount    int      `json:"failureCount"`
	CreatedAt       string   `json:"createdAt"`
	UpdatedAt       string   `json:"updatedAt"`
}

type WebhookDelivery

type WebhookDelivery struct {
	ID           string         `json:"id"`
	WebhookID    string         `json:"webhookId"`
	MessageID    *string        `json:"messageId"`
	EventType    string         `json:"eventType"`
	Channel      *string        `json:"channel"`
	Payload      map[string]any `json:"payload"`
	Status       string         `json:"status"`
	HTTPStatus   *int           `json:"httpStatus"`
	ResponseBody *string        `json:"responseBody"`
	ErrorMessage *string        `json:"errorMessage"`
	Attempts     int            `json:"attempts"`
	NextRetryAt  *string        `json:"nextRetryAt"`
	DeliveredAt  *string        `json:"deliveredAt"`
	CreatedAt    string         `json:"createdAt"`
}

type WebhookEvent

type WebhookEvent struct {
	Event     string         `json:"event"`
	Channel   string         `json:"channel,omitempty"`
	MessageID string         `json:"messageId,omitempty"`
	Timestamp string         `json:"timestamp"`
	Data      map[string]any `json:"data"`
}

func VerifyWebhook

func VerifyWebhook(payload []byte, signatureHeader, secret string, tolerance time.Duration) (*WebhookEvent, error)

type WebhookEventInfo

type WebhookEventInfo struct {
	Event       string `json:"event"`
	Description string `json:"description"`
}

type WebhookSecret

type WebhookSecret struct {
	Secret string `json:"secret"`
}

type WebhooksService

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

func (*WebhooksService) Create

func (*WebhooksService) Delete

func (s *WebhooksService) Delete(ctx context.Context, webhookID string) error

func (*WebhooksService) Deliveries

func (s *WebhooksService) Deliveries(ctx context.Context, webhookID string, limit int) ([]WebhookDelivery, error)

func (*WebhooksService) Events

func (*WebhooksService) Get

func (s *WebhooksService) Get(ctx context.Context, webhookID string) (*Webhook, error)

func (*WebhooksService) List

func (s *WebhooksService) List(ctx context.Context) ([]Webhook, error)

func (*WebhooksService) RotateSecret

func (s *WebhooksService) RotateSecret(ctx context.Context, webhookID string) (*WebhookSecret, error)

func (*WebhooksService) Test

func (s *WebhooksService) Test(ctx context.Context, webhookID string) (map[string]any, error)

func (*WebhooksService) Update

func (s *WebhooksService) Update(ctx context.Context, webhookID string, p UpdateWebhookParams) (*Webhook, error)

type WhatsAppMessage

type WhatsAppMessage struct {
	ID             string         `json:"id"`
	SID            string         `json:"sid,omitempty"`
	Channel        string         `json:"channel"`
	To             []string       `json:"to"`
	From           string         `json:"from"`
	Content        string         `json:"content"`
	MessageType    string         `json:"messageType"`
	Status         string         `json:"status"`
	Cost           float64        `json:"cost"`
	CostPerMessage float64        `json:"costPerMessage"`
	Currency       string         `json:"currency"`
	Sandbox        bool           `json:"sandbox,omitempty"`
	ScheduledAt    string         `json:"scheduledAt,omitempty"`
	CreatedAt      string         `json:"createdAt"`
	Metadata       map[string]any `json:"metadata,omitempty"`
}

type WhatsAppService

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

func (*WhatsAppService) Inbound

func (*WhatsAppService) List

func (*WhatsAppService) Send

type Workflow

type Workflow struct {
	ID              string         `json:"id"`
	Name            string         `json:"name"`
	Description     *string        `json:"description"`
	Status          string         `json:"status"`
	Draft           map[string]any `json:"draft"`
	ActiveVersionID *string        `json:"activeVersionId"`
	CreatedAt       string         `json:"createdAt"`
	UpdatedAt       string         `json:"updatedAt"`
}

type WorkflowHook

type WorkflowHook struct {
	URL       string `json:"url"`
	CreatedAt string `json:"createdAt"`
}

type WorkflowHookInfo

type WorkflowHookInfo struct {
	CreatedAt string `json:"createdAt"`
}

type WorkflowHooksService

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

func (*WorkflowHooksService) Create

func (s *WorkflowHooksService) Create(ctx context.Context, workflowID string) (*WorkflowHook, error)

func (*WorkflowHooksService) Delete

func (s *WorkflowHooksService) Delete(ctx context.Context, workflowID string) error

func (*WorkflowHooksService) Get

func (s *WorkflowHooksService) Get(ctx context.Context, workflowID string) (*WorkflowHookInfo, error)

type WorkflowLaunch

type WorkflowLaunch struct {
	ID          string  `json:"id"`
	WorkflowID  string  `json:"workflowId"`
	Status      string  `json:"status"`
	Sandbox     bool    `json:"sandbox"`
	RunAt       string  `json:"runAt"`
	Entered     int     `json:"entered"`
	Skipped     int     `json:"skipped"`
	CompletedAt *string `json:"completedAt"`
	CreatedAt   string  `json:"createdAt"`
}

type WorkflowLaunchesService

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

func (*WorkflowLaunchesService) Cancel

func (s *WorkflowLaunchesService) Cancel(ctx context.Context, launchID string) (*WorkflowLaunch, error)

func (*WorkflowLaunchesService) Create

func (*WorkflowLaunchesService) Get

func (*WorkflowLaunchesService) List

func (s *WorkflowLaunchesService) List(ctx context.Context, workflowID string) ([]WorkflowLaunch, error)

type WorkflowRun

type WorkflowRun struct {
	ID         string         `json:"id"`
	WorkflowID string         `json:"workflowId"`
	VersionID  string         `json:"versionId"`
	Status     string         `json:"status"`
	Sandbox    bool           `json:"sandbox"`
	ContactID  *string        `json:"contactId"`
	Input      map[string]any `json:"input"`
	Error      *string        `json:"error"`
	EndedAt    *string        `json:"endedAt"`
	CreatedAt  string         `json:"createdAt"`
}

type WorkflowRunsService

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

func (*WorkflowRunsService) Cancel

func (s *WorkflowRunsService) Cancel(ctx context.Context, runID string) (*WorkflowRun, error)

func (*WorkflowRunsService) Get

func (s *WorkflowRunsService) Get(ctx context.Context, runID string) (*WorkflowRun, error)

func (*WorkflowRunsService) List

func (s *WorkflowRunsService) List(ctx context.Context, workflowID string, opts *ListRunsOptions) (*Page[WorkflowRun], error)

func (*WorkflowRunsService) Start

func (s *WorkflowRunsService) Start(ctx context.Context, workflowID string, p StartRunParams) (*WorkflowRun, error)

type WorkflowSecret

type WorkflowSecret struct {
	Name      string `json:"name"`
	CreatedAt string `json:"createdAt"`
	UpdatedAt string `json:"updatedAt"`
}

type WorkflowSecretName

type WorkflowSecretName struct {
	Name string `json:"name"`
}

type WorkflowSecretsService

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

func (*WorkflowSecretsService) Delete

func (s *WorkflowSecretsService) Delete(ctx context.Context, name string) error

func (*WorkflowSecretsService) List

func (*WorkflowSecretsService) Set

type WorkflowsService

type WorkflowsService struct {
	Runs            *WorkflowRunsService
	Launches        *WorkflowLaunchesService
	Hooks           *WorkflowHooksService
	Secrets         *WorkflowSecretsService
	MessagingPolicy *MessagingPolicyService
	// contains filtered or unexported fields
}

func (*WorkflowsService) Archive

func (s *WorkflowsService) Archive(ctx context.Context, workflowID string) error

func (*WorkflowsService) Create

func (*WorkflowsService) Get

func (s *WorkflowsService) Get(ctx context.Context, workflowID string) (*Workflow, error)

func (*WorkflowsService) List

func (*WorkflowsService) NodeTypes

func (s *WorkflowsService) NodeTypes(ctx context.Context) ([]map[string]any, error)

func (*WorkflowsService) Pause

func (s *WorkflowsService) Pause(ctx context.Context, workflowID string) (*Workflow, error)

func (*WorkflowsService) PlatformEvents

func (s *WorkflowsService) PlatformEvents(ctx context.Context) ([]map[string]any, error)

func (*WorkflowsService) Publish

func (s *WorkflowsService) Publish(ctx context.Context, workflowID string) (*Workflow, error)

func (*WorkflowsService) Resume

func (s *WorkflowsService) Resume(ctx context.Context, workflowID string) (*Workflow, error)

func (*WorkflowsService) Update

func (s *WorkflowsService) Update(ctx context.Context, workflowID string, p UpdateWorkflowParams) (*Workflow, error)

func (*WorkflowsService) Validate

func (s *WorkflowsService) Validate(ctx context.Context, workflowID string) (*ValidationResult, error)

func (*WorkflowsService) Versions

func (s *WorkflowsService) Versions(ctx context.Context, workflowID string) ([]map[string]any, error)

Jump to

Keyboard shortcuts

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