Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

Latest commit

 

History

History
312 lines (269 loc) · 5.81 KB

06.User-resource.md

File metadata and controls

312 lines (269 loc) · 5.81 KB

User

Returns the current user logged in.

User schema

  • id: Gitter User ID.
  • username: Gitter/GitHub username.
  • displayName: Gitter/GitHub user real name.
  • url: Path to the user on Gitter.
  • avatarUrlSmall: User avatar URI (small).
  • avatarUrlMedium: User avatar URI (medium).

Get the current user

GET /v1/user
[{
  "id": "53307734c3599d1de448e192",
  "username": "malditogeek",
  "displayName": "Mauro Pompilio",
  "url": "/malditogeek",
  "avatarUrlSmall": "https://avatars.githubusercontent.com/u/14751?",
  "avatarUrlMedium": "https://avatars.githubusercontent.com/u/14751?"
}]

Try it from the CLI:

'demo api-access';
{
  "verb": "get",
  "resource": "{{api_url}}/v1/user"
}

User sub-resources

Rooms

List of Rooms the user is part of.

GET /v1/user/:userId/rooms
[{
  "id": "53307860c3599d1de448e19d",
  "name": "Andrew Newdigate",
  "topic": "",
  "oneToOne": true,
  "userCount": 2,
  "user": {
    "id": "53307831c3599d1de448e19a",
    "username": "suprememoocow",
    "displayName": "Andrew Newdigate",
    "url": "/suprememoocow",
    "avatarUrlSmall": "https://avatars.githubusercontent.com/u/594566?",
    "avatarUrlMedium": "https://avatars.githubusercontent.com/u/594566?"
  },
  "unreadItems": 0,
  "mentions": 0,
  "lastAccessTime": "2014-04-24T15:53:25.662Z",
  "lurk": false,
  "url": "/suprememoocow",
  "githubType": "ONETOONE"
}, {
  "id": "5330777dc3599d1de448e194",
  "name": "gitterHQ",
  "topic": "Gitter",
  "uri": "gitterHQ",
  "oneToOne": false,
  "userCount": 2,
  "unreadItems": 0,
  "mentions": 0,
  "lastAccessTime": "2014-04-24T17:34:00.738Z",
  "lurk": false,
  "url": "/gitterHQ",
  "githubType": "ORG",
  "v": 9
}, {
  "id": "53307793c3599d1de448e196",
  "name": "malditogeek/vmux",
  "topic": "VMUX - Plugin-free video calls in your browser using WebRTC",
  "uri": "malditogeek/vmux",
  "oneToOne": false,
  "userCount": 2,
  "unreadItems": 0,
  "mentions": 0,
  "lastAccessTime": "2014-03-25T11:51:03.758Z",
  "lurk": false,
  "url": "/malditogeek/vmux",
  "githubType": "REPO",
  "v": 1
}]

Try it from the CLI:

'demo api-access';
{
  "verb": "get",
  "resource": "{{api_url}}/v1/user/:userId/rooms"
}

Unread Items

You can retrieve unread items and mentions using the following endpoint.

GET /v1/user/:userId/rooms/:roomId/unreadItems
{
  "chat": [
    "560ae5f495756f1402bc841d",
    "560aeef6f4b61c106fb2a9f3",
    "560aef2b552ed7913279df52"
  ],
  "mention": [
    "560b167a967c1bad7852bc57"
  ]
}

Try it from the CLI:

'demo api-access';
{
  "verb": "get",
  "resource": "{{api_url}}/v1/user/:userId/rooms/:roomId/unreadItems"
}

Mark Unread Items as "read"

There is an additional endpoint nested under rooms that you can use to mark chat messages as read.

Parameters

  • chat: Array of chatIds.
POST /v1/user/:userId/rooms/:roomId/unreadItems
{
  "chat": [
    "560ae5f495756f1402bc841d",
    "560aeef6f4b61c106fb2a9f3",
    "560aef2b552ed7913279df52",
    "560aef4f081f3a9c044d7d61"
  ]
}

Try it from the CLI:

'demo api-access';
{
  "verb": "post",
  "resource": "{{api_url}}/v1/user/:userId/rooms/:roomId/unreadItems",
  "data": {
    "chat": [
      "560ae5f495756f1402bc841d",
      "560aeef6f4b61c106fb2a9f3",
      "560aef2b552ed7913279df52",
      "560aef4f081f3a9c044d7d61"
    ]
  }
}

Orgs

List of the user's GitHub Organisations and their respective Room if available.

GET /v1/user/:userId/orgs
[{
  "id": 5990364,
  "name": "gitterHQ",
  "avatar_url": "https://avatars.githubusercontent.com/u/5990364?",
  "room": {
    "id": "5330777dc3599d1de448e194",
    "name": "gitterHQ",
    "topic": "Gitter",
    "uri": "gitterHQ",
    "oneToOne": false,
    "userCount": 2,
    "unreadItems": 0,
    "mentions": 0,
    "lastAccessTime": "2014-03-25T11:50:49.799Z",
    "lurk": false,
    "url": "/gitterHQ",
    "githubType": "ORG",
    "v": 1
  }
}, {
  "id": 4046959,
  "name": "lnug",
  "avatar_url": "https://avatars.githubusercontent.com/u/4046959?"
}]

Try it from the CLI:

'demo api-access';
{
  "verb": "get",
  "resource": "{{api_url}}/v1/user/:userId/orgs"
}

Repos

List of the user's GitHub Repositories and their respective Room if available.

Note: It'll return private repositories if the current user has granted Gitter privileges to access them.

GET /v1/user/:userId/repos
[{
  "id": 10974239,
  "name": "malditogeek/vmux",
  "uri": "malditogeek/vmux",
  "private": false,
  "room": {
    "id": "53307793c3599d1de448e196",
    "name": "malditogeek/vmux",
    "topic": "VMUX - Plugin-free video calls in your browser using WebRTC",
    "uri": "malditogeek/vmux",
    "oneToOne": false,
    "userCount": 2,
    "unreadItems": 0,
    "mentions": 0,
    "lastAccessTime": "2014-03-25T11:51:03.758Z",
    "lurk": false,
    "url": "/malditogeek/vmux",
    "githubType": "REPO",
    "v": 1
  }
}, {
  "id": 15316813,
  "name": "gitterHQ/marked",
  "uri": "gitterHQ/marked",
  "private": false
}, {
  "id": 16485332,
  "name": "gitterHQ/emojify.js",
  "uri": "gitterHQ/emojify.js",
  "private": false
}]

Try it from the CLI:

'demo api-access';
{
  "verb": "get",
  "resource": "{{api_url}}/v1/user/:userId/repos"
}

Channels

List of Gitter channels nested under the current user.

GET /v1/user/:userId/channels
[{
  "id": "533177b9c3599d1de448e1a1",
  "name": "malditogeek/AMA",
  "topic": "",
  "uri": "malditogeek/AMA",
  "oneToOne": false,
  "unreadItems": 0,
  "mentions": 0,
  "lastAccessTime": "2014-03-25T12:34:03.681Z",
  "lurk": false,
  "url": "/malditogeek/AMA",
  "githubType": "USER_CHANNEL",
  "security": "PUBLIC"
}]

Try it from the CLI:

'demo api-access';
{
  "verb": "get",
  "resource": "{{api_url}}/v1/user/:userId/channels"
}