linagora-rse
Version:
603 lines (416 loc) • 13.7 kB
Markdown
# /api/user
## GET /api/user
Get a the authenticated user information.
**Request Headers:**
- Accept: application/json
**Response Headers:**
- Content-Length: Document size
- Content-Type: application/json
**Status Codes:**
- 200 OK. With the user profile
- 401 Unauthorized. The current request does not contains any valid data to be used for authentication
**Request:**
GET /api/user
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 OK
{
_id: 123456789,
firstname: "John",
lastname: "Doe",
emails: ["johndoe@linagora.com"]
}
# GET /api/user/profile
Get the current user profile.
**Request Headers:**
- Accept: application/json
**Response Headers:**
- Content-Length: Document size
- Content-Type: application/json
**Status Codes:**
- 200 OK. With the user profile as JSON.
- 401 Unauthorized.
**Request:**
GET /api/user/profile
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 OK
{
"firstname": "John",
"lastname": "Doe",
"job_title": "Manager",
"service": "Sales",
"phone": "+33467455653222"
}
# PUT /api/user/profile/{attribute_name}
Update an element of the current user profile.
**Parameters**
- attribute_name: The attribute name of the element to update (firstname, lastname, ...)
**Request Headers:**
- Accept: application/json
**Request JSON Object:**
- value: The attribute value.
**Response Headers:**
- Content-Length: Document size
- Content-Type: application/json
**Status Codes:**
- 200 OK. The profile element has been updated.
- 400 Bad Request.
- 401 Unauthorized. The current user does not have rights to update the user profile
**Request:**
PUT /api/user/profile/firstname
Accept: application/json
Host: localhost:8080
{value: 'Johnny'}
**Response:**
HTTP/1.1 200 OK
## POST /api/user/profile/avatar
Post a new avatar for the currently logged in user. The posted avatar is set as the default avatar for the user. The image should be a square, and at least be 128x128 px.
**Request query strings parameters**
- mimetype: the MIME type of the image. Valid values are 'image/png', 'image/gif' and 'image/jpeg'
- size: the size, in bytes, of the POSTed image. This size will be compared with the number of bytes recorded in the file storage service, thus ensuring that there were no data loss.
**Request Body:**
This endpoint expects the request body to be the raw image data
- 200 Ok. With the recorded image ID
- 400 Bad request. The current request is missing mandatory parameters
- 412 Precondition failed. The number of bytes recorded by the file storage service differs from the number of bytes given by the user agent
- 500 Internal server error: there was a problem, either storing the file, manipulating the image, or updating the user properties.
**Request:**
POST /api/user/profile/avatar?mimetype=image%2Fpng&size=12345
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 Ok
{
_id: '9f888058-e9e6-4915-814b-935d5b88389d'
}
## GET /api/user/profile/avatar
Get the avatar for the currently logged in user.
**Request Headers:**
- Accept: application/json
- If-Modified-Since: Date
**Query Parameters:**
- format: The avatar format. If not specified, it returns the avatar in 128x128 px. If format=original, returns the original uploaded file.
**Response Headers:**
- Content-Length: Document size
- Content-Type: application/json
- Last-Modified: Date
**Status Codes:**
- 200 Ok. With the stream of the avatar
- 304 Not modified. The avatar has not been changed since the last GET
- 404 Not found.
- 500 Internal server error: there was a problem with recovering the file.
**Request:**
GET /api/user/profile/avatar
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 Ok
Last-Modified: Wed, 18 Dec 2013 14:51:51 GMT
## GET /api/user/communities
List all of the communities across all of the domains to which the authenticated user belongs.
Check [./REST_community.md](Community API) for more details on communities.
**Request Headers:**
- Accept: application/json
**Response Headers:**
- Content-Type: application/json
**Response JSON Object**
An array of community objects the current user belongs to.
**Status Codes:**
- 200 OK
- 400 Bad request
- 500 Internal server error - Something went bad on the server side.
**Request:**
GET /api/user/communities
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 OK
[
{
"_id": "987654321",
"title": "Mean",
"description": "The Awesome MEAN stack",
"domain_ids": ["8292903883939282"],
"timestamps": {
"creation": "2014-05-16T09:47:11.703Z"
},
activity_stream: {
uuid: "9330-0393-7373-7280",
"timestamps": {
"creation": "2014-05-16T09:47:11.704Z"
}
}
},
{
"_id": "123456789",
"title": "Node.js",
"description": "All about node.js",
"domain_ids": ["8292903883939282"],
"timestamps": {
"creation": "2014-05-16T09:47:11.703Z"
},
activity_stream: {
uuid: "9330-0393-7373-7280",
"timestamps": {
"creation": "2014-05-16T09:47:11.704Z"
}
}
}
]
## GET /api/user/activitystreams
Get all the activity streams of the collaborations the current user can access.
**Request Headers:**
- Accept: application/json
**Request Query Strings Parameters:**
- domainid : Optional identifier of the domain in which to get the communities activity streams.
- writable : Boolean, optional. Get only activitystreams where the use can publish into when set to true.
- name: String, optional. Get only streams where the attached resource match or contains the given name.
- member: Boolean, optional. Get only the activitystreams where the current user is member of the linked collaboration.
**Response Headers:**
- Content-Type: application/json
**Response JSON Object**
An array of activity streams objects which can be read by the current user.
**Status Codes:**
- 200 OK
- 400 Bad request
- 401 Unauthorized
- 500 Internal server error
**Request:**
GET /api/user/activitystreams
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 OK
[
{
"uuid": "7aea8933-0a55-4e34-81ae-ec9812b8f891",
"target": {
"objectType": "domain",
"displayName": "rse",
"_id": "5375de4bd684db7f6fbd4f98",
"id": "urn:linagora.com:domain:5375de4bd684db7f6fbd4f98",
"image": ""
}
},
{
"uuid": "99363b89-b2d7-4eb7-872e-60c9909c5fb5",
"target": {
"objectType": "community",
"displayName": "node.js",
"_id": "53d76548974d22d21c9f249f",
"id": "urn:linagora.com:community:53d76548974d22d21c9f249f",
"image": "576875a0-1700-11e4-8141-013370dbdb36"
}
}
]
**Request:**
GET /api/user/activitystreams?domainid=5375de4bd684db7f6fbd4f98
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 OK
[
{
"uuid": "99363b89-b2d7-4eb7-872e-60c9909c5fb5",
"target": {
"objectType": "community",
"displayName": "node.js",
"_id": "53d76548974d22d21c9f249f",
"id": "urn:linagora.com:community:53d76548974d22d21c9f249f",
"image": "576875a0-1700-11e4-8141-013370dbdb36"
}
}
]
**Request:**
GET /api/user/activitystreams?name=node
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 OK
[
{
"uuid": "7aea8933-0a55-4e34-81ae-ec9812b8f891",
"target": {
"objectType": "domain",
"displayName": "Node.js",
"_id": "5375de4bd684db7f6fbd4f98",
"id": "urn:linagora.com:domain:5375de4bd684db7f6fbd4f98",
"image": ""
}
},
{
"uuid": "99363b89-b2d7-4eb7-872e-60c9909c5fb5",
"target": {
"objectType": "community",
"displayName": "Node",
"_id": "53d76548974d22d21c9f249f",
"id": "urn:linagora.com:community:53d76548974d22d21c9f249f",
"image": "576875a0-1700-11e4-8141-013370dbdb36"
}
}
]
## GET /api/user/oauth/clients
List all of the OAuth clients created by the current user.
Check [./REST_OAuth.md](OAuth API) for more details on OAuth support.
**Request Headers:**
- Accept: application/json
**Response Headers:**
- Content-Type: application/json
**Response JSON Object**
An array of OAuth clients the current user created.
**Status Codes:**
- 200 OK
- 400 Bad request
- 500 Internal server error - Something went bad on the server side.
**Request:**
GET /api/user/oauth/clients
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 OK
[
{
"_id":"54189f0c5375449a5d17f3d9",
"clientSecret":"OwISwURuiJ1KhBgRIgPdQNbMzyIpA9AEyuHTCRQH",
"clientId":"t0m0s3SS1cDLEVBK7pvL",
"name":"Twitter Streaming App",
"redirectUri":"http://twitter.com/oauth/",
"description":"Let's stream tweets",
"creator":"5375de9fd684db7f6fbd5010",
"__v":0,
"schemaVersion":1,
"created":"2014-09-16T20:35:24.643Z"
}
]
## GET /api/user/notifications
List all the 'user notifications' for the current user.
**Request Headers:**
- Accept: application/json
**Query Parameters:**
- limit (int): The number of members to return. This will only keep the N first members (where N=limit). Default value is 50.
- offset (int): Start the list of members after skipping N members (where N=offset). For example, if the size of the members list is 100 and the offset is 50, the result list will contain only members from 50 to 99 (list index starts at index 0).
- read (boolean): If true, show notifications marked as read, if false, show only unread ones. If undefined, show all.
**Response Headers:**
- Content-Type: application/json
- X-ESN-Items-Count: The total number of notifications for the user.
**Response JSON Object**
Array of user notifications.
**Status Codes:**
- 200 OK
- 400 Bad request
- 401 Unauthorized. The user is not authenticated on the platform.
- 500 Internal server error - Something went wrong on the server side.
**Request:**
GET /api/user/notifications?read=false
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 OK
[
{
_id: '54327ab55489fe31a957c4b2',
subject: { id: '54327ab55489fe31a957c4ae', objectType: 'user' },
verb: { label: 'created', text: 'created' },
complement: { id: 54327ab55489fe31a957c4af, objectType: 'community' },
category: 'A category',
acknowledged: false,
read: false,
target: [
{
objectType: 'user',
id: '54327ab55489fe31a957c4aa'
}
],
action: [],
interactive: false,
timestamps: { creation: '2014-10-06T11:19:17.035Z' }
}
]
## PUT /api/user/notifications/:uuid/read
Mark the user notification of id :uuid as read.
**Request Headers:**
- Accept: application/json
**Request Body:**
This endpoint expects the request body to be either { value : true } or { value : false } .
**Status Codes:**
- 205 Reset content
- 400 Bad request
- 401 Unauthorized
- 404 Not found
- 500 Internal server error
**Request:**
PUT /api/user/notifications/1234567589/read
Accept: application/json
Host: localhost:8080
{
value: true
}
**Response:**
HTTP/1.1 205 Reset content
## PUT /api/user/notifications/read?ids=[]
Mark each user notifications of id inside ids as read.
**Request Headers:**
- Accept: application/json
**Request Body:**
This endpoint expects the request body to be either { value : true } or { value : false } .
**Status Codes:**
- 205 Reset content
- 400 Bad request
- 401 Unauthorized
- 404 Not found
- 500 Internal server error
**Request:**
PUT /api/user/notifications/read?ids[]=123456&ids[]=789
Accept: application/json
Host: localhost:8080
{
value: true
}
**Response:**
HTTP/1.1 205 Reset content
## PUT /api/user/notifications/:uuid/acknowledged
Mark the user notification of id :uuid as acknowledged.
**Request Headers:**
- Accept: application/json
**Request Body:**
This endpoint expects the request body to be either { value : true } or { value : false } .
**Response Headers:**
- Content-Type: application/json
**Status Codes:**
- 205 Reset content
- 400 Bad request
- 401 Unauthorized
- 404 Not found
- 500 Internal server error
**Request:**
PUT /api/user/notifications/1234567589/acknowledged
Accept: application/json
Host: localhost:8080
{
value: true
}
**Response:**
HTTP/1.1 205 Reset content
## GET /api/user/notifications/unreadcount
Return the number of unread user notifications for the current user.
**Response Headers:**
- Content-Length: Document size
- Content-Type: application/json
**Response JSON Object:**
- unread_count: unread user notifications
**Status Codes:**
- 200 Ok.
- 401 Unauthorized.
- 500 Internal server error.
**Request:**
GET /api/user/notifications/unreadcount
Accept: application/json
Host: localhost:8080
**Response:**
HTTP/1.1 200 Ok
{
"unread_count": 42
}