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
- Variables
- type Api
- func (api *Api) CloseIdleConnections()
- func (api Api) GetBalance() (float64, error)
- func (api Api) GetBalanceAndCashBack() (float64, error)
- func (api Api) GetNumber(service string, forward bool, operator string, ref string, country int) (id uint64, number string, err error)
- func (api Api) GetNumbersStatus(country int, operator string) ([]Service, error)
- func (api Api) GetNumbersStatusAll() ([]Service, error)
- func (api Api) GetNumbersStatusCountry(country int) ([]Service, error)
- func (api Api) GetNumbersStatusOperator(operator string) ([]Service, error)
- func (api Api) GetPrices(service string, country int) ([]CountryPrice, error)
- func (api Api) GetPricesAll() ([]CountryPrice, error)
- func (api Api) GetPricesByCountry(country int) ([]CountryPrice, error)
- func (api Api) GetPricesByService(service string) ([]CountryPrice, error)
- func (api Api) GetQiwiRequisites() (QiwiRequisites, error)
- func (api Api) GetStatus(id uint64) (string, string, error)
- func (api Api) SetStatus(status int, id uint64, forward string) (string, error)
- type CountryPrice
- type ErrBanned
- type ErrUnknownResponse
- type QiwiRequisites
- type Service
- type ServiceCost
Constants ¶
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 ¶
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 (*Api) CloseIdleConnections ¶
func (api *Api) CloseIdleConnections()
CloseIdleConnections closes an idle connections. See also https://golang.org/pkg/net/http/#Client.CloseIdleConnections.
func (Api) GetBalance ¶
GetBalance requests an account balance. See also https://sms-activate.ru/en/api_doc#collapseOne.
func (Api) GetBalanceAndCashBack ¶
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 ¶
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 ¶
GetNumbersStatusAll requests the number of available phones. See also https://sms-activate.ru/en/api_doc#collapseSix.
func (Api) GetNumbersStatusCountry ¶
GetNumbersStatusCountry requests the number of available phones for the given country. See also https://sms-activate.ru/en/api_doc#collapseSix.
func (Api) GetNumbersStatusOperator ¶
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 ¶
GetStatus returns an activation status and an activation code if present. See also https://sms-activate.ru/en/api_doc#collapseFourth.
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 ¶
NewErrBanned returns a new error instance.
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 ¶
func (*QiwiRequisites) UnmarshalJSON ¶
func (reqs *QiwiRequisites) UnmarshalJSON(b []byte) (err error)