nti.webhooks.dialect

Implementations of dialects.

class nti.webhooks.dialect.DefaultWebhookDialect[source]

Bases: object

Default implementation of a nti.webhooks.interfaces.IWebhookDialect.

This class is intended to be subclassed; other dialect implementations should extend this class. This permits freedom in adding additional methods to the interface.

externalizeData(data, event)[source]

See nti.webhooks.interfaces.IWebhookDialect.externalizeData()

prepareRequest(http_session, subscription, attempt)[source]

See nti.webhooks.interfaces.IWebhookDialect.prepareRequest()

produce_payload(data, event) → IWebhookPayload[source]

Non-interface method. Given data delivered through an event, try to find a IWebhookPayload for it. From highest to lowest priority, this means:

  • A multi-adapter from the object and the event named externalizer_name.
  • The unnamed multi-adapter.
  • A single adapter from the object named externalizer_name
  • The unnamed single adapter.

The data is used as the context for the lookup in all cases. XXX: Or maybe we should use the subscription as the context?

Note that if there exists an adapter registration that returns None, we continue with lower-priority adapters.

content_type = 'application/json'

The MIME type of the body produced by externalizeData(). If you change the externalizer_format, you need to change this value.

externalizer_format = 'json'

Which representation to use. Passed to nti.externaliaztion.to_external_representation()

externalizer_name = 'webhook-delivery'

The name of the externalizer used to produce the external form. This is also the highest-priority name of the adapter used.

externalizer_policy_name = 'webhook-delivery'

The name of the externalization policy utility used to produce the external form. This defaults to one that uses ISO8601 format for Unix timestamps.

http_method = 'POST'

The HTTP method (verb) to use.

user_agent = 'nti.webhooks 0.0.6.dev0'

The HTTP “User-Agent” header.