- 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 [alex@erudika.com]
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.erudika.para.core.Votable
Votable.VoteValue
-
-
Method Summary
-
Methods inherited from class com.erudika.para.core.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 Detail
-
Webhook
public Webhook()
No-args constructor.
-
Webhook
public Webhook(String targetUrl)
Default constructor.- Parameters:
targetUrl- the URL where the payload will be sent
-
-
Method Detail
-
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 totargetUrl.
-
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
-
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:ParaObjectUpdates the object permanently. Changes toLockedfields are ignored.- Specified by:
updatein interfaceParaObject- Overrides:
updatein classSysprop- See Also:
Locked,DAO.update(com.erudika.para.core.ParaObject)
-
create
public String create()
Description copied from interface:ParaObjectStores this object in the data store.- Specified by:
createin interfaceParaObject- Overrides:
createin classSysprop- Returns:
- the id of the object (a new id if object is new)
- See Also:
Stored,DAO.create(com.erudika.para.core.ParaObject)
-
buildPayloadAsJSON
public String buildPayloadAsJSON(String event, Object payload)
Builds the JSON payload object.- Parameters:
event- Para.DAO method name or custom event namepayload- 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- appideventName- event name like "create", "delete" or "customEvents"eventValue- event value - for custom events this is the name of the custom eventpayload- the payload
-
-