httpsms package - github.com/NdoleStudio/httpsms-go - Go Packages

View Source

const EventTypeMessageCallMissed = "message.call.missed"

EventTypeMessageCallMissed is emitted when a new message is sent

View Source

const EventTypeMessagePhoneDelivered = "message.phone.delivered"

EventTypeMessagePhoneDelivered is emitted when the phone delivers a message

View Source

const EventTypeMessagePhoneReceived = "message.phone.received"

EventTypeMessagePhoneReceived is emitted when a new message is received by a mobile phone

View Source

const EventTypeMessagePhoneSent = "message.phone.sent"

EventTypeMessagePhoneSent is emitted when the phone sends a message

View Source

const EventTypeMessageSendExpired = "message.send.expired"

EventTypeMessageSendExpired is emitted when the phone a message expires

View Source

const EventTypeMessageSendFailed = "message.send.failed"

EventTypeMessageSendFailed is emitted when the phone could not send

View Source

const EventTypePhoneHeartbeatOffline = "phone.heartbeat.offline"

EventTypePhoneHeartbeatOffline is emitted when the phone is missing a heartbeat

View Source

const EventTypePhoneHeartbeatOnline = "phone.heartbeat.online"

EventTypePhoneHeartbeatOnline is emitted when the phone is missing a heartbeat

This section is empty.

This section is empty.

type ApiResponse[T any] struct {
	Data    T      `json:"data"`
	Message string `json:"message"`
	Status  string `json:"status"`
}
type CipherService service

CipherService is used to encrypt and decrypt SMS messages using the AES-256 algorithm

Decrypt the message content using the encryption key

Encrypt the message content using the encryption key

type Client struct {
	MessageThreads *MessageThreadService
	Heartbeats     *HeartbeatService
	Messages       *MessageService
	Cipher         *CipherService
	
}

Client is the campay API client. Do not instantiate this client with Client{}. Use the New method instead.

func New(options ...Option) *Client

New creates and returns a new campay.Client from a slice of campay.ClientOption.

type Heartbeat struct {
	ID        uuid.UUID `json:"id" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
	Owner     string    `json:"owner" gorm:"index:idx_heartbeats_owner_timestamp" example:"+18005550199"`
	UserID    string    `json:"user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
	Charging  bool      `json:"charging" example:"true"`
	Timestamp time.Time `json:"timestamp" example:"2022-06-05T14:26:01.520828+03:00"`
}

Heartbeat represents is a pulse from an active phone

type HeartbeatIndexParams struct {
	Skip  int     `json:"skip"`
	Owner string  `json:"owner"`
	Query *string `json:"query"`
	Limit int     `json:"limit"`
}

HeartbeatIndexParams is the payload for fetching entities.Heartbeat of a phone number

type HeartbeatService service

HeartbeatService is the API client for the `/heartbeats` endpoint

type HeartbeatsResponse ApiResponse[[]Heartbeat]

HeartbeatsResponse is the response gotten with a message content

type Message struct {
	ID        uuid.UUID `json:"id" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
	RequestID *string   `json:"request_id" example:"153554b5-ae44-44a0-8f4f-7bbac5657ad4"`
	Owner     string    `json:"owner" example:"+18005550199"`
	UserID    string    `json:"user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
	Contact   string    `json:"contact" example:"+18005550100"`
	Content   string    `json:"content" example:"This is a sample text message"`
	Type      string    `json:"type" example:"mobile-terminated"`
	Status    string    `json:"status" example:"pending"`
	Encrypted bool      `json:"encrypted" example:"false"`

	
	
	
	SIM string `json:"sim" example:"SIM1"`

	
	SendDuration *int64 `json:"send_time" example:"133414"`

	RequestReceivedAt       time.Time  `json:"request_received_at" example:"2022-06-05T14:26:01.520828+03:00"`
	CreatedAt               time.Time  `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
	UpdatedAt               time.Time  `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`
	OrderTimestamp          time.Time  `json:"order_timestamp" gorm:"index:idx_messages_order_timestamp" example:"2022-06-05T14:26:09.527976+03:00"`
	LastAttemptedAt         *time.Time `json:"last_attempted_at" example:"2022-06-05T14:26:09.527976+03:00"`
	NotificationScheduledAt *time.Time `json:"scheduled_at" example:"2022-06-05T14:26:09.527976+03:00"`
	SentAt                  *time.Time `json:"sent_at" example:"2022-06-05T14:26:09.527976+03:00"`
	DeliveredAt             *time.Time `json:"delivered_at" example:"2022-06-05T14:26:09.527976+03:00"`
	ExpiredAt               *time.Time `json:"expired_at" example:"2022-06-05T14:26:09.527976+03:00"`
	FailedAt                *time.Time `json:"failed_at" example:"2022-06-05T14:26:09.527976+03:00"`
	CanBePolled             bool       `json:"can_be_polled" example:"false"`
	SendAttemptCount        uint       `json:"send_attempt_count" example:"0"`
	MaxSendAttempts         uint       `json:"max_send_attempts" example:"1"`
	ReceivedAt              *time.Time `json:"received_at" example:"2022-06-05T14:26:09.527976+03:00"`
	FailureReason           *string    `json:"failure_reason" example:"UNKNOWN"`
}

Message represents and incoming or outgoing SMS message

type MessageIndexParams struct {
	Skip    int     `json:"skip"`
	Contact string  `json:"contact"`
	Owner   string  `json:"owner"`
	Query   *string `json:"query"`
	Limit   int     `json:"limit"`
}

MessageIndexParams is the payload fetching entities.Message sent between 2 numbers

type MessageResponse ApiResponse[Message]

MessageResponse is the response gotten with a message content

type MessageSendParams struct {
	Content   string `json:"content"`
	From      string `json:"from"`
	Encrypted bool   `json:"encrypted"`
	RequestID string `json:"request_id,omitempty"`
	To        string `json:"to"`
}

MessageSendParams is the request payload for sending a message

type MessageService service

MessageService is the API client for the `/` endpoint

type MessageThread struct {
	ID                 uuid.UUID `json:"id" example:"32343a19-da5e-4b1b-a767-3298a73703ca"`
	Owner              string    `json:"owner" example:"+18005550199"`
	Contact            string    `json:"contact" example:"+18005550100"`
	IsArchived         bool      `json:"is_archived" example:"false"`
	UserID             string    `json:"user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
	Color              string    `json:"color" example:"indigo"`
	Status             string    `json:"status" example:"pending"`
	LastMessageContent string    `json:"last_message_content" example:"This is a sample message content"`
	LastMessageID      uuid.UUID `json:"last_message_id" example:"32343a19-da5e-4b1b-a767-3298a73703ca"`
	CreatedAt          time.Time `json:"created_at" example:"2022-06-05T14:26:09.527976+03:00"`
	UpdatedAt          time.Time `json:"updated_at" example:"2022-06-05T14:26:09.527976+03:00"`
	OrderTimestamp     time.Time `json:"order_timestamp"  example:"2022-06-05T14:26:09.527976+03:00"`
}

MessageThread represents a message thread between 2 phone numbers

type MessageThreadIndexParams struct {
	IsArchived bool    `json:"is_archived"`
	Skip       int     `json:"skip"`
	Query      *string `json:"query"`
	Limit      int     `json:"limit"`
	Owner      string  `json:"owner"`
}

MessageThreadIndexParams is the payload fetching entities.MessageThread sent between 2 numbers

type MessageThreadService service

MessageThreadService is the API client for the `/message-threads` endpoint

type MessageThreadsResponse ApiResponse[[]MessageThread]

MessageThreadsResponse is the response gotten with a message content

type MessagesResponse ApiResponse[[]Message]

MessagesResponse is the response with multiple messages

type Option interface {
	
}

Option is options for constructing a client

WithAPIKey sets the api key for the httpsms API

func WithBaseURL(baseURL string) Option

WithBaseURL sets the base url for the httpsms API

WithHTTPClient sets the underlying HTTP client used for API requests. By default, http.DefaultClient is used.

Response captures the http response

Error ensures that the response can be decoded into a string inc ase it's an error response