twilight_model/application/monetization/
sku.rsuse serde::{Deserialize, Serialize};
use crate::id::{
marker::{ApplicationMarker, SkuMarker},
Id,
};
use super::{SkuFlags, SkuType};
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct Sku {
application_id: Id<ApplicationMarker>,
flags: SkuFlags,
id: Id<SkuMarker>,
#[serde(rename = "type")]
kind: SkuType,
name: String,
slug: String,
}
#[cfg(test)]
mod tests {
use serde_test::Token;
use crate::{
application::monetization::{SkuFlags, SkuType},
id::Id,
};
use super::Sku;
#[test]
fn sku() {
let value = Sku {
application_id: Id::new(1),
flags: SkuFlags::GUILD_SUBSCRIPTION,
id: Id::new(2),
kind: SkuType::Subscription,
name: "a name".to_owned(),
slug: "a-slug".to_owned(),
};
serde_test::assert_tokens(
&value,
&[
Token::Struct {
name: "Sku",
len: 6,
},
Token::Str("application_id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("1"),
Token::Str("flags"),
Token::U64(1 << 7),
Token::Str("id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("2"),
Token::Str("type"),
Token::U8(5),
Token::Str("name"),
Token::Str("a name"),
Token::Str("slug"),
Token::Str("a-slug"),
Token::StructEnd,
],
);
}
}