Skip to content

Commit b95de56

Browse files
pierre-lehnen-rcrodrigok
authored andcommitted
[NEW] Added Invite Links API docs (RocketChat#1551)
1 parent 11785a9 commit b95de56

File tree

11 files changed

+252
-18
lines changed

11 files changed

+252
-18
lines changed

.github/main.workflow

-12
This file was deleted.

.github/workflows/build_and_test.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,39 @@ name: Build and test with Rake
22

33
on: [push]
44

5+
# env:
6+
# NOKOGIRI_USE_SYSTEM_LIBRARIES: true # speeds up installation of html-proofer
7+
58
jobs:
69
build:
710

811
runs-on: ubuntu-latest
912

1013
steps:
1114
- uses: actions/checkout@v1
15+
1216
- name: Set up Ruby 2.6
1317
uses: actions/setup-ruby@v1
1418
with:
1519
ruby-version: 2.6.x
16-
- name: Build and test with Rake
20+
21+
- uses: actions/cache@v1
22+
id: gem-cache
23+
with:
24+
path: vendor/bundle
25+
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-gem-
28+
29+
- name: Install dependencies
1730
run: |
1831
gem install bundler
1932
bundle install --jobs 4 --retry 3 --deployment
33+
34+
- name: Lint
35+
run: |
2036
bundle exec mdl ./ -r ~MD004 -i -g
37+
38+
- name: Build and test with Rake
39+
run: |
2140
bundle exec "rake test"

_data/toc.yml

+6
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@
403403
- history
404404
- list
405405
- remove
406+
- Invites:
407+
- findOrCreateInvite
408+
- listInvites
409+
- removeInvite
410+
- useInviteToken
411+
- validateInviteToken
406412
- Livechat:
407413
- agent
408414
- appearance

contributing/documentation/documentation-map/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,12 @@ Here you can also find what articles are incomplete and missing.
397397
- history
398398
- list
399399
- remove
400+
- Invites:
401+
- findOrCreateInvite
402+
- listInvites
403+
- removeInvite
404+
- useInviteToken
405+
- validateInviteToken
400406
- Livechat:
401407
- agent
402408
- appearance

developer-guides/rest-api/README.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,23 @@ When calling a production Rocket.Chat server, ensure it is running via HTTPS and
224224
| `/api/v1/integrations.list` | Lists all of the integrations. | [Link](integration/list/) |
225225
| `/api/v1/integrations.remove` | Removes an integration. | [Link](integration/remove/) |
226226

227+
### Invites
228+
229+
| Url | Short Description | Details Page |
230+
| :------------------------------ | :------------------------------------------------------------------------- | :----------------------------------- |
231+
| `/api/v1/findOrCreateInvite` | Created a new Invite or returns an existing one with the same parameters. | [Link](invites/findOrCreateInvite/) |
232+
| `/api/v1/listInvites` | Lists all of the invite tokens. | [Link](invites/listInvites/) |
233+
| `/api/v1/removeInvite` | Removes an invite. | [Link](invites/removeInvite/) |
234+
| `/api/v1/useInviteToken` | Report to the server that an invite token was used. | [Link](invites/useInviteToken/) |
235+
| `/api/v1/validateInviteToken` | Checks if an invite token is valid. | [Link](invites/validateInviteToken/) |
236+
227237
### Livechat
228238

229-
| Url | Short Description | Details Page |
230-
| :------------------------------- | :------------------------------------------------------------ | :------------------------------- |
231-
| `/api/v1/livechat/inquiries.list`| Retrieves a list of open inquiries. | [Link](livechat/inquiries-list/) |
232-
| `/api/v1/livechat/inquiries.take`| Take an open inquiry. | [Link](livechat/inquiries-take/) |
233-
| `/api/v1/livechat/rooms` | Retrieves a list of livechat rooms. | [Link](livechat/rooms/) |
239+
| Url | Short Description | Details Page |
240+
| :------------------------------- | :-----------------------------------| :------------------------------------------------ |
241+
| `/api/v1/livechat/inquiries.list`| Retrieves a list of open inquiries. | [Link](livechat/inquiries/#inquiries-list) |
242+
| `/api/v1/livechat/inquiries.take`| Take an open inquiry. | [Link](livechat/inquiries/#livechat-take-inquiry) |
243+
| `/api/v1/livechat/rooms` | Retrieves a list of livechat rooms. | [Link](livechat/rooms/) |
234244

235245
### OAuthApps
236246

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Invite Methods
2+
3+
| Url | Short Description | Details Page |
4+
| :------------------------------ | :------------------------------------------------------------------------- | :--------------------------- |
5+
| `/api/v1/findOrCreateInvite` | Created a new Invite or returns an existing one with the same parameters. | [Link](findOrCreateInvite/) |
6+
| `/api/v1/listInvites` | Lists all of the invite tokens. | [Link](listInvites/) |
7+
| `/api/v1/removeInvite` | Removes an invite. | [Link](removeInvite/) |
8+
| `/api/v1/useInviteToken` | Report to the server that an invite token was used. | [Link](useInviteToken/) |
9+
| `/api/v1/validateInviteToken` | Checks if an invite token is valid. | [Link](validateInviteToken/) |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Find or Create Invite
2+
3+
Creates or return an existing invite with the specified parameters. Requires the `create-invite-links` permission.
4+
5+
| URL | Requires Auth | HTTP Method |
6+
| :--- | :--- | :--- |
7+
| `/api/v1/findOrCreateInvite` | `yes` | `POST` |
8+
9+
## Payload
10+
11+
| Argument | Example | Required | Description |
12+
| :--- | :--- | :--- | :--- |
13+
| `rid` | `'csFYrDeixJG7PnrAh'` | Required | The id of the room that the invite is being created for. |
14+
| `days` | `0` | Required | The number of days that the invite will be valid for. Send 0 for unlimited. |
15+
| `maxUses` | `20` | Required | The number of times that the invite can be used. Send 0 for unlimited. |
16+
17+
## Example Call
18+
19+
```bash
20+
curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
21+
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
22+
-H "Content-type: application/json" \
23+
http://localhost:3000/api/v1/findOrCreateInvite \
24+
-d '{ "rid": "csFYrDeixJG7PnrAh", "days": 10, "maxUses": 0 }'
25+
```
26+
27+
## Example Result
28+
29+
```json
30+
{
31+
"_id": "kDKQ3H",
32+
"days": 10,
33+
"maxUses": 0,
34+
"rid": "csFYrDeixJG7PnrAh",
35+
"userId": "sNiDqHit5nGAGFg8X",
36+
"createdAt": "2017-01-06T13:23:46.018Z",
37+
"expires": "2017-01-16T13:23:46.018Z",
38+
"_updatedAt": "2017-01-06T13:23:46.018Z",
39+
"uses": 0,
40+
"url": "http://open.rocket.chat/invite/kDKQ3H",
41+
"success": true
42+
}
43+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# List Invites
2+
3+
Lists all of the invites on the server. Requires the `create-invite-links` permission.
4+
5+
| URL | Requires Auth | HTTP Method |
6+
| :--- | :--- | :--- |
7+
| `/api/v1/listInvites` | `yes` | `GET` |
8+
9+
## Example Call
10+
11+
```bash
12+
curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
13+
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
14+
-H "Content-type: application/json" \
15+
http://localhost:3000/api/v1/listInvites
16+
```
17+
18+
## Example Result
19+
20+
```json
21+
[
22+
{
23+
"_id": "kDKQ3H",
24+
"days": 1,
25+
"maxUses": 1,
26+
"rid": "s7CE842q9WtvLctD7",
27+
"userId": "sNiDqHit5nGAGFg8X",
28+
"createdAt": "2019-12-20T03:31:56.774Z",
29+
"expires": "2019-12-21T03:31:56.774Z",
30+
"uses": 1,
31+
"_updatedAt": "2019-12-20T03:33:40.065Z"
32+
},
33+
{
34+
"_id": "99ScEP",
35+
"days": 1,
36+
"maxUses": 0,
37+
"rid": "s7CE842q9WtvLctD7",
38+
"userId": "sNiDqHit5nGAGFg8X",
39+
"createdAt": "2019-12-20T03:38:20.485Z",
40+
"expires": "2019-12-21T03:38:20.485Z",
41+
"uses": 0,
42+
"_updatedAt": "2019-12-20T03:38:20.485Z"
43+
},
44+
{
45+
"_id": "Y5JKM4",
46+
"days": 0,
47+
"maxUses": 1,
48+
"rid": "s7CE842q9WtvLctD7",
49+
"userId": "sNiDqHit5nGAGFg8X",
50+
"createdAt": "2019-12-20T03:38:25.313Z",
51+
"expires": null,
52+
"uses": 1,
53+
"_updatedAt": "2019-12-20T03:38:40.116Z"
54+
}
55+
]
56+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Remove Invite
2+
3+
Removes an invite from the server. Requires the `create-invite-links` permission.
4+
5+
| URL | Requires Auth | HTTP Method |
6+
| :--- | :--- | :--- |
7+
| `/api/v1/removeInvite` | `yes` | `DELETE` |
8+
9+
## Payload
10+
11+
| Argument | Example | Required | Description |
12+
| :--- | :--- | :--- | :--- |
13+
| `_id` | `'kDKQ3H'` | Required | The id of the invite to remove. |
14+
15+
## Example Call
16+
17+
```bash
18+
curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
19+
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
20+
-X DELETE \
21+
http://localhost:3000/api/v1/removeInvite/kDKQ3H
22+
```
23+
24+
## Example Result
25+
26+
```json
27+
true
28+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Use Invite Token
2+
3+
Report to the server that an invite token was used. No permissions are required.
4+
5+
| URL | Requires Auth | HTTP Method |
6+
| :--- | :--- | :--- |
7+
| `/api/v1/useInviteToken` | `yes` | `POST` |
8+
9+
## Payload
10+
11+
| Argument | Example | Required | Description |
12+
| :--- | :--- | :--- | :--- |
13+
| `token` | `iS7pza` | Required | The id of the invite being used. |
14+
15+
## Example Call
16+
17+
```bash
18+
curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
19+
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
20+
-H "Content-type: application/json" \
21+
http://localhost:3000/api/v1/useInviteToken \
22+
-d '{ "token": "iS7pza" }'
23+
```
24+
25+
## Example Result
26+
27+
```json
28+
{
29+
"room": {
30+
"rid": "QqsWiqNH2TnxtvZQq",
31+
"fname": "a-room-name",
32+
"name": "a-room-name",
33+
"t": "p"
34+
},
35+
"success": true
36+
}
37+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Validate Invite Token
2+
3+
Checks if an invite token is valid. No permissions are required.
4+
5+
| URL | Requires Auth | HTTP Method |
6+
| :--- | :--- | :--- |
7+
| `/api/v1/validateInviteToken` | `no` | `POST` |
8+
9+
## Payload
10+
11+
| Argument | Example | Required | Description |
12+
| :--- | :--- | :--- | :--- |
13+
| `token` | `iS7pza` | Required | The id of the invite being validated. |
14+
15+
## Example Call
16+
17+
```bash
18+
curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
19+
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
20+
-H "Content-type: application/json" \
21+
http://localhost:3000/api/v1/validateInviteToken \
22+
-d '{ "token": "iS7pza" }'
23+
```
24+
25+
## Example Result
26+
27+
```json
28+
{
29+
"valid": true,
30+
"success": true
31+
}
32+
```

0 commit comments

Comments
 (0)