-
Notifications
You must be signed in to change notification settings - Fork 14
/
poll.go
38 lines (32 loc) · 1 KB
/
poll.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
package gotwtr
type PollField string
/*
Poll field will only return
if you've also included the expansions=attachments.poll_ids query parameter in your request.
*/
const (
PollFieldID PollField = "id"
PollFieldOptions PollField = "options"
PollFieldDurationMinutes PollField = "duration_minutes"
PollFieldEndDateTime PollField = "end_datetime"
PollFieldVotingStatus PollField = "voting_status"
)
type Poll struct {
ID string `json:"id"`
Options []*PollOption `json:"options"`
DurationMinutes int `json:"duration_minutes,omitempty"`
EndDatetime string `json:"end_datetime,omitempty"`
VotingStatus string `json:"voting_status,omitempty"`
}
type PollOption struct {
Position int `json:"position"`
Label string `json:"label"`
Votes int `json:"votes"`
}
func pollFieldsToString(pfs []PollField) []string {
slice := make([]string, len(pfs))
for i, pf := range pfs {
slice[i] = string(pf)
}
return slice
}