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

com.taxjar.net.ApiRequest Maven / Gradle / Ivy

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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy