Create Notifications

How to create new notification

In order to create a new notification we have to call https://pistis-market.eu/srv/notifications/api/notifications with authorization (Bearer token) in headers Bearer eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..-Q39YYWOxngT3gVg... and specific body.

Body

{
  "userId": "string",
  "organizationId": "string",
  "type": "string",
  "message": "string",
  "isHidden": true
}

In the JSON above we need to fill in the fields in order to create the notification.

  • userId --> Is the user that we want to send the notification
  • organizationId --> Organization id tha we want to send the notification
  • type --> Is an ENUM with predefined strings to add(more information in the next section)
  • message --> The message that we want to send to the specific user
  • isHidden --> This need to be true so the user can see the new notification

For the type the strings that we accept are:

    `new_contract`
    `asset_updated`
    `asset_retrieved`
    `new_factory_registered`
    `factory_accepted`
    `factory_denied`
    `factory_activated`
    `factory_suspended`

If your notification does not fall under one of these types, contact someone from Suite5 to add a new type for you. You will also need to provide a message to accompany the type (the one the user will actually see).

Example

So lets say that we have 2 users Provider and Consumer. Consumer buys an asset from the Provider and the transfer begins. When the process finished we need to inform Provider that the asset retrieved. The flow is like below

  • We made a POST call to https://pistis-market.eu/srv/notifications/api/notifications
  • We include the token in headers
  • We add body in the call like the example below
{
  "userId": "b023c6ed-e355-4903-a2d3-7fbe2ef751ea",
  "organizationId": "3bbe83bb-8d39-4bfc-af3c-f03e8e60313a",
  "type": "asset_retrieved",
  "message": "Demo asset retrieved successfully",
  "isHidden": false
}

As a response we retrieve the following

{
  "id": "64b13177-9762-4aab-9e96-252fbfefeb88",
  "userId": "b023c6ed-e355-4903-a2d3-7fbe2ef751ea",
  "organizationId": "3bbe83bb-8d39-4bfc-af3c-f03e8e60313a",
  "type": "asset_retrieved",
  "message": "Demo asset retrieved successfully",
  "readAt": "2024-07-29T09:35:16.144Z",
  "isHidden": false,
  "createdAt": "2024-07-29T09:35:16.144Z",
  "updatedAt": "2024-07-29T09:35:16.144Z"
}

Now the Provider will see a new notification

Swagger Documentation

For further clarification, you can refer to the deployed Swagger documentation at https://pistis-market.eu/srv/notifications/api. Alternatively, feel free to reach out to a representative from Suite5 for assistance.