Documentation
¶
Overview ¶
Package sms provides an abstraction layer for sending SMS messages with support for multiple providers (Twilio, AWS SNS, Nexmo, etc.)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSSNSConfig ¶
type AWSSNSConfig struct {
Region string // AWS region
AccessKeyID string // AWS access key ID
SecretAccessKey string // AWS secret access key
}
AWSSNSConfig contains AWS SNS-specific configuration
type Client ¶
type Client interface {
// Send sends an SMS message
Send(ctx context.Context, msg *Message) (*SendResult, error)
// SendBulk sends multiple SMS messages in batch
SendBulk(ctx context.Context, messages []*Message) ([]*SendResult, error)
// GetStatus retrieves the status of a sent message
GetStatus(ctx context.Context, messageID string) (*SendResult, error)
// ValidatePhoneNumber checks if a phone number is valid
ValidatePhoneNumber(phoneNumber string) error
// Close closes the SMS client and releases resources
Close() error
}
Client is the interface that all SMS providers must implement
type Config ¶
type Config struct {
Provider Provider // SMS provider to use
From string // Default sender phone number or ID
Options map[string]string // Provider-specific options
}
Config contains configuration for SMS client
type Message ¶
type Message struct {
From string // Sender phone number or ID
To []string // Recipient phone numbers
Body string // Message text content
Unicode bool // Whether message contains Unicode characters
}
Message represents an SMS message
func (*Message) CalculateSegments ¶
CalculateSegments calculates the number of SMS segments needed
func (*Message) EstimateCost ¶
EstimateCost estimates the cost of sending the message Note: This is a rough estimate. Actual cost depends on the provider and destination
type MessageBirdConfig ¶
type MessageBirdConfig struct {
APIKey string // MessageBird API key
Originator string // Sender name or number
}
MessageBirdConfig contains MessageBird-specific configuration
type NexmoConfig ¶
type NexmoConfig struct {
APIKey string // Nexmo API key
APISecret string // Nexmo API secret
FromName string // Sender name or number
}
NexmoConfig contains Nexmo/Vonage-specific configuration
type Provider ¶
type Provider string
Provider represents an SMS service provider
const ( // ProviderTwilio uses Twilio API ProviderTwilio Provider = "twilio" // ProviderAWSSNS uses AWS Simple Notification Service ProviderAWSSNS Provider = "aws_sns" // ProviderNexmo uses Vonage/Nexmo API ProviderNexmo Provider = "nexmo" // ProviderMessageBird uses MessageBird API ProviderMessageBird Provider = "messagebird" )
type SendResult ¶
type SendResult struct {
MessageID string // Unique message identifier
SentAt time.Time // Time when SMS was sent
Provider Provider // Provider used to send the SMS
Status Status // Current message status
Cost float64 // Cost of sending (if available)
Segments int // Number of SMS segments used
}
SendResult contains the result of an SMS send operation
type Status ¶
type Status string
Status represents the status of an SMS message
const ( // StatusQueued indicates message is queued for sending StatusQueued Status = "queued" // StatusSending indicates message is being sent StatusSending Status = "sending" // StatusSent indicates message was sent successfully StatusSent Status = "sent" // StatusDelivered indicates message was delivered to recipient StatusDelivered Status = "delivered" // StatusFailed indicates message failed to send StatusFailed Status = "failed" // StatusUndelivered indicates message could not be delivered StatusUndelivered Status = "undelivered" )
type TwilioConfig ¶
type TwilioConfig struct {
AccountSID string // Twilio account SID
AuthToken string // Twilio auth token
FromNumber string // Sender phone number
}
TwilioConfig contains Twilio-specific configuration