message: short refactor
diff: @@ -31,9 +31,7 @@ impl APIClient {
  APIClient { configuration }
  }
  - pub fn request<T>(&self, request: http::Request<Vec<u8>>) -> Result<T, Error>
  - where
  - T: DeserializeOwned,
  + fn send(&self, request: http::Request<Vec<u8>>) -> Result<reqwest::Response, Error>
  {
  let (parts, body) = request.into_parts();
  let uri_str = format!("{}{}", self.configuration.base_path, parts.uri);
  @@ -46,7 +44,15 @@ impl APIClient {
  return Err(Error::from(format_err!("Invalid method: {}", other)));
  }
  }.body(body);
  - let mut res = req.send()?;
  + Ok(req.send()?)
  + }
  +
  +
  + pub fn request<T>(&self, request: http::Request<Vec<u8>>) -> Result<T, Error>
  + where
  + T: DeserializeOwned,
  + {
  + let mut res : reqwest::Response = self.send(request)?;
  if !res.status().is_success() {
  let text = res.text()?;
  // Print better debug when things do fail
  @@ -73,18 +79,7 @@ impl APIClient {
  where
  T: DeserializeOwned,
  {
  - let (parts, body) = request.into_parts();
  - let uri_str = format!("{}{}", self.configuration.base_path, parts.uri);
  - let req = match parts.method {
  - http::Method::GET => self.configuration.client.get(&uri_str),
  - http::Method::POST => self.configuration.client.post(&uri_str),
  - http::Method::DELETE => self.configuration.client.delete(&uri_str),
  - http::Method::PUT => self.configuration.client.put(&uri_str),
  - other => {
  - return Err(Error::from(format_err!("Invalid method: {}", other)));
  - }
  - }.body(body);
  - let mut res = req.send()?;
  + let mut res : reqwest::Response = self.send(request)?;
  if !res.status().is_success() {
  let text = res.text()?;
  // Print better debug when things do fail
  