client

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package client provides a Twilio API client wrapper using the official twilio-go SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	SID        string
	AccountSID string
	To         string
	From       string
	Status     string
	Direction  string
	Duration   string
	StartTime  string
	EndTime    string
}

Call represents a Twilio call resource.

type Client

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

Client wraps the official Twilio SDK for internal use.

func New

func New(cfg *Config) (*Client, error)

New creates a new Twilio client using the official SDK.

func (*Client) AccountSID

func (c *Client) AccountSID() string

AccountSID returns the account SID.

func (*Client) GetCall

func (c *Client) GetCall(ctx context.Context, callSID string) (*Call, error)

GetCall retrieves a call by SID.

func (*Client) HangupCall

func (c *Client) HangupCall(ctx context.Context, callSID string) (*Call, error)

HangupCall ends a call.

func (*Client) ListPhoneNumbers

func (c *Client) ListPhoneNumbers(ctx context.Context) ([]PhoneNumber, error)

ListPhoneNumbers returns all phone numbers on the account.

func (*Client) MakeCall

func (c *Client) MakeCall(ctx context.Context, params *MakeCallParams) (*Call, error)

MakeCall initiates an outbound call.

func (*Client) RestClient

func (c *Client) RestClient() *twilio.RestClient

RestClient returns the underlying Twilio REST client.

func (*Client) SendSMS

func (c *Client) SendSMS(ctx context.Context, params *SendSMSParams) (*Message, error)

SendSMS sends an SMS message.

func (*Client) UpdateCall

func (c *Client) UpdateCall(ctx context.Context, callSID string, params *UpdateCallParams) (*Call, error)

UpdateCall modifies an in-progress call.

type Config

type Config struct {
	AccountSID string
	AuthToken  string //nolint:gosec // G117: field intentionally stores credential
}

Config configures the Twilio client.

type MakeCallParams

type MakeCallParams struct {
	To                  string
	From                string
	URL                 string            // TwiML URL
	Twiml               string            // Inline TwiML
	StatusCallback      string            // Webhook for status updates
	StatusCallbackEvent []string          // Events to receive
	MachineDetection    string            // "Enable" or "DetectMessageEnd"
	Timeout             int               // Ring timeout in seconds
	Record              bool              // Record the call
	RecordingChannels   string            // "mono" or "dual"
	CustomParameters    map[string]string // Custom parameters (unused with SDK)
}

MakeCallParams are parameters for making a call.

type Message

type Message struct {
	SID        string
	AccountSID string
	To         string
	From       string
	Body       string
	Status     string
	Direction  string
	DateSent   string
}

Message represents an SMS/MMS message.

type PhoneNumber

type PhoneNumber struct {
	SID          string
	PhoneNumber  string
	FriendlyName string
	VoiceCapable bool
	SMSCapable   bool
	MMSCapable   bool
}

PhoneNumber represents a Twilio phone number.

type SendSMSParams

type SendSMSParams struct {
	To   string
	From string
	Body string
}

SendSMSParams are parameters for sending an SMS.

type UpdateCallParams

type UpdateCallParams struct {
	URL    string // New TwiML URL
	Twiml  string // Inline TwiML
	Status string // "completed" to hang up, "canceled" to cancel
}

UpdateCallParams are parameters for updating a call.

Jump to

Keyboard shortcuts

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