com.taxjar.net.ApiRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of taxjar-java Show documentation
Show all versions of taxjar-java Show documentation
TaxJar Java Sales Tax API Client
The newest version!
package com.taxjar.net;
import com.taxjar.exception.ApiConnectionException;
import com.taxjar.exception.TaxjarException;
import retrofit2.Call;
import retrofit2.Response;
import java.io.IOException;
public class ApiRequest {
protected Call apiCall;
public ApiRequest(Call call) {
apiCall = call;
}
public T execute() throws TaxjarException {
try {
Response response = apiCall.execute();
if (response.isSuccessful()) {
return response.body();
} else {
throw new TaxjarException(response.errorBody().string(), response.code());
}
} catch (IOException e) {
throw new ApiConnectionException(e.getMessage(), e);
}
}
}