@@ -37,7 +37,8 @@ type Applications interface {
37
37
GetApplicationRoleConnectionMetadata (applicationID snowflake.ID , opts ... RequestOpt ) ([]discord.ApplicationRoleConnectionMetadata , error )
38
38
UpdateApplicationRoleConnectionMetadata (applicationID snowflake.ID , newRecords []discord.ApplicationRoleConnectionMetadata , opts ... RequestOpt ) ([]discord.ApplicationRoleConnectionMetadata , error )
39
39
40
- GetEntitlements (applicationID snowflake.ID , userID snowflake.ID , guildID snowflake.ID , before snowflake.ID , after snowflake.ID , limit int , excludeEnded bool , skuIDs []snowflake.ID , opts ... RequestOpt ) ([]discord.Entitlement , error )
40
+ GetEntitlements (applicationID snowflake.ID , params GetEntitlementsParams , opts ... RequestOpt ) ([]discord.Entitlement , error )
41
+ GetEntitlement (applicationID snowflake.ID , entitlementID snowflake.ID , opts ... RequestOpt ) (* discord.Entitlement , error )
41
42
CreateTestEntitlement (applicationID snowflake.ID , entitlementCreate discord.TestEntitlementCreate , opts ... RequestOpt ) (* discord.Entitlement , error )
42
43
DeleteTestEntitlement (applicationID snowflake.ID , entitlementID snowflake.ID , opts ... RequestOpt ) error
43
44
ConsumeEntitlement (applicationID snowflake.ID , entitlementID snowflake.ID , opts ... RequestOpt ) error
@@ -51,6 +52,42 @@ type Applications interface {
51
52
GetActivityInstance (applicationID snowflake.ID , instanceID string , opts ... RequestOpt ) (* discord.ActivityInstance , error )
52
53
}
53
54
55
+ // GetEntitlementsParams holds query parameters for Applications.GetEntitlements (https://discord.com/developers/docs/resources/entitlement#list-entitlements)
56
+ type GetEntitlementsParams struct {
57
+ UserID snowflake.ID
58
+ SkuIDs []snowflake.ID
59
+ Before int
60
+ After int
61
+ Limit int
62
+ GuildID snowflake.ID
63
+ ExcludeEnded bool
64
+ ExcludeDeleted bool
65
+ }
66
+
67
+ func (p GetEntitlementsParams ) ToQueryValues () discord.QueryValues {
68
+ queryValues := discord.QueryValues {
69
+ "exclude_ended" : p .ExcludeEnded ,
70
+ "exclude_deleted" : p .ExcludeDeleted ,
71
+ "sku_ids" : slicehelper .JoinSnowflakes (p .SkuIDs ),
72
+ }
73
+ if p .UserID != 0 {
74
+ queryValues ["user_id" ] = p .UserID
75
+ }
76
+ if p .Before != 0 {
77
+ queryValues ["before" ] = p .Before
78
+ }
79
+ if p .After != 0 {
80
+ queryValues ["after" ] = p .After
81
+ }
82
+ if p .Limit != 0 {
83
+ queryValues ["limit" ] = p .Limit
84
+ }
85
+ if p .GuildID != 0 {
86
+ queryValues ["guild_id" ] = p .GuildID
87
+ }
88
+ return queryValues
89
+ }
90
+
54
91
type applicationsImpl struct {
55
92
client Client
56
93
}
@@ -183,27 +220,13 @@ func (s *applicationsImpl) UpdateApplicationRoleConnectionMetadata(applicationID
183
220
return
184
221
}
185
222
186
- func (s * applicationsImpl ) GetEntitlements (applicationID snowflake.ID , userID snowflake.ID , guildID snowflake.ID , before snowflake.ID , after snowflake.ID , limit int , excludeEnded bool , skuIDs []snowflake.ID , opts ... RequestOpt ) (entitlements []discord.Entitlement , err error ) {
187
- queryValues := discord.QueryValues {
188
- "exclude_ended" : excludeEnded ,
189
- "sku_ids" : slicehelper .JoinSnowflakes (skuIDs ),
190
- }
191
- if userID != 0 {
192
- queryValues ["user_id" ] = userID
193
- }
194
- if guildID != 0 {
195
- queryValues ["guild_id" ] = guildID
196
- }
197
- if before != 0 {
198
- queryValues ["before" ] = before
199
- }
200
- if after != 0 {
201
- queryValues ["after" ] = after
202
- }
203
- if limit != 0 {
204
- queryValues ["limit" ] = limit
205
- }
206
- err = s .client .Do (GetEntitlements .Compile (queryValues , applicationID ), nil , & entitlements , opts ... )
223
+ func (s * applicationsImpl ) GetEntitlements (applicationID snowflake.ID , params GetEntitlementsParams , opts ... RequestOpt ) (entitlements []discord.Entitlement , err error ) {
224
+ err = s .client .Do (GetEntitlements .Compile (params .ToQueryValues (), applicationID ), nil , & entitlements , opts ... )
225
+ return
226
+ }
227
+
228
+ func (s * applicationsImpl ) GetEntitlement (applicationID snowflake.ID , entitlementID snowflake.ID , opts ... RequestOpt ) (entitlement * discord.Entitlement , err error ) {
229
+ err = s .client .Do (GetEntitlement .Compile (nil , applicationID , entitlementID ), nil , & entitlement , opts ... )
207
230
return
208
231
}
209
232
0 commit comments