Skip to content

Commit

Permalink
fix(model): consumed is optional (#2378)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erk- authored Oct 6, 2024
1 parent 6584104 commit dc2544f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
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

0 comments on commit dc2544f

Please sign in to comment.