Class Webhook

java.lang.Object
com.erudika.para.core.Sysprop
com.erudika.para.core.Webhook
All Implemented Interfaces:
Linkable, ParaObject, Votable, Serializable

public class Webhook extends Sysprop
Represents a webhook registration.
Author:
Alex Bogdanovski [[email protected]]
See Also:
  • Constructor Details

    • Webhook

      public Webhook()
      No-args constructor.
    • Webhook

      public Webhook(String targetUrl)
      Default constructor.
      Parameters:
      targetUrl - the URL where the payload will be sent
  • Method Details

    • getTargetUrl

      public String getTargetUrl()
      Returns:
      the target URL
    • setTargetUrl

      public void setTargetUrl(String targetUrl)
      Parameters:
      targetUrl - target URL value
    • getSecret

      public String getSecret()
      Returns:
      the webhook secret key
    • setSecret

      public void setSecret(String secret)
      Parameters:
      secret - webhook secret key
    • getTypeFilter

      public String getTypeFilter()
      Returns:
      type filter
    • setTypeFilter

      public void setTypeFilter(String typeFilter)
      Parameters:
      typeFilter - type filter
    • getUrlEncoded

      public Boolean getUrlEncoded()
      Returns:
      if false, JSON is returned, otherwise x-www-form-urlencoded
    • setUrlEncoded

      public void setUrlEncoded(Boolean urlEncoded)
      Parameters:
      urlEncoded - false for JSON payloads
    • getActive

      public Boolean getActive()
      Returns:
      if false, nothing is sent to targetUrl.
    • setActive

      public void setActive(Boolean active)
      Parameters:
      active - if false, nothing is sent to targetUrl.
    • getTooManyFailures

      public Boolean getTooManyFailures()
      Returns:
      true if this was disabled by the system
    • setTooManyFailures

      public void setTooManyFailures(Boolean tooManyFailures)
      Parameters:
      tooManyFailures - don't set this manually
    • getCreate

      public Boolean getCreate()
      Returns:
      true if subscribed to DAO.create() methods
    • setCreate

      public void setCreate(Boolean create)
      Parameters:
      create - set to true to subscribe to create methods
    • getUpdate

      public Boolean getUpdate()
      Returns:
      true if subscribed to DAO.update() methods
    • setUpdate

      public void setUpdate(Boolean update)
      Parameters:
      update - set to true to subscribe to update methods
    • getDelete

      public Boolean getDelete()
      Returns:
      true if subscribed to DAO.delete() methods
    • setDelete

      public void setDelete(Boolean delete)
      Parameters:
      delete - set to true to subscribe to delete methods
    • getCreateAll

      public Boolean getCreateAll()
      Returns:
      true if subscribed to DAO.createAll() methods
    • setCreateAll

      public void setCreateAll(Boolean createAll)
      Parameters:
      createAll - set to true to subscribe to createAll methods
    • getUpdateAll

      public Boolean getUpdateAll()
      Returns:
      true if subscribed to DAO.updateAll() methods
    • setUpdateAll

      public void setUpdateAll(Boolean updateAll)
      Parameters:
      updateAll - set to true to subscribe to updateAll methods
    • getDeleteAll

      public Boolean getDeleteAll()
      Returns:
      true if subscribed to DAO.deleteAll() methods
    • setDeleteAll

      public void setDeleteAll(Boolean deleteAll)
      Parameters:
      deleteAll - set to true to subscribe to deleteAll methods
    • getCustomEvents

      public List<String> getCustomEvents()
      Returns:
      the name of the custom event
    • setCustomEvents

      public void setCustomEvents(List<String> customEvents)
      Parameters:
      customEvents - set the name of the custom event
    • getTriggeredEvent

      public String getTriggeredEvent()
      Returns:
      the name of the custom event to be triggered
    • setTriggeredEvent

      public void setTriggeredEvent(String triggeredEvent)
      Parameters:
      triggeredEvent - custom event name
    • getCustomPayload

      public Object getCustomPayload()
      Returns:
      the custom payload object
    • setCustomPayload

      public void setCustomPayload(Object customPayload)
      Parameters:
      customPayload - set the custom payload object which will be sent when a custom event is triggered
    • getRepeatedDeliveryAttempts

      public Integer getRepeatedDeliveryAttempts()
      Returns:
      the number of times to deliver the same payload to target.
    • setRepeatedDeliveryAttempts

      public void setRepeatedDeliveryAttempts(Integer repeatedDeliveryAttempts)
      Parameters:
      repeatedDeliveryAttempts - the number of times to deliver the same payload to target.
    • resetSecret

      public void resetSecret()
      Resets the secret key by generating a new one.
    • update

      public void update()
      Description copied from interface: ParaObject
      Updates the object permanently. Changes to Locked fields are ignored.
      Specified by:
      update in interface ParaObject
      Overrides:
      update in class Sysprop
      See Also:
    • create

      public String create()
      Description copied from interface: ParaObject
      Stores this object in the data store.
      Specified by:
      create in interface ParaObject
      Overrides:
      create in class Sysprop
      Returns:
      the id of the object (a new id if object is new)
      See Also:
    • buildPayloadAsJSON

      public String buildPayloadAsJSON(String event, Object payload)
      Builds the JSON payload object.
      Parameters:
      event - Para.DAO method name or custom event name
      payload - payload object to convert to JSON
      Returns:
      the payload + metadata object as JSON string
    • sendEventPayloadToQueue

      public static void sendEventPayloadToQueue(String appid, String eventName, Object eventValue, Object payload)
      Sends out the payload object for an event to the queue for processing.
      Parameters:
      appid - appid
      eventName - event name like "create", "delete" or "customEvents"
      eventValue - event value - for custom events this is the name of the custom event
      payload - the payload