Skip to main content

Handlers

A handler is invoked whenever a request is made to its associated path. A handler can take multiple shapes depending on desired operation. In general, it accepts a context object, and must return an API response.

Types

HandlersInput

Type used as input on a addHandler function call. Its shape changes depending on which type of handler you are adding.

type HandlersInput = {
getItem?: GetItemHandler;
getCollection?: GetCollectionHandler;
createItem?: CreateItemHandler;
updateItem?: UpdateItemHandler;
deleteItem?: DeleteItemHandler;
}
| { getCredentialAccount: GetCredentialAccountHandler; }
| { parseWebhooks: ParseWebhooksHandler; }
| { updateWebhookSubscriptions: UpdateWebhookSubscriptionsHandler; }
| { acknowledgeWebhooks: AcknowledgeWebhooksHandler; }

GetItemHandler

Handler called to get an individual item.

export type GetItemHandler = (context: GetItemContext<any, any>) => Promise<API.Item>;

GetCollectionHandler

Handler called to retrieve a collection of items.

export type GetCollectionHandler = (context: GetCollectionContext<any, any>) => Promise<API.Collection>;

CreateItemHandler

Handler called to create an item.

export type CreateItemHandler = (context: CreateItemContext<any, any, any>) => Promise<API.ItemSummary>;

UpdateItemHandler

Handler called to update an item.

export type UpdateItemHandler = (context: UpdateItemContext<any, any, any>) => Promise<API.Item>;

DeleteItemHandler

Handler called to delete an item.

export type DeleteItemHandler = (context: DeleteItemContext<any, any>) => Promise<void>;

GetCredentialAccountHandler

Handler called to retrieve the account details associated with the credentials.

export type GetCredentialAccountHandler = (context: GetCredentialAccountContext<any, any>) => Promise<API.CredentialAccount>;

ParseWebhooksHandler

Handler called to parse the content of an incoming webhook.

export type ParseWebhooksHandler = (context: ParseWebhooksContext<any, any, any>) => Promise<API.WebhookParseResponsePayload>;

UpdateWebhookSubscriptionsHandler

Handler called to subscribe or unsubscribe to a particular webhook.

export type UpdateWebhookSubscriptionsHandler = (context: UpdateWebhookSubscriptionsContext<any, any, any>) => Promise<void>;

AcknowledgeWebhooksHandler

Handler called to acknowledge the reception of a webhook.

export type AcknowledgeWebhooksHandler = (context: AcknowledgeWebhooksContext<any, any, any>) => Promise<API.WebhookAcknowledgeResponsePayload>;