Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeliveryReport ¶
type DeliveryReport struct {
ID string // AT message ID (matches messageId from send response)
Status string // Sent|Submitted|Buffered|Rejected|Success|Failed|AbsentSubscriber|Expired
PhoneNumber string
NetworkCode string
FailureReason string // Only present if Rejected or Failed
}
DeliveryReport represents an SMS delivery report callback from Africa's Talking. AT sends these as form-encoded POST requests to the configured callback URL.
func (DeliveryReport) IsFinalStatus ¶
func (d DeliveryReport) IsFinalStatus() bool
IsFinalStatus returns true if the delivery status is terminal (no further updates expected).
type DeliveryReportHandler ¶
type DeliveryReportHandler struct {
// contains filtered or unexported fields
}
DeliveryReportHandler processes SMS delivery report callbacks.
func NewDeliveryReportHandler ¶
func NewDeliveryReportHandler(opts ...DeliveryReportOption) *DeliveryReportHandler
NewDeliveryReportHandler creates a new DeliveryReportHandler. By default it logs reports using structured logging.
func (*DeliveryReportHandler) HandleReport ¶
func (h *DeliveryReportHandler) HandleReport(ctx context.Context, report DeliveryReport)
HandleReport processes a single delivery report.
type DeliveryReportOption ¶
type DeliveryReportOption func(*DeliveryReportHandler)
DeliveryReportOption configures a DeliveryReportHandler.
func WithReportHandler ¶
func WithReportHandler(fn func(ctx context.Context, report DeliveryReport)) DeliveryReportOption
WithReportHandler sets a custom handler function for delivery reports.
type SMSProvider ¶
type SMSProvider interface {
// SendSMS sends an SMS message using the provided context and request.
SendSMS(ctx context.Context, req SMSRequest) (SMSResponse, error)
// SendSingleSMS sends a single SMS message using the provided context, recipient, message, and sender.
SendSingleSMS(ctx context.Context, to string, message string, from string) (SMSResponse, error)
// SendBulkSMS sends a bulk SMS message using the provided context, recipients, message, and sender.
SendBulkSMS(ctx context.Context, to []string, message string, from string) (SMSResponse, error)
}
SMSProvider is an interface for sending SMS messages.
type SMSRequest ¶
type SMSRequest struct {
To string
ToMultiple []string
Message string
From string
ProviderOptions map[string]any // Provider-specific options
}
SMSRequest represents an SMS message request.
type SMSResponse ¶
type SMSResponse struct {
ProviderData any // Provider-specific response data
}
SMSResponse represents an SMS message response.
type SMSService ¶
type SMSService struct {
// contains filtered or unexported fields
}
SMSService is a service for managing SMS providers.
func (*SMSService) DeleteProvider ¶
func (s *SMSService) DeleteProvider(name string) error
DeleteProvider deletes a registered SMS provider by name.
func (*SMSService) DeleteProviders ¶
func (s *SMSService) DeleteProviders() error
DeleteProviders deletes all registered SMS providers.
func (*SMSService) GetProvider ¶
func (s *SMSService) GetProvider(name string) (SMSProvider, error)
GetProvider retrieves an SMS provider by name.
func (*SMSService) GetProviders ¶
func (s *SMSService) GetProviders() map[string]SMSProvider
GetProviders retrieves all registered SMS providers.
func (*SMSService) RegisterProvider ¶
func (s *SMSService) RegisterProvider(name string, provider SMSProvider)
RegisterProvider registers an SMS provider with the service.