// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/authorization/CredentialsImpl.java
// public class CredentialsImpl implements Credentials {
// 
//     private final String username;
//     private final String password;
// 
//     public CredentialsImpl(String username, String password){
//         this.username = username;
//         this.password = password;
//     }
// 
//     @Override
//     public String getUsername() {
//         return username;
//     }
// 
//     @Override
//     public String getPassword() {
//         return password;
//     }
// }
// 
// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/authorization/UrlConnectionBasicAuthorizator.java
// public class UrlConnectionBasicAuthorizator implements UrlConnectionAuthorizator {
// 
//     private final Credentials credentials;
// 
//     public UrlConnectionBasicAuthorizator(Credentials credentials){
//         if(credentials==null){
//             throw new InvalidParameterException("Credentials must not be null");
//         }
//         this.credentials = credentials;
//     }
// 
// 
//     @Override
//     public HttpURLConnection authorize(HttpURLConnection urlConnection) {
//         String userpass = credentials.getUsername() + ":" + credentials.getPassword();
//         String basicAuth = "Basic " + Base64.encodeToString(userpass.getBytes(), Base64.NO_WRAP);
// 
//         urlConnection.setRequestProperty("Authorization", basicAuth);
//         return urlConnection;
//     }
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/serialization/JsonSerializer.java
// public class JsonSerializer implements Serializer {
// 
//     private final ObjectMapper mapper = new ObjectMapper();
// 
//     @Override
//     public <T> T fromString(String string, Class<T> clazz) throws IOException {
//         return mapper.readValue(string, clazz);
//     }
// 
//     @Override
//     public String fromObject(Object object) throws IOException {
//         return mapper.writeValueAsString(object);
//     }
// 
//     @Override
//     public boolean isJson() {
//         return true;
//     }
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/serialization/Serializer.java
// public interface Serializer {
// 
//     <T> T fromString(String string, Class<T> clazz) throws IOException;
//     String fromObject(Object object) throws IOException;
//     boolean isJson();
// }
// 
// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/streams/StreamConverter.java
// public interface StreamConverter {
//     void writeToOutputStream(String string, OutputStream outputStream, boolean useGzip) throws IOException;
//     String readFromInputStream(InputStream inputStream) throws IOException;
//     int getContentLength(String stringBody, boolean useGzip);
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/streams/StreamConverterImpl.java
// public class StreamConverterImpl implements StreamConverter{
// 
//     private final String encoding;
// 
//     public StreamConverterImpl(String encoding){
//         this.encoding = encoding;
//     }
// 
//     @Override
//     public void writeToOutputStream(String content, OutputStream outputStream) throws IOException {
//         OutputStreamWriter out = new OutputStreamWriter( outputStream );
//         out.write(content);
//         out.close();
//     }
// 
//     @Override
//     public String readFromInputStream(InputStream inputStream) throws IOException {
// 
//         ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
//         byte[] buffer= new byte[1024];
//         int nread;
//         while ( (nread = inputStream.read(buffer)) >0 )  {
//             outBytes.write(buffer, 0, nread);
//         }
//         return new String(outBytes.toByteArray() , encoding);
// 
//     }
// 
//     @Override
//     public int getContentLength(String stringBody) {
//         return stringBody.getBytes().length;
//     }
// }
// 
// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/webservice/RequestExecutionAndroidFactory.java
// public class RequestExecutionAndroidFactory implements RequestExecutionFactory {
// 
//     private final Handler mainThreadHandler;
//     private UrlConnectionAuthorizator authorizator;
// 
//     public RequestExecutionAndroidFactory(Handler mainThreadHandler){
//         this.mainThreadHandler = mainThreadHandler;
//     }
// 
//     public void setAuthorizator(UrlConnectionAuthorizator authorizator){
//         this.authorizator = authorizator;
//     }
// 
//     @Override
//     public RequestExecution newInstance(ConnectionDefinition connectionDefinition, RequestExecutionCallbacks callbacks, List<MockRequest> mockRequests, WebserviceImpl webservice) {
// 
//         return new RequestExecutionImpl(connectionDefinition, new HandleredCallbackCallerImpl(mainThreadHandler,callbacks), webservice, authorizator, mockRequests);
// 
//     }
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/webservice/RequestExecutionFactory.java
// public interface RequestExecutionFactory {
// 
//     RequestExecution newInstance(ConnectionDefinition connectionDefinition, RequestExecutionCallbacks requestExecutionCallbacks, List<MockRequest> mockRequests, WebserviceImpl webservice);
// 
// }


import android.content.Context;
import android.os.Handler;
import com.greengrowapps.ggarest.authorization.CredentialsImpl;
import com.greengrowapps.ggarest.authorization.UrlConnectionBasicAuthorizator;
import com.greengrowapps.ggarest.serialization.JsonSerializer;
import com.greengrowapps.ggarest.serialization.Serializer;
import com.greengrowapps.ggarest.streams.StreamConverter;
import com.greengrowapps.ggarest.streams.StreamConverterImpl;
import com.greengrowapps.ggarest.webservice.RequestExecutionAndroidFactory;
import com.greengrowapps.ggarest.webservice.RequestExecutionFactory;
import java.security.InvalidParameterException;
import java.util.Map;
package com.greengrowapps.ggarest;




public class GgaRest {

    private static WebserviceImpl instance;
    private static RequestExecutionAndroidFactory executionFactory;
    private static Serializer serializer = new JsonSerializer();
    private static StreamConverter streamConverter = new StreamConverterImpl("UTF-8");

    private GgaRest(){

    }

    public static void init(Context context){
        executionFactory = new RequestExecutionAndroidFactory(new Handler());
    }

// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/authorization/CredentialsImpl.java
// public class CredentialsImpl implements Credentials {
// 
//     private final String username;
//     private final String password;
// 
//     public CredentialsImpl(String username, String password){
//         this.username = username;
//         this.password = password;
//     }
// 
//     @Override
//     public String getUsername() {
//         return username;
//     }
// 
//     @Override
//     public String getPassword() {
//         return password;
//     }
// }
// 
// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/authorization/UrlConnectionBasicAuthorizator.java
// public class UrlConnectionBasicAuthorizator implements UrlConnectionAuthorizator {
// 
//     private final Credentials credentials;
// 
//     public UrlConnectionBasicAuthorizator(Credentials credentials){
//         if(credentials==null){
//             throw new InvalidParameterException("Credentials must not be null");
//         }
//         this.credentials = credentials;
//     }
// 
// 
//     @Override
//     public HttpURLConnection authorize(HttpURLConnection urlConnection) {
//         String userpass = credentials.getUsername() + ":" + credentials.getPassword();
//         String basicAuth = "Basic " + Base64.encodeToString(userpass.getBytes(), Base64.NO_WRAP);
// 
//         urlConnection.setRequestProperty("Authorization", basicAuth);
//         return urlConnection;
//     }
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/serialization/JsonSerializer.java
// public class JsonSerializer implements Serializer {
// 
//     private final ObjectMapper mapper = new ObjectMapper();
// 
//     @Override
//     public <T> T fromString(String string, Class<T> clazz) throws IOException {
//         return mapper.readValue(string, clazz);
//     }
// 
//     @Override
//     public String fromObject(Object object) throws IOException {
//         return mapper.writeValueAsString(object);
//     }
// 
//     @Override
//     public boolean isJson() {
//         return true;
//     }
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/serialization/Serializer.java
// public interface Serializer {
// 
//     <T> T fromString(String string, Class<T> clazz) throws IOException;
//     String fromObject(Object object) throws IOException;
//     boolean isJson();
// }
// 
// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/streams/StreamConverter.java
// public interface StreamConverter {
//     void writeToOutputStream(String string, OutputStream outputStream, boolean useGzip) throws IOException;
//     String readFromInputStream(InputStream inputStream) throws IOException;
//     int getContentLength(String stringBody, boolean useGzip);
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/streams/StreamConverterImpl.java
// public class StreamConverterImpl implements StreamConverter{
// 
//     private final String encoding;
// 
//     public StreamConverterImpl(String encoding){
//         this.encoding = encoding;
//     }
// 
//     @Override
//     public void writeToOutputStream(String content, OutputStream outputStream) throws IOException {
//         OutputStreamWriter out = new OutputStreamWriter( outputStream );
//         out.write(content);
//         out.close();
//     }
// 
//     @Override
//     public String readFromInputStream(InputStream inputStream) throws IOException {
// 
//         ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
//         byte[] buffer= new byte[1024];
//         int nread;
//         while ( (nread = inputStream.read(buffer)) >0 )  {
//             outBytes.write(buffer, 0, nread);
//         }
//         return new String(outBytes.toByteArray() , encoding);
// 
//     }
// 
//     @Override
//     public int getContentLength(String stringBody) {
//         return stringBody.getBytes().length;
//     }
// }
// 
// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/webservice/RequestExecutionAndroidFactory.java
// public class RequestExecutionAndroidFactory implements RequestExecutionFactory {
// 
//     private final Handler mainThreadHandler;
//     private UrlConnectionAuthorizator authorizator;
// 
//     public RequestExecutionAndroidFactory(Handler mainThreadHandler){
//         this.mainThreadHandler = mainThreadHandler;
//     }
// 
//     public void setAuthorizator(UrlConnectionAuthorizator authorizator){
//         this.authorizator = authorizator;
//     }
// 
//     @Override
//     public RequestExecution newInstance(ConnectionDefinition connectionDefinition, RequestExecutionCallbacks callbacks, List<MockRequest> mockRequests, WebserviceImpl webservice) {
// 
//         return new RequestExecutionImpl(connectionDefinition, new HandleredCallbackCallerImpl(mainThreadHandler,callbacks), webservice, authorizator, mockRequests);
// 
//     }
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/webservice/RequestExecutionFactory.java
// public interface RequestExecutionFactory {
// 
//     RequestExecution newInstance(ConnectionDefinition connectionDefinition, RequestExecutionCallbacks requestExecutionCallbacks, List<MockRequest> mockRequests, WebserviceImpl webservice);
// 
// }


// Path: GgaRestAndroidLib/ggarest/src/main/java/com/greengrowapps/ggarest/GgaRest.java
import android.content.Context;
import android.os.Handler;
import com.greengrowapps.ggarest.authorization.CredentialsImpl;
import com.greengrowapps.ggarest.authorization.UrlConnectionBasicAuthorizator;
import com.greengrowapps.ggarest.serialization.JsonSerializer;
import com.greengrowapps.ggarest.serialization.Serializer;
import com.greengrowapps.ggarest.streams.StreamConverter;
import com.greengrowapps.ggarest.streams.StreamConverterImpl;
import com.greengrowapps.ggarest.webservice.RequestExecutionAndroidFactory;
import com.greengrowapps.ggarest.webservice.RequestExecutionFactory;
import java.security.InvalidParameterException;
import java.util.Map;

package com.greengrowapps.ggarest;




public class GgaRest {

    private static WebserviceImpl instance;
    private static RequestExecutionAndroidFactory executionFactory;
    private static Serializer serializer = new JsonSerializer();
    private static StreamConverter streamConverter = new StreamConverterImpl("UTF-8");

    private GgaRest(){

    }

    public static void init(Context context){
        executionFactory = new RequestExecutionAndroidFactory(new Handler());
    }

    public static void setSerializer(Serializer serializer) {