-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevent.go
106 lines (89 loc) · 3.21 KB
/
event.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package clubhouse
import "net/http"
type Event struct {
Channel *string `json:"channel"`
Club *Club `json:"club"`
Description string `json:"description"`
EventID int `json:"event_id"`
Hosts []EventHost `json:"hosts"`
IsAttending bool `json:"is_attending"`
IsExpired bool `json:"is_expired"`
IsMemberOnly bool `json:"is_member_only"`
Name string `json:"name"`
TimeStart string `json:"time_start"`
URL string `json:"url"`
}
type EventHost struct {
BaseUserProfile
Bio *string `json:"bio"`
Twitter *string `json:"twitter"`
}
type GetEventsParams struct {
IsFiltered bool `url:"is_filtered"`
Page *int `json:"-" url:"page,omitempty"`
PageSize *int `json:"-" url:"page_size,omitempty"`
}
type GetEventsResponse struct {
PageResponse
Events []struct {
Event
ClubIsFollower int `json:"club_is_follower"`
ClubIsMember int `json:"club_is_member"`
} `json:"events"`
}
func (c *Client) GetEvents(params *GetEventsParams) (*GetEventsResponse, *http.Response, error) {
apiRes := new(GetEventsResponse)
apiError := new(APIError)
res, err := c.sling.New().Get("get_events").QueryStruct(params).Receive(apiRes, apiError)
return apiRes, res, relevantError(err, *apiError)
}
type GetEventsForClubParams struct {
ClubID int `json:"club_id"`
InviteCode interface{} `json:"invite_code"` // TODO: Find real type
QueryID *string `json:"query_id"`
QueryResultPosition *int `json:"query_result_position"`
Slug *string `json:"slug"`
SourceTopicID *int `json:"source_topic_id"`
}
type GetEventsForClubResponse struct {
Response
Events []Event `json:"events"`
}
func (c *Client) GetEventsForClub(params *GetEventsForClubParams) (*GetEventsForClubResponse, *http.Response, error) {
apiRes := new(GetEventsForClubResponse)
apiError := new(APIError)
res, err := c.sling.New().Post("get_events_for_club").BodyJSON(params).Receive(apiRes, apiError)
return apiRes, res, relevantError(err, *apiError)
}
type GetEventsForUserParams struct {
UserID int `url:"user_id"`
Page *int `json:"-" url:"page,omitempty"`
PageSize *int `json:"-" url:"page_size,omitempty"`
}
type GetEventsForUserResponse struct {
PageResponse
Events []struct {
Event
ClubIsFollower int `json:"club_is_follower"`
ClubIsMember int `json:"club_is_member"`
} `json:"events"`
}
func (c *Client) GetEventsForUser(params *GetEventsForUserParams) (*GetEventsForUserResponse, *http.Response, error) {
apiRes := new(GetEventsForUserResponse)
apiError := new(APIError)
res, err := c.sling.New().Get("get_events_for_user").QueryStruct(params).Receive(apiRes, apiError)
return apiRes, res, relevantError(err, *apiError)
}
type RsvpEventParams struct {
EventID int `json:"event_id"`
IsAttending bool `json:"is_attending"`
}
type RsvpEventResponse struct {
Response
}
func (c *Client) RsvpEvent(params *RsvpEventParams) (*RsvpEventResponse, *http.Response, error) {
apiRes := new(RsvpEventResponse)
apiError := new(APIError)
res, err := c.sling.New().Post("rsvp_event").BodyJSON(params).Receive(apiRes, apiError)
return apiRes, res, relevantError(err, *apiError)
}