class HttpClientImpl implements HttpClient {

    <T> Callback createCallback(ResponseProcessor<? extends T> processor, CompletableFuture<T> resultFuture) {
        return new Callback() {
            @Override
            public void onFailure(@NotNull Call call, @NotNull IOException e) {
                resultFuture.completeExceptionally(e);
                LOG.error("Failed HTTP request {} {}", call.request().method(), call.request().url(), e);
            }

            @Override
            public void onResponse(@NotNull Call call, @NotNull Response response) {
                try {
                    LOG.debug("HTTP response {} - {} {}", response.code(), response.request().method(),
                            response.request().url());
                    T result = processor.process(new ResponseImpl(response));
                    resultFuture.complete(result);
                } catch (Exception e) {
                    // we really need to catch all exceptions here; otherwise, a client waiting for the
                    // future to complete will wait forever
                    resultFuture.completeExceptionally(e);
                    LOG.error("Failed HTTP request {} {}", call.request().method(), call.request().url(), e);
                } finally {
                    response.close();
                }
            }
        };
    }

    public  HttpClientImpl(OkHttpClient client, ObjectMapper mapper);

}