Skip to content

Commit

Permalink
add skus
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoffi committed Aug 2, 2024
1 parent efb7d7e commit 351f5e9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
4 changes: 4 additions & 0 deletions endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
18 changes: 18 additions & 0 deletions restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ----------------------------------------------------------------------
Expand Down
19 changes: 10 additions & 9 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Check failure on line 2409 in structs.go

View workflow job for this annotation

GitHub Actions / lint

comment on exported const `SKUFlagAvailable` should be of the form `SKUFlagAvailable ...` (golint)
SKUFlagAvailable SKUFlag = 1 << 2
SKUFlagGuildSubscription SKUFlag = 1 << 7
SKUFlageUserSubscription SKUFlag = 1 << 8
SKUFlagAvailable SKUFlags = 1 << 2
SKUFlagGuildSubscription SKUFlags = 1 << 7

Check failure on line 2411 in structs.go

View workflow job for this annotation

GitHub Actions / lint

exported const SKUFlagGuildSubscription should have comment (or a comment on this block) or be unexported (golint)
SKUFlageUserSubscription SKUFlags = 1 << 8
)

// SKU (stock-keeping units) represent premium offerings.
Expand All @@ -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)
Expand Down

0 comments on commit 351f5e9

Please sign in to comment.