telnyx

package module
v0.0.0-...-033f940 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExpectedCreateNumberOrderPayload = `{"phone_numbers":[{"phone_number":"+19705555098"}]}`
View Source
var ExpectedSendMessagePayload = `{"to":"+18665550001","from":"+18445550001","text":"Hello, World!"}`
View Source
var FakeErrorResponse = `` /* 261-byte string literal not displayed */
View Source
var FakeMessagingProfileResponse = `` /* 802-byte string literal not displayed */
View Source
var FakeNumberOrderResponse = `` /* 812-byte string literal not displayed */
View Source
var FakeNumberSearchResponse = `` /* 551-byte string literal not displayed */
View Source
var FakeSendMessageResponse = `` /* 1247-byte string literal not displayed */

Functions

This section is empty.

Types

type Account

type Account struct {
	DefaultEndpoint string
	// contains filtered or unexported fields
}

Account is main API object

func New

func New(opts Opts) (*Account, error)

New creates new instances of api It returns Account instance. Use it to make API calls.

func (*Account) CreateMessagingProfile

func (a *Account) CreateMessagingProfile(ctx context.Context, params *MessagingProfileParameters) (string, error)

CreateMessagingProfile creates the Messaging Profile and returns its ID.

func (*Account) CreateNumberOrder

func (a *Account) CreateNumberOrder(ctx context.Context, numberOrderParams *NumberOrderParameters) (*NumberOrderResponse, error)

CreateNumberOrder creates a phone number order.

func (*Account) CreateRequest

func (a *Account) CreateRequest(ctx context.Context, method, path string) (*http.Request, error)

func (*Account) NumberSearch

func (a *Account) NumberSearch(ctx context.Context, searchOpts *NumberSearchOptions) (*NumberSearchResponseList, error)

NumberSearch returns a response of available phone numbers.

func (*Account) RetreiveNumberOrder

func (a *Account) RetreiveNumberOrder(ctx context.Context, retreiveNumberOrderParams *RetreiveNumberOrderParameters) (*NumberOrderResponse, error)

RetreiveNumberOrder creates a phone number order.

func (*Account) SendMessage

func (a *Account) SendMessage(ctx context.Context, params *SendMessageParameters) (*SendMessageResponse, error)

SendMessage allows you to send a message with any messaging resource. Current messaging resources include: long-code, short-code, number-pool, and alphanumeric-sender-id.

func (*Account) TollFreeNumberSearch

func (a *Account) TollFreeNumberSearch(ctx context.Context, searchOpts *NumberSearchOptions) (*NumberSearchResponseList, error)

type DeliveryUpdateWebhook

type DeliveryUpdateWebhook struct {
	Data DeliveryUpdateWebhookData `json:"data"`
	Meta DeliveryUpdateWebhookMeta `json:"meta"`
}

type DeliveryUpdateWebhookData

type DeliveryUpdateWebhookData struct {
	EventType  string                       `json:"event_type"`
	ID         string                       `json:"id"`
	OccurredAt string                       `json:"occurred_at"`
	Payload    DeliveryUpdateWebhookPayload `json:"payload"`
	RecordType string                       `json:"record_type"`
}

type DeliveryUpdateWebhookFrom

type DeliveryUpdateWebhookFrom struct {
	Carrier     string `json:"carrier"`
	LineType    string `json:"line_type"`
	PhoneNumber string `json:"phone_number"`
}

Webhook Structs

type DeliveryUpdateWebhookMedia

type DeliveryUpdateWebhookMedia struct {
	ContentType interface{} `json:"content_type"`
	Sha256      interface{} `json:"sha256"`
	Size        interface{} `json:"size"`
	URL         string      `json:"url"`
}

type DeliveryUpdateWebhookMeta

type DeliveryUpdateWebhookMeta struct {
	Attempt     int    `json:"attempt"`
	DeliveredTo string `json:"delivered_to"`
}

type DeliveryUpdateWebhookPayload

type DeliveryUpdateWebhookPayload struct {
	CompletedAt        interface{}                  `json:"completed_at"`
	Cost               interface{}                  `json:"cost"`
	Direction          string                       `json:"direction"`
	Encoding           string                       `json:"encoding"`
	Errors             []interface{}                `json:"errors"`
	From               DeliveryUpdateWebhookFrom    `json:"from"`
	ID                 string                       `json:"id"`
	Media              []DeliveryUpdateWebhookMedia `json:"media"`
	MessagingProfileID string                       `json:"messaging_profile_id"`
	OrganizationID     string                       `json:"organization_id"`
	Parts              int                          `json:"parts"`
	ReceivedAt         time.Time                    `json:"received_at"`
	RecordType         string                       `json:"record_type"`
	SentAt             interface{}                  `json:"sent_at"`
	Subject            string                       `json:"subject"`
	Tags               []string                     `json:"tags"`
	Text               string                       `json:"text"`
	To                 []DeliveryUpdateWebhookTo    `json:"to"`
	Type               string                       `json:"type"`
	ValidUntil         interface{}                  `json:"valid_until"`
	WebhookFailoverURL string                       `json:"webhook_failover_url"`
	WebhookURL         string                       `json:"webhook_url"`
}

type DeliveryUpdateWebhookTo

type DeliveryUpdateWebhookTo struct {
	Carrier     string `json:"carrier"`
	LineType    string `json:"line_type"`
	PhoneNumber string `json:"phone_number"`
	Status      string `json:"status"`
}

type InboundMessageWebhook

type InboundMessageWebhook struct {
	Data InboundMessageWebhookData `json:"data"`
}

type InboundMessageWebhookData

type InboundMessageWebhookData struct {
	EventType  string                       `json:"event_type"`
	ID         string                       `json:"id"`
	OccurredAt string                       `json:"occurred_at"`
	Payload    InboundMessageWebhookPayload `json:"payload"`
	RecordType string                       `json:"record_type"`
}

type InboundMessageWebhookPayload

type InboundMessageWebhookPayload struct {
	CompletedAt        interface{}                      `json:"completed_at"`
	Cost               interface{}                      `json:"cost"`
	Direction          string                           `json:"direction"`
	Encoding           string                           `json:"encoding"`
	Errors             []interface{}                    `json:"errors"`
	From               InboundMessageWebhookToAndFrom   `json:"from"`
	ID                 string                           `json:"id"`
	Media              []interface{}                    `json:"media"`
	MessagingProfileID string                           `json:"messaging_profile_id"`
	OrganizationID     string                           `json:"organization_id"`
	Parts              int                              `json:"parts"`
	ReceivedAt         time.Time                        `json:"received_at"`
	RecordType         string                           `json:"record_type"`
	SentAt             interface{}                      `json:"sent_at"`
	Subject            string                           `json:"subject"`
	Tags               []string                         `json:"tags"`
	Text               string                           `json:"text"`
	To                 []InboundMessageWebhookToAndFrom `json:"to"`
	Type               string                           `json:"type"`
	ValidUntil         interface{}                      `json:"valid_until"`
	WebhookFailoverURL string                           `json:"webhook_failover_url"`
	WebhookURL         string                           `json:"webhook_url"`
}

type InboundMessageWebhookToAndFrom

type InboundMessageWebhookToAndFrom struct {
	Carrier     string `json:"carrier"`
	LineType    string `json:"line_type"`
	PhoneNumber string `json:"phone_number"`
	Status      string `json:"status"`
}

type MessagingProfileData

type MessagingProfileData struct {
	CreatedAt               time.Time                  `json:"created_at"`
	Enabled                 bool                       `json:"enabled"`
	ID                      string                     `json:"id"`
	Name                    string                     `json:"name"`
	NumberPoolSettings      NumberPoolSettingsResponse `json:"number_pool_settings"`
	RecordType              string                     `json:"record_type"`
	UpdatedAt               time.Time                  `json:"updated_at"`
	URLShortenerSettings    URLShortenerSettings       `json:"url_shortener_settings"`
	V1Secret                string                     `json:"v1_secret"`
	WebhookAPIVersion       string                     `json:"webhook_api_version"`
	WebhookFailoverURL      string                     `json:"webhook_failover_url"`
	WebhookURL              string                     `json:"webhook_url"`
	WhitelistedDestinations []string                   `json:"whitelisted_destinations"`
}

type MessagingProfileParameters

type MessagingProfileParameters struct {
	ProfileName    string             `json:"name"`
	IsEnabled      bool               `json:"enabled"`
	NumberPoolOpts NumberPoolSettings `json:"number_pool_settings"`
	WebhookUrl     string             `json:"webhook_url"`
}

type MessagingProfileResponse

type MessagingProfileResponse struct {
	Data MessagingProfileData `json:"data"`
}

type NumberOrderParameters

type NumberOrderParameters struct {
	BillingGroupID     string                     `json:"billing_group_id,omitempty"`
	ConnectionID       string                     `json:"connection_id,omitempty"`
	CustomerReference  string                     `json:"customer_reference,omitempty"`
	MessagingProfileID string                     `json:"messaging_profile_id,omitempty"`
	PhoneNumbers       *[]NumberOrderPhoneNumbers `json:"phone_numbers,omitempty"`
}

type NumberOrderPhoneNumbers

type NumberOrderPhoneNumbers struct {
	PhoneNumber            string `json:"phone_number"`
	RegulatoryRequirements []*struct {
	} `json:"regulatory_requirements,omitempty"`
}

type NumberOrderResponse

type NumberOrderResponse struct {
	Data NumberOrderResponseData `json:"data"`
}

type NumberOrderResponseData

type NumberOrderResponseData struct {
	BillingGroupID     string                            `json:"billing_group_id"`
	ConnectionID       string                            `json:"connection_id"`
	CreatedAt          time.Time                         `json:"created_at"`
	CustomerReference  string                            `json:"customer_reference"`
	ID                 string                            `json:"id"`
	MessagingProfileID string                            `json:"messaging_profile_id"`
	PhoneNumbersCount  int                               `json:"phone_numbers_count"`
	RecordType         string                            `json:"record_type"`
	RequirementsMet    bool                              `json:"requirements_met"`
	Status             string                            `json:"status"`
	UpdatedAt          time.Time                         `json:"updated_at"`
	PhoneNumbers       []NumberOrderResponsePhoneNumbers `json:"phone_numbers"`
}

type NumberOrderResponsePhoneNumbers

type NumberOrderResponsePhoneNumbers struct {
	ID                     string `json:"id"`
	PhoneNumber            string `json:"phone_number"`
	RecordType             string `json:"record_type"`
	RegulatoryGroupID      string `json:"regulatory_group_id"`
	RegulatoryRequirements []struct {
	} `json:"regulatory_requirements"`
	RequirementsMet bool   `json:"requirements_met"`
	Status          string `json:"status"`
}

Number Order Structs

type NumberOrderStatusUpdateWebhook

type NumberOrderStatusUpdateWebhook struct {
	Data NumberOrderStatusUpdateWebhookData `json:"data"`
}

type NumberOrderStatusUpdateWebhookData

type NumberOrderStatusUpdateWebhookData struct {
	EventType  string                                `json:"event_type"`
	ID         string                                `json:"id"`
	OccurredAt string                                `json:"occurred_at"`
	Payload    NumberOrderStatusUpdateWebhookPayload `json:"payload"`
	RecordType string                                `json:"record_type"`
}

type NumberOrderStatusUpdateWebhookPayload

type NumberOrderStatusUpdateWebhookPayload struct {
	BillingGroupID     string    `json:"billing_group_id"`
	ConnectionID       string    `json:"connection_id"`
	CreatedAt          time.Time `json:"created_at"`
	CustomerReference  string    `json:"customer_reference"`
	ID                 string    `json:"id"`
	MessagingProfileID string    `json:"messaging_profile_id"`
	PhoneNumbersCount  int       `json:"phone_numbers_count"`
	RecordType         string    `json:"record_type"`
	RequirementsMet    bool      `json:"requirements_met"`
	Status             string    `json:"status"`
	UpdatedAt          time.Time `json:"updated_at"`
}

type NumberPoolSettings

type NumberPoolSettings struct {
	Geomatch       bool `json:"geomatch"`
	LongCodeWeight int  `json:"long_code_weight"`
	SkipUnhealthy  bool `json:"skip_unhealthy"`
	StickySender   bool `json:"sticky_sender"`
	TollFreeWeight int  `json:"toll_free_weight"`
}

Messaging Profile Structs

type NumberPoolSettingsResponse

type NumberPoolSettingsResponse struct {
	Geomatch       bool        `json:"geomatch"`
	LongCodeWeight json.Number `json:"long_code_weight"`
	SkipUnhealthy  bool        `json:"skip_unhealthy"`
	StickySender   bool        `json:"sticky_sender"`
	TollFreeWeight json.Number `json:"toll_free_weight"`
}

type NumberSearchOptions

type NumberSearchOptions struct {
	AreaCode    string
	SearchLimit int
}

Number Search Structs

type NumberSearchResponse

type NumberSearchResponse struct {
	Data []NumberSearchResponseData `json:"data"`
	Meta NumberSearchResponseMeta   `json:"meta"`
}

type NumberSearchResponseCostInfo

type NumberSearchResponseCostInfo struct {
	Currency    string `json:"currency"`
	MonthlyCost string `json:"monthly_cost"`
	UpfrontCost string `json:"upfront_cost"`
}

type NumberSearchResponseData

type NumberSearchResponseData struct {
	BestEffort        bool                             `json:"best_effort"`
	CostInformation   NumberSearchResponseCostInfo     `json:"cost_information"`
	Features          []NumberSearchResponseFeatures   `json:"features"`
	PhoneNumber       string                           `json:"phone_number"`
	Quickship         bool                             `json:"quickship"`
	RecordType        string                           `json:"record_type"`
	RegionInformation []NumberSearchResponseRegionInfo `json:"region_information"`
	Reservable        bool                             `json:"reservable"`
	VanityFormat      string                           `json:"vanity_format"`
}

type NumberSearchResponseFeatures

type NumberSearchResponseFeatures struct {
	Name string `json:"name"`
}

type NumberSearchResponseList

type NumberSearchResponseList struct {
	PhoneNumbers []string
}

type NumberSearchResponseMeta

type NumberSearchResponseMeta struct {
	BestEffortResults int `json:"best_effort_results"`
	TotalResults      int `json:"total_results"`
}

type NumberSearchResponseRegionInfo

type NumberSearchResponseRegionInfo struct {
	RegionName string `json:"region_name"`
	RegionType string `json:"region_type"`
}

type Opts

type Opts struct {
	// mandatory options.
	AccountID, APIToken string
	//optional
	DefaultEndpoint string
	HTTPClient      *http.Client
	Verbose         bool
}

Opts are the options to create the account.

type RateLimitError

type RateLimitError struct {
	Reset time.Time
}

RateLimitError is error for 429 http error

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

type ReplacedClickWebhook

type ReplacedClickWebhook struct {
	Data ReplacedClickWebhookData `json:"data"`
}

type ReplacedClickWebhookData

type ReplacedClickWebhookData struct {
	MessageID   string `json:"message_id"`
	RecordType  string `json:"record_type"`
	TimeClicked string `json:"time_clicked"`
	To          string `json:"to"`
	URL         string `json:"url"`
}

type ResponseError

type ResponseError struct {
	Errors []ResponseErrorDetails `json:"errors"`
}

type ResponseErrorDetails

type ResponseErrorDetails struct {
	Code   string                 `json:"code"`
	Title  string                 `json:"title"`
	Detail string                 `json:"detail"`
	Source map[string]interface{} `json:"source"`
	Meta   map[string]interface{} `json:"meta"`
}

Telnyx error object

type RetreiveNumberOrderParameters

type RetreiveNumberOrderParameters struct {
	ID string `json:"number_order_id"`
}

type SendMessageParameters

type SendMessageParameters struct {
	To                 string   `json:"to"`
	AutoDetect         bool     `json:"auto_detect,omitempty"`
	From               string   `json:"from,omitempty"`
	MediaUrls          []string `json:"media_urls,omitempty"`
	MessagingProfileID string   `json:"messaging_profile_id,omitempty"`
	Subject            string   `json:"subject,omitempty"`
	Text               string   `json:"text,omitempty"`
	Type               string   `json:"type,omitempty"`
	UseProfileWebhooks bool     `json:"use_profile_webhooks,omitempty"`
	WebhookFailoverURL string   `json:"webhook_failover_url,omitempty"`
	WebhookURL         string   `json:"webhook_url,omitempty"`
}

SendMessage Structs

type SendMessageResponse

type SendMessageResponse struct {
	Data SendMessageResponseData `json:"data"`
}

type SendMessageResponseCost

type SendMessageResponseCost struct {
	Amount   string `json:"amount"`
	Currency string `json:"currency"`
}

type SendMessageResponseData

type SendMessageResponseData struct {
	CompletedAt        time.Time                  `json:"completed_at"`
	Cost               SendMessageResponseCost    `json:"cost"`
	Direction          string                     `json:"direction"`
	Encoding           string                     `json:"encoding"`
	Errors             []ResponseError            `json:"errors"`
	From               SendMessageResponseFrom    `json:"from"`
	ID                 string                     `json:"id"`
	Media              []SendMessageResponseMedia `json:"media"`
	MessagingProfileID string                     `json:"messaging_profile_id"`
	OrganizationID     string                     `json:"organization_id"`
	Parts              int                        `json:"parts"`
	ReceivedAt         time.Time                  `json:"received_at"`
	RecordType         string                     `json:"record_type"`
	SentAt             time.Time                  `json:"sent_at"`
	Subject            string                     `json:"subject"`
	Tags               []string                   `json:"tags"`
	Text               string                     `json:"text"`
	To                 []SendMessageResponseTo    `json:"to"`
	Type               string                     `json:"type"`
	ValidUntil         time.Time                  `json:"valid_until"`
	WebhookFailoverURL string                     `json:"webhook_failover_url"`
	WebhookURL         string                     `json:"webhook_url"`
}

type SendMessageResponseFrom

type SendMessageResponseFrom struct {
	Carrier     string `json:"carrier"`
	LineType    string `json:"line_type"`
	PhoneNumber string `json:"phone_number"`
}

type SendMessageResponseMedia

type SendMessageResponseMedia struct {
	ContentType interface{} `json:"content_type"`
	Sha256      interface{} `json:"sha256"`
	Size        interface{} `json:"size"`
	URL         string      `json:"url"`
}

type SendMessageResponseTo

type SendMessageResponseTo struct {
	Carrier     string `json:"carrier"`
	LineType    string `json:"line_type"`
	PhoneNumber string `json:"phone_number"`
	Status      string `json:"status"`
}

type URLShortenerSettings

type URLShortenerSettings struct {
	Domain               string `json:"domain"`
	Prefix               string `json:"prefix"`
	ReplaceBlacklistOnly bool   `json:"replace_blacklist_only"`
	SendWebhooks         bool   `json:"send_webhooks"`
}

Jump to

Keyboard shortcuts

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