All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jp.gopay.sdk.builders.RetrofitRequestBuilder Maven / Gradle / Ivy

There is a newer version: 0.11.17
Show newest version
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());
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy