Reactions
Introduction
Reactions
are a quick and easy way to provide feedback to Reactable
entities via an emoji. Each User can only submit one Reaction
per Reactable
.
The Reactions
of all Users are then summarized in order to obtain a quick picture of user sentiment for the Reactable
.
Model Definition
Relations
reactable
Reactable
Morph to
reactable_type
, reactable_id
Reactable types
infoboardPost
- React to a InfoboardPost.infoboardComment
- React to a InfoboardComment.manualEntry
- React to a ManualEntry.chatMessage
- React to aChatMessages
.
Appends
The following appends
can be applied on all Reactable
entities:
reactions_summary
reactions_summary
Adds the reactions_summary
append to the response, containing the reaction
and the count
. The reaction counts are sorted from highest to lowest.
Example response:
{
"reactions_summary": [
{
"reaction": "π",
"count": 2
},
{
"reaction": "π",
"count": 1
}
]
}
List by reactable
List the Reactions
for given Reactable
.
Definition
GET
/api/reactions/{reactableType}/{reactableId}
Example Request
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/reactions/infoboardPost/1', [
'headers' => ['Authorization' => "Bearer {accessToken}"],
]);
Example Response
[
{
"user_id": 1,
"reactable_id": 1,
"reactable_type": "infoboardPost",
"value": "π",
"created_at": "2024-07-01 12:00:00",
"updated_at": "2024-07-01 12:00:00"
},
{
"user_id": 2,
"reactable_id": 1,
"reactable_type": "infoboardPost",
"value": "π",
"created_at": "2024-07-01 13:00:00",
"updated_at": "2024-07-01 13:00:00"
},
{
"user_id": 3,
"reactable_id": 1,
"reactable_type": "infoboardPost",
"reaction": "π",
"created_at": "2024-07-01 14:00:00",
"updated_at": "2024-07-01 14:00:00"
}
]
Summary by reactable
Get a summary of Reactions
for given Reactable
. It has the same structure as the reactions_summary
append.
Definition
GET
/api/reactions/{reactableType}/{reactableId}/summary
Example Request
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/reactions/infoboardPost/1/summary', [
'headers' => ['Authorization' => "Bearer {accessToken}"],
]);
Example Response
[
{
"reaction": "π",
"count": 2
},
{
"reaction": "π",
"count": 1
}
]
Create or update
Create a new Reaction
. If the reaction for given reactable_type
, reactable_id
and the authenticated User's ID exits, it will be updated.
Definition
POST
/api/reactions
Request Keys
reactable_id
*
integer
The ID of the Reactable
entity.
value
*
string
The emoji to react to the Reactable
entity.
Keys with *
are required.
Example Request
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/reactions', [
'headers' => ['Authorization' => "Bearer {accessToken}"],
'json' => [
'reactable_id' => 1,
'reactable_type' => 'infoboardPost',
'value' => "π"
]
]);
Example Response
{
"id": 4,
"reactable_id": 1,
"reactable_type": "infoboardPost",
"value": "π",
"user_id": 1,
"created_at": "2024-07-01 15:00:00",
"updated_at": "2024-07-01 15:00:00"
}
Delete
Delete an Reaction
by id
.
Definition
DELETE
/api/reactions/{id}
Example Request
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/reactions/4', [
'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
Example Response
{
"status": "success",
"data": []
}
Last updated