use of co.melondev.cubedpay.envelope.APIEnvelopeTransformerConverterFactory in project CubedPay-Java by MelonDevelopment.
the class CubedPayAPI method create.
static CubedPayAPI create(String appID, String accessToken, String apiUrl) {
Dispatcher dispatcher = new Dispatcher();
CubedPayAPI api = new Retrofit.Builder().baseUrl(apiUrl).addConverterFactory(new Converter.Factory() {
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
return super.responseBodyConverter(type, annotations, retrofit);
}
}).addConverterFactory(new APIEnvelopeTransformerConverterFactory(GsonConverterFactory.create())).addCallAdapterFactory(Java8CallAdapterFactory.create()).client(new OkHttpClient.Builder().addInterceptor(chain -> chain.proceed(chain.request().newBuilder().addHeader("app-id", appID).url(chain.request().url().newBuilder().addQueryParameter("access_token", accessToken).build()).build())).dispatcher(dispatcher).build()).build().create(CubedPayAPI.class);
DispatcherMap.dispatcherMap.put(api, dispatcher);
return api;
}
Aggregations