Class Webhook
java.lang.Object
com.erudika.para.core.Sysprop
com.erudika.para.core.Webhook
- All Implemented Interfaces:
Linkable, ParaObject, Votable, Serializable
Represents a webhook registration.
- Author:
- Alex Bogdanovski [[email protected]]
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Votable
Votable.VoteValue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildPayloadAsJSON(String event, Object payload) Builds the JSON payload object.create()Creates the webhook.Returns true if the webhook is active.Returns true if subscribed to create events.Returns true if subscribed to create all events.Returns the list of custom events.Returns the custom payload.Returns true if subscribed to delete events.Returns true if subscribed to delete all events.Returns the property filter.Returns the number of repeated delivery attempts.Returns the webhook secret key.Returns the target URL.Returns true if the webhook has too many failures.Returns the triggered event name.Returns the type filter.Returns true if subscribed to update events.Returns true if subscribed to update all events.Returns true if the payload should be URL encoded.static booleanpropertyFilterMatches(Webhook webhook, Object payload) Matches a property filter against a payload.voidResets the secret key by generating a new one.static voidsendEventPayloadToQueue(String appid, String eventName, Object eventValue, Object payload) Sends out the payload object for an event to the queue for processing.voidSets the active flag.voidSets the create flag.voidsetCreateAll(Boolean createAll) Sets the create all flag.voidsetCustomEvents(List<String> customEvents) Sets the list of custom events.voidsetCustomPayload(Object customPayload) Sets the custom payload.voidSets the delete flag.voidsetDeleteAll(Boolean deleteAll) Sets the delete all flag.voidsetPropertyFilter(String propertyFilter) Sets the property filter.voidsetRepeatedDeliveryAttempts(Integer repeatedDeliveryAttempts) Sets the number of repeated delivery attempts.voidSets the webhook secret key.voidsetTargetUrl(String targetUrl) Sets the target URL.voidsetTooManyFailures(Boolean tooManyFailures) Sets the too many failures flag.voidsetTriggeredEvent(String triggeredEvent) Sets the triggered event name.voidsetTypeFilter(String typeFilter) Sets the type filter.voidSets the update flag.voidsetUpdateAll(Boolean updateAll) Sets the update all flag.voidsetUrlEncoded(Boolean urlEncoded) Sets the URL encoded flag.voidupdate()Updates the webhook.Methods inherited from class Sysprop
addProperty, countChildren, countLinks, delete, deleteChildren, equals, exists, findChildren, findLinkedObjects, getAppid, getCached, getChildren, getChildren, getCreatorid, getId, getIndexed, getLinkedObjects, getLinks, getName, getObjectURI, getParentid, getPlural, getProperties, getProperty, getStored, getTags, getTimestamp, getType, getUpdated, getVersion, getVotes, hashCode, hasProperty, isLinked, isLinked, link, removeProperty, setAppid, setCached, setCreatorid, setId, setIndexed, setName, setParentid, setProperties, setStored, setTags, setTimestamp, setType, setUpdated, setVersion, setVotes, toString, unlink, unlinkAll, voteDown, voteUp
-
Constructor Details
-
Webhook
public Webhook()No-args constructor. -
Webhook
Default constructor.- Parameters:
targetUrl- the URL where the payload will be sent
-
-
Method Details
-
getTargetUrl
-
setTargetUrl
Sets the target URL.- Parameters:
targetUrl- target URL value
-
getSecret
-
setSecret
Sets the webhook secret key.- Parameters:
secret- webhook secret key
-
getTypeFilter
-
setTypeFilter
Sets the type filter.- Parameters:
typeFilter- type filter
-
getPropertyFilter
-
setPropertyFilter
Sets the property filter.- Parameters:
propertyFilter- property filter
-
getUrlEncoded
Returns true if the payload should be URL encoded.- Returns:
- if false, JSON is returned, otherwise x-www-form-urlencoded
-
setUrlEncoded
Sets the URL encoded flag.- Parameters:
urlEncoded- false for JSON payloads
-
getActive
Returns true if the webhook is active.- Returns:
- if false, nothing is sent to
targetUrl.
-
setActive
Sets the active flag.- Parameters:
active- if false, nothing is sent totargetUrl.
-
getTooManyFailures
Returns true if the webhook has too many failures.- Returns:
- true if this was disabled by the system
-
setTooManyFailures
Sets the too many failures flag.- Parameters:
tooManyFailures- don't set this manually
-
getCreate
Returns true if subscribed to create events.- Returns:
- true if subscribed to DAO.create() methods
-
setCreate
Sets the create flag.- Parameters:
create- set to true to subscribe to create methods
-
getUpdate
Returns true if subscribed to update events.- Returns:
- true if subscribed to DAO.update() methods
-
setUpdate
Sets the update flag.- Parameters:
update- set to true to subscribe to update methods
-
getDelete
Returns true if subscribed to delete events.- Returns:
- true if subscribed to DAO.delete() methods
-
setDelete
Sets the delete flag.- Parameters:
delete- set to true to subscribe to delete methods
-
getCreateAll
Returns true if subscribed to create all events.- Returns:
- true if subscribed to DAO.createAll() methods
-
setCreateAll
Sets the create all flag.- Parameters:
createAll- set to true to subscribe to createAll methods
-
getUpdateAll
Returns true if subscribed to update all events.- Returns:
- true if subscribed to DAO.updateAll() methods
-
setUpdateAll
Sets the update all flag.- Parameters:
updateAll- set to true to subscribe to updateAll methods
-
getDeleteAll
Returns true if subscribed to delete all events.- Returns:
- true if subscribed to DAO.deleteAll() methods
-
setDeleteAll
Sets the delete all flag.- Parameters:
deleteAll- set to true to subscribe to deleteAll methods
-
getCustomEvents
-
setCustomEvents
-
getTriggeredEvent
Returns the triggered event name.- Returns:
- the name of the custom event to be triggered
-
setTriggeredEvent
Sets the triggered event name.- Parameters:
triggeredEvent- custom event name
-
getCustomPayload
-
setCustomPayload
Sets the custom payload.- Parameters:
customPayload- set the custom payload object which will be sent when a custom event is triggered
-
getRepeatedDeliveryAttempts
Returns the number of repeated delivery attempts.- Returns:
- the number of times to deliver the same payload to target.
-
setRepeatedDeliveryAttempts
Sets the number of repeated delivery attempts.- 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()Updates the webhook.- Specified by:
updatein interfaceParaObject- Overrides:
updatein classSysprop- See Also:
-
create
Creates the webhook.- Specified by:
createin interfaceParaObject- Overrides:
createin classSysprop- Returns:
- the id of the created webhook
- See Also:
-
buildPayloadAsJSON
-
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- appideventName- event name like "create", "delete" or "customEvents"eventValue- event value - for custom events this is the name of the custom eventpayload- the payload
-
propertyFilterMatches
-