This document follows on from the Comstack Private Messaging REST API documentation, same thinking rules etc applies.
With that in mind this document will only cover the endpoints and data models, if you want to know how paging, filtering, sorting and what else is available to you, refer to the Comstack Private Messaging REST API documentation.
The API will live at /api/v1/cs-fr
on the installed site.
See the end of this document.
List the current users friends. This will include pending friend requests which are noted by the
approved
property.Requires: Authenticated user session.
Default limit: 50.
Status | Description | Example |
---|---|---|
200 |
Valid response. |
Body{ "data": [ { "type": "relationship", "id": 1, "relationship_type": "comstack_friends", "user": { "type": "user", "id": 1, "name": "username" "avatars": { "100-100": "https://example.com/sites/default/files/styles/cs-100-100/public/avatars/av1.jpg?itok=123", "200-200": "https://example.com/sites/default/files/styles/cs-200-200/public/avatars/av1.jpg?itok=123" }, "contact_frequency": 0 }, "created": "2015-08-03T16:34:58+01:00", "changed": "2015-08-03T16:35:55+01:00", "approved": true }, ... ], "paging": { // See the Comstack Private Messaging documentation for that. } } |
204 |
No content (you don't have any friends :C). |
Send/create a new friend request.
Property | Type | Description | Required? |
---|---|---|---|
user | Integer |
The ID of the user you'd like to be friends with. |
{ "user": 2 }
Status | Description | Example |
---|---|---|
201 |
Request sent. |
HeadersBody{ // See relationship model. } |
400 |
Validation issue, in this case you've not sent a valid ID number. |
Get a specific relationship.
Requires: Authenticated user session.
Status | Description | Example |
---|---|---|
200 |
Relationship found. |
Body{ // See relationship model. } |
404 |
Relationship not found. |
Delete a friend relationship.
Status | Description | Example |
---|---|---|
200 |
The relationship has been deleted. | |
400 |
Failed to delete relationship. | |
404 |
Relationship not found. |
Approve a pending friend request.
Requires: Authenticated user session.
Status | Description | Example |
---|---|---|
200 |
The relationship has been approved. | |
400 |
Failed to approve relationship. | |
404 |
Relationship not found. |
Reject a friend request.
Requires: Authenticated user session.
Status | Description | Example |
---|---|---|
200 |
The friend request has been rejected. | |
400 |
Failed to reject the request. | |
404 |
Request not found. |
Cancel a friend request.
Requires: Authenticated user session.
Status | Description | Example |
---|---|---|
200 |
A friend request has been cancelled. | |
204 |
No content (no messages in conversation). | |
404 |
Conversation not found. |
List the users that the current user has blocked.
Requires: Authenticated user session.
Default limit: 50.
Status | Description | Example |
---|---|---|
200 |
Valid response. |
Body{ "data": [ { "type": "relationship", "id": 2, "relationship_type": "comstack_blocked", "user": { "type": "user", "id": 3, "name": "username" "avatars": { "100-100": "https://example.com/sites/default/files/styles/cs-100-100/public/avatars/av1.jpg?itok=123", "200-200": "https://example.com/sites/default/files/styles/cs-200-200/public/avatars/av1.jpg?itok=123" }, "contact_frequency": 0 }, "created": "2015-08-03T16:34:58+01:00", "changed": "2015-08-03T16:35:55+01:00", }, ... ], "paging": { // See the Comstack Private Messaging documentation for that. } } |
204 |
No content (you've not blocked anyone). |
Create a new blocked relationship, block someone.
Property | Type | Description | Required? |
---|---|---|---|
user | Integer |
The ID of the user you'd like to block. |
{ "user": 3 }
Status | Description | Example |
---|---|---|
201 |
Request sent. |
Body{ // See relationship model. } |
400 |
Validation issue, in this case you've not sent a valid ID number. |
Get a specific blocked relationship.
Requires: Authenticated user session.
Status | Description | Example |
---|---|---|
200 |
Relationship found. |
Body{ // See relationship model. } |
404 |
Relationship not found. |
Delete a blocked relationship, unblock someone.
Status | Description | Example |
---|---|---|
200 |
The relationship has been deleted. | |
400 |
Failed to delete relationship. | |
404 |
Relationship not found. |
Property | Type | Description |
---|---|---|
type | String |
The type of entity that this is for convenience, relationship . |
id | Integer |
ID of the relationship record. |
user | Object |
The user that this relationship is with. |
created | String |
An ISO 8601 date and time including timezone of when the relationship was started or requested. |
changed | String |
An ISO 8601 date and time including timezone of when the relationship was last updated. |
approved | Boolean |
Whether or not the relationship has been approved, for friends if false then the request is pending. Blocked relationships are one sided so always approved. |
{ "type": "relationship", "id": 1, "relationship_type": "comstack_friends", "user": { "type": "user", "id": 1, "name": "username" "avatars": { "100-100": "https://example.com/sites/default/files/styles/cs-100-100/public/avatars/av1.jpg?itok=123", "200-200": "https://example.com/sites/default/files/styles/cs-200-200/public/avatars/av1.jpg?itok=123" }, "contact_frequency": 0 }, "created": "2015-08-03T16:34:58+01:00", "changed": "2015-08-03T16:35:55+01:00", "approved": true }
Get me a list of my friends:
GET /api/v1/cs-fr/friends?filter[approved]=1
Get me a list of pending friend requests for me to approve or reject:
GET /api/v1/cs-fr/friends?filter[approved]=0
Check to see if I'm friends with someone, where their user ID is 9
:
GET /api/v1/cs-fr/friends?filter[user]=9