forked from SevereCloud/vksdk
/
polls.go
89 lines (78 loc) · 2.64 KB
/
polls.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package object // import "github.com/akss1/vksdk/5.92/object"
import (
"fmt"
)
type pollsAnswer struct {
ID int `json:"id"`
Rate float64 `json:"rate"`
Text string `json:"text"`
Votes int `json:"votes"`
}
// PollsPoll struct
type PollsPoll struct {
AnswerID int `json:"answer_id"` // Current user's answer ID
Answers []pollsAnswer `json:"answers"`
Created int `json:"created"` // Date when poll has been created in Unixtime
ID int `json:"id"` // Poll ID
OwnerID int `json:"owner_id"` // Poll owner's ID
Question string `json:"question"` // Poll question
Votes int `json:"votes"` // Votes number
AnswerIDs []int `json:"answer_ids"`
EndDate int `json:"end_date"`
Anonymous bool `json:"anonymous"` // Information whether the pole is anonymous
Closed bool `json:"closed"`
IsBoard bool `json:"is_board"`
CanEdit bool `json:"can_edit"`
CanVote bool `json:"can_vote"`
CanReport bool `json:"can_report"`
CanShare bool `json:"can_share"`
Multiple bool `json:"multiple"`
Photo PhotosPhoto `json:"photo"`
AuthorID int `json:"author_id"`
Background PollsBackground `json:"background"`
Friends []pollsFriend `json:"friends"`
Profiles []UsersUser `json:"profiles"`
Groups []GroupsGroup `json:"groups"`
}
// ToAttachment return attachment format
func (poll PollsPoll) ToAttachment() string {
return fmt.Sprintf("poll%d_%d", poll.OwnerID, poll.ID)
}
type pollsFriend struct {
ID int `json:"id"`
}
// PollsVoters struct
type PollsVoters struct {
AnswerID int `json:"answer_id"` // Answer ID
Users pollsVotersUsers `json:"users"`
}
type pollsVotersUsers struct {
Count int `json:"count"` // Votes number
Items []int `json:"items"`
}
// PollsVotersFields struct
type PollsVotersFields struct {
AnswerID int `json:"answer_id"` // Answer ID
Users pollsVotersUsersFields `json:"users"`
}
type pollsVotersUsersFields struct {
Count int `json:"count"` // Votes number
Items []UsersUser `json:"items"`
}
// PollsBackground struct
type PollsBackground struct {
Type string `json:"type"`
Angle int `json:"angle"`
Color string `json:"color"`
Points []struct {
Position float64 `json:"position"`
Color string `json:"color"`
} `json:"points"`
ID int `json:"id"`
}
// PollsPhoto struct
type PollsPhoto struct {
ID int `json:"id"`
Color string `json:"color"`
Images []PhotosImage `json:"images"`
}