code: private StringBuilder responseBodyTreatment(StringBuilder responseBody, int responseCode, HttpURLConnection connection) {
  
          try {
  
              if (responseCode >= 200 && responseCode < 299) {
                  responseBody = tools.readBody(connection.getInputStream());
              }
  
              if (responseCode == 401) {
                  throw new UnauthorizedException();
              }
  
              if (responseCode >= 400 && responseCode < 499) {
                  responseBody = tools.readBody(connection.getErrorStream());
                  LOGGER.debug("API ERROR {}", responseBody.toString());
  
                  Errors errors = new Errors();
  
                  try {
  
                      errors = tools.getGsonInstance().fromJson(responseBody.toString(), Errors.class);
  
                  } catch (Exception e) {
  
                      LOGGER.debug("There was not possible cast the JSON to object");
                  }
  
                  throw new ValidationException(responseCode, connection.getResponseMessage(), errors);
              }
  
              if (responseCode >= 500) {
                  throw new UnexpectedException();
              }
  
          } catch (IOException e) {
              throw new MoipAPIException("Error occurred connecting to Moip API: " + e.getMessage(), e);
          }
  
          return responseBody;
      }
docs: This method is used to check the response code and apply the correct treatment to the
  response body. Basically, if the response code is between 200 and 299, this method returns
  a response body charged with the right input stream. If the response code is 401, this
  method throws a {@code UnauthorizedException}. If the code is between 400 and 499 (except 401),
  this method create and charge an {@code Error} object with a deserialize JSON returned from
  Moip API to build a {@code ValidationException} and throw it. And finally, if the response
  code is 500 or higher, this method throws a {@code UnexpectedException}.
  
  @param   responseBody
  {@code StringBuilder} the response body returned from API.
  
  @param   responseCode
  {@code int} the response code returned from API.
  
  @param   connection
  {@code HttpURLConnection} the object containing the connection
  with Moip API.
  
  @return  {@code StringBuilder} response body.