Documentation
¶
Overview ¶
Package gateway provides an embedded SDK for the message gateway.
Usage:
gw, err := gateway.New(gateway.Config{
DefaultEmailProvider: "memory",
})
result, err := gw.SendEmail(ctx, &contracts.Email{
To: []string{"user@example.com"},
Subject: "Hello",
HTML: "<p>World</p>",
})
Index ¶
- type ChatConfig
- type CommonConfig
- type Config
- type EmailConfig
- type Gateway
- func (g *Gateway) SendChat(ctx context.Context, chat *contracts.ChatMessage) (*contracts.SendResult, error)
- func (g *Gateway) SendChatWith(ctx context.Context, provider string, chat *contracts.ChatMessage) (*contracts.SendResult, error)
- func (g *Gateway) SendEmail(ctx context.Context, email *contracts.Email) (*contracts.SendResult, error)
- func (g *Gateway) SendEmailWith(ctx context.Context, provider string, email *contracts.Email) (*contracts.SendResult, error)
- func (g *Gateway) SendPush(ctx context.Context, push *contracts.PushNotification) (*contracts.SendResult, error)
- func (g *Gateway) SendPushWith(ctx context.Context, provider string, push *contracts.PushNotification) (*contracts.SendResult, error)
- func (g *Gateway) SendSMS(ctx context.Context, sms *contracts.SMS) (*contracts.SendResult, error)
- func (g *Gateway) SendSMSWith(ctx context.Context, provider string, sms *contracts.SMS) (*contracts.SendResult, error)
- type PushConfig
- type SMSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatConfig ¶ added in v1.1.2
type ChatConfig = registry.ChatConfig
Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.
type CommonConfig ¶ added in v1.1.2
type CommonConfig = registry.CommonConfig
Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.
type Config ¶
type Config struct {
DefaultEmailProvider string
DefaultSMSProvider string
DefaultPushProvider string
DefaultChatProvider string
// Provider-specific configurations keyed by provider name.
// Uses registry types as single source of truth.
EmailProviders map[string]registry.EmailConfig
SMSProviders map[string]registry.SMSConfig
PushProviders map[string]registry.PushConfig
ChatProviders map[string]registry.ChatConfig
// MailpitEnabled enables SMTP forwarding for the memory provider.
MailpitEnabled bool
}
Config holds the gateway configuration.
type EmailConfig ¶ added in v1.1.2
type EmailConfig = registry.EmailConfig
Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the main entry point for sending messages.
func (*Gateway) SendChat ¶
func (g *Gateway) SendChat(ctx context.Context, chat *contracts.ChatMessage) (*contracts.SendResult, error)
SendChat sends a chat message using the default provider.
func (*Gateway) SendChatWith ¶
func (g *Gateway) SendChatWith(ctx context.Context, provider string, chat *contracts.ChatMessage) (*contracts.SendResult, error)
SendChatWith sends a chat message using a specific provider.
func (*Gateway) SendEmail ¶
func (g *Gateway) SendEmail(ctx context.Context, email *contracts.Email) (*contracts.SendResult, error)
SendEmail sends an email using the default provider.
func (*Gateway) SendEmailWith ¶
func (g *Gateway) SendEmailWith(ctx context.Context, provider string, email *contracts.Email) (*contracts.SendResult, error)
SendEmailWith sends an email using a specific provider.
func (*Gateway) SendPush ¶
func (g *Gateway) SendPush(ctx context.Context, push *contracts.PushNotification) (*contracts.SendResult, error)
SendPush sends a push notification using the default provider.
func (*Gateway) SendPushWith ¶
func (g *Gateway) SendPushWith(ctx context.Context, provider string, push *contracts.PushNotification) (*contracts.SendResult, error)
SendPushWith sends a push notification using a specific provider.
type PushConfig ¶ added in v1.1.2
type PushConfig = registry.PushConfig
Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.