Skip to content

Commit

Permalink
[Auto Generated] 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jigardafda committed Jan 16, 2024
1 parent ef9f61e commit c1a3dfa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/com/sdk/common/RetrofitServiceFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.net.CookieStore;
import java.security.cert.CertificateException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -78,6 +79,32 @@ public <S> S createService(String baseUrl, Class<S> serviceClass, List<Intercept
return retrofit.create(serviceClass);
}

public <S> S getInstance(String baseUrl, Class<S> serviceClass) {
return getInstance(baseUrl, serviceClass, null);
}

/**
* This method generates retrofit Service call object
*
* @param baseUrl the base url for retrofit
* @param serviceClass the class call object which needs to be returned
* @return the service class call object
*/
public <S> S getInstance(String baseUrl, Class<S> serviceClass, CookieStore cookieStore) {
setApiBaseUrl(baseUrl);
List<Interceptor> interceptorList = new ArrayList<>();
interceptorList.add(new RequestSignerInterceptor());
if (!interceptorList.contains(logging)) {
interceptorList.add(logging);
}
if(!interceptorList.contains(ok2CurlInterceptor)){
interceptorList.add(ok2CurlInterceptor);
}
builder.client(getUnsafeOkHttpClient(interceptorList, cookieStore));
retrofit = builder.build();
return retrofit.create(serviceClass);
}

private static OkHttpClient getUnsafeOkHttpClient(List<Interceptor> interceptorList, CookieStore cookieStore) {
try {
// Create a trust manager that does not validate certificate chains
Expand Down

0 comments on commit c1a3dfa

Please sign in to comment.