// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java
// public interface Call<T, S> extends CallAsync<T, S> {
//     Response<T, S> execute();
// }
// 
// Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java
// public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> {
// }
// 
// Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java
// public interface Callback<T, S> {
// 
//     void onSuccess(T result);
// 
//     void onError(S e);
// 
// }
// 
// Path: common/src/main/java/com/tresorit/zerokit/call/Response.java
// public class Response<T, S> {
// 
//     private T result;
//     private S error;
// 
//     public static <T, S> Response<T, S> fromValue(T value){
//         Response<T, S> response = new Response<>();
//         response.setResult(value);
//         return response;
//     }
// 
//     public static <T, S> Response<T, S> fromError(S error){
//         Response<T, S> response = new Response<>();
//         response.setError(error);
//         return response;
//     }
// 
//     public static <T, S> Response<T, S> from(T value, S error){
//         Response<T, S> response = new Response<>();
//         response.setResult(value);
//         response.setError(error);
//         return response;
//     }
// 
//     private Response(){}
// 
//     private void setError(S error) {
//         this.error = error;
//     }
// 
//     void setResult(T result) {
//         this.result = result;
//     }
// 
//     public boolean isError() {
//         return error != null;
//     }
// 
//     public T getResult() {
//         return result;
//     }
// 
//     public S getError() {
//         return error;
//     }
// }
// 
// Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java
// public class ResponseAdminApiError {
//     private String code;
//     private String message;
//     private ResponseExtensionException exception;
// 
//     public ResponseAdminApiError(String message) {
//         this.message = message;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("code: %s, message: %s", code, message);
//     }
// }
// 
// Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java
// public class ResponseAdminApiInitUserRegistration  {
//     private String userId;
//     private String regSessionId;
// 
//     public String getUserId() {
//         return userId;
//     }
// 
//     public String getRegSessionId() {
//         return regSessionId;
//     }
// 
// 
// }
// 
// Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java
// public class ResponseAdminApiLoginByCode {
//     private String userId;
// 
//     private String id;
// 
//     private String validUntil;
// 
//     public String getId() {
//         return id;
//     }
// 
// }
// 
// Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java
// public class Holder<T>{
//     public T t;
// }


import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.test.espresso.IdlingResource;
import com.google.gson.Gson;
import com.tresorit.zerokit.call.Call;
import com.tresorit.zerokit.call.CallBase;
import com.tresorit.zerokit.call.Callback;
import com.tresorit.zerokit.call.Response;
import com.tresorit.zerokit.response.ResponseAdminApiError;
import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration;
import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode;
import com.tresorit.zerokit.util.Holder;
import com.zerokit.zerokit.BuildConfig;
import org.json.JSONException;
import java.io.EOFException;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
    public Call<Void, ResponseAdminApiError> acceptedInvitationLink(final String operationId) {
        return new CallRetrofit<>(adminApiService.acceptedInvitationLink(operationId));
    }

    public Call<Void, ResponseAdminApiError> createdInvitationLink(final String operationId) {
        return new CallRetrofit<>(adminApiService.createdInvitationLink(operationId));
    }

    public Call<Void, ResponseAdminApiError> revokedInvitationLink(final String operationId) {
        return new CallRetrofit<>(adminApiService.revokedInvitationLink(operationId));
    }


    private class CallRetrofit<T> extends CallBase<T, ResponseAdminApiError> {

        final retrofit2.Call<T> call;

        CallRetrofit(retrofit2.Call<T> call) {
            this.call = call;
        }

        @Override
        public void enqueue(Callback<? super T, ? super ResponseAdminApiError> callback) {
            incrementIdlingResource();
            call.enqueue(new CallbackRetrofit<>(callback));
        }

        @Override
        public Response<T, ResponseAdminApiError> execute() {
            incrementIdlingResource();
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java
// public interface Call<T, S> extends CallAsync<T, S> {
//     Response<T, S> execute();
// }
// 
// Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java
// public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> {
// }
// 
// Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java
// public interface Callback<T, S> {
// 
//     void onSuccess(T result);
// 
//     void onError(S e);
// 
// }
// 
// Path: common/src/main/java/com/tresorit/zerokit/call/Response.java
// public class Response<T, S> {
// 
//     private T result;
//     private S error;
// 
//     public static <T, S> Response<T, S> fromValue(T value){
//         Response<T, S> response = new Response<>();
//         response.setResult(value);
//         return response;
//     }
// 
//     public static <T, S> Response<T, S> fromError(S error){
//         Response<T, S> response = new Response<>();
//         response.setError(error);
//         return response;
//     }
// 
//     public static <T, S> Response<T, S> from(T value, S error){
//         Response<T, S> response = new Response<>();
//         response.setResult(value);
//         response.setError(error);
//         return response;
//     }
// 
//     private Response(){}
// 
//     private void setError(S error) {
//         this.error = error;
//     }
// 
//     void setResult(T result) {
//         this.result = result;
//     }
// 
//     public boolean isError() {
//         return error != null;
//     }
// 
//     public T getResult() {
//         return result;
//     }
// 
//     public S getError() {
//         return error;
//     }
// }
// 
// Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java
// public class ResponseAdminApiError {
//     private String code;
//     private String message;
//     private ResponseExtensionException exception;
// 
//     public ResponseAdminApiError(String message) {
//         this.message = message;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("code: %s, message: %s", code, message);
//     }
// }
// 
// Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java
// public class ResponseAdminApiInitUserRegistration  {
//     private String userId;
//     private String regSessionId;
// 
//     public String getUserId() {
//         return userId;
//     }
// 
//     public String getRegSessionId() {
//         return regSessionId;
//     }
// 
// 
// }
// 
// Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java
// public class ResponseAdminApiLoginByCode {
//     private String userId;
// 
//     private String id;
// 
//     private String validUntil;
// 
//     public String getId() {
//         return id;
//     }
// 
// }
// 
// Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java
// public class Holder<T>{
//     public T t;
// }


// Path: adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.test.espresso.IdlingResource;
import com.google.gson.Gson;
import com.tresorit.zerokit.call.Call;
import com.tresorit.zerokit.call.CallBase;
import com.tresorit.zerokit.call.Callback;
import com.tresorit.zerokit.call.Response;
import com.tresorit.zerokit.response.ResponseAdminApiError;
import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration;
import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode;
import com.tresorit.zerokit.util.Holder;
import com.zerokit.zerokit.BuildConfig;
import org.json.JSONException;
import java.io.EOFException;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;

    public Call<Void, ResponseAdminApiError> acceptedInvitationLink(final String operationId) {
        return new CallRetrofit<>(adminApiService.acceptedInvitationLink(operationId));
    }

    public Call<Void, ResponseAdminApiError> createdInvitationLink(final String operationId) {
        return new CallRetrofit<>(adminApiService.createdInvitationLink(operationId));
    }

    public Call<Void, ResponseAdminApiError> revokedInvitationLink(final String operationId) {
        return new CallRetrofit<>(adminApiService.revokedInvitationLink(operationId));
    }


    private class CallRetrofit<T> extends CallBase<T, ResponseAdminApiError> {

        final retrofit2.Call<T> call;

        CallRetrofit(retrofit2.Call<T> call) {
            this.call = call;
        }

        @Override
        public void enqueue(Callback<? super T, ? super ResponseAdminApiError> callback) {
            incrementIdlingResource();
            call.enqueue(new CallbackRetrofit<>(callback));
        }

        @Override
        public Response<T, ResponseAdminApiError> execute() {
            incrementIdlingResource();
            final Holder<Response<T, ResponseAdminApiError>> result = new Holder<>();