# EventListener

An object representing an callback that should be made for certain events for a specific auth token, and thereby webshop. This is to push notifications of changes to external systems to avoid the need of polling our API about updates. EventListeners can only be accessed by administrators or through valid auth tokens. Each AuthToken can only specify one listener per unique eventName.

# Properties

Property Type Description
uid integer The unique identifier for the object.
created string Date and time of object creation.
changed string Date and time of last update to the object.
status Status Information about if the object is active and, if not, when it was inactivated.
eventName string The event that will trigger calling the specified URL.
url string The URL called on specified event trigger.
authToken string The AuthToken associated with the eventName and URL combination.

# Status

Property Type Description
inactiveSince string The date and time when the event was last inactivated.
active boolean If the EventListener is active.

# Methods

# create

Creates a new EventListener.

# Parameters

Parameters Description
patch An object containing the properties and values to set.
query A query specifying what to return after object creation has been successful (optional). See Query language.

# Example

EventListener.create({
  "authToken": "XYV0aDpRS4F7bdFom444RO9ygHObnnb/zIOds3iuXFhtoDGbWiUt",
  "eventName": "Order/discarded",
  "url": "https://www.example.com"
}, [
  "uid",
  "status"
])

# delete

Removes an existing EventListener.

# Parameters

Parameters Description
uid UID of object to delete.

# Example

EventListener.delete(1234)

# get

Fetches information about a specific EventListener.

# Parameters

Parameters Description
uid The unique identifier of an eventlistener.
query Which info to return. See Query language.

# Example

EventListener.get(1234, [
  "url",
  "eventName"
])

# getLog

Fetch the running log of the EventListener.

# Parameters

Parameters Description
uid UID of object.

# Example

EventListener.getLog(1234)

# getSchema

Fetches the JSON Schema which can be used for client-side validation.

# Parameters

The unique identifier of an event listener or null for a new instance.

# list

Fetches all accessible EventListeners for given webshop or AuthToken.

# Parameters

Parameter Description
query Which info to return. See Query language.
selection Which integrations to list. See List selection.

# Example

The request below returns the settings URL, type and unique identifier of all the integrations created since 1 January 2015, sorted by type.

EventListener.list([
  "status",
  "uid"
], {
  "filters": {
    "/created": {
      "min": "2015-01-01"
    }
  },
  "sort": "uid"
})

# set

Updates an existing EventListener.

# Parameters

Parameters Description
uid UID of object to change.
patch An object containing the properties and values to set.
query A query specifying what to return after object creation has been successful (optional). See Query language.

# Example

EventListener.set(1234, {
  "status": {
    "active": false
  }
}, [
  "uid",
  "status"
])