diff --git a/endpoints.go b/endpoints.go index 1a4731819..412bc84f8 100644 --- a/endpoints.go +++ b/endpoints.go @@ -172,6 +172,10 @@ var ( return EndpointPoll(cID, mID) + "/expire" } + EndpointSKUs = func(aID string) string { + return EndpointApplication(aID) + "/skus" + } + EndpointEntitlements = func(aID string) string { return EndpointApplication(aID) + "/entitlements" } diff --git a/restapi.go b/restapi.go index ae53debcd..061b845c1 100644 --- a/restapi.go +++ b/restapi.go @@ -3501,6 +3501,24 @@ func (s *Session) PollExpire(channelID, messageID string) (msg *Message, err err return } +// ---------------------------------------------------------------------- +// Functions specific to SKUs +// ---------------------------------------------------------------------- + +// SKUs returns all SKUs for a given application. +// appID : The ID of the application. +func (s *Session) SKUs(appID string) (skus []*SKU, err error) { + endpoint := EndpointSKUs(appID) + + body, err := s.RequestWithBucketID("GET", endpoint, nil, endpoint) + if err != nil { + return + } + + err = unmarshal(body, &skus) + return +} + // ---------------------------------------------------------------------- // Functions specific to entitlements // ---------------------------------------------------------------------- diff --git a/structs.go b/structs.go index 781b5fe31..202676413 100644 --- a/structs.go +++ b/structs.go @@ -2395,21 +2395,21 @@ type SKUType int // Valid SKUType values const ( - SKUTypeDurable SKUType = 2 - SKUTypeConsumable SKUType = 3 + SKUTypeDurable SKUType = 2 + SKUTypeConsumable SKUType = 3 SKUTypeSubscription SKUType = 5 // SKUTypeSubscriptionGroup is a system-generated group for each subscription SKU. SKUTypeSubscriptionGroup SKUType = 6 ) -// SKUFlag is a bitfield of flags used to differentiate user and server subscriptions. -type SKUFlag int +// SKUFlags is a bitfield of flags used to differentiate user and server subscriptions. +type SKUFlags int const ( // SKUFlageAvailable indicates that the SKU is available for purchase. - SKUFlagAvailable SKUFlag = 1 << 2 - SKUFlagGuildSubscription SKUFlag = 1 << 7 - SKUFlageUserSubscription SKUFlag = 1 << 8 + SKUFlagAvailable SKUFlags = 1 << 2 + SKUFlagGuildSubscription SKUFlags = 1 << 7 + SKUFlageUserSubscription SKUFlags = 1 << 8 ) // SKU (stock-keeping units) represent premium offerings. @@ -2429,8 +2429,9 @@ type SKU struct { // System-generated URL slub based on the SKU's name. Slug string `json:"slug"` - // SKUFlags combined as a bitfield - Flags int `json:"flags"` + // SKUFlags combined as a bitfield. The presence of a certain falg can be checked + // by performing a bitwise AND operation between this int and the flag. + Flags SKUFlags `json:"flags"` } // EntitlementType is the type of entitlement (see EntitlementType* consts)