Documentation
¶
Index ¶
- func EstimateCost(content string, smsType string) float64
- func FormatPhone(phone string) string
- type BaseProvider
- func (p *BaseProvider) CreateProviderError(code, message string, retryable bool) *ProviderError
- func (p *BaseProvider) GetName() string
- func (p *BaseProvider) GetTimeout() time.Duration
- func (p *BaseProvider) SetTimeout(timeout time.Duration)
- func (p *BaseProvider) ValidateBatchRequest(req *BatchSMSRequest) error
- func (p *BaseProvider) ValidateRequest(req *SendSMSRequest) error
- type BatchSMSRequest
- type BatchSMSResponse
- type BatchSMSResult
- type ProviderError
- type ProviderFactory
- type QuerySMSRequest
- type QuerySMSResponse
- type QuotaResponse
- type SMSProvider
- type SendSMSRequest
- type SendSMSResponse
- type SpaceIoTConfig
- type SpaceIoTProvider
- func (p *SpaceIoTProvider) GetQuota(ctx context.Context) (*QuotaResponse, error)
- func (p *SpaceIoTProvider) HealthCheck(ctx context.Context) error
- func (p *SpaceIoTProvider) QuerySMS(ctx context.Context, req *QuerySMSRequest) (*QuerySMSResponse, error)
- func (p *SpaceIoTProvider) SendBatchSMS(ctx context.Context, req *BatchSMSRequest) (*BatchSMSResponse, error)
- func (p *SpaceIoTProvider) SendSMS(ctx context.Context, req *SendSMSRequest) (*SendSMSResponse, error)
- func (p *SpaceIoTProvider) ValidateConfig() error
- type SpaceIoTQueryRequest
- type SpaceIoTQueryResponse
- type SpaceIoTQueryResultData
- type SpaceIoTSendRequest
- type SpaceIoTSendResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseProvider ¶
type BaseProvider struct {
// contains filtered or unexported fields
}
BaseProvider 基础提供商实现
func (*BaseProvider) CreateProviderError ¶
func (p *BaseProvider) CreateProviderError(code, message string, retryable bool) *ProviderError
CreateProviderError 创建提供商错误
func (*BaseProvider) GetTimeout ¶
func (p *BaseProvider) GetTimeout() time.Duration
GetTimeout 获取超时时间
func (*BaseProvider) SetTimeout ¶
func (p *BaseProvider) SetTimeout(timeout time.Duration)
SetTimeout 设置超时时间
func (*BaseProvider) ValidateBatchRequest ¶
func (p *BaseProvider) ValidateBatchRequest(req *BatchSMSRequest) error
ValidateBatchRequest 验证批量请求参数
func (*BaseProvider) ValidateRequest ¶
func (p *BaseProvider) ValidateRequest(req *SendSMSRequest) error
ValidateRequest 验证请求参数
type BatchSMSRequest ¶
type BatchSMSRequest struct { Requests []*SendSMSRequest `json:"requests"` // 短信请求列表 BatchID string `json:"batch_id"` // 批次ID }
BatchSMSRequest 批量发送短信请求
type BatchSMSResponse ¶
type BatchSMSResponse struct { BatchID string `json:"batch_id"` // 批次ID Total int `json:"total"` // 总数 Success int `json:"success"` // 成功数 Failed int `json:"failed"` // 失败数 Results []*BatchSMSResult `json:"results"` // 结果列表 StartedAt time.Time `json:"started_at"` // 开始时间 FinishedAt time.Time `json:"finished_at"` // 完成时间 Cost float64 `json:"cost"` // 总费用 }
BatchSMSResponse 批量发送短信响应
type BatchSMSResult ¶
type BatchSMSResult struct { Index int `json:"index"` // 索引 Phone string `json:"phone"` // 手机号 MessageID string `json:"message_id,omitempty"` // 消息ID ProviderID string `json:"provider_id,omitempty"` // 提供商消息ID Status string `json:"status"` // 状态 Cost float64 `json:"cost,omitempty"` // 费用 SentAt *time.Time `json:"sent_at,omitempty"` // 发送时间 ErrorCode string `json:"error_code,omitempty"` // 错误代码 ErrorMessage string `json:"error_message,omitempty"` // 错误消息 }
BatchSMSResult 批量发送结果
type ProviderError ¶
type ProviderError struct { Code string `json:"code"` // 错误代码 Message string `json:"message"` // 错误消息 Provider string `json:"provider"` // 提供商 Retryable bool `json:"retryable"` // 是否可重试 }
ProviderError 提供商错误
type ProviderFactory ¶
type ProviderFactory interface { // CreateProvider 创建提供商实例 CreateProvider(providerType string, config interface{}) (SMSProvider, error) // GetSupportedProviders 获取支持的提供商列表 GetSupportedProviders() []string // ValidateProviderConfig 验证提供商配置 ValidateProviderConfig(providerType string, config interface{}) error }
ProviderFactory 提供商工厂接口
type QuerySMSRequest ¶
type QuerySMSRequest struct { MessageID string `json:"message_id,omitempty"` // 消息ID ProviderID string `json:"provider_id,omitempty"` // 提供商消息ID Phone string `json:"phone,omitempty"` // 手机号 }
QuerySMSRequest 查询短信状态请求
type QuerySMSResponse ¶
type QuerySMSResponse struct { MessageID string `json:"message_id"` // 消息ID ProviderID string `json:"provider_id"` // 提供商消息ID Phone string `json:"phone"` // 手机号 Content string `json:"content"` // 短信内容 Status string `json:"status"` // 状态 SentAt *time.Time `json:"sent_at,omitempty"` // 发送时间 DeliveredAt *time.Time `json:"delivered_at,omitempty"` // 送达时间 FailedAt *time.Time `json:"failed_at,omitempty"` // 失败时间 ErrorCode string `json:"error_code,omitempty"` // 错误代码 ErrorMessage string `json:"error_message,omitempty"` // 错误消息 Cost float64 `json:"cost,omitempty"` // 费用 Metadata map[string]string `json:"metadata,omitempty"` // 元数据 }
QuerySMSResponse 查询短信状态响应
type QuotaResponse ¶
type QuotaResponse struct { Total int64 `json:"total"` // 总配额 Used int64 `json:"used"` // 已使用 Remaining int64 `json:"remaining"` // 剩余 ResetAt time.Time `json:"reset_at"` // 重置时间 }
QuotaResponse 配额响应
type SMSProvider ¶
type SMSProvider interface { // GetName 获取提供商名称 GetName() string // SendSMS 发送单条短信 SendSMS(ctx context.Context, req *SendSMSRequest) (*SendSMSResponse, error) // SendBatchSMS 批量发送短信 SendBatchSMS(ctx context.Context, req *BatchSMSRequest) (*BatchSMSResponse, error) // QuerySMS 查询短信状态 QuerySMS(ctx context.Context, req *QuerySMSRequest) (*QuerySMSResponse, error) // GetQuota 获取剩余配额 GetQuota(ctx context.Context) (*QuotaResponse, error) // ValidateConfig 验证配置 ValidateConfig() error // HealthCheck 健康检查 HealthCheck(ctx context.Context) error }
SMSProvider SMS提供商接口
type SendSMSRequest ¶
type SendSMSRequest struct { Phone string `json:"phone"` // 手机号 Content string `json:"content"` // 短信内容 Sign string `json:"sign,omitempty"` // 短信签名 Type string `json:"type,omitempty"` // 短信类型 Priority int `json:"priority,omitempty"` // 优先级 Scheduled *time.Time `json:"scheduled,omitempty"` // 定时发送时间 Metadata map[string]string `json:"metadata,omitempty"` // 元数据 MessageID string `json:"message_id"` // 消息ID }
SendSMSRequest 发送短信请求
type SendSMSResponse ¶
type SendSMSResponse struct { MessageID string `json:"message_id"` // 消息ID Status string `json:"status"` // 状态 ProviderID string `json:"provider_id"` // 提供商消息ID Cost float64 `json:"cost,omitempty"` // 费用 SentAt time.Time `json:"sent_at"` // 发送时间 DeliveredAt *time.Time `json:"delivered_at,omitempty"` // 送达时间 ErrorCode string `json:"error_code,omitempty"` // 错误代码 ErrorMessage string `json:"error_message,omitempty"` // 错误消息 Metadata map[string]string `json:"metadata,omitempty"` // 元数据 }
SendSMSResponse 发送短信响应
type SpaceIoTConfig ¶
type SpaceIoTConfig struct { BaseURL string `json:"base_url"` // API基础URL Sign string `json:"sign"` // 签名 Key string `json:"key"` // 密钥 Timeout time.Duration `json:"timeout"` // 超时时间 }
SpaceIoTConfig Space IoT配置
type SpaceIoTProvider ¶
type SpaceIoTProvider struct { *BaseProvider // contains filtered or unexported fields }
SpaceIoTProvider Space IoT SMS提供商实现
func NewSpaceIoTProvider ¶
func NewSpaceIoTProvider(config *SpaceIoTConfig) *SpaceIoTProvider
NewSpaceIoTProvider 创建Space IoT提供商实例
func (*SpaceIoTProvider) GetQuota ¶
func (p *SpaceIoTProvider) GetQuota(ctx context.Context) (*QuotaResponse, error)
GetQuota 获取剩余配额
func (*SpaceIoTProvider) HealthCheck ¶
func (p *SpaceIoTProvider) HealthCheck(ctx context.Context) error
HealthCheck 健康检查
func (*SpaceIoTProvider) QuerySMS ¶
func (p *SpaceIoTProvider) QuerySMS(ctx context.Context, req *QuerySMSRequest) (*QuerySMSResponse, error)
QuerySMS 查询短信状态
func (*SpaceIoTProvider) SendBatchSMS ¶
func (p *SpaceIoTProvider) SendBatchSMS(ctx context.Context, req *BatchSMSRequest) (*BatchSMSResponse, error)
SendBatchSMS 批量发送短信
func (*SpaceIoTProvider) SendSMS ¶
func (p *SpaceIoTProvider) SendSMS(ctx context.Context, req *SendSMSRequest) (*SendSMSResponse, error)
SendSMS 发送单条短信
func (*SpaceIoTProvider) ValidateConfig ¶
func (p *SpaceIoTProvider) ValidateConfig() error
ValidateConfig 验证配置
type SpaceIoTQueryRequest ¶
type SpaceIoTQueryRequest struct { AccountName string `json:"accountName"` // 账户名称 Phone string `json:"phone"` // 手机号 Timestamp string `json:"timestamp"` // 时间戳 RandomString string `json:"randomString"` // 随机字符串 Sign string `json:"sign"` // 签名 }
SpaceIoTQueryRequest Space IoT查询请求
type SpaceIoTQueryResponse ¶
type SpaceIoTQueryResponse struct { Code int `json:"code"` // 响应代码 Message string `json:"message"` // 响应消息 Data *SpaceIoTQueryResultData `json:"data"` // 响应数据 }
SpaceIoTQueryResponse Space IoT查询响应
type SpaceIoTQueryResultData ¶
type SpaceIoTQueryResultData struct { Status string `json:"status"` // 状态 SentAt string `json:"sentAt"` // 发送时间 DeliveredAt string `json:"deliveredAt"` // 送达时间 ErrorCode string `json:"errorCode"` // 错误代码 ErrorMsg string `json:"errorMsg"` // 错误消息 }
SpaceIoTQueryResultData Space IoT查询结果数据
type SpaceIoTSendRequest ¶
type SpaceIoTSendRequest struct { AccountName string `json:"accountName"` // 账户名称 Phone string `json:"phone"` // 手机号 Content string `json:"content"` // 短信内容 Timestamp string `json:"timestamp"` // 时间戳 RandomString string `json:"randomString"` // 随机字符串 Sign string `json:"sign"` // 签名 }
SpaceIoTSendRequest Space IoT发送请求
type SpaceIoTSendResponse ¶
type SpaceIoTSendResponse struct { Code int `json:"code"` // 响应代码 Message string `json:"message"` // 响应消息 Data bool `json:"data"` // 响应数据 }
SpaceIoTSendResponse Space IoT发送响应