package io.apptik.comm.jus.okhttp;


import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.RequestBody;

import java.util.Map;

import io.apptik.comm.jus.NetworkRequest;
import io.apptik.comm.jus.http.Headers;

public class JusOk {

    private JusOk() {
    }

    public static Headers jusHeaders(com.squareup.okhttp.Headers okHeaders) {
        return new Headers.Builder().addMMap(okHeaders.toMultimap()).build();
    }

    public static com.squareup.okhttp.Headers okHeaders(Headers jusHeaders, Headers
            additionalHeaders) {
        if (jusHeaders == null) {
            jusHeaders = new Headers.Builder().build();
        }

        Map<String, String> headers = jusHeaders.toMap();
        if (additionalHeaders == null)
        {
            headers.putAll(additionalHeaders.toMap());
        }
        return com.squareup.okhttp.Headers.of(headers);
    }

    public static RequestBody okBody(NetworkRequest request) {
        if (request == null)
            return null;
        return RequestBody.create(MediaType.parse(request.contentType.toString()), request.data);
    }
}

@@ -109,16 +109,46 @@
 tBody;%0A%0A
+import java.util.Collections;%0A
 import j
@@ -567,32 +567,70 @@
 tionalHeaders) %7B
+%0A%0A        Map%3CString, String%3E headers;
 %0A        if (jus
@@ -660,20 +660,17 @@
         
-jusH
+h
 eaders =
@@ -674,35 +674,28 @@
 s = 
-new Headers.Builder().build
+Collections.emptyMap
 ();%0A
@@ -699,25 +699,31 @@
 );%0A        %7D
-%0A
+ else %7B
 %0A        Map
@@ -723,57 +723,175 @@
     
-Map%3CString, String%3E headers = jusHeaders.toMap();
+    //check if we have content type in Jus headers ad remove it if yes%0A            headers = jusHeaders.toMap();%0A            headers.remove(%22Content-Type%22);%0A        %7D%0A
 %0A   
@@ -913,25 +913,25 @@
 onalHeaders 
-=
+!
 = null)%0A    

fix okhttp stack