co.omise.resources.DisputeResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of omise-java Show documentation
Show all versions of omise-java Show documentation
Java bindings for the Omise API
package co.omise.resources;
import co.omise.Endpoint;
import co.omise.models.Dispute;
import co.omise.models.DisputeStatus;
import co.omise.models.ScopedList;
import com.fasterxml.jackson.core.type.TypeReference;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import java.io.IOException;
public class DisputeResource extends Resource {
public DisputeResource(OkHttpClient httpClient) {
super(httpClient);
}
public ScopedList list() throws IOException {
return list(null, new ScopedList.Options());
}
public ScopedList list(ScopedList.Options options) throws IOException {
return list(null, options);
}
public ScopedList list(DisputeStatus status) throws IOException {
return list(status, new ScopedList.Options());
}
public ScopedList list(DisputeStatus status, ScopedList.Options options) throws IOException {
String path = status == null ? "" : status.name().toLowerCase();
return httpGet(urlFor(path)).params(options).returns(new TypeReference>() {
});
}
public Dispute get(String disputeId) throws IOException {
return httpGet(urlFor(disputeId)).returns(Dispute.class);
}
public Dispute update(String disputeId, Dispute.Update params) throws IOException {
return httpPatch(urlFor(disputeId)).params(params).returns(Dispute.class);
}
private HttpUrl urlFor(String disputeId) {
return buildUrl(Endpoint.API, "disputes", disputeId);
}
}