use super::*;
use helix::RequestGet;
#[derive(PartialEq, typed_builder::TypedBuilder, Deserialize, Serialize, Clone, Debug)]
#[non_exhaustive]
pub struct GetGamesRequest {
#[builder(default)]
pub id: Vec<types::CategoryId>,
#[builder(default)]
pub name: Vec<String>,
}
pub type Game = types::TwitchCategory;
impl Request for GetGamesRequest {
type Response = Vec<Game>;
const PATH: &'static str = "games";
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[];
}
impl RequestGet for GetGamesRequest {}
#[cfg(test)]
#[test]
fn test_request() {
use helix::*;
let req = GetGamesRequest::builder().id(vec!["493057".into()]).build();
let data = br#"
{
"data": [
{
"box_art_url": "https://static-cdn.jtvnw.net/ttv-boxart/Fortnite-52x72.jpg",
"id": "33214",
"name": "Fortnite"
},
{
"box_art_url": "https://static-cdn.jtvnw.net/ttv-boxart/Fortnite-52x72.jpg",
"id": "33214",
"name": "Fortnite"
}
],
"pagination": {
"cursor": "eyJiIjpudWxsLCJhIjp7IkN"
}
}
"#
.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/games?id=493057"
);
dbg!(GetGamesRequest::parse_response(Some(req), &uri, http_response).unwrap());
}