use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_repr::*;
use serde_with::{serde_as, NoneAsEmptyString};
#[derive(Debug, Serialize, Deserialize)]
pub struct User {
pub user_id: String,
pub channel_id: String,
pub username: String,
pub nickname: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GetUsersPayload {
pub user: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GetUsersResponse {
pub users: Vec<User>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GetChannelByIdPayload {
pub channel_id: String,
}
#[derive(Debug, Deserialize)]
pub struct ChannelInfo {
pub is_live: bool,
pub category_id: String,
pub category_name: String,
pub live_title: String,
pub audi_type: AudienceType,
pub language_code: String,
pub thumbnail: String,
pub current_viewers: u64,
pub followers: u64,
pub streamer_info: String,
pub profile_pic: String,
pub channel_url: String,
#[serde(with = "serde_with::chrono_0_4::datetime_utc_ts_seconds_from_any")]
pub created_at: DateTime<Utc>,
pub subscriber_num: u64,
pub username: String,
pub social_links: Vec<SocialLink>,
#[serde(with = "serde_with::chrono_0_4::datetime_utc_ts_seconds_from_any")]
pub started_at: DateTime<Utc>,
#[serde(with = "serde_with::chrono_0_4::datetime_utc_ts_seconds_from_any")]
pub ended_at: DateTime<Utc>,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum AudienceType {
#[serde(rename = "CHANNEL_AUDIENCE_TYPE_FAMILYFRIENDLY")]
FamilyFriendly,
#[serde(rename = "CHANNEL_AUDIENCE_TYPE_TEEN")]
Teen,
#[serde(rename = "CHANNEL_AUDIENCE_TYPE_EIGHTEENPLUS")]
EighteenPlus,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SocialLink {
#[serde(rename = "type")]
type_: String,
url: String,
}
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Eq, Debug)]
#[repr(i16)]
pub enum EmoteFetchType {
All = 0,
Custom = 1,
Platform = 2,
}
impl Default for EmoteFetchType {
fn default() -> Self {
Self::All
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GetEmotesPayload {
pub emote_type: EmoteFetchType,
pub channel_id: Vec<String>,
}
#[serde_as]
#[derive(Debug, Serialize, Deserialize)]
pub struct Emote {
pub name: String,
pub description: String,
pub url: String,
pub status: String,
pub activity_name: Option<String>,
#[serde(default)]
#[serde_as(as = "NoneAsEmptyString")]
pub gifp: Option<String>,
#[serde(default)]
#[serde_as(as = "NoneAsEmptyString")]
pub webp: Option<String>,
pub update_time: Option<String>,
}
#[derive(Debug, Deserialize)]
pub struct GetEmotesResponse {
pub channels: EmoteChannels,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EmoteChannels {
pub customized_emotes: CustomizedEmotes,
pub event_emotes: Vec<Emote>,
pub global_emotes: Vec<Emote>,
}
#[derive(Debug, Deserialize)]
pub struct CustomizedEmotes {
pub channel: Vec<ChannelEmotes>,
}
#[derive(Debug, Deserialize)]
pub struct ChannelEmotes {
pub channel_id: String,
pub emotes: Vec<Emote>,
}
#[derive(Debug, Serialize)]
pub struct ChannelUpdatePayload {
pub channel_id: String,
#[serde(flatten)]
pub update: ChannelUpdate,
}
#[derive(Debug, Default, Serialize)]
pub struct ChannelUpdate {
pub live_title: Option<String>,
pub category_id: Option<String>,
pub language_code: Option<String>,
pub audi_type: Option<AudienceType>,
}