pub async fn req_get_custom<'d, R, D, T>(
        &'a self,
        request: R,
        token: &T,
    ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as crate::HttpClient<'a>>::Error>>
    where
        R: Request + RequestGet,
        D: serde::de::Deserialize<'d> + 'd,
        T: TwitchToken + ?Sized,
        C: Send,
    {
        let req = request.create_request(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 request = Some(request);
            let uri = &uri;
            let text = std::str::from_utf8(response.body()).map_err(|e| {
                HelixRequestGetError::Utf8Error(response.body().clone(), e, uri.clone())
            })?;
            //eprintln!("\n\nmessage is ------------ {} ------------", text);
            if let Ok(HelixRequestError {
                error,
                status,
                message,
            }) = parse_json::<HelixRequestError>(text, false)
            {
                return Err(HelixRequestGetError::Error {
                    error,
                    status: status.try_into().unwrap_or(http::StatusCode::BAD_REQUEST),
                    message,
                    uri: uri.clone(),
                }
                .into());
            }
            let response: CustomInnerResponse<'_> = crate::parse_json(text, true).map_err(|e| {
                HelixRequestGetError::DeserializeError(
                    text.to_owned(),
                    e,
                    uri.clone(),
                    response.status(),
                )
            })?;
            Ok(CustomResponse {
                pagination: response.pagination.cursor,
                request,
                total: response.total,
                other: response.other,
                raw_data: response.data.to_owned(),
                pd: <_>::default(),
            })
        }
    }
/// Request on a valid [`RequestGet`] endpoint, with the ability to return borrowed data and specific fields.
Request on a valid [`RequestGet`] endpoint, with the ability to return borrowed data and specific fields.
Request on a valid [ ` RequestGet ` ] endpoint with the ability to return borrowed data and specific fields .
pub async fn req_get_custom<'d, R, D, T>(
        &'a self,
        request: R,
        token: &T,
    ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as crate::HttpClient<'a>>::Error>>
    where
        R: Request + RequestGet,
        D: serde::de::Deserialize<'d> + 'd,
        T: TwitchToken + ?Sized,
        C: Send,
    {
        let req = request.create_request(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 request = Some(request);
            let uri = &uri;
            let text = std::str::from_utf8(response.body()).map_err(|e| {
                HelixRequestGetError::Utf8Error(response.body().clone(), e, uri.clone())
            })?;
            //eprintln!("\n\nmessage is ------------ {} ------------", text);
            if let Ok(HelixRequestError {
                error,
                status,
                message,
            }) = parse_json::<HelixRequestError>(text, false)
            {
                return Err(HelixRequestGetError::Error {
                    error,
                    status: status.try_into().unwrap_or(http::StatusCode::BAD_REQUEST),
                    message,
                    uri: uri.clone(),
                }
                .into());
            }
            let response: CustomInnerResponse<'_> = crate::parse_json(text, true).map_err(|e| {
                HelixRequestGetError::DeserializeError(
                    text.to_owned(),
                    e,
                    uri.clone(),
                    response.status(),
                )
            })?;
            Ok(CustomResponse {
                pagination: response.pagination.cursor,
                request,
                total: response.total,
                other: response.other,
                raw_data: response.data.to_owned(),
                pd: <_>::default(),
            })
        }
    }
pub async fn req_get_custom < ' d , R , D , T > ( & ' a self , request : R , token : & T , ) -> Result < CustomResponse < ' d , R , D > , ClientRequestError < < C as crate :: HttpClient < ' a > > :: Error > > where R : Request + RequestGet , D : serde :: de :: Deserialize < ' d > + ' d , T : TwitchToken + ? Sized , C : Send , { let req = request . create_request ( 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 request = Some ( request ) ; let uri = & uri ; let text = std :: str :: from_utf8 ( response . body ( ) ) . map_err ( | e | { HelixRequestGetError :: Utf8Error ( response . body ( ) . clone ( ) , e , uri . clone ( ) ) } ) ? ; //eprintln!("\n\nmessage is ------------ {} ------------", text); if let Ok ( HelixRequestError { error , status , message , } ) = parse_json :: < HelixRequestError > ( text , false ) { return Err ( HelixRequestGetError :: Error { error , status : status . try_into ( ) . unwrap_or ( http :: StatusCode :: BAD_REQUEST ) , message , uri : uri . clone ( ) , } . into ( ) ) ; } let response : CustomInnerResponse < ' _ > = crate :: parse_json ( text , true ) . map_err ( | e | { HelixRequestGetError :: DeserializeError ( text . to_owned ( ) , e , uri . clone ( ) , response . status ( ) , ) } ) ? ; Ok ( CustomResponse { pagination : response . pagination . cursor , request , total : response . total , other : response . other , raw_data : response . data . to_owned ( ) , pd : < _ > :: default ( ) , } ) } }
Request on a valid [`RequestGet`] endpoint, with the ability to return borrowed data and specific fields.
Request on a valid [ ` RequestGet ` ] endpoint with the ability to return borrowed data and specific fields .
&'a self
request
R
token
&T
&'a self
request
R
token
&T