// Path: library/src/main/java/org/mariotaku/restfu/http/mime/Body.java
// public interface Body extends Closeable {
//     ContentType contentType();
// 
//     String contentEncoding();
// 
//     long length() throws IOException;
// 
//     long writeTo(final OutputStream os) throws IOException;
// 
//     InputStream stream() throws IOException;
// 
//     void close() throws IOException;
// 
// }


import okhttp3.*;
import okio.BufferedSink;
import okio.Okio;
import org.jetbrains.annotations.NotNull;
import org.mariotaku.commons.collection.Pair;
import org.mariotaku.restfu.http.*;
import org.mariotaku.restfu.http.mime.Body;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
    @Override
    public HttpCall newCall(@NotNull final HttpRequest httpRequest) {
        final Request.Builder builder = new Request.Builder();
        builder.method(httpRequest.getMethod(), RestToOkRequestBody.wrap(httpRequest.getBody()));
        builder.url(httpRequest.getUrl());
        final MultiValueMap<String> headers = httpRequest.getHeaders();
        if (headers != null) {
            for (Pair<String, String> header : headers.toList()) {
                builder.addHeader(header.first, header.second);
            }
        }
        return new OkToRestCall(client.newCall(builder.build()));
    }

    @Override
    public void enqueue(@NotNull final HttpCall call, @NotNull final HttpCallback callback) {
        call.enqueue(callback);
    }

    public void setClient(OkHttpClient client) {
        if (client == null) throw new NullPointerException();
        this.client = client;
    }

    public OkHttpClient getClient() {
        return client;
    }

    private static class OkToRestResponse extends HttpResponse {
        private final Response response;
// Path: library/src/main/java/org/mariotaku/restfu/http/mime/Body.java
// public interface Body extends Closeable {
//     ContentType contentType();
// 
//     String contentEncoding();
// 
//     long length() throws IOException;
// 
//     long writeTo(final OutputStream os) throws IOException;
// 
//     InputStream stream() throws IOException;
// 
//     void close() throws IOException;
// 
// }


// Path: okhttp3/src/main/java/org/mariotaku/restfu/okhttp3/OkHttpRestClient.java
import okhttp3.*;
import okio.BufferedSink;
import okio.Okio;
import org.jetbrains.annotations.NotNull;
import org.mariotaku.commons.collection.Pair;
import org.mariotaku.restfu.http.*;
import org.mariotaku.restfu.http.mime.Body;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

    @Override
    public HttpCall newCall(@NotNull final HttpRequest httpRequest) {
        final Request.Builder builder = new Request.Builder();
        builder.method(httpRequest.getMethod(), RestToOkRequestBody.wrap(httpRequest.getBody()));
        builder.url(httpRequest.getUrl());
        final MultiValueMap<String> headers = httpRequest.getHeaders();
        if (headers != null) {
            for (Pair<String, String> header : headers.toList()) {
                builder.addHeader(header.first, header.second);
            }
        }
        return new OkToRestCall(client.newCall(builder.build()));
    }

    @Override
    public void enqueue(@NotNull final HttpCall call, @NotNull final HttpCallback callback) {
        call.enqueue(callback);
    }

    public void setClient(OkHttpClient client) {
        if (client == null) throw new NullPointerException();
        this.client = client;
    }

    public OkHttpClient getClient() {
        return client;
    }

    private static class OkToRestResponse extends HttpResponse {
        private final Response response;
        private final Body body;