gonlinesim

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 9 Imported by: 0

README

gonlinesim

golang client for https://onlinesim.io/ API.

Documentation

Index

Constants

View Source
const (
	LangFR = "fr"
	LangDE = "de"
	LangRU = "ru"
	LangEN = "en"
	LangZH = "zh"
)

Variables

View Source
var (
	ErrAccountBlocked    = errors.New("account blocked")
	ErrWrongKey          = errors.New("wrong key")
	ErrNoKey             = errors.New("no key")
	ErrNoService         = errors.New("no service or invalid service name")
	ErrRequestNotFound   = errors.New("request not found")
	ErrAPIAccessDisabled = errors.New("api access disabled")
	ErrAPIAccessIP       = errors.New("api access blocked for this IP")
	ErrLowBalance        = errors.New("low balance")
)

Functions

This section is empty.

Types

type BaseResp

type BaseResp struct {
	Response interface{} `json:"response"`
}

type Client

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

func NewClient

func NewClient(apiKey string) *Client

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context,
	opts ...Option) (*GetBalanceResp, error)

func (Client) GetFreeList

func (c Client) GetFreeList(ctx context.Context,
	opts ...Option) (*GetFreeListResponse, error)

GetFreeList depending on the parameters returns information on available countries with free numbers, received messages and the list of restricted services.

Without parameters: returns a list of available countries with free numbers, messages received by the first number from the list and the list of restricted services.

With country parameter: returns a list of available free numbers of that country, messages received by the first number from the list and the list of restricted services.

With country and number parameters: returns a list of SMS messages received by this number and the list of restrices services. You can send this request to get a number that can be used for SMS receiption

later on, for example for testing.

func (*Client) GetTariffs

func (c *Client) GetTariffs(ctx context.Context,
	opts ...Option) (*GetTariffsResp, error)

type GetBalanceResp

type GetBalanceResp struct {
	BaseResp
	Balance  string `json:"balance"`
	ZBalance string `json:"zbalance"`
}

type GetFreeListResponse

type GetFreeListResponse struct {
	BaseResp
	Countries []struct {
		PhoneCode    int    `json:"country"`
		Name         string `json:"country_text"`
		OriginalName string `json:"country_original"`
	} `json:"countries"`
	Numbers map[string]struct {
		CountryCode int    `json:"country"`
		CountryName string `json:"country_original"`
		DateHumans  string `json:"data_humans"`
		FullNumber  string `json:"full_number"`
		Archived    bool   `json:"is_archive"`
	} `json:"numbers"`
	Messages struct {
		CurrentPage  int        `json:"current_page"`
		Data         []*Message `json:"data"`
		FirstPageURL string     `json:"first_page_url"`
		From         int        `json:"from"`
		LastPage     int        `json:"last_page"`
		LastPageURL  string     `json:"last_page_url"`
		Links        []*Link    `json:"links"`
		NextPageURL  string     `json:"next_page_url"`
		Path         string     `json:"path"`
		PerPage      int        `json:"per_page"`
		PrevPageURL  string     `json:"prev_page_url"`
		To           int        `json:"to"`
		Total        int        `json:"total"`
		Number       string     `json:"number"`
		Country      int        `json:"country"`
	} `json:"messages"`
	Ignore string `json:"ignore"`
}

type GetTariffsResp

type GetTariffsResp struct {
	BaseResp
	Country int    `json:"country"`
	Page    int    `json:"page"`
	End     bool   `json:"end"`
	Filter  string `json:"filter"`
}
type Link struct {
	URL    string `json:"url"`
	Label  string `json:"label"`
	Active bool   `json:"active"`
}

type Message

type Message struct {
	Text              string    `json:"text"`
	InNumber          string    `json:"in_number"`
	MyNumber          float64   `json:"my_number"`
	CreatedAt         time.Time `json:"created_at"`
	CreatedAtReadable string    `json:"data_humans"`
}

type Option

type Option func(*resty.Request)

func WithCountryCode

func WithCountryCode(val uint) Option

func WithLang

func WithLang(val string) Option

func WithPhone

func WithPhone(val string) Option

Jump to

Keyboard shortcuts

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