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 integrations. EventListeners can only be accessed by administrators or through valid auth tokens. Each AuthToken can only specify one listener per unique eventName.

Properties

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

Methods

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.

API Console
EventListener.list({"status": true, "uid": true}, {"filters":{"/created":{"min":"2015-01-01"}}, "sort": "uid"})
Response
[
  {
    "status": {
      "active": false,
      "inactiveSince": "2015-01-01 00:00T+01:00"
    },
    "uid": 1234
  },
  {
    "status": {
      "active": true
    },
    "uid": 1238
  },
  {
    "status": {
      "active": true
    },
    "uid": 1244
  },
  {
    "status": {
      "active": false,
      "inactiveSince": "2015-11-07 00:00T+01:00"
    },
    "uid": 1254
  }
]

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

API Console
EventListener.get(1234 ["url", "eventName"])
Response
{
  "url": "http://www.example.com",
  "eventName": "Order/changed"
}

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

API Console
EventListener.create(
  {
    "authToken": "XYV0aDpRS4F7bdFom444RO9ygHObnnb/zIOds3iuXFhtoDGbWiUt",
    "eventName": "Order/discarded",
    "url": "http://www.example.com"
  },
  ["uid", "status"]
)
Response
{
  "uid": 1234,
  "status": {
    "active": true
  }
}

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

API Console
EventListener.set(
  1234,
  {
     "status": {
       "active": false
     }
  },
  ["uid", "status"]
)
Response
{
  "uid": 1234,
  "status": {
    "active": false,
    "inactiveSince": "2015-11-17 17:27T+01:00"
  }
}

delete

Removes an existing EventListener.

Parameters

Parameters Description
uid UID of object to delete.

Example

API Console
EventListener.delete(1234)
Response
null

getLog

Fetch the running log of the EventListener.

Parameters

Parameters Description
uid UID of object.

Example

API Console
EventListener.getLog(1234)
Response
[
  {
    "level": "INFO",
    "created": "2015-11-17 21:00T+01:00",
    "message": "Event completed"
  }
]