forked from serenity-rs/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9121e0c
commit 5ebc6cd
Showing
5 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use crate::model::prelude::*; | ||
|
||
/// A premium offering that can be made available to an application's users and guilds. | ||
/// | ||
/// [Discord docs](https://discord.com/developers/docs/monetization/skus#sku-object) | ||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub struct Sku { | ||
/// The unique ID of the SKU. | ||
pub id: SkuId, | ||
/// The type of the SKU. | ||
#[serde(rename = "type")] | ||
pub kind: SkuKind, | ||
/// Id of the SKU's parent application. | ||
pub application_id: ApplicationId, | ||
/// The customer-facing name of the premium offering. | ||
pub name: String, | ||
/// A system-generated URL slug based on the SKU. | ||
pub slug: String, | ||
} | ||
|
||
enum_number! { | ||
/// Differentiates between SKU types. | ||
/// | ||
/// [Discord docs](https://discord.com/developers/docs/monetization/skus#sku-object-sku-types) | ||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
#[serde(from = "u8", into = "u8")] | ||
#[non_exhaustive] | ||
pub enum SkuKind { | ||
/// Represents a recurring subscription. | ||
Subscription = 5, | ||
/// A system-generated group for each SKU created of type [`SkuKind::Subscription`]. | ||
SubscriptionGroup = 6, | ||
_ => Unknown(u8), | ||
} | ||
} | ||
|
||
/// Represents that a user or guild has access to a premium offering in the application. | ||
/// | ||
/// [Discord docs](https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-structure) | ||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub struct Entitlement { | ||
/// The ID of the entitlement. | ||
pub id: EntitlementId, | ||
/// The ID of the corresponding SKU. | ||
pub sku_id: SkuId, | ||
/// The ID of the user that is granted access to the SKU. | ||
pub user_id: Option<UserId>, | ||
/// The ID of the guild that is granted access to the SKU. | ||
pub guild_id: Option<GuildId>, | ||
/// The ID of the parent application. | ||
pub application_id: ApplicationId, | ||
/// The type of the entitlement. | ||
#[serde(rename = "type")] | ||
pub kind: EntitlementKind, | ||
/// Whether the entitlement has been consumed or not. Will always be `false` for ongoing App | ||
/// Subscriptions. | ||
pub consumed: bool, | ||
/// Start date after which the entitlement is valid. Not present when using test entitlements. | ||
pub starts_at: Option<Timestamp>, | ||
/// End date after which the entitlement is no longer valid. Not present when using test | ||
/// entitlements. | ||
pub ends_at: Option<Timestamp>, | ||
} | ||
|
||
enum_number! { | ||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
#[serde(from = "u8", into = "u8")] | ||
#[non_exhaustive] | ||
pub enum EntitlementKind { | ||
ApplicationSubscription = 8, | ||
_ => Unknown(u8), | ||
} | ||
} | ||
|
||
pub enum EntitlementOwner { | ||
User(UserId), | ||
Guild(GuildId), | ||
} |