twitch_api/helix/endpoints/moderation/remove_suspicious_status_from_chat_user.rs
1//! Remove a suspicious user status from a chatter on broadcaster’s channel.
2//! [`remove-suspicious-status-from-chat-user`](https://dev.twitch.tv/docs/api/reference#remove-suspicious-status-from-chat-user)
3//!
4//! # Accessing the endpoint
5//!
6//! ## Request: [RemoveSuspiciousStatusFromChatUserRequest]
7//!
8//! To use this endpoint, construct a [`RemoveSuspiciousStatusFromChatUserRequest`] with the [`RemoveSuspiciousStatusFromChatUserRequest::new()`] method.
9//!
10//! ```rust
11//! use twitch_api::helix::moderation::remove_suspicious_status_from_chat_user;
12//! let request = remove_suspicious_status_from_chat_user::RemoveSuspiciousStatusFromChatUserRequest::new("1234", "5678", "9876");
13//! ```
14//!
15//! ## Response: [SuspiciousUserInfo]
16//!
17//! Send the request to receive the response with [`HelixClient::req_delete()`](helix::HelixClient::req_delete).
18//!
19//! ```rust, no_run
20//! use twitch_api::helix::{self, moderation::{remove_suspicious_status_from_chat_user, SuspiciousUserInfo}};
21//! # use twitch_api::client;
22//! # #[tokio::main]
23//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
24//! # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
25//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
26//! # let token = twitch_oauth2::UserToken::from_existing(&client, token, None, None).await?;
27//! let request = remove_suspicious_status_from_chat_user::RemoveSuspiciousStatusFromChatUserRequest::new("1234", "5678", "9876");
28//! let response: SuspiciousUserInfo = client.req_delete(request, &token).await?.data;
29//! # Ok(())
30//! # }
31//! ```
32//!
33//! You can also get the [`http::Request`] with [`request.create_request(&token, &client_id)`](helix::RequestDelete::create_request)
34//! and parse the [`http::Response`] with [`RemoveSuspiciousStatusFromChatUserRequest::parse_response(None, &request.get_uri(), response)`](RemoveSuspiciousStatusFromChatUserRequest::parse_response)
35
36use super::*;
37use helix::RequestDelete;
38
39/// Query Parameters for [Remove Suspicious Status From Chat User](super::remove_suspicious_status_from_chat_user)
40///
41/// [`remove-suspicious-status-from-chat-user`](https://dev.twitch.tv/docs/api/reference#remove-suspicious-status-from-chat-user)
42#[derive(PartialEq, Eq, Deserialize, Serialize, Clone, Debug)]
43#[cfg_attr(feature = "typed-builder", derive(typed_builder::TypedBuilder))]
44#[must_use]
45#[non_exhaustive]
46pub struct RemoveSuspiciousStatusFromChatUserRequest<'a> {
47 /// The user ID of the broadcaster, indicating the channel where the status is being removed.
48 #[cfg_attr(feature = "typed-builder", builder(setter(into)))]
49 #[cfg_attr(feature = "deser_borrow", serde(borrow = "'a"))]
50 pub broadcaster_id: Cow<'a, types::UserIdRef>,
51 /// The user ID of the moderator who is removing the status.
52 #[cfg_attr(feature = "typed-builder", builder(setter(into)))]
53 #[cfg_attr(feature = "deser_borrow", serde(borrow = "'a"))]
54 pub moderator_id: Cow<'a, types::UserIdRef>,
55 /// The ID of the user having the suspicious status removed.
56 #[cfg_attr(feature = "typed-builder", builder(setter(into)))]
57 #[cfg_attr(feature = "deser_borrow", serde(borrow = "'a"))]
58 pub user_id: Cow<'a, types::UserIdRef>,
59}
60
61impl<'a> RemoveSuspiciousStatusFromChatUserRequest<'a> {
62 /// Remove a suspicious user status from a chatter on broadcaster’s channel.
63 pub fn new(
64 broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
65 moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
66 user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
67 ) -> Self {
68 Self {
69 broadcaster_id: broadcaster_id.into_cow(),
70 moderator_id: moderator_id.into_cow(),
71 user_id: user_id.into_cow(),
72 }
73 }
74}
75
76impl Request for RemoveSuspiciousStatusFromChatUserRequest<'_> {
77 type PaginationData = ();
78 type Response = SuspiciousUserInfo;
79
80 const PATH: &'static str = "moderation/suspicious_users";
81 #[cfg(feature = "twitch_oauth2")]
82 const SCOPE: twitch_oauth2::Validator =
83 twitch_oauth2::validator![twitch_oauth2::Scope::ModeratorManageSuspiciousUsers];
84}
85
86impl<'a> RequestDelete for RemoveSuspiciousStatusFromChatUserRequest<'a> {
87 fn parse_inner_response(
88 request: Option<Self>,
89 uri: &http::Uri,
90 response: &str,
91 status: http::StatusCode,
92 ) -> Result<helix::Response<Self, Self::Response>, helix::HelixRequestDeleteError>
93 where
94 Self: Sized,
95 {
96 helix::parse_single_return(request, uri, response, status)
97 }
98}
99
100#[cfg(test)]
101#[test]
102fn test_request() {
103 use helix::*;
104 let req = RemoveSuspiciousStatusFromChatUserRequest::new("141981764", "12826", "9876");
105
106 dbg!(req.create_request("token", "clientid").unwrap());
107
108 // From twitch docs
109 let data = br#"
110 {
111 "data": [
112 {
113 "user_id": "9876",
114 "broadcaster_id": "141981764",
115 "moderator_id": "12826",
116 "updated_at": "2025-12-01T23:08:18+00:00",
117 "status": "NO_TREATMENT",
118 "types": [
119 "MANUALLY_ADDED"
120 ]
121 }
122 ]
123 }
124 "#
125 .to_vec();
126
127 let http_response = http::Response::builder().body(data).unwrap();
128
129 let uri = req.get_uri().unwrap();
130 assert_eq!(
131 uri.to_string(),
132 "https://api.twitch.tv/helix/moderation/suspicious_users?broadcaster_id=141981764&moderator_id=12826&user_id=9876"
133 );
134
135 dbg!(
136 RemoveSuspiciousStatusFromChatUserRequest::parse_response(Some(req), &uri, http_response)
137 .unwrap()
138 );
139}