From c9f2c5b020b4c7a36330fe06463106e9cfd38fca Mon Sep 17 00:00:00 2001 From: n1ck_pro <59617443+N1ckPro@users.noreply.github.com> Date: Thu, 25 Apr 2024 18:30:55 +0200 Subject: [PATCH] feat: one time premium app purchases (#966) --- deno/payloads/v10/monetization.ts | 42 ++++++++++++++++++++++++++++++- deno/payloads/v9/monetization.ts | 42 ++++++++++++++++++++++++++++++- deno/rest/v10/mod.ts | 8 ++++++ deno/rest/v10/monetization.ts | 5 ++++ deno/rest/v9/mod.ts | 8 ++++++ deno/rest/v9/monetization.ts | 5 ++++ payloads/v10/monetization.ts | 42 ++++++++++++++++++++++++++++++- payloads/v9/monetization.ts | 42 ++++++++++++++++++++++++++++++- rest/v10/index.ts | 8 ++++++ rest/v10/monetization.ts | 5 ++++ rest/v9/index.ts | 8 ++++++ rest/v9/monetization.ts | 5 ++++ 12 files changed, 216 insertions(+), 4 deletions(-) diff --git a/deno/payloads/v10/monetization.ts b/deno/payloads/v10/monetization.ts index 7b06e504d..a3948b6ce 100644 --- a/deno/payloads/v10/monetization.ts +++ b/deno/payloads/v10/monetization.ts @@ -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, } /** @@ -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 */ diff --git a/deno/payloads/v9/monetization.ts b/deno/payloads/v9/monetization.ts index 7b06e504d..a3948b6ce 100644 --- a/deno/payloads/v9/monetization.ts +++ b/deno/payloads/v9/monetization.ts @@ -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, } /** @@ -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 */ diff --git a/deno/rest/v10/mod.ts b/deno/rest/v10/mod.ts index 1120ff806..75d9c7712 100644 --- a/deno/rest/v10/mod.ts +++ b/deno/rest/v10/mod.ts @@ -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'; diff --git a/deno/rest/v10/monetization.ts b/deno/rest/v10/monetization.ts index cf07900c9..2139fec82 100644 --- a/deno/rest/v10/monetization.ts +++ b/deno/rest/v10/monetization.ts @@ -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; diff --git a/deno/rest/v9/mod.ts b/deno/rest/v9/mod.ts index e5a50d3be..a041fbced 100644 --- a/deno/rest/v9/mod.ts +++ b/deno/rest/v9/mod.ts @@ -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'; diff --git a/deno/rest/v9/monetization.ts b/deno/rest/v9/monetization.ts index cf07900c9..2139fec82 100644 --- a/deno/rest/v9/monetization.ts +++ b/deno/rest/v9/monetization.ts @@ -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; diff --git a/payloads/v10/monetization.ts b/payloads/v10/monetization.ts index 38e6902fc..a2d50b466 100644 --- a/payloads/v10/monetization.ts +++ b/payloads/v10/monetization.ts @@ -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, } /** @@ -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 */ diff --git a/payloads/v9/monetization.ts b/payloads/v9/monetization.ts index 38e6902fc..a2d50b466 100644 --- a/payloads/v9/monetization.ts +++ b/payloads/v9/monetization.ts @@ -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, } /** @@ -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 */ diff --git a/rest/v10/index.ts b/rest/v10/index.ts index efac5dae0..306277991 100644 --- a/rest/v10/index.ts +++ b/rest/v10/index.ts @@ -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'; diff --git a/rest/v10/monetization.ts b/rest/v10/monetization.ts index 23967cde1..b2849c370 100644 --- a/rest/v10/monetization.ts +++ b/rest/v10/monetization.ts @@ -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; diff --git a/rest/v9/index.ts b/rest/v9/index.ts index 78625e9cf..6fc30fdea 100644 --- a/rest/v9/index.ts +++ b/rest/v9/index.ts @@ -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'; diff --git a/rest/v9/monetization.ts b/rest/v9/monetization.ts index 23967cde1..b2849c370 100644 --- a/rest/v9/monetization.ts +++ b/rest/v9/monetization.ts @@ -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;