package queue import "time" const SchemaVersion = "v1" type MessageType string const ( MessageTypeSubmitCommand MessageType = "SubmitCommand" MessageTypeSubmitResult MessageType = "SubmitResult" MessageTypeReceiptEvent MessageType = "ReceiptEvent" MessageTypeUplinkEvent MessageType = "UplinkEvent" MessageTypeConnectChannel MessageType = "ConnectChannel" MessageTypeDisconnectChannel MessageType = "DisconnectChannel" ) type Envelope struct { SchemaVersion string `json:"schemaVersion"` MessageType MessageType `json:"messageType"` TraceID string `json:"traceId"` MessageID string `json:"messageId"` ChannelID string `json:"channelId"` CreatedAt time.Time `json:"createdAt"` } type SubmitCommand struct { Envelope TenantID string `json:"tenantId"` ApplicationID string `json:"applicationId"` TaskID string `json:"taskId,omitempty"` SubmitID string `json:"submitId"` PhoneNumber string `json:"phoneNumber"` Content string `json:"content"` Signature string `json:"signature"` TemplateID string `json:"templateId"` BillingUnits int `json:"billingUnits"` QueuePriority string `json:"queuePriority"` Route Route `json:"route"` CMPP CMPP `json:"cmpp"` Upstream UpstreamConfig `json:"upstream"` Retry Retry `json:"retry"` } type Route struct { ChannelCode string `json:"channelCode"` CMPPAccountCode string `json:"cmppAccountCode"` Priority int `json:"priority"` RateLimitPerSecond int `json:"rateLimitPerSecond,omitempty"` } type CMPP struct { ServiceID string `json:"serviceId"` SrcID string `json:"srcId"` ExtensionDigits int `json:"extensionDigits"` RegisteredDelivery int `json:"registeredDelivery"` MsgFmt int `json:"msgFmt"` FeeUserType int `json:"feeUserType,omitempty"` FeeCode string `json:"feeCode,omitempty"` FeeType string `json:"feeType,omitempty"` } type UpstreamConfig struct { GatewayHost string `json:"gatewayHost"` GatewayPort int `json:"gatewayPort"` Account string `json:"account"` PasswordCipher string `json:"passwordCipher"` CMPPVersion string `json:"cmppVersion"` DesiredConnections int `json:"desiredConnections,omitempty"` WindowSize int `json:"windowSize,omitempty"` HeartbeatIntervalSeconds int `json:"heartbeatIntervalSeconds,omitempty"` HeartbeatMissThreshold int `json:"heartbeatMissThreshold,omitempty"` } type Retry struct { Attempt int `json:"attempt"` MaxAttempts int `json:"maxAttempts"` } type SubmitResult struct { Envelope SequenceID uint32 `json:"sequenceId"` GatewayMessageID string `json:"gatewayMessageId"` SubmitStatus string `json:"submitStatus"` ErrorCode string `json:"errorCode,omitempty"` ErrorMessage string `json:"errorMessage,omitempty"` SubmittedAt time.Time `json:"submittedAt"` Segments []SubmitSegmentResult `json:"segments,omitempty"` } type SubmitSegmentResult struct { SegmentTotal int `json:"segmentTotal"` SegmentIndex int `json:"segmentIndex"` SequenceID uint32 `json:"sequenceId"` GatewayMessageID string `json:"gatewayMessageId"` SubmitStatus string `json:"submitStatus"` ErrorCode string `json:"errorCode,omitempty"` ErrorMessage string `json:"errorMessage,omitempty"` SubmittedAt time.Time `json:"submittedAt"` } type ReceiptEvent struct { Envelope SequenceID uint32 `json:"sequenceId"` GatewayMessageID string `json:"gatewayMessageId"` PhoneNumber string `json:"phoneNumber,omitempty"` ReceiptStatus string `json:"receiptStatus"` RawStatus string `json:"rawStatus"` ErrorCode string `json:"errorCode,omitempty"` DeliveredAt time.Time `json:"deliveredAt"` ConnectionID string `json:"connectionId,omitempty"` } type UplinkEvent struct { Envelope SequenceID uint32 `json:"sequenceId"` PhoneNumber string `json:"phoneNumber"` DestID string `json:"destId"` Content string `json:"content"` ReceivedAt time.Time `json:"receivedAt"` } type ConnectChannelCommand struct { SchemaVersion string `json:"schemaVersion"` MessageType MessageType `json:"messageType"` TraceID string `json:"traceId"` ChannelID string `json:"channelId"` ConnectionID string `json:"connectionId"` CreatedAt time.Time `json:"createdAt"` Reason string `json:"reason"` DesiredConnections int `json:"desiredConnections"` Channel ConnectChannelConfig `json:"channel"` } type ConnectChannelConfig struct { Code string `json:"code"` Name string `json:"name"` GatewayHost string `json:"gatewayHost"` GatewayPort int `json:"gatewayPort"` Account string `json:"account"` PasswordCipher string `json:"passwordCipher"` SrcID string `json:"srcId"` CMPPVersion string `json:"cmppVersion"` RateLimitPerSecond int `json:"rateLimitPerSecond"` WindowSize int `json:"windowSize,omitempty"` HeartbeatIntervalSeconds int `json:"heartbeatIntervalSeconds,omitempty"` HeartbeatMissThreshold int `json:"heartbeatMissThreshold,omitempty"` } type DisconnectChannelCommand struct { SchemaVersion string `json:"schemaVersion"` MessageType MessageType `json:"messageType"` TraceID string `json:"traceId"` ChannelID string `json:"channelId"` ConnectionID string `json:"connectionId"` CreatedAt time.Time `json:"createdAt"` Reason string `json:"reason"` }