use super::*;
use helix::RequestGet;
#[derive(PartialEq, Eq, Deserialize, Serialize, Clone, Debug, Default)]
#[cfg_attr(feature = "typed-builder", derive(typed_builder::TypedBuilder))]
#[non_exhaustive]
#[must_use]
pub struct GetGlobalEmotesRequest {}
impl GetGlobalEmotesRequest {
pub const fn new() -> Self { Self {} }
}
pub type GetChannelEmotesResponse = GlobalEmote;
impl Request for GetGlobalEmotesRequest {
type Response = Vec<GetChannelEmotesResponse>;
const PATH: &'static str = "chat/emotes/global";
#[cfg(feature = "twitch_oauth2")]
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![];
}
impl RequestGet for GetGlobalEmotesRequest {}
#[cfg(test)]
#[test]
fn test_request() {
use helix::*;
let req = GetGlobalEmotesRequest::default();
let data = br#"
{
"data": [
{
"id": "196892",
"name": "TwitchUnity",
"images": {
"url_1x": "https://static-cdn.jtvnw.net/emoticons/v2/196892/static/light/1.0",
"url_2x": "https://static-cdn.jtvnw.net/emoticons/v2/196892/static/light/2.0",
"url_4x": "https://static-cdn.jtvnw.net/emoticons/v2/196892/static/light/3.0"
},
"format": [
"static"
],
"scale": [
"1.0",
"2.0",
"3.0"
],
"theme_mode": [
"light",
"dark"
]
}
],
"template": "https://static-cdn.jtvnw.net/emoticons/v2/{{id}}/{{format}}/{{theme_mode}}/{{scale}}"
}
"#
.to_vec();
let http_response = http::Response::builder().body(data).unwrap();
let uri = req.get_uri().unwrap();
assert_eq!(
uri.to_string(),
"https://api.twitch.tv/helix/chat/emotes/global?"
);
dbg!(GetGlobalEmotesRequest::parse_response(Some(req), &uri, http_response).unwrap());
}