Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidNumber is returned if the phone number is invalid ErrInvalidNumber = errors.New("phone number is invalid") // ErrRateLimited indicates that the call was rate limited ErrRateLimited = errors.New("rate limited") // ErrInvalidVerificationCode is returned when the verification does not // match what's expected in a Confirm call ErrInvalidVerificationCode = errors.New("verification code does not match") // ErrNoVerification indicates that no verification is in progress for // the provided phone number in a Confirm call. Several reasons this // can occur include a verification being expired or having reached a // maximum check threshold. ErrNoVerification = errors.New("verification not in progress") // ErrUnsupportedPhoneType indicates the provided phone number maps to // a type of phone that isn't supported. ErrUnsupportedPhoneType = errors.New("unsupported phone type") )
View Source
var IsoToMcc map[string]map[int]struct{}
View Source
var MccToIso = map[int]map[string]struct{}{}/* 238 elements not displayed */
Functions ¶
func IsE164Format ¶
IsE164Format returns whether a string is a E.164 formatted phone number.
func IsMccIsoCode ¶
IsMccIsoCode determines whether a MCC is associated with the provided ISO country code
func IsVerificationCode ¶
IsVerificationCode returns whether a string is a 4-10 digit numberical verification code.
Types ¶
type Metadata ¶
type Metadata struct {
// The phone number associated with the set of metadata
PhoneNumber string
// The type of phone. Currently, this is always expected to be a mobile type.
Type *Type
// Identifies the country and MNO
// https://www.twilio.com/docs/iot/supersim/api/network-resource#the-identifiers-property
MobileCountryCode *int
MobileNetworkCode *int
}
Metadata provides additional information regarding a phone number. Information is provided on a best-effort basis as provided by third party solutions. This can be used for antispam and fraud measures.
func (*Metadata) SetMobileCountryCode ¶
func (*Metadata) SetMobileNetworkCode ¶
type Verifier ¶
type Verifier interface {
// SendCode sends a verification code via SMS to the provided phone number.
// If an active verification is already taking place, the existing code will
// be resent. A unique ID for the verification and phone metadata is returned on
// success.
SendCode(ctx context.Context, phoneNumber string) (string, *Metadata, error)
// Check verifies a SMS code sent to a phone number.
Check(ctx context.Context, phoneNumber, code string) error
// Cancel cancels an active verification. No error is returned if the
// verification doesn't exist, previously canceled or successfully
// completed.
Cancel(ctx context.Context, id string) error
// IsVerificationActive checks whether a verification is active or not
IsVerificationActive(ctx context.Context, id string) (bool, error)
// IsValid validates a phone number is real and is able to receive
// a verification code.
IsValidPhoneNumber(ctx context.Context, phoneNumber string) (bool, error)
}
Click to show internal directories.
Click to hide internal directories.