/// Request on a valid [`RequestPatch`] endpoint, with the ability to return borrowed data and specific fields.
///
/// # Notes
///
/// This is probably not useful, as `PATCH` endpoints do not usually return json
Request on a valid [`RequestPatch`] endpoint, with the ability to return borrowed data and specific fields.
Request on a valid [ ` RequestPatch ` ] endpoint with the ability to return borrowed data and specific fields .
pub async fn req_patch_custom<'d, R, B, D, T, F>(
        &'a self,
        request: R,
        body: B,
        token: &T,
        function: F,
    ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as crate::HttpClient<'a>>::Error>>
    where
        R: Request + RequestPatch + RequestPatch<Body = B>,
        B: HelixRequestBody,
        D: serde::de::Deserialize<'d> + 'd,
        T: TwitchToken + ?Sized,
        C: Send,
        F: Fn(&R, &http::Uri, &str, http::StatusCode) -> Result<(), HelixRequestPatchError>,
    {
        let req =
            request.create_request(body, token.token().secret(), token.client_id().as_str())?;
        let uri = req.uri().clone();
        let response = self
            .client
            .req(req)
            .await
            .map_err(ClientRequestError::RequestError)?;
        {
            let uri = &uri;
            let text = std::str::from_utf8(response.body()).map_err(|e| {
                HelixRequestPatchError::Utf8Error(response.body().clone(), e, uri.clone())
            })?;
            if let Ok(HelixRequestError {
                error,
                status,
                message,
            }) = parse_json::<HelixRequestError>(text, false)
            {
                return Err(HelixRequestPatchError::Error {
                    error,
                    status: status.try_into().unwrap_or(http::StatusCode::BAD_REQUEST),
                    message,
                    uri: uri.clone(),
                    body: response.body().clone(),
                }
                .into());
            }
            function(&request, uri, text, response.status())?;
            let response: CustomInnerResponse<'_> = crate::parse_json(text, true).map_err(|e| {
                HelixRequestPatchError::DeserializeError(
                    text.to_owned(),
                    e,
                    uri.clone(),
                    response.status(),
                )
            })?;
            Ok(CustomResponse {
                pagination: response.pagination.cursor,
                request: Some(request),
                total: response.total,
                other: response.other,
                raw_data: response.data.to_owned(),
                pd: <_>::default(),
            })
        }
    }
pub async fn req_patch_custom < ' d , R , B , D , T , F > ( & ' a self , request : R , body : B , token : & T , function : F , ) -> Result < CustomResponse < ' d , R , D > , ClientRequestError < < C as crate :: HttpClient < ' a > > :: Error > > where R : Request + RequestPatch + RequestPatch < Body = B > , B : HelixRequestBody , D : serde :: de :: Deserialize < ' d > + ' d , T : TwitchToken + ? Sized , C : Send , F : Fn ( & R , & http :: Uri , & str , http :: StatusCode ) -> Result < ( ) , HelixRequestPatchError > , { let req = request . create_request ( body , token . token ( ) . secret ( ) , token . client_id ( ) . as_str ( ) ) ? ; let uri = req . uri ( ) . clone ( ) ; let response = self . client . req ( req ) . await . map_err ( ClientRequestError :: RequestError ) ? ; { let uri = & uri ; let text = std :: str :: from_utf8 ( response . body ( ) ) . map_err ( | e | { HelixRequestPatchError :: Utf8Error ( response . body ( ) . clone ( ) , e , uri . clone ( ) ) } ) ? ; if let Ok ( HelixRequestError { error , status , message , } ) = parse_json :: < HelixRequestError > ( text , false ) { return Err ( HelixRequestPatchError :: Error { error , status : status . try_into ( ) . unwrap_or ( http :: StatusCode :: BAD_REQUEST ) , message , uri : uri . clone ( ) , body : response . body ( ) . clone ( ) , } . into ( ) ) ; } function ( & request , uri , text , response . status ( ) ) ? ; let response : CustomInnerResponse < ' _ > = crate :: parse_json ( text , true ) . map_err ( | e | { HelixRequestPatchError :: DeserializeError ( text . to_owned ( ) , e , uri . clone ( ) , response . status ( ) , ) } ) ? ; Ok ( CustomResponse { pagination : response . pagination . cursor , request : Some ( request ) , total : response . total , other : response . other , raw_data : response . data . to_owned ( ) , pd : < _ > :: default ( ) , } ) } }
Request on a valid [`RequestPatch`] endpoint, with the ability to return borrowed data and specific fields.
Request on a valid [ ` RequestPatch ` ] endpoint with the ability to return borrowed data and specific fields .
&'a self
request
R
body
B
token
&T
function
F
notes
This is probably not useful, as `PATCH` endpoints do not usually return json
This is probably not useful as ` PATCH ` endpoints do not usually return json