Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidWebhookEvent(e WebhookEvent) bool
- type Client
- type Config
- type Device
- type ErrorResponse
- type GetLogsResponse
- type HealthCheck
- type HealthChecks
- type HealthResponse
- type HealthStatus
- type LogEntry
- type LogEntryPriority
- type Message
- type MessageState
- type MessagesExportRequest
- type MobileChangePasswordRequest
- type MobileDeviceResponse
- type MobileRegisterRequest
- type MobileRegisterResponse
- type MobileUpdateRequest
- type ProcessingState
- type PushEventType
- type PushNotification
- type RecipientState
- type UpstreamPushRequest
- type Webhook
- type WebhookEvent
Constants ¶
View Source
const BASE_URL = "https://api.sms-gate.app/3rdparty/v1"
Variables ¶
View Source
var ErrConflictFields = errors.New("conflict fields")
Functions ¶
func IsValidWebhookEvent ¶ added in v1.1.0
func IsValidWebhookEvent(e WebhookEvent) bool
IsValid checks if the given event type is valid.
e is the event type to be checked. Returns true if the event type is valid, false otherwise.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
type Device ¶
type Device struct { ID string `json:"id" example:"PyDmBQZZXYmyxMwED8Fzy"` // ID Name string `json:"name" example:"My Device"` // Name CreatedAt time.Time `json:"createdAt" example:"2020-01-01T00:00:00Z"` // Created at (read only) UpdatedAt time.Time `json:"updatedAt" example:"2020-01-01T00:00:00Z"` // Updated at (read only) DeletedAt *time.Time `json:"deletedAt,omitempty" example:"2020-01-01T00:00:00Z"` // Deleted at (read only) LastSeen time.Time `json:"lastSeen" example:"2020-01-01T00:00:00Z"` // Last seen at (read only) }
Device
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message" example:"An error occurred"` // Error message Code int32 `json:"code,omitempty"` // Error code Data any `json:"data,omitempty"` // Error context }
Error response
type GetLogsResponse ¶ added in v1.0.2
type GetLogsResponse []LogEntry
type HealthCheck ¶
type HealthCheck struct { // A human-readable description of the check. Description string `json:"description,omitempty"` // Unit of measurement for the observed value. ObservedUnit string `json:"observedUnit,omitempty"` // Observed value of the check. ObservedValue int `json:"observedValue"` // Status of the check. // It can be one of the following values: "pass", "warn", or "fail". Status HealthStatus `json:"status"` }
Details of a health check.
type HealthChecks ¶
type HealthChecks map[string]HealthCheck
Map of check names to their respective details.
type HealthResponse ¶
type HealthResponse struct { // Overall status of the application. // It can be one of the following values: "pass", "warn", or "fail". Status HealthStatus `json:"status"` // Version of the application. Version string `json:"version,omitempty"` // Release ID of the application. // It is used to identify the version of the application. ReleaseID int `json:"releaseId,omitempty"` // A map of check names to their respective details. Checks HealthChecks `json:"checks,omitempty"` }
Health status of the application.
type HealthStatus ¶
type HealthStatus string
const ( HealthStatusPass HealthStatus = "pass" HealthStatusWarn HealthStatus = "warn" HealthStatusFail HealthStatus = "fail" )
type LogEntry ¶ added in v1.0.2
type LogEntry struct { ID uint64 `json:"id"` // A unique identifier for the log entry. Priority LogEntryPriority `json:"priority"` // The priority level of the log entry. Module string `json:"module"` // The module or component of the system that generated the log entry. Message string `json:"message"` // A message describing the log event. Context map[string]string `json:"context"` // Additional context information related to the log entry, typically including data relevant to the log event. CreatedAt time.Time `json:"createdAt"` // The timestamp when this log entry was created. }
LogEntry represents a log entry
type LogEntryPriority ¶ added in v1.0.2
type LogEntryPriority string
const ( LogEntryPriorityDebug LogEntryPriority = "DEBUG" LogEntryPriorityInfo LogEntryPriority = "INFO" LogEntryPriorityWarn LogEntryPriority = "WARN" LogEntryPriorityError LogEntryPriority = "ERROR" )
type Message ¶
type Message struct { ID string `json:"id,omitempty" validate:"omitempty,max=36" example:"PyDmBQZZXYmyxMwED8Fzy"` // ID (if not set - will be generated) Message string `json:"message" validate:"required,max=65535" example:"Hello World!"` // Content SimNumber *uint8 `json:"simNumber,omitempty" validate:"omitempty,max=3" example:"1"` // SIM card number (1-3), if not set - default SIM will be used WithDeliveryReport *bool `json:"withDeliveryReport,omitempty" example:"true"` // With delivery report IsEncrypted bool `json:"isEncrypted,omitempty" example:"true"` // Is encrypted PhoneNumbers []string `json:"phoneNumbers" validate:"required,min=1,max=100,dive,required,min=10,max=128" example:"79990001234"` // Recipients (phone numbers) TTL *uint64 `json:"ttl,omitempty" validate:"omitempty,min=5" example:"86400"` // Time to live in seconds (conflicts with `validUntil`) ValidUntil *time.Time `json:"validUntil,omitempty" example:"2020-01-01T00:00:00Z"` // Valid until (conflicts with `ttl`) }
Message
type MessageState ¶
type MessageState struct { ID string `json:"id,omitempty" validate:"omitempty,max=36" example:"PyDmBQZZXYmyxMwED8Fzy"` // Message ID State ProcessingState `json:"state" validate:"required" example:"Pending"` // State IsHashed bool `json:"isHashed" example:"false"` // Hashed IsEncrypted bool `json:"isEncrypted" example:"false"` // Encrypted Recipients []RecipientState `json:"recipients" validate:"required,min=1,dive"` // Recipients states States map[string]time.Time `json:"states"` // History of states }
Message state
func (MessageState) Validate ¶
func (m MessageState) Validate() error
type MessagesExportRequest ¶ added in v1.3.0
type MessagesExportRequest struct { // DeviceID is the ID of the device to export messages for. DeviceID string `json:"deviceId" example:"PyDmBQZZXYmyxMwED8Fzy" validate:"required,max=21"` // Since is the start of the time range to export. Since time.Time `json:"since" example:"2024-01-01T00:00:00Z" validate:"required,ltefield=Until"` // Until is the end of the time range to export. Until time.Time `json:"until" example:"2024-01-01T23:59:59Z" validate:"required,gtefield=Since"` }
Messages export request
type MobileChangePasswordRequest ¶ added in v1.2.0
type MobileChangePasswordRequest struct { CurrentPassword string `json:"currentPassword" validate:"required" example:"cp2pydvxd2zwpx"` // Current password NewPassword string `json:"newPassword" validate:"required,min=14" example:"cp2pydvxd2zwpx"` // New password, at least 14 characters }
Device change password request
type MobileDeviceResponse ¶ added in v1.1.0
type MobileDeviceResponse struct { Device *Device `json:"device,omitempty"` // Device information, empty if device is not registered on the server ExternalIP string `json:"externalIp,omitempty"` // External IP }
Device self-information response
type MobileRegisterRequest ¶
type MobileRegisterRequest struct { Name *string `json:"name,omitempty" validate:"omitempty,max=128" example:"Android Phone"` // Device name PushToken *string `json:"pushToken" validate:"omitempty,max=256" example:"gHz-T6NezDlOfllr7F-Be"` // FCM token }
Device registration request
type MobileRegisterResponse ¶
type MobileRegisterResponse struct { Id string `json:"id" example:"QslD_GefqiYV6RQXdkM6V"` // New device ID Token string `json:"token" example:"bP0ZdK6rC6hCYZSjzmqhQ"` // Device access token Login string `json:"login" example:"VQ4GII"` // User login Password string `json:"password" example:"cp2pydvxd2zwpx"` // User password }
Device registration response
type MobileUpdateRequest ¶
type MobileUpdateRequest struct { Id string `json:"id" example:"QslD_GefqiYV6RQXdkM6V"` // ID PushToken string `json:"pushToken" validate:"omitempty,max=256" example:"gHz-T6NezDlOfllr7F-Be"` // FCM token }
Device update request
type ProcessingState ¶
type ProcessingState string
Processing state
const ( ProcessingStatePending ProcessingState = "Pending" // Pending ProcessingStateProcessed ProcessingState = "Processed" // Processed (received by device) ProcessingStateSent ProcessingState = "Sent" // Sent ProcessingStateDelivered ProcessingState = "Delivered" // Delivered ProcessingStateFailed ProcessingState = "Failed" // Failed )
type PushEventType ¶ added in v1.0.1
type PushEventType string
The type of event.
const ( // A message is enqueued. PushMessageEnqueued PushEventType = "MessageEnqueued" // Webhooks are updated. PushWebhooksUpdated PushEventType = "WebhooksUpdated" // Messages export is requested. PushMessagesExportRequested PushEventType = "MessagesExportRequested" )
type PushNotification ¶
type PushNotification struct { // The token of the device that receives the notification. Token string `json:"token" validate:"required" example:"PyDmBQZZXYmyxMwED8Fzy"` // The type of event. Event PushEventType `` /* 147-byte string literal not displayed */ // The additional data associated with the event. Data map[string]string `json:"data"` }
A push notification.
type RecipientState ¶
type RecipientState struct { PhoneNumber string `json:"phoneNumber" validate:"required,min=10,max=128" example:"79990001234"` // Phone number or first 16 symbols of SHA256 hash State ProcessingState `json:"state" validate:"required" example:"Pending"` // State Error *string `json:"error,omitempty" example:"timeout"` // Error (for `Failed` state) }
Recipient state
type Webhook ¶ added in v1.0.1
type Webhook struct { // The unique identifier of the webhook. ID string `json:"id" validate:"max=36" example:"123e4567-e89b-12d3-a456-426614174000"` // The URL the webhook will be sent to. URL string `json:"url" validate:"required,http_url" example:"https://example.com/webhook"` // The type of event the webhook is triggered for. Event WebhookEvent `json:"event" validate:"required" example:"sms:received"` }
A webhook configuration.
type WebhookEvent ¶ added in v1.0.1
type WebhookEvent = string
const ( // Triggered when an SMS is received. WebhookEventSmsReceived WebhookEvent = "sms:received" // Triggered when an SMS is sent. WebhookEventSmsSent WebhookEvent = "sms:sent" // Triggered when an SMS is delivered. WebhookEventSmsDelivered WebhookEvent = "sms:delivered" // Triggered when an SMS processing fails. WebhookEventSmsFailed WebhookEvent = "sms:failed" // Triggered when the device pings the server. WebhookEventSystemPing WebhookEvent = "system:ping" )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.