smsgateway

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BASE_URL = "https://sms.capcom.me/api/3rdparty/v1"

Variables

View Source
var ErrConflictFields = errors.New("conflict fields")

Functions

This section is empty.

Types

type Client

type Client struct {
	Config Config
}

func NewClient

func NewClient(config Config) *Client

func (*Client) GetState

func (c *Client) GetState(ctx context.Context, messageID string) (MessageState, error)

func (*Client) Send

func (c *Client) Send(ctx context.Context, message Message) (MessageState, error)

type Config

type Config struct {
	Client   *http.Client
	BaseURL  string
	User     string
	Password string
}

type Device added in v1.6.0

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 HealthCheck added in v1.9.0

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 added in v1.9.0

type HealthChecks map[string]HealthCheck

Map of check names to their respective details.

type HealthResponse added in v1.9.0

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 added in v1.9.0

type HealthStatus string
const (
	HealthStatusPass HealthStatus = "pass"
	HealthStatusWarn HealthStatus = "warn"
	HealthStatusFail HealthStatus = "fail"
)

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)
	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

func (Message) Validate added in v1.5.3

func (m Message) Validate() error

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 added in v1.8.0

func (m MessageState) Validate() error

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 added in v1.8.0

type ProcessingState string
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 PushNotification added in v1.7.0

type PushNotification struct {
	Token string `json:"token" validate:"required" example:"PyDmBQZZXYmyxMwED8Fzy"` // Device FCM token
}

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 UpstreamPushRequest added in v1.7.0

type UpstreamPushRequest = []PushNotification

Push request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL