A connection or a relationship between two users is established first when one of them sends a request,
that actually is a connection with the status pending.
When the receiver accepts the request, its status changes to confirmed.
This is the full version of a Connection JSON entity:
{
"id": "1d8661627f0001013e43838b8622206e",
"href": "http://localhost:8080/rest/v1/social/usersRelationships/1d8661627f0001013e43838b8622206e",
"sender": "http://localhost:8080/rest/v1/social/users/root",
"receiver": "http://localhost:8080/rest/v1/social/users/john",
"status": "CONFIRMED"
}There are two services that work on this entity. Their functionalities are basically identical.
/v1/social/relationships
/v1/social/usersRelationships
In Create and Update, you can use the exact JSON like above, or a simpler version. Pay attention to fields "sender" and "receiver" in the following examples:
Send a request. "john" is the authenticated user and is the sender.
POST /v1/social/usersRelationships
{
"sender":"john",
"receiver":"user1",
"status":"pending"
}POST /v1/social/relationships
{
"sender":"john",
"receiver":"user1",
"status":"pending"
}Get "pending" requests (you need to handle the paging that is not described here).
GET /v1/social/usersRelationships?returnSize=true&offset=0&status=pending
GET /v1/social/relationships?returnSize=true&offset=0&status=pending
Accept a pending request by its Id.
PUT /v1/social/usersRelationships/5a1b9e8b7f0001012bb08188031afa28
{
"status":"confirmed"
}PUT /v1/social/relationships/5a1b9e8b7f0001012bb08188031afa28
{
"status":"confirmed"
}Cancel/Remove a connection.
DELETE /v1/social/usersRelationships/5a1b9e8b7f0001012bb08188031afa28
DELETE /v1/social/relationships/5a1b9e8b7f0001012bb08188031afa28