-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Entitlements / SKUs #1552
Add Entitlements / SKUs #1552
Changes from 5 commits
f004123
2e7eb30
4bbe559
84ecf01
6725cb4
ccb5a90
7ad7e1b
87c3490
9620435
38a1aff
efb7d7e
351f5e9
7bf00e8
d2057dc
b7ed8b8
5b3da13
34c29b0
6eb85e1
faf1279
887cdb3
20d5f76
54287e3
7cf6c73
2c97651
e9b116e
d9d9f4b
621e4ad
f81b609
347e932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2437,6 +2437,48 @@ type SKU struct { | |
Flags SKUFlags `json:"flags"` | ||
} | ||
|
||
// Subscription represents a user making recurring payments for at least one SKU over an ongoing period. | ||
// https://discord.com/developers/docs/resources/subscription#subscription-object | ||
type Subscription struct { | ||
// ID of the subscription | ||
ID string `json:"id"` | ||
|
||
// ID of the user who is subscribed | ||
UserID string `json:"user_id"` | ||
|
||
// List of SKUs subscribed to | ||
SKUIDs []string `json:"sku_ids"` | ||
|
||
// List of entitlements granted for this subscription | ||
EntitlementIDs []string `json:"entitlement_ids"` | ||
|
||
// Start of the current subscription period | ||
CurrentPeriodStart time.Time `json:"current_period_start"` | ||
|
||
// End of the current subscription period | ||
CurrentPeriodEnd time.Time `json:"current_period_end"` | ||
|
||
// Current status of the subscription | ||
Status SubscriptionStatus `json:"status"` | ||
|
||
// When the subscription was canceled. Only present if the subscription has been canceled. | ||
CanceledAt *time.Time `json:"canceled_at,omitempty"` | ||
|
||
// ISO3166-1 alpha-2 country code of the payment source used to purchase the subscription. Missing unless queried with a private OAuth scope. | ||
Country *string `json:"country,omitempty"` | ||
} | ||
|
||
// SubscriptionStatus is the current status of a Subscription Object | ||
// https://discord.com/developers/docs/resources/subscription#subscription-statuses | ||
type SubscriptionStatus int | ||
|
||
// Valid SubscriptionStatus values | ||
const ( | ||
SubscriptionStatusActive = 0 | ||
SubscriptionStatusEnding = 1 | ||
SubscriptionStatusInactive = 2 | ||
) | ||
|
||
// EntitlementType is the type of entitlement (see EntitlementType* consts) | ||
// https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types | ||
type EntitlementType int | ||
|
@@ -2467,7 +2509,7 @@ type Entitlement struct { | |
|
||
// The ID of the user that is granted access to the entitlement's sku | ||
// Only available for user subscriptions. | ||
UserID string `json:"user_id,omitempty"` | ||
UserID *string `json:"user_id,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there ever a point at which we'd expect/want a default string value here? Wondering if the introduction of pointer risk is necessary or if we can roll with default values without losing any important data (no user has no ID, no guild has no ID, no entitlement has a start time at zero, etc.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, thank you. However, I would keep all the optional timestamps as pointers, since this is also done in other structs (e.g., Channel, Member, Invite). |
||
|
||
// The type of the entitlement | ||
Type EntitlementType `json:"type"` | ||
|
@@ -2480,16 +2522,20 @@ type Entitlement struct { | |
StartsAt *time.Time `json:"starts_at,omitempty"` | ||
|
||
// The date at which the entitlement is no longer valid. | ||
// Not present when using test entitlements. | ||
// Not present when using test entitlements or when receiving an ENTITLEMENT_CREATE event. | ||
EndsAt *time.Time `json:"ends_at,omitempty"` | ||
|
||
// The ID of the guild that is granted access to the entitlement's sku. | ||
// Only available for guild subscriptions. | ||
GuildID string `json:"guild_id,omitempty"` | ||
GuildID *string `json:"guild_id,omitempty"` | ||
|
||
// Whether or not the entitlement has been consumed. | ||
// Only available for consumable items. | ||
Consumed bool `json:"consumed,omitempty"` | ||
Consumed *bool `json:"consumed,omitempty"` | ||
|
||
// The SubscriptionID of the entitlement. | ||
// Not present when using test entitlements. | ||
SubscriptionID *string `json:"subscription_id,omitempty"` | ||
} | ||
|
||
// EntitlementOwnerType is the type of entitlement (see EntitlementOwnerType* consts) | ||
|
@@ -2521,11 +2567,11 @@ type EntitlementFilterOptions struct { | |
// Optional array of SKU IDs to check for. | ||
SkuIDs []string | ||
|
||
// Optional timestamp (snowflake) to retrieve Entitlements before this time. | ||
BeforeID string | ||
// Optional timestamp to retrieve Entitlements before this time. | ||
Before *time.Time | ||
|
||
// Optional timestamp (snowflake) to retrieve Entitlements after this time. | ||
AfterID string | ||
// Optional timestamp to retrieve Entitlements after this time. | ||
After *time.Time | ||
|
||
// Optional maximum number of entitlements to return (1-100, default 100). | ||
Limit int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for including country code type