// Path: saltedge-library/src/main/java/com/saltedge/sdk/network/ExtraJsonDataAdapter.java
// public class ExtraJsonDataAdapter implements JsonDeserializer<JSONObject> {
// 
//     @Override
//     public JSONObject deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
//         return SEJsonTools.stringToJSON(json.getAsJsonObject().toString());
//     }
// }
// 
// Path: saltedge-library/src/main/java/com/saltedge/sdk/network/HeaderInterceptor.java
// public class HeaderInterceptor implements Interceptor {
// 
//     private String acceptType;
// 
//     public HeaderInterceptor(String acceptType) {
//         this.acceptType = acceptType;
//     }
// 
//     @Override
//     public Response intercept(Chain chain) throws IOException {
//         Request.Builder requestBuilder = chain.request().newBuilder()
//                 .header(SEApiConstants.KEY_HEADER_CONTENT_TYPE, SEApiConstants.MIME_TYPE_JSON)
//                 .header(SEApiConstants.KEY_HEADER_APP_ID, SaltEdgeSDK.getInstance().getAppId())
//                 .header(SEApiConstants.KEY_HEADER_APP_SECRET, SaltEdgeSDK.getInstance().getAppSecret());
//         if (acceptType != null) {
//             requestBuilder.header(SEApiConstants.KEY_HEADER_ACCEPT, acceptType);
//         }
//         return chain.proceed(requestBuilder.build());
//     }
// }
// 
// Path: saltedge-library/src/main/java/com/saltedge/sdk/preferences/SEPreferencesRepository.java
// public class SEPreferencesRepository {
// 
//     private static final String KEY_PINS_EXPIRE_AT = "KEY_SE_PINS_EXPIRE_AT";
//     private static final String KEY_PINS_SET = "KEY_SE_PINS_SET";
//     private static SEPreferencesRepository instance;
//     private String[] pinsArray = new String[0];
//     private long expireAt = 0L;
// 
//     public static SEPreferencesRepository getInstance() {
//         if (instance == null) {
//             instance = new SEPreferencesRepository();
//         }
//         return instance;
//     }
// 
//     private SEPreferencesRepository() {
//         loadStoredValues();
//     }
// 
//     public void updatePinsAndMaxAge(String[] pinsArray, long expireAt) {
//         try {
//             this.pinsArray = pinsArray == null ? new String[0] : pinsArray;
//             this.expireAt = expireAt;
//             SharedPreferences.Editor editor = getPreferences(SaltEdgeSDK.getInstance().getContext()).edit();
//             editor.putLong(KEY_PINS_EXPIRE_AT, this.expireAt);
//             editor.putStringSet(KEY_PINS_SET, new HashSet<>(Arrays.asList(this.pinsArray)));
//             editor.commit();
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public String[] getPins() {
//         return pinsArray;
//     }
// 
//     public long getExpireAt() {
//         return expireAt;
//     }
// 
//     private static SharedPreferences getPreferences(Context context) {
//         return PreferenceManager.getDefaultSharedPreferences(context);
//     }
// 
//     private void loadStoredValues() {
//         try {
//             SharedPreferences preferences = getPreferences(SaltEdgeSDK.getInstance().getContext());
//             Set<String> result = preferences.getStringSet(KEY_PINS_SET, new HashSet<String>());
//             pinsArray = result.toArray(new String[result.size()]);
//             expireAt = preferences.getLong(KEY_PINS_EXPIRE_AT, 0L);
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//     }
// }


import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.saltedge.sdk.network.ExtraJsonDataAdapter;
import com.saltedge.sdk.network.HeaderInterceptor;
import com.saltedge.sdk.preferences.SEPreferencesRepository;
import org.json.JSONObject;
import java.util.Calendar;
/*
Copyright © 2019 Salt Edge. https://saltedge.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package com.saltedge.sdk;





public class TestTools {

    public static Retrofit createMockRetrofit(HttpUrl url) {
        return new Retrofit.Builder()
                .baseUrl(url)
                .client(createTestClient())
                .addConverterFactory(GsonConverterFactory.create(createDefaultGson()))
                .build();
    }

    private static Gson createDefaultGson() {
        return new GsonBuilder()
                .registerTypeAdapter(JSONObject.class, new ExtraJsonDataAdapter())
                .create();
    }

    private static OkHttpClient createTestClient() {
        return new OkHttpClient.Builder()
// Path: saltedge-library/src/main/java/com/saltedge/sdk/network/ExtraJsonDataAdapter.java
// public class ExtraJsonDataAdapter implements JsonDeserializer<JSONObject> {
// 
//     @Override
//     public JSONObject deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
//         return SEJsonTools.stringToJSON(json.getAsJsonObject().toString());
//     }
// }
// 
// Path: saltedge-library/src/main/java/com/saltedge/sdk/network/HeaderInterceptor.java
// public class HeaderInterceptor implements Interceptor {
// 
//     private String acceptType;
// 
//     public HeaderInterceptor(String acceptType) {
//         this.acceptType = acceptType;
//     }
// 
//     @Override
//     public Response intercept(Chain chain) throws IOException {
//         Request.Builder requestBuilder = chain.request().newBuilder()
//                 .header(SEApiConstants.KEY_HEADER_CONTENT_TYPE, SEApiConstants.MIME_TYPE_JSON)
//                 .header(SEApiConstants.KEY_HEADER_APP_ID, SaltEdgeSDK.getInstance().getAppId())
//                 .header(SEApiConstants.KEY_HEADER_APP_SECRET, SaltEdgeSDK.getInstance().getAppSecret());
//         if (acceptType != null) {
//             requestBuilder.header(SEApiConstants.KEY_HEADER_ACCEPT, acceptType);
//         }
//         return chain.proceed(requestBuilder.build());
//     }
// }
// 
// Path: saltedge-library/src/main/java/com/saltedge/sdk/preferences/SEPreferencesRepository.java
// public class SEPreferencesRepository {
// 
//     private static final String KEY_PINS_EXPIRE_AT = "KEY_SE_PINS_EXPIRE_AT";
//     private static final String KEY_PINS_SET = "KEY_SE_PINS_SET";
//     private static SEPreferencesRepository instance;
//     private String[] pinsArray = new String[0];
//     private long expireAt = 0L;
// 
//     public static SEPreferencesRepository getInstance() {
//         if (instance == null) {
//             instance = new SEPreferencesRepository();
//         }
//         return instance;
//     }
// 
//     private SEPreferencesRepository() {
//         loadStoredValues();
//     }
// 
//     public void updatePinsAndMaxAge(String[] pinsArray, long expireAt) {
//         try {
//             this.pinsArray = pinsArray == null ? new String[0] : pinsArray;
//             this.expireAt = expireAt;
//             SharedPreferences.Editor editor = getPreferences(SaltEdgeSDK.getInstance().getContext()).edit();
//             editor.putLong(KEY_PINS_EXPIRE_AT, this.expireAt);
//             editor.putStringSet(KEY_PINS_SET, new HashSet<>(Arrays.asList(this.pinsArray)));
//             editor.commit();
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public String[] getPins() {
//         return pinsArray;
//     }
// 
//     public long getExpireAt() {
//         return expireAt;
//     }
// 
//     private static SharedPreferences getPreferences(Context context) {
//         return PreferenceManager.getDefaultSharedPreferences(context);
//     }
// 
//     private void loadStoredValues() {
//         try {
//             SharedPreferences preferences = getPreferences(SaltEdgeSDK.getInstance().getContext());
//             Set<String> result = preferences.getStringSet(KEY_PINS_SET, new HashSet<String>());
//             pinsArray = result.toArray(new String[result.size()]);
//             expireAt = preferences.getLong(KEY_PINS_EXPIRE_AT, 0L);
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//     }
// }


// Path: saltedge-library/src/androidTest/java/com/saltedge/sdk/TestTools.java
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.saltedge.sdk.network.ExtraJsonDataAdapter;
import com.saltedge.sdk.network.HeaderInterceptor;
import com.saltedge.sdk.preferences.SEPreferencesRepository;
import org.json.JSONObject;
import java.util.Calendar;

/*
Copyright © 2019 Salt Edge. https://saltedge.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package com.saltedge.sdk;





public class TestTools {

    public static Retrofit createMockRetrofit(HttpUrl url) {
        return new Retrofit.Builder()
                .baseUrl(url)
                .client(createTestClient())
                .addConverterFactory(GsonConverterFactory.create(createDefaultGson()))
                .build();
    }

    private static Gson createDefaultGson() {
        return new GsonBuilder()
                .registerTypeAdapter(JSONObject.class, new ExtraJsonDataAdapter())
                .create();
    }

    private static OkHttpClient createTestClient() {
        return new OkHttpClient.Builder()
                .addInterceptor(new HeaderInterceptor("json"))