twilio

package
v0.0.0-...-cbc9d59 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientSingleton

func ClientSingleton(conf *Config) (singleton.Singleton[Client, Config], error)

Types

type ApiKeyConfig

type ApiKeyConfig struct {
	AccountSid string `json:"account_sid" yaml:"account_sid" toml:"AccountSid"`
	ApiKey     string `json:"key" yaml:"key" toml:"Key"`
	ApiSecret  string `json:"secret" yaml:"secret" toml:"Secret"`
}

func (ApiKeyConfig) Account

func (c ApiKeyConfig) Account() string

func (ApiKeyConfig) Key

func (c ApiKeyConfig) Key() string

func (ApiKeyConfig) Secret

func (c ApiKeyConfig) Secret() string

type AuthConfig

type AuthConfig struct {
	AuthToken *AuthTokenConfig `json:"auth_token,omitempty" yaml:"auth_token,omitempty" toml:"AuthToken,omitempty"`
	ApiKey    *ApiKeyConfig    `json:"api_key,omitempty" yaml:"api_key,omitempty" toml:"ApiKey,omitempty"`
}

type AuthTokenConfig

type AuthTokenConfig struct {
	AccountSid string `json:"account_sid" yaml:"account_sid" toml:"AccountSid"`
	Token      string `json:"token" yaml:"token" toml:"Token"`
}

func (AuthTokenConfig) Account

func (c AuthTokenConfig) Account() string

func (AuthTokenConfig) Key

func (c AuthTokenConfig) Key() string

func (AuthTokenConfig) Secret

func (c AuthTokenConfig) Secret() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (*Client, error)

func NewClientFromConfig

func NewClientFromConfig(conf Config) (*Client, error)

func (*Client) Message

func (c *Client) Message(ctx context.Context, msgSid string) (*openapi.ApiV2010Message, error)

func (*Client) MessageStatus

func (c *Client) MessageStatus(ctx context.Context, msgSid string) (MessageSendStatus, error)

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, msg messages.Message, recipient string) (SendSMSResponse, error)

type Config

type Config struct {
	Auth            *AuthConfig `json:"auth,omitempty" yaml:"auth,omitempty" toml:"Auth,omitempty"`
	SenderNumber    string      `json:"sender_number" yaml:"sender_number" toml:"SenderNumber"`
	RecipientNumber string      `json:"recipient_number" yaml:"recipient_number" toml:"RecipientNumber"`
}

func LoadConfig

func LoadConfig(confPath string) (conf Config, err error)

LoadConfig reads configuration data from the file at the passed path and returns it as a fully loaded Config. `confPath` is expected to be an absolute file path. Supported file types: json, yaml, toml

type MessageSendStatus

type MessageSendStatus string
const (
	StatusQueued      MessageSendStatus = "queued"
	StatusFailed      MessageSendStatus = "failed"
	StatusSent        MessageSendStatus = "sent"
	StatusDelivered   MessageSendStatus = "delivered"
	StatusUndelivered MessageSendStatus = "undelivered"
)

type SendSMSResponse

type SendSMSResponse struct {
	TimeSent      time.Time
	MessageSid    string
	MessageStatus MessageSendStatus
	MessageError  string
	Success       bool
}

Jump to

Keyboard shortcuts

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