use super::*;
use helix::RequestGet;
#[derive(PartialEq, typed_builder::TypedBuilder, Deserialize, Serialize, Clone, Debug)]
#[non_exhaustive]
pub struct GetChannelEmotesRequest {
#[builder(setter(into))]
pub broadcaster_id: types::UserId,
}
pub type GetChannelEmotesResponse = ChannelEmote;
impl Request for GetChannelEmotesRequest {
type Response = Vec<GetChannelEmotesResponse>;
const PATH: &'static str = "chat/emotes";
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[];
}
impl RequestGet for GetChannelEmotesRequest {}
#[cfg(test)]
#[test]
fn test_request() {
use helix::*;
let req = GetChannelEmotesRequest::builder()
.broadcaster_id("304456832")
.build();
let data = br#"
{
"data": [
{
"id": "304456832",
"name": "twitchdevPitchfork",
"images": {
"url_1x": "https://static-cdn.jtvnw.net/emoticons/v2/304456832/static/light/1.0",
"url_2x": "https://static-cdn.jtvnw.net/emoticons/v2/304456832/static/light/2.0",
"url_4x": "https://static-cdn.jtvnw.net/emoticons/v2/304456832/static/light/3.0"
},
"tier": "1000",
"emote_type": "subscriptions",
"emote_set_id": "301590448",
"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?broadcaster_id=304456832"
);
dbg!(GetChannelEmotesRequest::parse_response(Some(req), &uri, http_response).unwrap());
}