nexmo

package module
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2020 License: MIT Imports: 10 Imported by: 18

README

Nexmo Server SDK For Go

Go Report Card Build Status Coverage GoDoc

This is the community-supported Golang library for Nexmo. It has support for most of our APIs, but is still under active development. Issues, pull requests and other input is very welcome.

If you don't already know Nexmo: We make telephony APIs. If you need to make a call, check a phone number, or send an SMS then you are in the right place! If you don't have a Nexmo yet, you can sign up for a Nexmo account and get some free credit to get you started.

Installation

Find current and past releases on the releases page.

Import the package and use it:

import ("github.com/nexmo-community/nexmo-go")

Older versions of Go (<= 1.12)

To install the package, use go get:

go get github.com/nexmo-community/nexmo-go

Or import the package into your project and then do go get ..

Usage

Here are some simple examples to get you started. If there's anything else you'd like to see here, please open an issue and let us know! Be aware that this library is still at an alpha stage so things may change between versions.

Number Insight
package main

import (
	"fmt"
	"net/http"

	"log"

	"github.com/nexmo-community/nexmo-go"
)

func main() {
	auth := nexmo.NewAuthSet()
	auth.SetAPISecret(API_KEY, API_SECRET)
	client := nexmo.New(http.DefaultClient, auth)
	insight, _, err := client.Insight.GetBasicInsight(nexmo.BasicInsightRequest{
		Number: PHONE_NUMBER,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Country Name:", insight.CountryName)
	fmt.Println("Local Formatting:", insight.NationalFormatNumber)
	fmt.Println("International Formatting:", insight.InternationalFormatNumber)
}
Sending SMS
package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/nexmo-community/nexmo-go"
)

func main() {
	auth := nexmo.NewAuthSet()
	auth.SetAPISecret(API_KEY, API_SECRET)

	client := nexmo.NewClient(http.DefaultClient, auth)
	smsReq := nexmo.SendSMSRequest {
	    From: FROM_NUMBER,
	    To: TO_NUMBER,
	    Text: "This message comes to you from Nexmo via Golang",
    }

	callR, _, err := client.SMS.SendSMS(smsReq)

	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("Status:", callR.Messages[0].Status)
}
Receiving SMS
package main

import (
	"fmt"
	"log"
	"net/http"
)

func main() {

	http.HandleFunc("/webhooks/inbound-sms", func(w http.ResponseWriter, r *http.Request) {
		params := r.URL.Query()
		fmt.Println("SMS from " + params["msisdn"][0] + ": " + string(params["text"][0]))
	})

	http.ListenAndServe(":8080", nil)
}
Starting a Verify Request
    package main

    import (
        "fmt"
        "github.com/nexmo-community/nexmo-go"
        "log"
        "net/http"
    )

    func verify_start() {
        auth := nexmo.NewAuthSet()
        auth.SetAPISecret(API_KEY, API_SECRET)
        client := nexmo.NewClient(http.DefaultClient, auth)
        verification, _, err := client.Verify.Start(nexmo.StartVerificationRequest{
            Number: PHONE_NUMBER,
            Brand:  "Golang Docs",
        })
        if err != nil {
            log.Fatal(err)
        }
        fmt.Println("Request ID:", verification.RequestID)
    }

    func main() {
        verify_start()
    }
Confirming a Verify Code
    package main

    import (
        "fmt"
        "github.com/nexmo-community/nexmo-go"
        "log"
        "net/http"
    )

    func verify_check() {
        auth := nexmo.NewAuthSet()
        auth.SetAPISecret(API_KEY, API_SECRET)
        client := nexmo.NewClient(http.DefaultClient, auth)
        response, _, err := client.Verify.Check(nexmo.CheckVerificationRequest{
            RequestID: REQUEST_ID,
            Code:      CODE,
        })
        if err != nil {
            log.Fatal(err)
        }
        fmt.Println("Status:", response.Status)
        fmt.Println("Cost:", response.Price)
    }

    func main() {
        verify_check()
    }
Make a Phone Call

The Voice API uses applications and private keys for authentication. To use this snippet you will need a Nexmo number (for the "from" field), and an application with an ID and a private key. You can learn more about creating applications on the Developer Portal.

	// get the private key ready, assume file name private.key
	file, file_err := os.Open("private.key")
	if file_err != nil {
		log.Fatal(file_err)
	}
	defer file.Close()

	key, _ := ioutil.ReadAll(file)

	auth := nexmo.NewAuthSet()
	auth.SetApplicationAuth(APPLICATION_ID, key)
	client := nexmo.NewClient(http.DefaultClient, auth)

	to := make([]interface{}, 1)
	to[0] = nexmo.PhoneCallEndpoint{
		Type:   "phone",
		Number: TO_NUMBER,
	}

	response, _, err := client.Call.CreateCall(nexmo.CreateCallRequest{
		From:      nexmo.PhoneCallEndpoint{"phone", NEXMO_NUMBER, ""},
		To:        to,
		AnswerURL: []string{ANSWER_URL},
		EventURL:  []string{EVENT_URL},
	})

	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Status:", response.Status)

Getting Help

We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:

Further Reading

Documentation

Overview

Simple client for using Nexmo's communication APIs. See https://nexmo.com for more information about the APIs.

Index

Constants

View Source
const (
	PortedStatusUnknown          PortedStatus = "unknown"
	PortedStatusPorted           PortedStatus = "ported"
	PortedStatusNotPorted        PortedStatus = "not_ported"
	PortedStatusAssumedPorted    PortedStatus = "assumed_ported"
	PortedStatusAssumedNotPorted PortedStatus = "assumed_not_ported"

	CallerTypeBusiness CallerType = "business"
	CallerTypeConsumer CallerType = "consumer"
	CallerTypeUnknown  CallerType = "unknown"
)
View Source
const (
	RoamingStatusRoaming    RoamingStatus = "roaming"
	RoamingStatusUnknown    RoamingStatus = "unkown"
	RoamingStatusNotRoaming RoamingStatus = "not_roaming"

	ValidNumberStatusValid    ValidNumberStatus = "valid"
	ValidNumberStatusUnknown  ValidNumberStatus = "unknown"
	ValidNumberStatusNotValid ValidNumberStatus = "not_valid"

	ReachableStatusUnknown       ReachableStatus = "unknown"
	ReachableStatusReachable     ReachableStatus = "reachable"
	ReachableStatusUndeliverable ReachableStatus = "undeliverable"
	ReachableStatusAbsent        ReachableStatus = "absent"
	ReachableStatusBadNumber     ReachableStatus = "bad_number"
	ReachableStatusBlacklisted   ReachableStatus = "blacklisted"

	IPMatchLevelCountry  IPMatchLevel = "country"
	IPMatchLevelMismatch IPMatchLevel = "mismatch"

	IPWarningsUnknown   IPWarnings = "unknown"
	IPWarningsNoWarning IPWarnings = "no_warning"

	LookupOutcomeSuccess LookupOutcome = iota
	LookupOutcomePartial
	LookupOutcomeFailed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status       int64
	ErrorMessage string
}

func (APIError) Error

func (a APIError) Error() string

type AdvancedInsightRequest

type AdvancedInsightRequest struct {
	Credentials
	Number  string `json:"number,omitempty"`
	Country string `json:"country,omitempty"`
	CNAM    bool   `json:"cnam,omitempty"`
	IP      string `json:"ip,omitempty"`
}

type AdvancedInsightResponse

type AdvancedInsightResponse struct {
	StandardInsightResponse
	ValidNumber ValidNumberStatus `json:"valid_number"`
	Reachable   ReachableStatus   `json:"reachable"`
	Ported      string            `json:"ported"`
	Roaming     struct {
		Status             RoamingStatus `json:"status"`
		RoamingCountryCode string        `json:"roaming_country_code"`
		RoamingNetworkCode string        `json:"roaming_network_code"`
		RoamingNetworkName string        `json:"roaming_network_name"`
	} `json:"roaming"`
	LookupOutcome        LookupOutcome `json:"lookup_outcome"`
	LookupOutcomeMessage string        `json:"lookup_outcome_message"`
	IP                   string        `json:"ip"`
	IPWarnings           IPWarnings    `json:"ip_warnings"`
	IPMatchLevel         IPMatchLevel  `json:"ip_match_level"`
	IPCountry            string        `json:"ip_country"`
}

type ApplicationConfiguration

type ApplicationConfiguration struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Voice struct {
		Webhooks []struct {
			EndpointType string `json:"endpoint_type"`
			Endpoint     string `json:"endpoint"`
			HTTPMethod   string `json:"http_method"`
		} `json:"webhooks"`
	}
	Keys struct {
		PublicKey  string `json:"public_key"`
		PrivateKey string `json:"private_key"`
	} `json:"keys"`
	Links Links `json:"_links"`
}

type ApplicationService

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

Use the Application API to create and manage your applications. More info: https://developer.nexmo.com/application

func (*ApplicationService) CreateApplication

Create a new application in your Nexmo account

func (*ApplicationService) DeleteApplication

func (s *ApplicationService) DeleteApplication(id string) (*http.Response, error)

Destroy an application

func (*ApplicationService) GetApplication

func (s *ApplicationService) GetApplication(id string) (*GetApplicationResponse, *http.Response, error)

Fetch a specific application's details

func (*ApplicationService) ListApplications

List the applications on the Nexmo account

func (*ApplicationService) ModifyApplication

Update an existing application by applying changed config to it

func (*ApplicationService) SetBaseURL

func (c *ApplicationService) SetBaseURL(baseURL string)

Set the base URL for the API calls. Useful for testing.

type AuthSet

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

API credentials to access the Nexmo APIs

func NewAuthSet

func NewAuthSet() *AuthSet

func (*AuthSet) ApplyAPICredentials

func (a *AuthSet) ApplyAPICredentials(request apiSecretRequest)

func (*AuthSet) ApplyJWT

func (a *AuthSet) ApplyJWT(sling *sling.Sling) error

func (*AuthSet) GenerateToken

func (a *AuthSet) GenerateToken() (string, error)

func (*AuthSet) SetAPISecret

func (a *AuthSet) SetAPISecret(apiKey, apiSecret string)

func (*AuthSet) SetApplicationAuth

func (a *AuthSet) SetApplicationAuth(appID string, key []byte) error

type AuthType

type AuthType uint8
const (
	ApiSecretAuth AuthType = iota + 1
	ApiSecretPathAuth
	JwtAuth
)

type BasicInsightRequest

type BasicInsightRequest struct {
	Credentials
	Number  string `json:"number,omitempty"`
	Country string `json:"country,omitempty"`
}

type BasicInsightResponse

type BasicInsightResponse struct {
	Status                    int64  `json:"status,omitempty"`
	StatusMessage             string `json:"status_message,omitempty"`
	ErrorText                 string `json:"error_text,omitempty"`
	RequestID                 string `json:"request_id,omitempty"`
	InternationalFormatNumber string `json:"international_format_number,omitempty"`
	NationalFormatNumber      string `json:"national_format_number,omitempty"`
	CountryCode               string `json:"country_code,omitempty"`
	CountryCodeIso3           string `json:"country_code_iso3,omitempty"`
	CountryName               string `json:"country_name,omitempty"`
	CountryPrefix             string `json:"country_prefix,omitempty"`
}

type CallErrorResponse

type CallErrorResponse struct {
	Type       string `json:"type,omitempty"`
	ErrorTitle string `json:"error_title,omitempty"`
}

func (*CallErrorResponse) Error

func (c *CallErrorResponse) Error() string

type CallInfo

type CallInfo struct {
	UUID             string      `json:"uuid,omitempty"`
	ConversationUUID string      `json:"conversation_uuid,omitempty"`
	To               interface{} `json:"to,omitempty"`
	From             interface{} `json:"from,omitempty"`
	Status           string      `json:"status,omitempty"`
	Direction        string      `json:"direction,omitempty"`
	Rate             string      `json:"rate,omitempty"`
	Price            string      `json:"price,omitempty"`
	Duration         string      `json:"duration,omitempty"`
	Network          string      `json:"network,omitempty"`
	StartTime        string      `json:"start_time,omitempty"`
	EndTime          string      `json:"end_time,omitempty"`
}

type CallService

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

For working with the Voice API. More information about Voice: https://developer.nexmo.com/voice/voice-api/

func (*CallService) CreateCall

func (c *CallService) CreateCall(request CreateCallRequest) (*CreateCallResponse, *http.Response, error)

CreateCall starts a voice call, configured using the provided CreateCallRequest.

func (*CallService) GetCallInfo

func (c *CallService) GetCallInfo(uuid string) (*CallInfo, *http.Response, error)

Get information about a current or past call by call ID

func (*CallService) ModifyCall

func (c *CallService) ModifyCall(uuid string, request interface{}) (*ModifyCallResponse, *http.Response, error)

Change the in-progress call by performing an action, such as hangup, transfer, mute, etc. See the API reference: https://developer.nexmo.com/api/voice#updateCall

func (*CallService) SearchCalls

func (c *CallService) SearchCalls(request SearchCallsRequest) (*SearchCallsResponse, *http.Response, error)

SearchCalls returns information about calls matching the filter in the provided SearchCallsRequest

func (*CallService) SendDTMF

func (c *CallService) SendDTMF(uuid string, request DTMFRequest) (*ModifyCallResponse, *http.Response, error)

Play DTMF tones into a call

func (*CallService) SetBaseURL

func (c *CallService) SetBaseURL(baseURL string)

Set the base URL for the API requests. Mostly useful for testing.

func (*CallService) StopStream

func (c *CallService) StopStream(uuid string) (*ModifyCallResponse, *http.Response, error)

Stop the audio stream from playing in a call

func (*CallService) StopTalk

func (c *CallService) StopTalk(uuid string) (*ModifyCallResponse, *http.Response, error)

Stop the text-to-speech that is currently being sent into a call

func (*CallService) Stream

func (c *CallService) Stream(uuid string, request StreamRequest) (*ModifyCallResponse, *http.Response, error)

Start playing an audio file into a call

func (*CallService) Talk

func (c *CallService) Talk(uuid string, request TalkRequest) (*ModifyCallResponse, *http.Response, error)

Send text-to-speech into a call

type CallerType

type CallerType string

type CarrierRecord

type CarrierRecord struct {
	NetworkCode string      `json:"network_code"`
	Name        string      `json:"name"`
	Country     string      `json:"country"`
	NetworkType NetworkType `json:"network_type"`
}

type CheckVerificationRequest

type CheckVerificationRequest struct {
	Credentials
	RequestID string `json:"request_id"`
	Code      string `json:"code"`
	IPAddress string `json:"ip_address,omitempty"`
}

type CheckVerificationResponse

type CheckVerificationResponse struct {
	RequestID string `json:"event_id"`
	Status    string `json:"status"`
	Price     string `json:"price"`
	Currency  string `json:"currency"`
	ErrorText string `json:"error_text"`
}

type Client

type Client struct {
	Insight     *InsightService
	SMS         *SMSService
	Call        *CallService
	Verify      *VerifyService
	Developer   *DeveloperService
	Application *ApplicationService
	// contains filtered or unexported fields
}

The main client object

func New

func New(httpClient *http.Client, authSet *AuthSet) *Client

func NewClient

func NewClient(httpClient *http.Client, authSet *AuthSet) *Client

Get a new Client object with the auth configured

type ControlVerificationRequest

type ControlVerificationRequest struct {
	Credentials
	RequestID string `json:"request_id"`
	Command   string `json:"cmd"`
}

type ControlVerificationResponse

type ControlVerificationResponse struct {
	Status    string `json:"status"`
	Command   string `json:"command"`
	ErrorText string `json:"error_text"`
}

type CountryPrices

type CountryPrices struct {
	MT       string         `json:"mt"`
	Country  string         `json:"country"`
	Prefix   string         `json:"prefix"`
	Name     string         `json:"name"`
	Networks []NetworkPrice `json:"networks"`
}

type CreateApplicationRequest

type CreateApplicationRequest struct {
	Credentials
	Name         string `json:"name"`
	Type         string `json:"type"`
	AnswerURL    string `json:"answer_url"`
	AnswerMethod string `json:"answer_method,omitempty"`
	EventURL     string `json:"event_url"`
	EventMethod  string `json:"event_method,omitempty"`
}

type CreateApplicationResponse

type CreateApplicationResponse ApplicationConfiguration

type CreateCallRequest

type CreateCallRequest struct {
	To               []interface{} `json:"to"`
	From             interface{}   `json:"from"`
	AnswerURL        []string      `json:"answer_url"`
	AnswerMethod     string        `json:"answer_method,omitempty"`
	EventURL         []string      `json:"event_url,omitempty"`
	EventMethod      string        `json:"event_method,omitempty"`
	MachineDetection string        `json:"machine_detection,omitempty"`
	LengthTimer      int64         `json:"length_timer,omitempty"`
	RingingTimer     int64         `json:"ringing_timer,omitempty"`
}

type CreateCallResponse

type CreateCallResponse struct {
	UUID             string `json:"uuid"`
	ConversationUUID string `json:"conversation_uuid"`
	Direction        string `json:"direction"`
	Status           string `json:"status"`
}

type Credentials

type Credentials struct {
	APIKey    string `json:"api_key" url:"api_key"`
	APISecret string `json:"api_secret" url:"api_secret"`
}

type DTMFRequest

type DTMFRequest struct {
	Digits string `json:"digits"`
}

type DeveloperService

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

Developer API allows configuration of account and balance checking. See also: https://developer.nexmo.com/api/account

func (*DeveloperService) GetBalance

func (s *DeveloperService) GetBalance() (*GetBalanceResponse, *http.Response, error)

Get the current balance of your account

func (*DeveloperService) GetOutboundPricingForCountry

func (s *DeveloperService) GetOutboundPricingForCountry(request GetOutboundPricingForCountryRequest) (*CountryPrices, *http.Response, error)

GetOutboundPricingForCountry requests pricing for a given country

func (*DeveloperService) GetOutboundProductPricing

GetOutboundProductPricing requests prices for a product in a given country

func (*DeveloperService) GetPhoneOutboundPricing

GetPhoneOutboundPricing requests outbound pricing for a given phone number

func (*DeveloperService) GetPrefixOutboundPricing

GetPrefixOutboundPricing requests outbound pricing for a given international prefix

func (*DeveloperService) SetBaseURL

func (c *DeveloperService) SetBaseURL(baseURL string)

Set the base URL for the API request, useful for testing

type EmbeddedCalls

type EmbeddedCalls struct {
	Calls []CallInfo `json:"calls,omitempty"`
}

type GetApplicationRequest

type GetApplicationRequest struct {
	// Created with embedded Credentials, so this will support setApiCredentials
	// (if we alias to Credentials, we lose the implementation)
	Credentials
}

type GetApplicationResponse

type GetApplicationResponse ApplicationConfiguration

type GetBalanceResponse

type GetBalanceResponse struct {
	Value float64 `json:"value,omitempty"`
}

type GetOutboundPricingForCountryRequest

type GetOutboundPricingForCountryRequest struct {
	Credentials
	Country string `url:"country"`
}

type GetOutboundProductPricingRequest

type GetOutboundProductPricingRequest struct {
	Credentials
	Product string `url:"-"`
	Country string `url:"country"`
}

type GetOutboundProductPricingResponse

type GetOutboundProductPricingResponse struct {
	DialingPrefix      string           `json:"dialingPrefix"`
	DefaultPrice       string           `json:"defaultPrice"`
	Currency           string           `json:"currency"`
	CountryDisplayName string           `json:"countryDisplayName"`
	CountryCode        string           `json:"countryCode"`
	CountryName        string           `json:"countryName"`
	Networks           []NetworkDetails `json:"networks"`
}

type GetPhoneOutboundPricingRequest

type GetPhoneOutboundPricingRequest struct {
	// This is defined here because Product must not be serialized, and I haven't implemented that in the json-schema
	Credentials
	Phone   string `url:"phone"`
	Product string `url:"-"`
}

GetPhoneOutboundPricingRequest is the request object for DeveloperService.GetPhoneOutboundPricing

type GetPhoneOutboundPricingResponse

type GetPhoneOutboundPricingResponse struct {
	Network     string `json:"network,omitempty"`
	Phone       string `json:"phone,omitempty"`
	CountryCode string `json:"country-code,omitempty"`
	Price       string `json:"price,omitempty"`
}

type GetPrefixOutboundPricingRequest

type GetPrefixOutboundPricingRequest struct {
	Credentials
	Prefix string `url:"prefix"`
}

type GetPrefixOutboundPricingResponse

type GetPrefixOutboundPricingResponse struct {
	Count  int64           `json:"count"`
	Prices []CountryPrices `json:"prices"`
}

type IPMatchLevel

type IPMatchLevel string

type IPWarnings

type IPWarnings string

type InsightService

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

Number Insights provides information at varying levels of detail (basic/standard/advanced) about a phone number. For more information, visit the developer documentation https://developer.nexmo.com/number-insight

func (*InsightService) GetAdvancedInsight

Perform a Number Insight request at an advanced level of detail

func (*InsightService) GetBasicInsight

func (c *InsightService) GetBasicInsight(request BasicInsightRequest) (BasicInsightResponse, *http.Response, error)

Perform a Number Insight request at a basic level of detail

func (*InsightService) GetStandardInsight

Perform a Number Insight request at a standard level of detail

func (*InsightService) SetBaseURL

func (c *InsightService) SetBaseURL(baseURL string)

Set the base URL for the API request. This is mostly useful for testing.

type Link struct {
	Href string `json:"href,omitempty"`
}
type Links struct {
	Self  Link `json:"self,omitempty"`
	Next  Link `json:"next,omitempty"`
	Prev  Link `json:"prev,omitempty"`
	First Link `json:"first,omitempty"`
	Last  Link `json:"last,omitempty"`
}

type ListApplicationsRequest

type ListApplicationsRequest struct {
	Credentials
	PageSize  int64 `url:"page_size,omitempty"`
	PageIndex int64 `url:"page_index,omitempty"`
}

type ListApplicationsResponse

type ListApplicationsResponse struct {
	Count    int64 `json:"count,omitempty"`
	PageSize int64 `json:"page_size,omitempty"`
	Embedded struct {
		Applications []ApplicationConfiguration `json:"applications"`
	} `json:"_embedded"`
	Links Links `json:"_links"`
}

type LookupOutcome

type LookupOutcome int8

type MessageType

type MessageType string
const (
	MessageTypeText    MessageType = "text"
	MessageTypeBinary  MessageType = "binary"
	MessageTypeWAPPush MessageType = "wappush"
	MessageTypeUnicode MessageType = "unicode"
)

type ModifyApplicationRequest

type ModifyApplicationRequest CreateApplicationRequest

type ModifyApplicationResponse

type ModifyApplicationResponse ApplicationConfiguration

type ModifyCallResponse

type ModifyCallResponse struct {
	Message string `json:"message,omitempty"`
	UUID    string `json:"uuid,omitempty"`
}

type NetworkDetails

type NetworkDetails struct {
	Type        string  `json:"type"`
	Price       string  `json:"price"`
	Currency    string  `json:"currency"`
	Ranges      []int64 `json:"ranges"`
	MNC         string  `json:"mnc"`
	MCC         string  `json:"mcc"`
	NetworkCode string  `json:"networkCode"`
	NetworkName string  `json:"networkName"`
}

type NetworkPrice

type NetworkPrice struct {
	Network string `json:"network"`
	Code    string `json:"code"`
	MTPrice string `json:"mtPrice"`
}

type NetworkType

type NetworkType string
const (
	NetworkTypeMobile           NetworkType = "mobile"
	NetworkTypeLandline         NetworkType = "landline"
	NetworkTypeLandlinePremium  NetworkType = "landline_premium"
	NetworkTypeLandlineTollFree NetworkType = "landline_tollfree"
	NetworkTypeVirtual          NetworkType = "virtual"
	NetworkTypeUnknown          NetworkType = "unknown"
	NetworkTypePager            NetworkType = "pager"
)

type PhoneCallEndpoint

type PhoneCallEndpoint struct {
	Type       string `json:"type"`
	Number     string `json:"number"`
	Dtmfanswer string `json:"dtmfAnswer,omitempty"`
}

type PortedStatus

type PortedStatus string

type RandomProvider

type RandomProvider interface {
	Int31() int32
}

type ReachableStatus

type ReachableStatus string

type RoamingStatus

type RoamingStatus string

type SIPCallEndpoint

type SIPCallEndpoint struct {
	Type string `json:"type"`
	URI  string `json:"uri"`
}

type SMSService

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

Work with the SMS API to send SMS messges. More information about this API: https://developer.nexmo.com/messaging/sms

func (*SMSService) SendSMS

func (c *SMSService) SendSMS(request SendSMSRequest) (*SendSMSResponse, *http.Response, error)

Send an SMS message

func (*SMSService) SetBaseURL

func (c *SMSService) SetBaseURL(baseURL string)

type SearchCallsRequest

type SearchCallsRequest struct {
	Status           string `url:"status,omitempty"`
	DateStart        string `url:"date_start,omitempty"`
	DateEnd          string `url:"date_end,omitempty"`
	PageSize         int64  `url:"page_size,omitempty"`
	RecordIndex      int64  `url:"record_index,omitempty"`
	Order            string `url:"order,omitempty"`
	ConversationUUID string `url:"conversation_uuid,omitempty"`
}

type SearchCallsResponse

type SearchCallsResponse struct {
	Count       int64         `json:"count,omitempty"`
	PageSize    int64         `json:"page_size,omitempty"`
	RecordIndex int64         `json:"record_index,omitempty"`
	Links       Links         `json:"_links,omitempty"`
	Embedded    EmbeddedCalls `json:"_embedded,omitempty"`
}

type SearchVerificationRequest

type SearchVerificationRequest struct {
	Credentials
	RequestIDs []string `json:"request_ids" url:"request_ids"`
}

type SearchVerificationResponse

type SearchVerificationResponse struct {
	Status               string `json:"status"`
	ErrorText            string `json:"error_text"`
	VerificationRequests []struct {
		RequestID      string `json:"request_id"`
		AccountID      string `json:"account_id"`
		Number         string `json:"number"`
		SenderID       string `json:"sender_id"`
		DateSubmitted  string `json:"date_submitted"`
		DateFinalized  string `json:"date_finalized"`
		FirstEventDate string `json:"first_event_date"`
		LastEventDate  string `json:"last_event_date"`
		Status         string `json:"status"`
		Price          string `json:"price"`
		Currency       string `json:"currency"`
		Checks         []struct {
			DateReceived string `json:"date_received"`
			Code         string `json:"code"`
			Status       string `json:"status"`
			IPAddress    string `json:"ip_address"`
		} `json:"checks"`
	} `json:"verification_requests"`
}

type SendSMSRequest

type SendSMSRequest struct {
	APIKey          string      `json:"api_key"`
	APISecret       string      `json:"api_secret"`
	From            string      `json:"from,omitempty"`
	To              string      `json:"to,omitempty"`
	Type            MessageType `json:"type,omitempty"`
	Text            string      `json:"text,omitempty"`
	StatusReportReq int64       `json:"status-report-req,omitempty"`
	ClientRef       string      `json:"client-ref,omitempty"`
	Vcard           string      `json:"vcard,omitempty"`
	Vcal            string      `json:"vcal,omitempty"`
	TTL             int64       `json:"ttl,omitempty"`
	Callback        string      `json:"callback,omitempty"`
	MessageClass    int64       `json:"message-class,omitempty"`
	Udh             string      `json:"udh,omitempty"`
	ProtocolID      int64       `json:"protocol-id,omitempty"`
	Body            string      `json:"body,omitempty"`
	Title           string      `json:"title,omitempty"`
	URL             string      `json:"url,omitempty"`
	Validity        int64       `json:"validity,omitempty"`
}

type SendSMSResponse

type SendSMSResponse struct {
	MessageCount string                   `json:"message-count,omitempty"`
	Messages     []SendSMSResponseMessage `json:"messages,omitempty"`
}

type SendSMSResponseMessage

type SendSMSResponseMessage struct {
	Status           string `json:"status,omitempty"`
	MessageID        string `json:"message-id,omitempty"`
	To               string `json:"to,omitempty"`
	ClientRef        string `json:"client-ref,omitempty"`
	RemainingBalance string `json:"remaining-balance,omitempty"`
	MessagePrice     string `json:"message-price,omitempty"`
	Network          string `json:"network,omitempty"`
	ErrorText        string `json:"error-text,omitempty"`
}

type SimpleModifyCallRequest

type SimpleModifyCallRequest struct {
	Action string `json:"action,omitempty"`
}

type StandardInsightRequest

type StandardInsightRequest struct {
	Credentials
	Number  string `json:"number,omitempty"`
	Country string `json:"country,omitempty"`
	CNAM    bool   `json:"cnam,omitempty"`
}

type StandardInsightResponse

type StandardInsightResponse struct {
	BasicInsightResponse
	RequestPrice     string         `json:"request_price"`
	RefundPrice      string         `json:"refund_price"`
	RemainingBalance string         `json:"remaining_balance"`
	Ported           PortedStatus   `json:"ported"`
	CurrentCarrier   *CarrierRecord `json:"current_carrier,omitempty"`
	OriginalCarrier  *CarrierRecord `json:"original_carrier,omitempty"`

	// CNAM fields:
	CallerName string     `json:"caller_name"`
	LastName   string     `json:"last_name"`
	FirstName  string     `json:"first_name"`
	CallerType CallerType `json:"caller_type"`
}

type StartVerificationRequest

type StartVerificationRequest struct {
	Credentials
	Number        string `json:"number"`
	Brand         string `json:"brand"`
	Country       string `json:"country,omitempty"`
	SenderID      string `json:"sender_id,omitempty"`
	CodeLength    int8   `json:"code_length,omitempty"`
	LG            string `json:"lg,omitempty"`
	RequireType   string `json:"require_type,omitempty"`
	PINExpiry     int16  `json:"pin_expiry,omitempty"`
	NextEventWait int16  `json:"next_event_wait,omitempty"`
	WorkflowID    int8   `json:"workflow_id,omitempty"`
}

type StartVerificationResponse

type StartVerificationResponse struct {
	RequestID string `json:"request_id"`
	Status    string `json:"status"`
	ErrorText string `json:"error_text"`
}

type StreamRequest

type StreamRequest struct {
	StreamURL []string `json:"stream_url"`
	Loop      int64    `json:"loop,omitempty"`
}

type TalkRequest

type TalkRequest struct {
	Text      string `json:"text"`
	VoiceName string `json:"voice_name,omitempty"`
	Loop      int64  `json:"loop,omitempty"`
}

type TransferCallRequest

type TransferCallRequest struct {
	Action      string              `json:"action,omitempty"`
	Destination TransferDestination `json:"destination,omitempty"`
}

type TransferDestination

type TransferDestination struct {
	Type string   `json:"type,omitempty"`
	URL  []string `json:"url,omitempty"`
}

type ValidNumberStatus

type ValidNumberStatus string

type VerifyService

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

Use Verify API for 2FA, passwordless login, or confirming that a user has given a correct phone number. More information: https://developer.nexmo.com/verify

func (*VerifyService) Check

Check if the code the user supplied is correct for this request

func (*VerifyService) Control

The control endpoint allows cancellation of a request or moving to the next verification stage

func (*VerifyService) Search

Search for current or past verify requests, their costs and statuses

func (*VerifyService) SetBaseURL

func (s *VerifyService) SetBaseURL(baseURL string)

func (*VerifyService) Start

Begin the process of verifying a phone number, you probably want to capture the request_id

type WebSocketCallEndpoint

type WebSocketCallEndpoint struct {
	Type        string      `json:"type"`
	URI         string      `json:"uri"`
	ContentType string      `json:"content-type,omitempty"`
	Headers     interface{} `json:"headers,omitempty"`
}

Jump to

Keyboard shortcuts

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