telesign

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: MIT Imports: 12 Imported by: 0

README

================= unofficial TeleSign Go SDK

Need a lot of improvements and adding more resources support. I hope Telesign soon will release their official Go SDK.

INSTALLATION

go get github.com/feelinc/go_telesign

Features!

  • SMS API
  • SMS Verify API
  • Voice Verify API
  • PhoneID API
  • PhoneID Live API
  • Score API
  • Get Status API
Example

Check all the TEST

Todos
  • Integration test
  • Improve existing test
  • Implement remaining Telesign resources
FOUND BUGS

Please open a issue (please check if similar issue exist reported here, just comment). We will consider to fix or close without fixing it.

IMPROVING

Thank you for your help improving it. Please fork and create push request.

License

MIT license.

Documentation

Index

Constants

View Source
const (

	// EnvStandard is the standard env
	EnvStandard = "Standard"
	// EnvEnterprise is the enterprise env
	EnvEnterprise = "Enterprise"

	// MessageARN type
	MessageARN = "ARN"
	// MessageMKT type
	MessageMKT = "MKT"
	// MessageOTP type
	MessageOTP = "OTP"

	// UcidAtck For use in a 2FA situation like updating an account, or trying to log in.
	UcidAtck = "ATCK"
	// UcidBacf For creating an account on somebody's service in a situation where the service may be vulnerable to bulk attacks or individual fraudsters.
	UcidBacf = "BACF"
	// UcidBacs For creating an account on somebody's service in a situation where the service may be vulnerable to bulk attacks or individual spammers.
	UcidBacs = "BACS"
	// UcidChbk For use in a situation such as someone trying to buy something expensive or unusual on your platform, and you want to verify that it is really them.
	UcidChbk = "CHBK"
	// UcidCldr Calendar Event
	UcidCldr = "CLDR"
	// UcidLead For use in a situation where you require a person to enter their personal information in order to obtain information about something like a loan or realty or a school, and you want to check if the person is bogus or not.
	UcidLead = "LEAD"
	// UcidOthr For use in a 2FA situation like updating an account, or trying to log in.
	UcidOthr = "OTHR"
	// UcidPwrt For use in a situation where a password reset is required.
	UcidPwrt = "PWRT"
	// UcidResv For use in a situation where you have end users making reservations and not showing up, and you want to be able to include some kind of phone verification in that loop.
	UcidResv = "RESV"
	// UcidRxpf For use in situations where you are trying to prevent prescription fraud.
	UcidRxpf = "RXPF"
	// UcidShip For use in situations where you are sending a shipping notification.
	UcidShip = "SHIP"
	// UcidThef For use in situations where you are trying to prevent an end user from deactivating or redirecting a phone number in order to take over someone else's identity.
	UcidThef = "THEF"
	// UcidTrvf For use in situations where you are transferring money, and you want to check to see if it is approved by sending a text message or phone call to your end user. This is similar to CHBK, but is specifically for a money transaction.
	UcidTrvf = "TRVF"
	// UcidUnkn is the same as OTHR.
	UcidUnkn = "UNKN"

	// PhoneTypeFixedLineCode number
	PhoneTypeFixedLineCode = "1"
	// PhoneTypeFixedLine name
	PhoneTypeFixedLine = "FIXED_LINE"
	// PhoneTypeMobileCode number
	PhoneTypeMobileCode = "2"
	// PhoneTypeMobile name
	PhoneTypeMobile = "MOBILE"
	// PhoneTypePrepaidCode number
	PhoneTypePrepaidCode = "3"
	// PhoneTypePrepaid name
	PhoneTypePrepaid = "PREPAID"
	// PhoneTypeTollFreeCode number
	PhoneTypeTollFreeCode = "4"
	// PhoneTypeTollFree name
	PhoneTypeTollFree = "TOLL_FREE"
	// PhoneTypeVoipCode number
	PhoneTypeVoipCode = "5"
	// PhoneTypeVoip name
	PhoneTypeVoip = "VOIP"
	// PhoneTypePagerCode number
	PhoneTypePagerCode = "6"
	// PhoneTypePager name
	PhoneTypePager = "PAGER"
	// PhoneTypePayphoneCode number
	PhoneTypePayphoneCode = "7"
	// PhoneTypePayphone name
	PhoneTypePayphone = "PAYPHONE"
	// PhoneTypeInvalidCode number
	PhoneTypeInvalidCode = "8"
	// PhoneTypeInvalid name
	PhoneTypeInvalid = "INVALID"
	// PhoneTypeRestrictedPremiumCode number
	PhoneTypeRestrictedPremiumCode = "9"
	// PhoneTypeRestrictedPremium name
	PhoneTypeRestrictedPremium = "RESTRICTED_PREMIUM"
	// PhoneTypePersonalCode number
	PhoneTypePersonalCode = "10"
	// PhoneTypePersonal name
	PhoneTypePersonal = "PERSONAL"
	// PhoneTypeVoicemailCode number
	PhoneTypeVoicemailCode = "11"
	// PhoneTypeVoicemail name
	PhoneTypeVoicemail = "VOICEMAIL"
	// PhoneTypeOtherCode number
	PhoneTypeOtherCode = "12"
	// PhoneTypeOther name
	PhoneTypeOther = "OTHER"

	// CallForwardActionBlock name
	CallForwardActionBlock = "block"

	// AccountLifecycleEventCreate name
	AccountLifecycleEventCreate = "create"

	// Active name
	Active = "ACTIVE"
	// Valid name
	Valid = "VALID"
	// Reachable name
	Reachable = "REACHABLE"
	// Unavailable name
	Unavailable = "UNAVAILABLE"
)

Variables

This section is empty.

Functions

func StructToURLValues

func StructToURLValues(i interface{}) url.Values

StructToURLValues convert struct data to URL Values

Types

type AdditionalInfo added in v1.0.4

type AdditionalInfo struct {
	CodeEntered       string `json:"code_entered"`
	MessagePartsCount int    `json:"message_parts_count"`
}

AdditionalInfo returned by telesign API

type Config

type Config struct {
	Env         string
	CustomerID  string
	APIKey      string
	HTTPTimeout int
}

Config data

type Connection

type Connection interface {
	SetEnv(env string)
	SetCustomerID(id string)
	SetAPIKey(key string)
	SetHTTPTimeout(i int)
	Execute(req Request) (Response, error)
}

Connection interface

func NewPhoneID

func NewPhoneID(options ...OptConFunc) Connection

NewPhoneID return a new PhoneID connection

func NewSMS

func NewSMS(options ...OptConFunc) Connection

NewSMS return a new SMS connection

func NewScore

func NewScore(options ...OptConFunc) Connection

NewScore return a new Score connection

func NewStatus added in v1.0.4

func NewStatus(options ...OptConFunc) Connection

NewStatus return a new Status connection

func NewVoice

func NewVoice(options ...OptConFunc) Connection

NewVoice return a new Voice connection

type Error added in v1.0.4

type Error struct {
	Code        int    `json:"code"`
	Description string `json:"description"`
}

Error returned by telesign API

type MainResponse

type MainResponse struct {
	StatusCode  int
	ResourceURI string         `json:"resource_uri"`
	ReferenceID string         `json:"reference_id"`
	Status      StatusResponse `json:"status"`
}

MainResponse returned by telesign API

func (MainResponse) Failure

func (r MainResponse) Failure() bool

Failure return true if failure, otherwise false

func (MainResponse) GetStatusCode

func (r MainResponse) GetStatusCode() int

GetStatusCode return response HTTP status code

func (MainResponse) Message

func (r MainResponse) Message() string

Message return status description

type OptConFunc

type OptConFunc func(Connection) error

OptConFunc is a function that configures a Connection

func SetConAPIKey

func SetConAPIKey(key string) OptConFunc

SetConAPIKey set the API Key

func SetConCustomerID

func SetConCustomerID(id string) OptConFunc

SetConCustomerID set the customer ID

func SetConEnv

func SetConEnv(env string) OptConFunc

SetConEnv set the environment

type OptFunc

type OptFunc func(*Telesign) error

OptFunc is a function that configures a Telesign

func SetAPIKey

func SetAPIKey(key string) OptFunc

SetAPIKey set the API Key

func SetCustomerID

func SetCustomerID(id string) OptFunc

SetCustomerID set the customer ID

func SetEnv

func SetEnv(env string) OptFunc

SetEnv set the environment

type PhoneID

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

PhoneID object

func (PhoneID) Execute

func (s PhoneID) Execute(req Request) (Response, error)

Execute the request

func (*PhoneID) SetAPIKey

func (s *PhoneID) SetAPIKey(key string)

SetAPIKey set the current API key

func (*PhoneID) SetCustomerID

func (s *PhoneID) SetCustomerID(id string)

SetCustomerID set the current customer ID

func (*PhoneID) SetEnv

func (s *PhoneID) SetEnv(env string)

SetEnv set the current environment

func (*PhoneID) SetHTTPTimeout

func (s *PhoneID) SetHTTPTimeout(i int)

SetHTTPTimeout set the current HTTP request timeout

type Request

type Request interface {
	GetMethod() string
	GetURI() string
	GetPath() string
	GetBody() string
	ParseResponse(statusCode int, content []byte) (Response, error)
}

Request interface

type Response

type Response interface {
	GetStatusCode() int
	Failure() bool
	Message() string
}

Response interface

func Execute

func Execute(customerID string, apiKey string, httpTimeout int,
	req *http.Request, resource string, body string, resParser responseParser) (Response, error)

Execute execute the request return a response

type SMS

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

SMS object

func (SMS) Execute

func (s SMS) Execute(req Request) (Response, error)

Execute the request

func (*SMS) SetAPIKey

func (s *SMS) SetAPIKey(key string)

SetAPIKey set the current API key

func (*SMS) SetCustomerID

func (s *SMS) SetCustomerID(id string)

SetCustomerID set the current customer ID

func (*SMS) SetEnv

func (s *SMS) SetEnv(env string)

SetEnv set the current environment

func (*SMS) SetHTTPTimeout

func (s *SMS) SetHTTPTimeout(i int)

SetHTTPTimeout set the current HTTP request timeout

type Score

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

Score object

func (Score) Execute

func (s Score) Execute(req Request) (Response, error)

Execute the request

func (*Score) SetAPIKey

func (s *Score) SetAPIKey(key string)

SetAPIKey set the current API key

func (*Score) SetCustomerID

func (s *Score) SetCustomerID(id string)

SetCustomerID set the current customer ID

func (*Score) SetEnv

func (s *Score) SetEnv(env string)

SetEnv set the current environment

func (*Score) SetHTTPTimeout

func (s *Score) SetHTTPTimeout(i int)

SetHTTPTimeout set the current HTTP request timeout

type Status added in v1.0.4

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

Status object

func (Status) Execute added in v1.0.4

func (s Status) Execute(req Request) (Response, error)

Execute the request

func (*Status) SetAPIKey added in v1.0.4

func (s *Status) SetAPIKey(key string)

SetAPIKey set the current API key

func (*Status) SetCustomerID added in v1.0.4

func (s *Status) SetCustomerID(id string)

SetCustomerID set the current customer ID

func (*Status) SetEnv added in v1.0.4

func (s *Status) SetEnv(env string)

SetEnv set the current environment

func (*Status) SetHTTPTimeout added in v1.0.4

func (s *Status) SetHTTPTimeout(i int)

SetHTTPTimeout set the current HTTP request timeout

type StatusResponse

type StatusResponse struct {
	Code        int    `json:"code"`
	UpdatedOn   string `json:"updated_on"`
	Description string `json:"description"`
}

StatusResponse returned by telesign API

type Telesign

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

Telesign object

func New

func New(options ...OptFunc) *Telesign

New return a new Telesign

func (*Telesign) PhoneID

func (t *Telesign) PhoneID(options ...OptConFunc) Connection

PhoneID return PhoneID service

func (*Telesign) SMS

func (t *Telesign) SMS(options ...OptConFunc) Connection

SMS return SMS service

func (*Telesign) Score

func (t *Telesign) Score(options ...OptConFunc) Connection

Score return Score service

func (*Telesign) Status added in v1.0.5

func (t *Telesign) Status(options ...OptConFunc) Connection

Status return Status service

func (*Telesign) Voice

func (t *Telesign) Voice(options ...OptConFunc) Connection

Voice return Voice service

type Voice

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

Voice object

func (Voice) Execute

func (s Voice) Execute(req Request) (Response, error)

Execute the request

func (*Voice) SetAPIKey

func (s *Voice) SetAPIKey(key string)

SetAPIKey set the current API key

func (*Voice) SetCustomerID

func (s *Voice) SetCustomerID(id string)

SetCustomerID set the current customer ID

func (*Voice) SetEnv

func (s *Voice) SetEnv(env string)

SetEnv set the current environment

func (*Voice) SetHTTPTimeout

func (s *Voice) SetHTTPTimeout(i int)

SetHTTPTimeout set the current HTTP request timeout

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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