From 83390b529637762755c1bc1c2094337aa29e2aca Mon Sep 17 00:00:00 2001 From: sebm253 <42180891+sebm253@users.noreply.github.com> Date: Mon, 2 Dec 2024 00:32:28 +0100 Subject: [PATCH] move QueryParamsGetEntitlements --- rest/applications.go | 37 +++++++++++++++++++++++++++++++++++++ rest/query_params.go | 38 -------------------------------------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/rest/applications.go b/rest/applications.go index f16b70ac..410a83be 100644 --- a/rest/applications.go +++ b/rest/applications.go @@ -1,6 +1,7 @@ package rest import ( + "github.com/disgoorg/disgo/internal/slicehelper" "github.com/disgoorg/snowflake/v2" "github.com/disgoorg/disgo/discord" @@ -51,6 +52,42 @@ type Applications interface { GetActivityInstance(applicationID snowflake.ID, instanceID string, opts ...RequestOpt) (*discord.ActivityInstance, error) } +// QueryParamsGetEntitlements holds query parameters for Applications.GetEntitlements (https://discord.com/developers/docs/resources/entitlement#list-entitlements) +type QueryParamsGetEntitlements struct { + UserID snowflake.ID + SkuIDs []snowflake.ID + Before int + After int + Limit int + GuildID snowflake.ID + ExcludeEnded bool + ExcludeDeleted bool +} + +func (p QueryParamsGetEntitlements) ToQueryValues() discord.QueryValues { + queryValues := discord.QueryValues{ + "exclude_ended": p.ExcludeEnded, + "exclude_deleted": p.ExcludeDeleted, + "sku_ids": slicehelper.JoinSnowflakes(p.SkuIDs), + } + if p.UserID != 0 { + queryValues["user_id"] = p.UserID + } + if p.Before != 0 { + queryValues["before"] = p.Before + } + if p.After != 0 { + queryValues["after"] = p.After + } + if p.Limit != 0 { + queryValues["limit"] = p.Limit + } + if p.GuildID != 0 { + queryValues["guild_id"] = p.GuildID + } + return queryValues +} + type applicationsImpl struct { client Client } diff --git a/rest/query_params.go b/rest/query_params.go index 4dce5721..9d17c83d 100644 --- a/rest/query_params.go +++ b/rest/query_params.go @@ -2,8 +2,6 @@ package rest import ( "github.com/disgoorg/disgo/discord" - "github.com/disgoorg/disgo/internal/slicehelper" - "github.com/disgoorg/snowflake/v2" ) // QueryParams serves as a generic interface for implementations of rest endpoint query parameters. @@ -11,39 +9,3 @@ type QueryParams interface { // ToQueryValues transforms fields from the QueryParams interface implementations into discord.QueryValues. ToQueryValues() discord.QueryValues } - -// QueryParamsGetEntitlements holds query parameters for Applications.GetEntitlements (https://discord.com/developers/docs/resources/entitlement#list-entitlements) -type QueryParamsGetEntitlements struct { - UserID snowflake.ID - SkuIDs []snowflake.ID - Before int - After int - Limit int - GuildID snowflake.ID - ExcludeEnded bool - ExcludeDeleted bool -} - -func (p QueryParamsGetEntitlements) ToQueryValues() discord.QueryValues { - queryValues := discord.QueryValues{ - "exclude_ended": p.ExcludeEnded, - "exclude_deleted": p.ExcludeDeleted, - "sku_ids": slicehelper.JoinSnowflakes(p.SkuIDs), - } - if p.UserID != 0 { - queryValues["user_id"] = p.UserID - } - if p.Before != 0 { - queryValues["before"] = p.Before - } - if p.After != 0 { - queryValues["after"] = p.After - } - if p.Limit != 0 { - queryValues["limit"] = p.Limit - } - if p.GuildID != 0 { - queryValues["guild_id"] = p.GuildID - } - return queryValues -}