Search in sources :

Example 1 with WebhookPayload

use of org.finos.symphony.webhookbot.domain.WebhookPayload in project spring-bot by finos.

the class ReceiveController method createEntityJson.

public static EntityJson createEntityJson(JsonNode body, ActiveWebHooks active, WebHook webhook) throws JsonProcessingException {
    WebhookPayload payload = new WebhookPayload();
    payload.setContents(body);
    return createEntityJson(active, webhook, payload);
}
Also used : WebhookPayload(org.finos.symphony.webhookbot.domain.WebhookPayload)

Example 2 with WebhookPayload

use of org.finos.symphony.webhookbot.domain.WebhookPayload in project spring-bot by finos.

the class UpdateTemplateConsumer method apply.

@Override
public List<Response> apply(ElementsAction t) {
    if (t.getAction().equals(WebHookOps.TEMPLATE_UPDATE)) {
        try {
            Template template = (Template) t.getFormData();
            EntityJson workflow = t.getData();
            ActiveWebHooks awh = (ActiveWebHooks) workflow.get(EntityJsonConverter.WORKFLOW_001);
            WebHook active = (WebHook) workflow.get(ReceiveController.INVOKED_WEBHOOK);
            WebHook wh = ReceiveController.getHook(awh, active.getHookId().getId());
            wh.setTemplate(template);
            WebhookPayload payload = (WebhookPayload) workflow.get(ReceiveController.PAYLOAD);
            EntityJson out = ReceiveController.createEntityJson(payload.getContents(), awh, wh);
            MessageResponse mr = new MessageResponse(t.getWorkflow(), t.getAddressable(), out, "", "", template.getContents());
            return Collections.singletonList(mr);
        } catch (JsonProcessingException e) {
            return Collections.singletonList(new ErrorResponse(t.getWorkflow(), t.getAddressable(), e.getMessage()));
        }
    } else {
        return Collections.emptyList();
    }
}
Also used : ActiveWebHooks(org.finos.symphony.webhookbot.domain.ActiveWebHooks) EntityJson(org.finos.symphony.toolkit.json.EntityJson) WebhookPayload(org.finos.symphony.webhookbot.domain.WebhookPayload) MessageResponse(org.finos.symphony.toolkit.workflow.response.MessageResponse) WebHook(org.finos.symphony.webhookbot.domain.WebHook) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Template(org.finos.symphony.webhookbot.domain.Template) ErrorResponse(org.finos.symphony.toolkit.workflow.response.ErrorResponse)

Aggregations

WebhookPayload (org.finos.symphony.webhookbot.domain.WebhookPayload)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 EntityJson (org.finos.symphony.toolkit.json.EntityJson)1 ErrorResponse (org.finos.symphony.toolkit.workflow.response.ErrorResponse)1 MessageResponse (org.finos.symphony.toolkit.workflow.response.MessageResponse)1 ActiveWebHooks (org.finos.symphony.webhookbot.domain.ActiveWebHooks)1 Template (org.finos.symphony.webhookbot.domain.Template)1 WebHook (org.finos.symphony.webhookbot.domain.WebHook)1