Webhook

Webhook

Source:
Webhook instances

Type Definitions

WebhookCollection

Source:
Properties:
Name Type Description
total number
skip number
limit number
items Array.<Webhook.Webhook>
toPlainObject() function Returns this Webhook collection as a plain JS object

Methods

(static) delete() → {Promise}

Source:
Deletes this object on the server.
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.getSpace('<space_id>')
.then((space) => space.getWebhook('<webhook_id>'))
.then((webhook) => webhook.delete())
.then((webhook) => console.log(`webhook ${webhook.sys.id} updated.`))
.catch(console.error)
Returns:
Promise for the deletion. It contains no data, but the Promise error case should be handled.
Type
Promise

(static) getCalls() → {Promise.<object>}

Source:
List of the most recent webhook calls. See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-call-overviews for more details.
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.getSpace('<space_id>')
.then((space) => space.getWebhook('<webhook_id>'))
.then((webhook) => webhook.getCalls())
.then((response) => console.log(response.items)) // webhook calls
.catch(console.error)
Returns:
Promise for list of calls
Type
Promise.<object>

(static) getCalls() → {Promise.<object>}

Source:
Webhook call with specific id. See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-call-overviews for more details
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.getSpace('<space_id>')
.then((space) => space.getWebhook('<webhook_id>'))
.then((webhook) => webhook.getCall(<call-id>))
.then((webhookCall) => console.log(webhookCall))
.catch(console.error)
Returns:
Promise for call details
Type
Promise.<object>

(static) getHealth() → {Promise.<object>}

Source:
Overview of the health of webhook calls. See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-call-overviews for more details.
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.getSpace('<space_id>')
.then((space) => space.getWebhook('<webhook_id>'))
.then((webhook) => webhook.getHealth())
.then((webhookHealth) => console.log(webhookHealth))
.catch(console.error)
Returns:
Promise for health info
Type
Promise.<object>

(static) update() → {Promise.<Webhook>}

Source:
Sends an update to the server with any changes made to the object's properties
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.getSpace('<space_id>')
.then((space) => space.getWebhook('<webhook_id>'))
.then((webhook) => {
 webhook.name = 'new webhook name'
 return webhook.update()
})
.then((webhook) => console.log(`webhook ${webhook.sys.id} updated.`))
.catch(console.error)
Returns:
Object returned from the server with updated changes.
Type
Promise.<Webhook>