numverify

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CountriesEndpoint = "http://apilayer.net/api/countries"
	ValidateEndpoint  = "http://apilayer.net/api/validate"
)

Variables

View Source
var EnvNumverifyAccessKey = "NUMVERIFY_ACCESS_KEY"
View Source
var MultiLimit = 0 // test limit to gracefully exit process early.

Functions

func GetNumbers

func GetNumbers(nvClient Client, filebase string, byNumber *histogram.Histogram) error

Types

type Client

type Client struct {
	AccessKey string
}

func NewClient

func NewClient(accessKey string) Client

func (*Client) Countries

func (nc *Client) Countries() (map[string]Country, *ResponseError, *http.Response, error)

Countries returns separate objects for API Success and API Error structs because Numverify API will return a 200 OK for errors such as auth errors.

func (*Client) Validate

func (nc *Client) Validate(params Params) (*Response, *http.Response, error)

Returns separate objects for API Success and API Error structs because Numverify API will return a 200 OK for errors such as auth errors.

type Country

type Country struct {
	CountryName string `json:"country_name,omitempty"`
	DialingCode string `json:"dialling_code,omitempty"`
}

type Error

type Error struct {
	Code int    `json:"code,omitempty"`
	Type string `json:"type,omitempty"`
	Info string `json:"info,omitempty"`
}

type MultiResults

type MultiResults struct {
	Counts    map[string]int
	Responses map[string]*Response
}

MultiResults is designed to handle large volumes of requests.

func GetWriteValidationMulti

func GetWriteValidationMulti(client *Client, requestNumbers, skipNumbers []string, filenameBase string, logAt, fileAt uint) MultiResults

func NewMultiResults

func NewMultiResults() MultiResults

func ReadFilesMultiResults added in v0.0.2

func ReadFilesMultiResults(dir string, rxPattern string) (MultiResults, error)

func (*MultiResults) AddResponses

func (mr *MultiResults) AddResponses(resps map[string]*Response)

func (*MultiResults) Inflate

func (mr *MultiResults) Inflate()

func (*MultiResults) NumbersSuccess

func (mr *MultiResults) NumbersSuccess() []string

func (*MultiResults) Write

func (mr *MultiResults) Write(filename string) error

type Params

type Params struct {
	AccessKey   string `url:"access_key" json:"access_key,omitempty"`
	Number      string `url:"number" json:"number,omitempty"`
	CountryCode string `url:"country_code" json:"country_code,omitempty"`
	Format      int    `url:"format" json:"format,omitempty"`
	Callback    string `url:"callback" json:"callback,omitempty"`
}

Params is the request query parameters for the API. AccessKey is added by the client and is not needed per-request.

func (*Params) MapStringSlice added in v0.0.3

func (params *Params) MapStringSlice() map[string][]string

type Response

type Response struct {
	StatusCode int
	Body       string
	ClientErr  error
	Success    *ResponseSuccess
	Failure    *ResponseError
	Time       time.Time
}

type ResponseError

type ResponseError struct {
	Success bool  `json:"success"`
	Error   Error `json:"error,omitempty"`
}

type ResponseSuccess

type ResponseSuccess struct {
	Valid               bool   `json:"valid,omitempty"`
	Number              string `json:"number,omitempty"`
	LocalFormat         string `json:"local_format,omitempty"`
	InternationalFormat string `json:"international_format,omitempty"`
	CountryPrefix       string `json:"country_prefix,omitempty"`
	CountryCode         string `json:"country_code,omitempty"`
	CountryName         string `json:"country_name,omitempty"`
	Location            string `json:"location,omitempty"`
	Carrier             string `json:"carrier,omitempty"`
	LineType            string `json:"line_type,omitempty"`
}

Jump to

Keyboard shortcuts

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