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

com.easypost.model.Webhook Maven / Gradle / Ivy

There is a newer version: 5.5.0
Show newest version
package com.easypost.model;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.easypost.exception.EasyPostException;
import com.easypost.net.EasyPostResource;

public class Webhook extends EasyPostResource {
    public String id;
    String mode;
    String url;
    Date disabledAt;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }

    public String getMode() {
        return mode;
    }
    public void setMode(String mode) {
        this.mode = mode;
    }

    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }

    public Date getDisabledAt() {
        return disabledAt;
    }
    public void setDisabledAt(Date disabledAt) {
        this.disabledAt = disabledAt;
    }

    // create
    public static Webhook create(Map params) throws EasyPostException {
        return create(params, null);
    }
    public static Webhook create(Map params, String apiKey) throws EasyPostException {
        Map wrappedParams = new HashMap();
        wrappedParams.put("webhook", params);

        return request(RequestMethod.POST, classURL(Webhook.class), wrappedParams, Webhook.class, apiKey);
    }

    // retrieve
    public static Webhook retrieve(String id) throws EasyPostException {
        return retrieve(id, null);
    }
    public static Webhook retrieve(String id, String apiKey) throws EasyPostException {
        return request(RequestMethod.GET, instanceURL(Webhook.class, id), null, Webhook.class, apiKey);
    }

    // all
    public static WebhookCollection all() throws EasyPostException {
        Map params = new HashMap();
        return all(params, null);
    }
    public static WebhookCollection all(Map params) throws EasyPostException {
        return all(params, null);
    }
    public static WebhookCollection all(Map params, String apiKey) throws EasyPostException {
        return request(RequestMethod.GET, classURL(Webhook.class), params, WebhookCollection.class, apiKey);
    }

    // delete
    public void delete() throws EasyPostException {
        this.delete(null);
    }
    public void delete(String apiKey) throws EasyPostException {
        request(RequestMethod.DELETE, instanceURL(Webhook.class, this.getId()), null, Webhook.class, apiKey);
    }

    // update
    public Webhook update() throws EasyPostException {
        Map params = new HashMap();
        return this.update(params, null);
    }
    public Webhook update(Map params) throws EasyPostException {
        return this.update(params, null);
    }
    public Webhook update(Map params, String apiKey) throws EasyPostException {
        Map wrappedParams = new HashMap();
        wrappedParams.put("webhook", params);

        Webhook response = request(RequestMethod.PUT, instanceURL(Webhook.class, this.getId()), wrappedParams, Webhook.class, apiKey);

        this.merge(this, response);
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy