Search in sources :

Example 1 with ChallengeItemFactory

use of com.meniga.sdk.helpers.ChallengeItemFactory in project mobile-sdk-android by meniga.

the class MockClient method getApi.

public static MenigaAPI getApi(Interceptor myInterceptor) {
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(myInterceptor).build();
    final Retrofit retrofit = new Retrofit.Builder().addConverterFactory(new MenigaTransactionsConverter()).addConverterFactory(new MenigaFeedConverter(new MockFeedItemFactory())).addConverterFactory(new MenigaCategoryConverter()).addConverterFactory(new MenigaOfferConverter()).addConverterFactory(new MenigaRedemptionConverter()).addConverterFactory(new MenigaReimbursementAccountConverter()).addConverterFactory(new MenigaIdNameKeyValConverter()).addConverterFactory(new MenigaChallengesConverter(new ChallengeItemFactory())).addConverterFactory(new MenigaFeedItemConverter(new MockFeedItemFactory())).addConverterFactory(new MenigaBaseConverter()).addConverterFactory(GsonConverterFactory.create()).baseUrl("http://meniga.is/api/").client(client).build();
    return retrofit.create(MenigaAPI.class);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MenigaFeedItemConverter(com.meniga.sdk.converters.MenigaFeedItemConverter) MenigaIdNameKeyValConverter(com.meniga.sdk.converters.MenigaIdNameKeyValConverter) MenigaFeedConverter(com.meniga.sdk.converters.MenigaFeedConverter) MenigaTransactionsConverter(com.meniga.sdk.converters.MenigaTransactionsConverter) MenigaReimbursementAccountConverter(com.meniga.sdk.converters.MenigaReimbursementAccountConverter) ChallengeItemFactory(com.meniga.sdk.helpers.ChallengeItemFactory) MockFeedItemFactory(com.meniga.sdk.helpers.MockFeedItemFactory) Retrofit(retrofit2.Retrofit) MenigaChallengesConverter(com.meniga.sdk.converters.MenigaChallengesConverter) MenigaBaseConverter(com.meniga.sdk.converters.MenigaBaseConverter) MenigaOfferConverter(com.meniga.sdk.converters.MenigaOfferConverter) MenigaCategoryConverter(com.meniga.sdk.converters.MenigaCategoryConverter) MenigaRedemptionConverter(com.meniga.sdk.converters.MenigaRedemptionConverter)

Example 2 with ChallengeItemFactory

use of com.meniga.sdk.helpers.ChallengeItemFactory in project mobile-sdk-android by meniga.

the class MenigaChallengesTest method gson.

private List<MenigaChallenge> gson(String file) {
    ChallengeItemFactory factory = new ChallengeItemFactory();
    List<MenigaChallenge> items = new ArrayList<>();
    try {
        JsonArray arr = MenigaConverter.getAsArray(FileImporter.getInputStreamFromRaw(file));
        for (int i = 0; i < arr.size(); i++) {
            JsonObject item = arr.get(i).getAsJsonObject();
            items.add(factory.getMenigaChallengeItem(item));
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return items;
}
Also used : JsonArray(com.google.gson.JsonArray) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) IOException(java.io.IOException) ChallengeItemFactory(com.meniga.sdk.helpers.ChallengeItemFactory)

Aggregations

ChallengeItemFactory (com.meniga.sdk.helpers.ChallengeItemFactory)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 MenigaBaseConverter (com.meniga.sdk.converters.MenigaBaseConverter)1 MenigaCategoryConverter (com.meniga.sdk.converters.MenigaCategoryConverter)1 MenigaChallengesConverter (com.meniga.sdk.converters.MenigaChallengesConverter)1 MenigaFeedConverter (com.meniga.sdk.converters.MenigaFeedConverter)1 MenigaFeedItemConverter (com.meniga.sdk.converters.MenigaFeedItemConverter)1 MenigaIdNameKeyValConverter (com.meniga.sdk.converters.MenigaIdNameKeyValConverter)1 MenigaOfferConverter (com.meniga.sdk.converters.MenigaOfferConverter)1 MenigaRedemptionConverter (com.meniga.sdk.converters.MenigaRedemptionConverter)1 MenigaReimbursementAccountConverter (com.meniga.sdk.converters.MenigaReimbursementAccountConverter)1 MenigaTransactionsConverter (com.meniga.sdk.converters.MenigaTransactionsConverter)1 MockFeedItemFactory (com.meniga.sdk.helpers.MockFeedItemFactory)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 OkHttpClient (okhttp3.OkHttpClient)1 Retrofit (retrofit2.Retrofit)1