code: <P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException {
          HttpURLConnection connection = null;
          InputStream inputStream = null;
  
          if (METHOD_PATCH.equalsIgnoreCase(method)) {
              // It'd perhaps be cleaner to call this in the constructor, but
              // we'd then need to throw GeneralExceptions from there. This means
              // it wouldn't be possible to declare AND initialize _instance_
              // fields of MessageBirdServiceImpl at the same time. This method
              // already throws this exception, so now we don't have to pollute
              // our public API further.
              allowPatchRequestsIfNeeded();
          }
  
          try {
              connection = getConnection(url, payload, method);
              int status = connection.getResponseCode();
  
              if (APIResponse.isSuccessStatus(status)) {
                  inputStream = connection.getInputStream();
              } else {
                  inputStream = connection.getErrorStream();
              }
  
              return new APIResponse(readToEnd(inputStream), status);
          } catch (IOException ioe) {
              throw new GeneralException(ioe);
          } finally {
              saveClose(inputStream);
  
              if (connection != null) {
                  connection.disconnect();
              }
          }
      }
docs: Actually sends a HTTP request and returns its body and HTTP status code.
  
  @param method  HTTP method.
  @param url     Absolute URL.
  @param payload Payload to JSON encode for the request body. May be null.
  @param <P>     Type of the payload.
  @return APIResponse containing the response's body and status.