Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Docs for the new livechat rooms endpoint (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosSpessatto authored and renatobecker committed Aug 16, 2019
1 parent 412c805 commit dfbd0c1
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions _data/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
- inquiries.take
- message
- room
- rooms
- sms-incoming
- users
- video-call
Expand Down
1 change: 1 addition & 0 deletions contributing/documentation/documentation-map/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ Here you can also find what articles are incomplete and missing.
- inquiries.take
- message
- room
- rooms
- sms-incoming
- users
- video-call
Expand Down
1 change: 1 addition & 0 deletions developer-guides/rest-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ When calling a production Rocket.Chat server, ensure it is running via HTTPS and
| :------------------------------- | :------------------------------------------------------------ | :------------------------------- |
| `/api/v1/livechat/inquiries.list`| Retrieves a list of open inquiries. | [Link](livechat/inquiries-list/) |
| `/api/v1/livechat/inquiries.take`| Take an open inquiry. | [Link](livechat/inquiries-take/) |
| `/api/v1/livechat/rooms` | Retrieves a list of livechat rooms. | [Link](livechat/rooms/) |

### Permissions

Expand Down
1 change: 1 addition & 0 deletions developer-guides/rest-api/livechat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Manage Livechat related data:
| `/api/v1/livechat/message/:_id` | `DELETE` | Delete a Livechat message. | [info](message/index.html#removes-a-livechat-message) |
| `/api/v1/livechat/messages.history/:rid` | `GET` | Load Livechat messages history. | [info](message/index.html#load-livechat-messages-history) |
| `/api/v1/livechat/offline.message` | `POST` | Send a new Livechat offline message. | [info](message/index.html#send-a-new-livechat-offline-message) |
| `/api/v1/livechat/rooms` | `GET` | Retrieves a list of livechat rooms. | [info](rooms/) |
| `/api/v1/livechat/room` | `GET` | Get the Livechat room data or open a new room. | [info](room/index.html) |
| `/api/v1/livechat/room.close` | `POST` | Close a Livechat room. | [info](room/index.html#close-livechat-room) |
| `/api/v1/livechat/room.transfer` | `POST` | Transfer a Livechat room to another agent or department. | [info](room/index.html#transfer-livechat-room) |
Expand Down
102 changes: 102 additions & 0 deletions developer-guides/rest-api/livechat/rooms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Get a list of livechat rooms

Retrieves a list of livechat rooms. It supports the [Offset, Count, and Sort Query Parameters](../../offset-and-count-and-sort-info/) along with [Fields Query Parameters](../../query-and-fields-info/).

| URL | Requires Auth | HTTP Method |
| :--- | :--- | :--- |
| `/api/v1/livechat/rooms` | `yes` | `GET` |

## Query Parameters

| Argument | Example | Required | Description |
| :--- | :--- | :--- | :--- |
| `agents` | `['b32h3b2hhwb25d']` | Optional | A list of agents, can be a list of ids or usernames |
| `departmentId` | `AkzpHAvZpdnuchw2a` | Optional | The department's id |
| `open` | `true` | Optional | If it should filter by open/closed rooms |
| `createdAt` | `{"start": "2018-01-26T00:11:22.345Z", "end": "2018-01-26T00:11:22.345Z"}` | Optional | An object representing when the room was created(Can also be filtered only with `start` or `end`) |
| `closedAt` | `{"start": "2018-01-26T00:11:22.345Z", "end": "2018-01-26T00:11:22.345Z"}` | Optional | An object representing when the room was closed(Can also be filtered only with `start` or `end`) |
| `tags` | `['rocket', 'chat']` | Optional | A list of tags |
| `customFields` | `{"docId": "aobEdbYhXfu5hkeqG"}` | Optional | An object with custom fields to be filtered(previously created and populated at custom fields endpoints) |

## Example Call

```bash
curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
http://localhost:3000/api/v1/livechat/rooms?agents[]=teste&departamentId=123&open=true&createdAt={"start": "2018-01-26T00:11:22.345Z", "end": "2018-01-26T00:11:22.345Z"}&closedAt={"start": "2018-01-26T00:11:22.345Z", "end": "2018-01-26T00:11:22.345Z"}&tags[]=rocket&customFields={"docId": "031041"}&count=3&offset=1&sort={"_updatedAt": 1}&fields={"msgs": 1}
```

## Example Result

```json
{
"rooms": [
{
"_id": "9dQMveZhqxiDgCM3B",
"msgs": 1,
"usersCount": 1,
"lm": "2019-08-09T20:18:02.350Z",
"fname": "Marcos Defendi",
"t": "l",
"ts": "2019-08-09T20:18:02.108Z",
"v": {
"_id": "xh45w4y7oPW5SiMJu",
"username": "guest-4",
"token": "xn5hdkyptei11m07f3me",
"status": "online"
},
"servedBy": {
"_id": "3kyWm8PsmwhC7xgwg",
"username": "marcos",
"ts": "2019-08-09T20:18:02.109Z"
},
"cl": false,
"open": true,
"waitingResponse": true,
"departmentId": "xnmXQmytuvxp2TuSC",
"_updatedAt": "2019-08-09T20:19:34.856Z",
"lastMessage": {
"_id": "TBEz7zSCBaKsfyrzc",
"rid": "9dQMveZhqxiDgCM3B",
"msg": "Hello",
"token": "xn5hdkyptei11m07f3me",
"alias": "Marcos Defendi",
"ts": "2019-08-09T20:18:02.350Z",
"u": {
"_id": "xh45w4y7oPW5SiMJu",
"username": "guest-4",
"name": "Marcos Defendi"
},
"_updatedAt": "2019-08-09T20:18:02.383Z",
"mentions": [],
"channels": [],
"newRoom": false,
"showConnecting": false
},
"metrics": {
"v": {
"lq": "2019-08-09T20:18:02.350Z"
}
},
"livechatData": {
"docId": "0310584343112"
},
"tags": [
"rocket",
"chat"
],
"name": "Marcos Defendi"
}
],
"count": 1,
"offset": 1,
"total": 7,
"success": true
}
```

## Change Log

| Version | Description |
| :--- | :--- |
| 2.0.0 | Added |

0 comments on commit dfbd0c1

Please sign in to comment.