func (e *APIError) Error() string {
	return fmt.Sprintf("vk.APIError %d: %s", e.Code, e.Message)
}
Error implements error interface
package vk
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"net/url"
	"net/http"
	"github.com/google/go-querystring/query"
)
const (
	apiBaseURL = "https://api.vk.com/method/"
)
type API interface {
	Request(method string, params interface{}) (json.RawMessage, error)
	HTTPClient() *http.Client
}
type BaseAPI struct {
	BaseURL     string `url:"-"`
	AccessToken string `url:"access_token,omitempty"`
	Version     string `url:"v,omitempty"`
	Language    string `url:"lang,omitempty"`
	client *http.Client
}
type BaseAPIConfig struct {
	AccessToken string
	Language string
	Client *http.Client
}
func NewBaseAPI(cfg BaseAPIConfig) (*BaseAPI, error) {
	if cfg.AccessToken == "" {
		return nil, errors.New("AccessToken is required")
	}
	client := cfg.Client
	if client == nil {
		client = http.DefaultClient
	}
	return &BaseAPI{
		AccessToken: cfg.AccessToken,
		Version:     APIVersion,
		BaseURL:     apiBaseURL,
		Language:    cfg.Language,
		client: client,
	}, nil
}
type APIError struct {
	Code          int    `json:"error_code"`
	Message       string `json:"error_msg"`
	RequestParams []struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	} `json:"request_params"`
}