Skip to content

Latest commit

 

History

History
448 lines (320 loc) · 15.2 KB

File metadata and controls

448 lines (320 loc) · 15.2 KB

Webhooks

Overview

Available Operations

  • listEventTypes - List all available event types that can be subscribed to.
  • list - List all webhooks configured for the account.
  • create - Create a new webhook for the account.
  • get - Get details of a specific webhook.
  • update - Update an existing webhook.
  • disable - Disable a webhook. Disabled webhooks will no longer receive events.
  • ping - Send a test ping to a webhook to verify it is configured correctly.
  • getSecret - Get the secret key for verifying webhook payloads.

listEventTypes

List all available event types that can be subscribed to.

Example Usage

package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.Security;
import io.moov.sdk.models.operations.ListEventTypesResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        ListEventTypesResponse res = sdk.webhooks().listEventTypes()
                .call();

        if (res.eventTypes().isPresent()) {
            System.out.println(res.eventTypes().get());
        }
    }
}

Response

ListEventTypesResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

list

List all webhooks configured for the account.

Example Usage

package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.Security;
import io.moov.sdk.models.operations.ListWebhooksResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        ListWebhooksResponse res = sdk.webhooks().list()
                .call();

        if (res.webhooks().isPresent()) {
            System.out.println(res.webhooks().get());
        }
    }
}

Response

ListWebhooksResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

create

Create a new webhook for the account.

Example Usage

package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.*;
import io.moov.sdk.models.errors.CreateWebhookValidationError;
import io.moov.sdk.models.errors.GenericError;
import io.moov.sdk.models.operations.CreateWebhookResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws GenericError, CreateWebhookValidationError, Exception {

        Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        CreateWebhook req = CreateWebhook.builder()
                .url("https://experienced-sailor.biz/")
                .status(WebhookStatus.DISABLED)
                .eventTypes(List.of())
                .description("overdue bonnet failing")
                .build();

        CreateWebhookResponse res = sdk.webhooks().create()
                .request(req)
                .call();

        if (res.webhook().isPresent()) {
            System.out.println(res.webhook().get());
        }
    }
}

Parameters

Parameter Type Required Description
request CreateWebhook ✔️ The request object to use for the request.

Response

CreateWebhookResponse

Errors

Error Type Status Code Content Type
models/errors/GenericError 400, 409 application/json
models/errors/CreateWebhookValidationError 422 application/json
models/errors/APIException 4XX, 5XX */*

get

Get details of a specific webhook.

Example Usage

package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.Security;
import io.moov.sdk.models.operations.GetWebhookResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        GetWebhookResponse res = sdk.webhooks().get()
                .webhookID("deeb5a05-74d4-40ad-b4be-a9265fd49428")
                .call();

        if (res.webhook().isPresent()) {
            System.out.println(res.webhook().get());
        }
    }
}

Parameters

Parameter Type Required Description
webhookID String ✔️ N/A

Response

GetWebhookResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

update

Update an existing webhook.

Example Usage

package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.*;
import io.moov.sdk.models.errors.GenericError;
import io.moov.sdk.models.errors.UpdateWebhookValidationError;
import io.moov.sdk.models.operations.UpdateWebhookResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws GenericError, UpdateWebhookValidationError, Exception {

        Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        UpdateWebhookResponse res = sdk.webhooks().update()
                .webhookID("954b566e-0c37-481b-bf92-6cdbd0e47dc0")
                .updateWebhook(UpdateWebhook.builder()
                    .url("https://nimble-affect.name")
                    .status(WebhookStatus.ENABLED)
                    .eventTypes(List.of())
                    .description("hmph eyeglasses pink stylish blah")
                    .build())
                .call();

        if (res.webhook().isPresent()) {
            System.out.println(res.webhook().get());
        }
    }
}

Parameters

Parameter Type Required Description
webhookID String ✔️ N/A
updateWebhook UpdateWebhook ✔️ N/A

Response

UpdateWebhookResponse

Errors

Error Type Status Code Content Type
models/errors/GenericError 400, 409 application/json
models/errors/UpdateWebhookValidationError 422 application/json
models/errors/APIException 4XX, 5XX */*

disable

Disable a webhook. Disabled webhooks will no longer receive events.

Example Usage

package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.Security;
import io.moov.sdk.models.errors.GenericError;
import io.moov.sdk.models.operations.DisableWebhookResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws GenericError, Exception {

        Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        DisableWebhookResponse res = sdk.webhooks().disable()
                .webhookID("c88929b3-cbb6-4144-923f-e9a5ba645708")
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description
webhookID String ✔️ N/A

Response

DisableWebhookResponse

Errors

Error Type Status Code Content Type
models/errors/GenericError 400, 409 application/json
models/errors/APIException 4XX, 5XX */*

ping

Send a test ping to a webhook to verify it is configured correctly.

Example Usage

package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.Security;
import io.moov.sdk.models.operations.PingWebhookResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        PingWebhookResponse res = sdk.webhooks().ping()
                .webhookID("87e0ecc6-d6c3-4eeb-99e8-6dbe9212a6a2")
                .call();

        if (res.pingResponse().isPresent()) {
            System.out.println(res.pingResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
webhookID String ✔️ N/A

Response

PingWebhookResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

getSecret

Get the secret key for verifying webhook payloads.

Example Usage

package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.Security;
import io.moov.sdk.models.operations.GetWebhookSecretResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        GetWebhookSecretResponse res = sdk.webhooks().getSecret()
                .webhookID("1fac81d6-2d5b-4180-8765-81282a450eda")
                .call();

        if (res.webhookSecret().isPresent()) {
            System.out.println(res.webhookSecret().get());
        }
    }
}

Parameters

Parameter Type Required Description
webhookID String ✔️ N/A

Response

GetWebhookSecretResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*