This repository has been archived by the owner on Aug 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
75 lines (62 loc) · 3.4 KB
/
client.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
package tatsumakigo
import "context"
// Client is the main interface to interact with the API.
type Client struct {
restClient *restClient
}
// New creates a new instance of the Tatsumaki client.
func New(token string) *Client {
return &Client{
newRestClient(token),
}
}
// AdjustGuildUserPoints wraps AdjustGuildUserPointsWithContext using the background context.
func (t *Client) AdjustGuildUserPoints(guildID string, userID string, amount int, action Action) (*GuildUserPoints, error) {
return t.AdjustGuildUserPointsWithContext(context.Background(), guildID, userID, amount, action)
}
// AdjustGuildUserPointsWithContext adjusts a user's points in a guild.
// The amount must be between 0 and 50,000 (inclusive) and must be above 0 if the action is add or remove.
func (t *Client) AdjustGuildUserPointsWithContext(ctx context.Context, guildID string, userID string, amount int,
action Action) (*GuildUserPoints, error) {
return t.restClient.adjustGuildUserPoints(ctx, guildID, userID, amount, action)
}
// AdjustGuildUserScore wraps AdjustGuildUserScoreWithContext using the background context.
func (t *Client) AdjustGuildUserScore(guildID string, userID string, amount int,
action Action) (*GuildUserScore, error) {
return t.AdjustGuildUserScoreWithContext(context.Background(), guildID, userID, amount, action)
}
// AdjustGuildUserScoreWithContext adjusts a user's score in a guild.
// The amount must be between 0 and 50,000 (inclusive) and must be above 0 if the action is add or remove.
func (t *Client) AdjustGuildUserScoreWithContext(ctx context.Context, guildID string, userID string, amount int,
action Action) (*GuildUserScore, error) {
return t.restClient.adjustGuildUserScore(ctx, guildID, userID, amount, action)
}
// GuildLeaderboard wraps GuildLeaderboardWithContext using the background context.
// To get all guild member rankings for the leaderboard, set limit to -1.
// If limit is set to 0, the default value will be used as per the API.
func (t *Client) GuildLeaderboard(guildID string, limit int) ([]*GuildRankedUser, error) {
return t.GuildLeaderboardWithContext(context.Background(), guildID, limit)
}
// GuildLeaderboardWithContext gets the leaderboard for a guild.
// To get all guild member rankings for the leaderboard, set limit to -1.
// If limit is set to 0, the default value will be used as per the API.
func (t *Client) GuildLeaderboardWithContext(ctx context.Context, guildID string, limit int) ([]*GuildRankedUser, error) {
return t.restClient.guildLeaderboard(ctx, guildID, limit)
}
// GuildUserStats wraps GuildUserStatsWithContext using the background context.
func (t *Client) GuildUserStats(guildID string, userID string) (*GuildUserStats, error) {
return t.GuildUserStatsWithContext(context.Background(), guildID, userID)
}
// GuildUserStatsWithContext gets a user's stats for a guild.
// @me is accepted for the user ID, which will retrieve stats for the owner of the API token.
func (t *Client) GuildUserStatsWithContext(ctx context.Context, guildID string, userID string) (*GuildUserStats, error) {
return t.restClient.guildUserStats(ctx, guildID, userID)
}
// User wraps UserWithContext using the background context.
func (t *Client) User(userID string) (*User, error) {
return t.UserWithContext(context.Background(), userID)
}
// UserWithContext gets a Tatsumaki user profile.
func (t *Client) UserWithContext(ctx context.Context, userID string) (*User, error) {
return t.restClient.user(ctx, userID)
}