Skip to content
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

fix(model): consumed is optional #2378

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions twilight-model/src/application/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ mod tests {
}))),
entitlements: vec![Entitlement {
application_id: Id::new(100),
consumed: false,
consumed: Some(false),
deleted: false,
ends_at: None,
guild_id: None,
Expand Down Expand Up @@ -738,19 +738,16 @@ mod tests {
Token::Seq { len: Some(1) },
Token::Struct {
name: "Entitlement",
len: 10,
len: 6,
},
Token::Str("application_id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("100"),
Token::Str("consumed"),
Token::Some,
Token::Bool(false),
Token::Str("deleted"),
Token::Bool(false),
Token::Str("ends_at"),
Token::None,
Token::Str("guild_id"),
Token::None,
Token::Str("id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("200"),
Expand All @@ -759,10 +756,6 @@ mod tests {
Token::Str("sku_id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("300"),
Token::Str("starts_at"),
Token::None,
Token::Str("user_id"),
Token::None,
Token::StructEnd,
Token::SeqEnd,
Token::Str("guild_id"),
Expand Down
10 changes: 8 additions & 2 deletions twilight-model/src/application/monetization/entitlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ pub struct Entitlement {
/// ID of the parent application.
pub application_id: Id<ApplicationMarker>,
/// Not applicable for App Subscriptions. Subscriptions are not consumed and will be `false`
pub consumed: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub consumed: Option<bool>,
/// Entitlement was deleted.
pub deleted: bool,
/// Date at which the entitlement is no longer valid. Not present when using test entitlements.
#[serde(skip_serializing_if = "Option::is_none")]
pub ends_at: Option<Timestamp>,
/// ID of the guild that is granted access to the entitlement's sku.
#[serde(skip_serializing_if = "Option::is_none")]
pub guild_id: Option<Id<GuildMarker>>,
/// ID of the entitlement.
pub id: Id<EntitlementMarker>,
Expand All @@ -31,8 +34,10 @@ pub struct Entitlement {
/// ID of the SKU.
pub sku_id: Id<SkuMarker>,
/// Start date at which the entitlement is valid. Not present when using test entitlements.
#[serde(skip_serializing_if = "Option::is_none")]
pub starts_at: Option<Timestamp>,
/// ID of the user that is granted access to the entitlement's sku.
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<Id<UserMarker>>,
}

Expand All @@ -56,7 +61,7 @@ mod tests {

let value = Entitlement {
application_id: Id::new(1),
consumed: false,
consumed: Some(false),
deleted: false,
ends_at: ends_at.into(),
guild_id: Some(Id::new(10)),
Expand All @@ -78,6 +83,7 @@ mod tests {
Token::NewtypeStruct { name: "Id" },
Token::Str("1"),
Token::Str("consumed"),
Token::Some,
Token::Bool(false),
Token::Str("deleted"),
Token::Bool(false),
Expand Down