use super::*;
use helix::RequestGet;
#[derive(PartialEq, typed_builder::TypedBuilder, Deserialize, Serialize, Clone, Debug)]
#[non_exhaustive]
pub struct GetChannelEditorsRequest {
#[builder(setter(into))]
pub broadcaster_id: types::UserId,
}
#[derive(PartialEq, Deserialize, Serialize, Debug, Clone)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct Editor {
pub user_id: types::UserId,
pub user_name: types::DisplayName,
pub created_at: types::Timestamp,
}
impl Request for GetChannelEditorsRequest {
type Response = Vec<Editor>;
const PATH: &'static str = "channels/editors";
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::ChannelReadEditors];
}
impl RequestGet for GetChannelEditorsRequest {}
#[cfg(test)]
#[test]
fn test_request() {
use helix::*;
let req = GetChannelEditorsRequest::builder()
.broadcaster_id("44445592".to_string())
.build();
let data = br#"
{
"data": [
{
"user_id": "182891647",
"user_name": "mauerbac",
"created_at": "2019-02-15T21:19:50.380833Z"
},
{
"user_id": "135093069",
"user_name": "BlueLava",
"created_at": "2018-03-07T16:28:29.872937Z"
}
]
}
"#
.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/channels/editors?broadcaster_id=44445592"
);
dbg!(GetChannelEditorsRequest::parse_response(Some(req), &uri, http_response).unwrap());
}