Search in sources :

Example 1 with JSONAPIConverterFactory

use of com.github.jasminb.jsonapi.retrofit.JSONAPIConverterFactory in project open-event-android by fossasia.

the class APIClient method getOpenEventAPI.

public static OpenEventAPI getOpenEventAPI() {
    if (openEventAPI == null) {
        OkHttpClient okHttpClient = okHttpClientBuilder.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC)).authenticator(AuthUtil.getAuthenticator()).build();
        ObjectMapper objectMapper = getObjectMapper();
        Class[] classes = { Event.class, Track.class, Speaker.class, Sponsor.class, Session.class, Microlocation.class, User.class, FAQ.class, Notification.class, DiscountCode.class };
        openEventAPI = new Retrofit.Builder().client(okHttpClient).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).addConverterFactory(new JSONAPIConverterFactory(objectMapper, classes)).addConverterFactory(JacksonConverterFactory.create(getObjectMapper())).baseUrl(Urls.BASE_URL).build().create(OpenEventAPI.class);
    }
    return openEventAPI;
}
Also used : OkHttpClient(okhttp3.OkHttpClient) JSONAPIConverterFactory(com.github.jasminb.jsonapi.retrofit.JSONAPIConverterFactory) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JSONAPIConverterFactory (com.github.jasminb.jsonapi.retrofit.JSONAPIConverterFactory)1 OkHttpClient (okhttp3.OkHttpClient)1 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)1