function confirmSubscription()

in serverless-workflow-examples/serverless-workflow-newsletter-subscription/subscription-flow/src/main/resources/META-INF/resources/app.js [104:136]


function confirmSubscription(subscriptionId, subscriptionEmail) {
    const cloudEventJson = {
        specversion: "1.0",
        id: createUUID(),
        source: "webApp",
        type: "confirm.subscription",
        kogitoprocrefid: subscriptionId,
        datacontenttype: "application/json",
        data: {
            id: subscriptionId,
            confirmed: true
        }
    }
    const ceInput = JSON.stringify(cloudEventJson);
    showSpinnerDialog("Confirming subscription: " + subscriptionId + ", " + subscriptionEmail);
    $.ajax({
        url: "/",
        type: "POST",
        dataType: "text",
        contentType: "application/cloudevents+json; charset=UTF-8",
        data: ceInput,
        success: function (result) {
            console.log(result);
            closeSpinnerDialog();
            // TODO: ideally, we have a websocket listening for the new subscription event, then we update the table
            setTimeout(refreshSubsTable, 2000);
        },
    }).fail(function (xhr, status, error) {
        closeSpinnerDialog();
        console.log(error);
        showError("An error '" + xhr.responseText + "' (status: " + status + ") was produced during the serverless workflow instance create attempt, please check that que subscription-flow application is running.");
    });
}