#![doc(alias = "channel.update")]
use super::*;
#[derive(Clone, Debug, typed_builder::TypedBuilder, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct ChannelUpdateV1 {
#[builder(setter(into))]
pub broadcaster_user_id: types::UserId,
}
impl EventSubscription for ChannelUpdateV1 {
type Payload = ChannelUpdateV1Payload;
const EVENT_TYPE: EventType = EventType::ChannelUpdate;
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[];
const VERSION: &'static str = "1";
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct ChannelUpdateV1Payload {
pub broadcaster_user_id: types::UserId,
pub broadcaster_user_login: types::UserName,
pub broadcaster_user_name: types::DisplayName,
pub title: String,
pub language: String,
pub category_id: types::CategoryId,
pub category_name: String,
pub is_mature: bool,
}
#[cfg(test)]
#[test]
fn parse_payload() {
let payload = r#"
{
"subscription": {
"id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
"type": "channel.update",
"version": "1",
"status": "enabled",
"cost": 0,
"condition": {
"broadcaster_user_id": "1337"
},
"transport": {
"method": "webhook",
"callback": "https://example.com/webhooks/callback"
},
"created_at": "2019-11-16T10:11:12.123Z"
},
"event": {
"broadcaster_user_id": "1337",
"broadcaster_user_login": "cool_user",
"broadcaster_user_name": "Cool_User",
"title": "Best Stream Ever",
"language": "en",
"category_id": "21779",
"category_name": "Fortnite",
"is_mature": false
}
}
"#;
let val = dbg!(crate::eventsub::Event::parse(payload).unwrap());
crate::tests::roundtrip(&val)
}