Interceptors - Modifying All Service Responses

One Plugin for Multiple API Calls

In some cases, you might want to modify all the responses from a certain type of service.
For example, if all patients show their date of birth, but you would like to show their age.
You could either subscribe to each API that returns a patient entity in its response, or you could use the ADAPT_ENTITY option instead.

Subscribing with ADAPT_ENTITY

When you perform a subscribe API call:
POST​<https://your-biot-domain.com/><service>/v1​/hooks​/interceptions​/subscribe
The service parameter, is the service whose entities you want to intercept.
In the type parameter, you can pass the value of ADAPT_ENTITY.
This will allow you to specify the entity name you would like to intercept, in the entityName parameter. BioT will then call the endpoint for each API call that responds with the specified entity.

For example:
​<https://your-biot-domain.com/organization/v1​/hooks​/interceptions​/subscribe>
With Body:

{
  "type": "ADAPT_ENTITY",
  "entityName": "patient",
  "endpoint": "https://<my_lambda_uri>"
}

This will result in BioT hooking your lambda to the following API calls:

  • PATCH/organization/v1/users/patients/{id}
  • GET/organization/v1/users/patients
  • DELETE/organization/v1/users/patients/{id}
  • POST/organization/v1/users/patients
  • POST/organization/v1/users/patients/{id}/enabled-state/{state}
  • GET/organization/v1/users/patients/{id}
  • GET/organization/v1/users/patients/self

As seen in POST_REQUEST, the code will receive the original API response body and is expected to return it, modified or not, as the lambda response.

📘

Call sequence

Note that the ADAPT_ENTITY callbacks are made after PRE_REQUEST but before POST_REQUEST callbacks. This means that changes made during POST_REQUEST will override the ADAPT_ENTITY changes.


Did this page help you?