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

co.omise.resources.DisputeResource Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy