Skip to content

Commit

Permalink
feat: one time premium app purchases (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
N1ckPro committed Apr 25, 2024
1 parent 312947d commit c9f2c5b
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 4 deletions.
42 changes: 41 additions & 1 deletion deno/payloads/v10/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,48 @@ export interface APIEntitlement {
* Date at which the entitlement is no longer valid. Not present when using test entitlements.
*/
ends_at?: string;
/**
* For consumable items, whether or not the entitlement has been consumed
*/
consumed?: boolean;
}

/**
* https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types
*/
export enum EntitlementType {
/**
* Entitlement was purchased by user
*/
Purchase = 1,
/**
* Entitlement for Discord Nitro subscription
*/
PremiumSubscription,
/**
* Entitlement was gifted by developer
*/
DeveloperGift,
/**
* Entitlement was purchased by a dev in application test mode
*/
TestModePurchase,
/**
* Entitlement was granted when the SKU was free
*/
FreePurchase,
/**
* Entitlement was gifted by another user
*/
UserGift,
/**
* Entitlement was claimed by user for free as a Nitro Subscriber
*/
PremiumPurchase,
/**
* Entitlement was purchased as an app subscription
*/
ApplicationSubscription = 8,
ApplicationSubscription,
}

/**
Expand Down Expand Up @@ -104,6 +136,14 @@ export enum SKUFlags {
}

export enum SKUType {
/**
* Durable one-time purchase
*/
Durable = 2,
/**
* Consumable one-time purchase
*/
Consumable = 3,
/**
* Represents a recurring subscription
*/
Expand Down
42 changes: 41 additions & 1 deletion deno/payloads/v9/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,48 @@ export interface APIEntitlement {
* Date at which the entitlement is no longer valid. Not present when using test entitlements.
*/
ends_at?: string;
/**
* For consumable items, whether or not the entitlement has been consumed
*/
consumed?: boolean;
}

/**
* https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types
*/
export enum EntitlementType {
/**
* Entitlement was purchased by user
*/
Purchase = 1,
/**
* Entitlement for Discord Nitro subscription
*/
PremiumSubscription,
/**
* Entitlement was gifted by developer
*/
DeveloperGift,
/**
* Entitlement was purchased by a dev in application test mode
*/
TestModePurchase,
/**
* Entitlement was granted when the SKU was free
*/
FreePurchase,
/**
* Entitlement was gifted by another user
*/
UserGift,
/**
* Entitlement was claimed by user for free as a Nitro Subscriber
*/
PremiumPurchase,
/**
* Entitlement was purchased as an app subscription
*/
ApplicationSubscription = 8,
ApplicationSubscription,
}

/**
Expand Down Expand Up @@ -104,6 +136,14 @@ export enum SKUFlags {
}

export enum SKUType {
/**
* Durable one-time purchase
*/
Durable = 2,
/**
* Consumable one-time purchase
*/
Consumable = 3,
/**
* Represents a recurring subscription
*/
Expand Down
8 changes: 8 additions & 0 deletions deno/rest/v10/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,14 @@ export const Routes = {
guildBulkBan(guildId: Snowflake) {
return `/guilds/${guildId}/bulk-ban` as const;
},

/**
* Route for:
* - POST `/applications/${application.id}/entitlements/${entitlement.id}/consume`
*/
consumeEntitlement(applicationId: Snowflake, entitlementId: Snowflake) {
return `/applications/${applicationId}/entitlements/${entitlementId}/consume` as const;
},
};

export const StickerPackApplicationId = '710982414301790216';
Expand Down
5 changes: 5 additions & 0 deletions deno/rest/v10/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ export type RESTDeleteAPIEntitlementResult = never;
* https://discord.com/developers/docs/monetization/skus#list-skus
*/
export type RESTGetAPISKUsResult = APISKU[];

/**
* https://discord.com/developers/docs/monetization/entitlements#consume-an-entitlement
*/
export type RESTPostAPIEntitlementConsumeResult = never;
8 changes: 8 additions & 0 deletions deno/rest/v9/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,14 @@ export const Routes = {
guildBulkBan(guildId: Snowflake) {
return `/guilds/${guildId}/bulk-ban` as const;
},

/**
* Route for:
* - POST `/applications/${application.id}/entitlements/${entitlement.id}/consume`
*/
consumeEntitlement(applicationId: Snowflake, entitlementId: Snowflake) {
return `/applications/${applicationId}/entitlements/${entitlementId}/consume` as const;
},
};

export const StickerPackApplicationId = '710982414301790216';
Expand Down
5 changes: 5 additions & 0 deletions deno/rest/v9/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ export type RESTDeleteAPIEntitlementResult = never;
* https://discord.com/developers/docs/monetization/skus#list-skus
*/
export type RESTGetAPISKUsResult = APISKU[];

/**
* https://discord.com/developers/docs/monetization/entitlements#consume-an-entitlement
*/
export type RESTPostAPIEntitlementConsumeResult = never;
42 changes: 41 additions & 1 deletion payloads/v10/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,48 @@ export interface APIEntitlement {
* Date at which the entitlement is no longer valid. Not present when using test entitlements.
*/
ends_at?: string;
/**
* For consumable items, whether or not the entitlement has been consumed
*/
consumed?: boolean;
}

/**
* https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types
*/
export enum EntitlementType {
/**
* Entitlement was purchased by user
*/
Purchase = 1,
/**
* Entitlement for Discord Nitro subscription
*/
PremiumSubscription,
/**
* Entitlement was gifted by developer
*/
DeveloperGift,
/**
* Entitlement was purchased by a dev in application test mode
*/
TestModePurchase,
/**
* Entitlement was granted when the SKU was free
*/
FreePurchase,
/**
* Entitlement was gifted by another user
*/
UserGift,
/**
* Entitlement was claimed by user for free as a Nitro Subscriber
*/
PremiumPurchase,
/**
* Entitlement was purchased as an app subscription
*/
ApplicationSubscription = 8,
ApplicationSubscription,
}

/**
Expand Down Expand Up @@ -104,6 +136,14 @@ export enum SKUFlags {
}

export enum SKUType {
/**
* Durable one-time purchase
*/
Durable = 2,
/**
* Consumable one-time purchase
*/
Consumable = 3,
/**
* Represents a recurring subscription
*/
Expand Down
42 changes: 41 additions & 1 deletion payloads/v9/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,48 @@ export interface APIEntitlement {
* Date at which the entitlement is no longer valid. Not present when using test entitlements.
*/
ends_at?: string;
/**
* For consumable items, whether or not the entitlement has been consumed
*/
consumed?: boolean;
}

/**
* https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types
*/
export enum EntitlementType {
/**
* Entitlement was purchased by user
*/
Purchase = 1,
/**
* Entitlement for Discord Nitro subscription
*/
PremiumSubscription,
/**
* Entitlement was gifted by developer
*/
DeveloperGift,
/**
* Entitlement was purchased by a dev in application test mode
*/
TestModePurchase,
/**
* Entitlement was granted when the SKU was free
*/
FreePurchase,
/**
* Entitlement was gifted by another user
*/
UserGift,
/**
* Entitlement was claimed by user for free as a Nitro Subscriber
*/
PremiumPurchase,
/**
* Entitlement was purchased as an app subscription
*/
ApplicationSubscription = 8,
ApplicationSubscription,
}

/**
Expand Down Expand Up @@ -104,6 +136,14 @@ export enum SKUFlags {
}

export enum SKUType {
/**
* Durable one-time purchase
*/
Durable = 2,
/**
* Consumable one-time purchase
*/
Consumable = 3,
/**
* Represents a recurring subscription
*/
Expand Down
8 changes: 8 additions & 0 deletions rest/v10/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,14 @@ export const Routes = {
guildBulkBan(guildId: Snowflake) {
return `/guilds/${guildId}/bulk-ban` as const;
},

/**
* Route for:
* - POST `/applications/${application.id}/entitlements/${entitlement.id}/consume`
*/
consumeEntitlement(applicationId: Snowflake, entitlementId: Snowflake) {
return `/applications/${applicationId}/entitlements/${entitlementId}/consume` as const;
},
};

export const StickerPackApplicationId = '710982414301790216';
Expand Down
5 changes: 5 additions & 0 deletions rest/v10/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ export type RESTDeleteAPIEntitlementResult = never;
* https://discord.com/developers/docs/monetization/skus#list-skus
*/
export type RESTGetAPISKUsResult = APISKU[];

/**
* https://discord.com/developers/docs/monetization/entitlements#consume-an-entitlement
*/
export type RESTPostAPIEntitlementConsumeResult = never;
8 changes: 8 additions & 0 deletions rest/v9/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,14 @@ export const Routes = {
guildBulkBan(guildId: Snowflake) {
return `/guilds/${guildId}/bulk-ban` as const;
},

/**
* Route for:
* - POST `/applications/${application.id}/entitlements/${entitlement.id}/consume`
*/
consumeEntitlement(applicationId: Snowflake, entitlementId: Snowflake) {
return `/applications/${applicationId}/entitlements/${entitlementId}/consume` as const;
},
};

export const StickerPackApplicationId = '710982414301790216';
Expand Down
5 changes: 5 additions & 0 deletions rest/v9/monetization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ export type RESTDeleteAPIEntitlementResult = never;
* https://discord.com/developers/docs/monetization/skus#list-skus
*/
export type RESTGetAPISKUsResult = APISKU[];

/**
* https://discord.com/developers/docs/monetization/entitlements#consume-an-entitlement
*/
export type RESTPostAPIEntitlementConsumeResult = never;

0 comments on commit c9f2c5b

Please sign in to comment.