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

br.com.moip.models.Webhooks Maven / Gradle / Ivy

The newest version!
package br.com.moip.models;

import br.com.moip.api.request.RequestMaker;
import br.com.moip.api.request.RequestProperties;
import br.com.moip.api.request.RequestPropertiesBuilder;
import org.apache.http.entity.ContentType;

import java.util.Map;

public class Webhooks {

    private static final String ENDPOINT = "/v2/webhooks";
    private static final ContentType CONTENT_TYPE = ContentType.APPLICATION_JSON;
    private RequestMaker requestMaker;

    /**
     * This method is used to get the data of a specific webhook sent from Moip by Moip
     * resource external ID.
     *
     * @param   resourceId
     *          {@code String} the Moip external ID of a resource (Orders, Payments, Refunds...).
     *
     * @param   setup
     *          {@code Setup} the setup object.
     *
     * @return  {@code Map}
     */
    public Map get(String resourceId, Setup setup) {
        this.requestMaker = new RequestMaker(setup);
        RequestProperties props = new RequestPropertiesBuilder()
                .method("GET")
                .endpoint(ENDPOINT + String.format("?resourceId=%s", resourceId))
                .type(Webhooks.class)
                .contentType(CONTENT_TYPE)
                .build();

        return this.requestMaker.doRequest(props);
    }

    /**
     * This method is used to get all sent webhooks.
     *
     * @param   setup
     *          {@code Setup} the setup object.
     *
     * @return  {@code Map}
     */
    public Map list(Setup setup) {
        this.requestMaker = new RequestMaker(setup);
        RequestProperties props = new RequestPropertiesBuilder()
                .method("GET")
                .endpoint(ENDPOINT)
                .type(Webhooks.class)
                .contentType(CONTENT_TYPE)
                .build();

        return this.requestMaker.doRequest(props);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy