-
Notifications
You must be signed in to change notification settings - Fork 1
/
reactions.go
66 lines (51 loc) · 2.16 KB
/
reactions.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
package guildedgo
import (
"errors"
"strconv"
)
type reactionEndpoints struct{}
func (e *reactionEndpoints) Default(channelId string, contentId string, emoteId int) string {
return guildedApi + "/channels/" + channelId + "/content/" + contentId + "/emotes/" + strconv.Itoa(emoteId)
}
func (e *reactionEndpoints) Topic(channelId string, topicId int, emoteId int) string {
return guildedApi + "/channels/" + channelId + "/topics/" + strconv.Itoa(topicId) + "/emotes/" + strconv.Itoa(emoteId)
}
type ReactionService interface {
AddReactionEmote(channelId string, contentId string, emoteId int) error
DeleteReactionEmote(channelId string, contentId string, emoteId int) error
AddTopicReactionEmote(channelId string, topicId int, emoteId int) error
DeleteTopicReactionEmote(channelId string, topicId int, emoteId int) error
}
type reactionService struct {
client *Client
endpoints *reactionEndpoints
}
var _ ReactionService = &reactionService{}
func (service *reactionService) AddReactionEmote(channelId string, contentId string, emoteId int) error {
_, err := service.client.PutRequest(service.endpoints.Default(channelId, contentId, emoteId), nil)
if err != nil {
return errors.New("Failed to add reaction emote: " + err.Error())
}
return nil
}
func (service *reactionService) DeleteReactionEmote(channelId string, contentId string, emoteId int) error {
_, err := service.client.DeleteRequest(service.endpoints.Default(channelId, contentId, emoteId))
if err != nil {
return errors.New("Failed to delete reaction emote: " + err.Error())
}
return nil
}
func (service *reactionService) AddTopicReactionEmote(channelId string, topicId int, emoteId int) error {
_, err := service.client.PutRequest(service.endpoints.Topic(channelId, topicId, emoteId), nil)
if err != nil {
return errors.New("Failed to add topic reaction emote: " + err.Error())
}
return nil
}
func (service *reactionService) DeleteTopicReactionEmote(channelId string, topicId int, emoteId int) error {
_, err := service.client.DeleteRequest(service.endpoints.Topic(channelId, topicId, emoteId))
if err != nil {
return errors.New("Failed to add topic reaction emote: " + err.Error())
}
return nil
}