fn handle_http_response<T: DeserializeOwned>(&self, response: &Response) -> Result<T> {
        let api_response = response.deserialize::<ApiResponse<serde_json::Value>>()?;
        match api_response.code {
            200 => {
                let response = response.deserialize::<ApiResponse<T>>()?;
                Ok(response.data)
            }
            1000 => Err(ApiError::from(api_response)).context(ApiErrorKind::AccessTokenRequired),
            1001 | 1002 => Err(ApiError::from(api_response)).context(ApiErrorKind::InvalidToken),
            _ => Err(ApiError::from(api_response)).context(ApiErrorKind::UnknownError),
        }
    }
/// Handle http response internally to return correct api error according to api response code.
Handle http response internally to return correct api error according to api response code.
Handle http response internally to return correct api error according to api response code .
fn handle_http_response<T: DeserializeOwned>(&self, response: &Response) -> Result<T> {
        let api_response = response.deserialize::<ApiResponse<serde_json::Value>>()?;
        match api_response.code {
            200 => {
                let response = response.deserialize::<ApiResponse<T>>()?;
                Ok(response.data)
            }
            1000 => Err(ApiError::from(api_response)).context(ApiErrorKind::AccessTokenRequired),
            1001 | 1002 => Err(ApiError::from(api_response)).context(ApiErrorKind::InvalidToken),
            _ => Err(ApiError::from(api_response)).context(ApiErrorKind::UnknownError),
        }
    }
fn handle_http_response < T : DeserializeOwned > ( & self , response : & Response ) -> Result < T > { let api_response = response . deserialize :: < ApiResponse < serde_json :: Value > > ( ) ? ; match api_response . code { 200 => { let response = response . deserialize :: < ApiResponse < T > > ( ) ? ; Ok ( response . data ) } 1000 => Err ( ApiError :: from ( api_response ) ) . context ( ApiErrorKind :: AccessTokenRequired ) , 1001 | 1002 => Err ( ApiError :: from ( api_response ) ) . context ( ApiErrorKind :: InvalidToken ) , _ => Err ( ApiError :: from ( api_response ) ) . context ( ApiErrorKind :: UnknownError ) , } }
Handle http response internally to return correct api error according to api response code.
Handle http response internally to return correct api error according to api response code .
&self
response
&Response
&self
response
&Response