Documentation ¶
Index ¶
- Constants
- Variables
- func IsServerError(err error) bool
- type APIClient
- type Auth
- type Bool
- type City
- type Client
- type Country
- type CountryID
- type Encoder
- type Error
- type ErrorResponse
- type Errors
- type ExecuteError
- type Factory
- type Group
- type GroupAdminLevel
- type GroupDeactivatedStatus
- type GroupGetFields
- type GroupGetResult
- type GroupSearchFields
- type GroupSearchResult
- type GroupType
- type Groups
- type HTTPClient
- type Permission
- type Raw
- type Relation
- type Request
- type RequestFactory
- type RequestParam
- type Resource
- type Response
- type ResponseProcessor
- type Scope
- type ServerError
- type Sex
- type User
- type Video
- type VideoFiles
- type VideoGetFields
- type VideoGetResult
- type VideoImage
- type VideoItem
Constants ¶
View Source
const ( GroupOpen GroupType = 0 GroupClosed GroupType = 1 GroupPrivate GroupType = 2 GroupDeactivated GroupDeactivatedStatus = "deleted" GroupBanned GroupDeactivatedStatus = "banned" GroupActive GroupDeactivatedStatus = "" )
View Source
const UserFields = "id,first_name,last_name,sex,country,city,photo_max,last_seen"
UserFields all fields that are in User struct
Variables ¶
View Source
var (
Debug = false
)
Functions ¶
func IsServerError ¶
Types ¶
type Bool ¶
type Bool bool
Bool is special format for vk bool values that are represented as integers - 1,0
func (Bool) MarshalJSON ¶
func (*Bool) UnmarshalJSON ¶
type Client ¶
Client for vk api
func NewWithToken ¶
func (*Client) SetHTTPClient ¶
func (c *Client) SetHTTPClient(httpClient HTTPClient)
SetHTTPClient sets underlying http client
type Error ¶
type Error struct { Code ServerError `json:"error_code,omitempty"` Message string `json:"error_msg,omitempty"` Params []RequestParam `json:"request_params,omitempty"` Request Request `json:"-"` }
func GetServerError ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error Error `json:"error"`
}
type ExecuteError ¶
type ExecuteError struct { Method string `json:"method"` Code ServerError `json:"error_code"` Message string `json:"error_msg"` }
func (ExecuteError) Error ¶
func (e ExecuteError) Error() string
type Group ¶
type Group struct { ID int `json:"id"` Name string `json:"name` Slug string `json:"screen_name"` Deactivated GroupDeactivatedStatus `json:"deactivated"` IsClosed GroupType `json:"is_closed"` IsAdmin Bool `json:"is_admin"` IsMember Bool `json:"is_member"` AdminLevel GroupAdminLevel `json:"admin_level"` Type string `json:"type"` Photo50 string `json:"photo_50"` Photo100 string `json:"photo_100"` Photo200 string `json:"photo_200"` Description string `json:"description"` MembersCount int `json:"members_count"` Status string `json:"status"` }
type GroupAdminLevel ¶
type GroupAdminLevel int
const ( GroupModerator GroupAdminLevel = 1 GroupRedactor GroupAdminLevel = 2 GroupAdministrator GroupAdminLevel = 3 )
func (GroupAdminLevel) String ¶
func (i GroupAdminLevel) String() string
type GroupDeactivatedStatus ¶
type GroupDeactivatedStatus string
type GroupGetFields ¶
type GroupGetResult ¶
type GroupSearchFields ¶
type GroupSearchFields struct {
ID int `structs:"id"`
}
type GroupSearchResult ¶
type Groups ¶
type Groups struct {
Resource
}
func (Groups) Get ¶
func (g Groups) Get(fields GroupGetFields) (result GroupGetResult, err error)
func (Groups) GetBatch ¶
func (g Groups) GetBatch(getFields GroupGetFields) ([]User, int, error)
batch get
func (Groups) GetMembers ¶
func (g Groups) GetMembers(q GroupSearchFields) (result GroupSearchResult, err error)
type HTTPClient ¶
HTTPClient is abstaction under http client, that can Do requests
type Permission ¶
type Permission string
Permission of application
const ( PermOffline Permission = "offline" PermFriends Permission = "friends" PermPhotos Permission = "photos" PermGroups Permission = "groups" )
func (Permission) String ¶
func (p Permission) String() string
type Raw ¶
type Raw []byte
RawString is a raw encoded JSON object. It implements Marshaler and Unmarshaler and can be used to delay JSON decoding or precompute a JSON encoding.
func (Raw) MarshalJSON ¶
MarshalJSON returns *m as the JSON encoding of m.
func (*Raw) UnmarshalJSON ¶
UnmarshalJSON sets *m to a copy of data.
type Request ¶
type Request struct { Method string `json:"method"` Token string `json:"token"` Values url.Values `json:"values"` }
Request to vk api serializable
type RequestFactory ¶
var ( // DefaultClient uses defaultHTTPClient for transport DefaultClient = New() // DefaultFactory with blank token DefaultFactory RequestFactory = Factory{} )
type RequestParam ¶
type Resource ¶
type Resource struct { APIClient RequestFactory }
type Response ¶
type Response struct { Errors Errors `json:"execute_errors,omitempty"` Error `json:"error,omitempty"` Response Raw `json:"response,omitempty"` }
func (Response) ServerError ¶
type ResponseProcessor ¶
ResponseProcessor fills response struct from response
type Scope ¶
type Scope map[Permission]bool
func NewScope ¶
func NewScope(permissions ...Permission) Scope
func (Scope) Add ¶
func (s Scope) Add(permissions ...Permission)
func (Scope) Del ¶
func (s Scope) Del(permissions ...Permission)
func (Scope) Has ¶
func (s Scope) Has(p Permission) bool
type ServerError ¶
type ServerError int
const ( // Possible error codes // https://vk.com/dev/errors ErrZero ServerError = iota ErrUnknown ErrApplicationDisabled ErrUnknownMethod ErrInvalidSignature ErrAuthFailed ErrTooManyRequests ErrInsufficientPermissions ErrInvalidRequest ErrTooManyOneTypeRequests ErrInternalServerError ErrAppInTestMode ErrCaptchaNeeded ErrNotAllowed ErrHttpsOnly ErrNeedValidation ErrStandaloneOnly ErrStandaloneOpenAPIOnly ErrMethodDisabled ErrNeedConfirmation ErrOneOfParametersInvalid ServerError = 100 ErrInvalidAPIID ServerError = 101 ErrInvalidAUserID ServerError = 113 ErrInvalidTimestamp ServerError = 150 ErrAlbumAccessProhibited ServerError = 200 ErrGroupAccessProhibited ServerError = 203 ErrAlbumOverflow ServerError = 300 ErrMoneyTransferNotAllowed ServerError = 500 ErrInsufficientPermissionsAd ServerError = 600 ErrInternalServerErrorAd ServerError = 603 ErrBadResponseCode ServerError = -1 )
func (ServerError) Error ¶
func (s ServerError) Error() string
func (ServerError) Is ¶
func (e ServerError) Is(err error) bool
Is returns true, if err equals (or is Error with code equals) e
func (ServerError) String ¶
func (i ServerError) String() string
type User ¶
type User struct { ID int `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Sex Sex `json:"sex"` Country Country `json:"country"` City City `json:"city"` Hidden Bool `json:"hidden"` Birthday string `json:"bdate"` PhotoMax string `json:"photo_max"` Status string `json:"status"` LastSeen struct { Time int64 `json:"time"` Platform int `json:"platform"` } `json:"last_seen"` Books string `json:"books"` About string `json:"about"` }
type Video ¶
type Video struct {
Resource
}
func (Video) Get ¶
func (v Video) Get(fields VideoGetFields) (result VideoGetResult, err error)
type VideoFiles ¶
type VideoFiles struct {
External string `json:"external"`
}
type VideoGetFields ¶
type VideoGetResult ¶
type VideoImage ¶
type VideoImage struct { Height int `json:"height"` Width int `json:"width"` URL string `json:"url"` }
func (*VideoImage) UnmarshalJSON ¶
func (v *VideoImage) UnmarshalJSON(b []byte) error
type VideoItem ¶
type VideoItem struct { Duration int `json:"duration"` Player string `json:"player"` Files VideoFiles `json:"files"` Images []VideoImage `json:"image"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.