jp.gopay.sdk.builders.RetrofitRequestBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gopay-java-sdk Show documentation
Show all versions of gopay-java-sdk Show documentation
Official Gyro-n Payments Java SDK
package jp.gopay.sdk.builders;
import jp.gopay.sdk.models.response.GoPayResponse;
import retrofit2.Call;
import retrofit2.Retrofit;
import java.lang.reflect.ParameterizedType;
public abstract class RetrofitRequestBuilder
implements RequestBuilder> {
private Class resourceClass;
private Retrofit retrofit;
public RetrofitRequestBuilder(Retrofit retrofit) {
this.retrofit = retrofit;
this.resourceClass = (Class) ((ParameterizedType) getClass()
.getGenericSuperclass()).getActualTypeArguments()[1];
}
Call createCall() {
R resource = retrofit.create(resourceClass);
return getRequest(resource);
}
protected abstract Call getRequest(R resource);
@Override
public Request build() {
return new RetrofitRequestCaller<>(retrofit, createCall());
}
}