Base Webhook Object¶
-
class
jook.models.webhooks.
BaseWebhook
(url, event, webhook_id=1, webhook_name='Webhook', mode='json', randomize=False, timer=0, *args, **kwargs)[source]¶ The base webhook object.
Contains all shared methods used by child objects.
Parameters: - url (str) – The target URL (must contain the scheme)
- event (str) – The type of webhook event. The available event types
are defined in the
valid_event
attribute for the object. - mode (str) –
The type of data to send when calling
fire()
.Can only be ‘json’ or ‘xml’
- randomize (bool) –
Values for the webhook object’s
data
are randomly generated every time when set toTrue
.If
False
certain values are generated during the object’s creation and stored. These values will be the same each timefire()
is called.If
True
those values will be set toNone
and generated at the timefire()
is called. - timer (int) – An optional value in seconds to specify the delay when
using
start_timer()
. - webhook_id (int) – An optional ID value for the webhook event.
- webhook_name (str) – An optional name for the webhook event.
Raises: - InvalidEvent –
- InvalidMode –
- InvalidURL –
- TypeError –
-
data
¶ This method generates the object data in JSON or XML format which is set by the
data_type
attributes.This method should be overridden by children that inherit this object.
The
data
object contains the event specific key-values. It is then updated with the key-values from_base_data
.
-
fire
()[source]¶ Send a POST request containing the object’s data in the specified data type to the stored URL.