-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathgift.go
46 lines (37 loc) · 949 Bytes
/
gift.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package vkapi
import (
"encoding/json"
"net/url"
"strconv"
)
type Gift struct {
Count int `json:"count"`
Gifts []*GiftItem `json:"items"`
}
type GiftItem struct {
ID int `json:"id"`
FromID int `json:"from_id"`
Message string `json:"message"`
Date int64 `json:"date"`
Info *GiftInfo `json:"gift"`
Privacy int `json:"privacy"`
}
type GiftInfo struct {
ID int `json:"id"`
Thumb256 string `json:"thumb_256"`
Thumb48 string `json:"thumb_48"`
Thumb96 string `json:"thumb_96"`
}
func (client *VKClient) GetGifts(id int, count int, offset int) (*Gift, error) {
params := url.Values{}
params.Set("user_id", strconv.Itoa(id))
params.Set("count", strconv.Itoa(count))
params.Set("offset", strconv.Itoa(offset))
resp, err := client.MakeRequest("gifts.get", params)
if err != nil {
return nil, err
}
var gift *Gift
json.Unmarshal(resp.Response, &gift)
return gift, nil
}