smsactivate

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: MIT Imports: 8 Imported by: 0

README

go-sms-activate

A client for sms-activate.ru API

GoDoc

Install

go get -u github.com/dvz1/go-sms-activate

Import

import (
	smsactivate "github.com/dvz1/go-sms-activate"
)

Examples

See examples/main.go

Changelog

CHANGELOG.md

Documentation

Overview

Package smsactivate is a client for sms-activate.ru API. For API description see https://sms-activate.ru/en/api_doc.

Index

Constants

View Source
const (
	// A service successfully activated.
	AccessActivation = "ACCESS_ACTIVATION"
	// An activation canceled.
	AccessCancel = "ACCESS_CANCEL"
	// A number readiness confirmed.
	AccessReady = "ACCESS_READY"
	// Waiting for a new sms.
	AccessRetryGet = "ACCESS_RETRY_GET"

	// An activation canceled.
	StatusCancel = "STATUS_CANCEL"
	// Waiting for sms.
	StatusWaitCode = "STATUS_WAIT_CODE"
	// Received an activation code.
	StatusOK = "STATUS_OK"
	// Waiting for code refinement.
	StatusWaitRetry = "STATUS_WAIT_RETRY"
	// Waiting for SMS re-sending (the software should perform status change to 6).
	StatusWaitResend = "STATUS_WAIT_RESEND"
)

Variables

View Source
var (
	// ErrBadKey is a wrapper for BAD_KEY response.
	ErrBadKey = errors.New(prefix + ": invalid API key")
	// ErrSQL is a wrapper for ERROR_SQL response.
	ErrSQL = errors.New(prefix + ": SQL-server error")
	// ErrBadAction is a wrapper for BAD_ACTION response.
	ErrBadAction = errors.New(prefix + ": incorrect action")
	// ErrBadService is a wrapper for BAD_SERVICE response.
	ErrBadService = errors.New(prefix + ": incorrect service name")
	// ErrNoActivation is a wrapper for NO_ACTIVATION response.
	ErrNoActivation = errors.New(prefix + ": activation id does not exist")
	// ErrBadStatus is a wrapper for BAD_STATUS response.
	ErrBadStatus = errors.New(prefix + ": incorrect status")
	// ErrNoKey is a wrapper for NO_KEY response.
	ErrNoKey = errors.New(prefix + ": no API key provided")
	// ErrNoAction is a wrapper for NO_ACTION response.
	ErrNoAction = errors.New(prefix + ": no action provided")
	// ErrNoBalance is a wrapper for NO_BALANCE response.
	ErrNoBalance = errors.New(prefix + ": balance ended")
	// ErrNoNumbers is a wrapper for NO_NUMBERS response.
	ErrNoNumbers = errors.New(prefix + ": no available numbers")
)

Functions

This section is empty.

Types

type Api

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

Api is a wrapper for an http.Client which performs requests to sms-activate.ru API.

func New

func New(apiKey string) Api

New creates a new Api instance with the given API key.

func (*Api) CloseIdleConnections

func (api *Api) CloseIdleConnections()

CloseIdleConnections closes an idle connections. See also https://golang.org/pkg/net/http/#Client.CloseIdleConnections.

func (Api) GetBalance

func (api Api) GetBalance() (float64, error)

GetBalance requests an account balance. See also https://sms-activate.ru/en/api_doc#collapseOne.

func (Api) GetBalanceAndCashBack

func (api Api) GetBalanceAndCashBack() (float64, error)

GetBalanceAndCashBack requests a balance with cashback account. See also https://sms-activate.ru/en/api_doc#collapseOne.

func (Api) GetNumber

func (api Api) GetNumber(service string, forward bool, operator string, ref string, country int) (id uint64, number string, err error)

GetNumbers requests an order of a phone number. See also https://sms-activate.ru/en/api_doc#collapseSeven.

func (Api) GetNumbersStatus

func (api Api) GetNumbersStatus(country int, operator string) ([]Service, error)

GetNumbersStatus requests the number of available phones for the given country and mobile network operator. See also https://sms-activate.ru/en/api_doc#collapseSix.

func (Api) GetNumbersStatusAll

func (api Api) GetNumbersStatusAll() ([]Service, error)

GetNumbersStatusAll requests the number of available phones. See also https://sms-activate.ru/en/api_doc#collapseSix.

func (Api) GetNumbersStatusCountry

func (api Api) GetNumbersStatusCountry(country int) ([]Service, error)

GetNumbersStatusCountry requests the number of available phones for the given country. See also https://sms-activate.ru/en/api_doc#collapseSix.

func (Api) GetNumbersStatusOperator

func (api Api) GetNumbersStatusOperator(operator string) ([]Service, error)

GetNumbersStatusOperator requests the number of available phones for the given mobile network operator. See also https://sms-activate.ru/en/api_doc#collapseSix.

func (Api) GetPrices

func (api Api) GetPrices(service string, country int) ([]CountryPrice, error)

GetPrices requests current prices for the given service and country. See also https://sms-activate.ru/en/api_doc#collapseTen.

func (Api) GetPricesAll

func (api Api) GetPricesAll() ([]CountryPrice, error)

GetPricesAll requests current prices. See also https://sms-activate.ru/en/api_doc#collapseTen.

func (Api) GetPricesByCountry

func (api Api) GetPricesByCountry(country int) ([]CountryPrice, error)

GetPricesAll requests current prices for the given country. See also https://sms-activate.ru/en/api_doc#collapseTen.

func (Api) GetPricesByService

func (api Api) GetPricesByService(service string) ([]CountryPrice, error)

GetPricesAll requests current prices for the given service. See also https://sms-activate.ru/en/api_doc#collapseTen.

func (Api) GetQiwiRequisites

func (api Api) GetQiwiRequisites() (QiwiRequisites, error)

GetQiwiRequisites requests an up-to-date top-up wallet for Qiwi. See also https://sms-activate.ru/en/api_doc#collapseEleven.

func (Api) GetStatus

func (api Api) GetStatus(id uint64) (string, string, error)

GetStatus returns an activation status and an activation code if present. See also https://sms-activate.ru/en/api_doc#collapseFourth.

func (Api) SetStatus

func (api Api) SetStatus(status int, id uint64, forward string) (string, error)

SetStatus requests changing of activation status. See also https://sms-activate.ru/en/api_doc#collapseFifth.

type CountryPrice

type CountryPrice struct {
	Country string
	Price   []ServiceCost
}

type ErrBanned

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

ErrBanned is a wrapper for BANNED:$time answer.

func NewErrBanned

func NewErrBanned(until time.Time) ErrBanned

NewErrBanned returns a new error instance.

func (ErrBanned) Error

func (err ErrBanned) Error() string

Error implements an error interface.

type ErrUnknownResponse

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

ErrUnknownResponse is an error returned for unknown response received from sms-activate.ru

func NewErrUnknownResponse

func NewErrUnknownResponse(resp string) ErrUnknownResponse

NewErrUnknownResponse returns a new error instance.

func (ErrUnknownResponse) Error

func (err ErrUnknownResponse) Error() string

Error implements an error interface.

type QiwiRequisites

type QiwiRequisites struct {
	Status   string
	Wallet   string
	UpToDate time.Time
	Comment  string
}

func (*QiwiRequisites) UnmarshalJSON

func (reqs *QiwiRequisites) UnmarshalJSON(b []byte) (err error)

type Service

type Service struct {
	Name    string
	Forward bool
	Numbers int
}

type ServiceCost

type ServiceCost struct {
	Service

	Cost float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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