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 GetGlobalChatBadgesRequest {}
impl GetGlobalChatBadgesRequest {
pub fn new() -> Self { Self::default() }
}
pub type GetGlobalChatBadgesResponse = BadgeSet;
impl Request for GetGlobalChatBadgesRequest {
type Response = Vec<GetGlobalChatBadgesResponse>;
const PATH: &'static str = "chat/badges/global";
#[cfg(feature = "twitch_oauth2")]
const SCOPE: twitch_oauth2::Validator = twitch_oauth2::validator![];
}
impl RequestGet for GetGlobalChatBadgesRequest {}
#[cfg(test)]
#[test]
fn test_request() {
use helix::*;
let req = GetGlobalChatBadgesRequest::new();
let data = br#"
{
"data": [
{
"set_id": "vip",
"versions": [
{
"id": "1",
"image_url_1x": "https://static-cdn.jtvnw.net/badges/v1/b817aba4-fad8-49e2-b88a-7cc744dfa6ec/1",
"image_url_2x": "https://static-cdn.jtvnw.net/badges/v1/b817aba4-fad8-49e2-b88a-7cc744dfa6ec/2",
"image_url_4x": "https://static-cdn.jtvnw.net/badges/v1/b817aba4-fad8-49e2-b88a-7cc744dfa6ec/3",
"title": "VIP",
"description": "VIP"
}
]
}
]
}
"#
.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/badges/global?"
);
dbg!(GetGlobalChatBadgesRequest::parse_response(Some(req), &uri, http_response).unwrap());
}