Wiki

Clone wiki

ac-koa-hipchat / REST Client

Tenant REST Client

A tenant REST client is provided that automatically handles the construction of authenticated requests for each of operations available in the HipChat API v2. The REST client automatically generates and refreshes OAuth2 tokens as needed.

The REST client is available through the ctx.tenantClient interface. Each of the listed methods below are asynchronous and return a promise. Where available, options are specified as query parameters in the HipChat REST API documentation.

Emoticons

Method Description
getEmoticons(options) Get all emoticons.
getEmoticon(emoticonIdOrShortcut, options) Get emoticon by id or key

Sessions

Method Description
getToken(scopes) Gets an OAuth token with the specified scopes.
getSession(sessionId) Gets the session via its id
deleteSession(sessionId) Delete session by id

Rooms

The ctx.roomClient interface is thin wrapper around the tenantClient object that's provided in room-specific request contexts. Only the methods of the tenantClient that require a room id are exposed on this object, with the room id already partially applied for convenience.

Method Description
getRooms(options) List non-achived rooms
createRoom(room, options) Create a room. The room argument must be a map representing the request body.
getRoom(roomIdOrName, options) Get room details
updateRoom(roomIdOrName, room) Update room details
deleteRoom(roomIdOrName) Delete room and kick participants
getRoomHistory(roomIdOrName, options) Fetch chat history for this room
getRecentRoomHistory(roomIdOrName, options) Fetches latest chat history for this room
getRoomStatistics(roomIdOrName) Fetch statistics for this room
getRoomMembers(roomIdOrName) Get all room members
setRoomTopic(roomIdOrName, topic) Set the room topic
shareLinkWithRoom(roomIdOrName, link, message) Share link with room
addRoomMember(roomIdOrName, userIdOrEmail) Invite a user to a room
removeRoomMember(roomIdOrName, userIdOrEmail) Remove user from a private room
Room Messages
Method Description
sendNotification(message, options) Send a message to a room
getRoomMessage(roomIdOrName, messageId, options) Fetch one specific message by id
replyToMessage(roomIdOrName, parentMessageId, message) Reply to a message in a room
Room Webhooks
Method Description
createRoomWebhook(roomIdOrName, webhook) Create a room webhook. The webhook argument must be a map representing the request body.
getRoomWebhook(roomIdOrName, webhookId, options) Get a room webhook
getRoomWebhooks(roomIdOrName) Retrieves all room webhooks
deleteRoomWebhook(roomIdOrName, webhookId) Delete a room webhook

For details on webhook REST client operations, please see the Webhooks page.

Users

Method Description
getPrivateChatMessage(userIdOrEmail, messageId, options) Fetch one specific message by id
getRecentPrivateChatHistory(userIdOrEmail, options) Fetch latest chat history
createUser(user) Create a user. The user argument must be a map representing the request body.
getUsers(options) List all users
getUser(userIdOrEmail, options) Get user's details
updateUser(userIdOrEmail, user) Update a user. The user argument must be a map representing the request body.
deleteUser(userIdOrEmail) Delete a user
updateUserPhoto(userIdOrEmail, photo) Update a user photo
deleteUserPhoto(userIdOrEmail) Delete a user photo
shareLinkWithUser(userIdOrEmail, link, message) Share a link with a user

Helpers

Methods that operate on a room or a user can be instantiated using a thin wrapper that provides methods to operate on the specified user or room. For example:

#!js

var roomId = 1;

// Using room methods on ctx:
ctx.getRoom(roomId);
ctx.getRoomMembers(roomId);

// Using helper wrapper:
var roomHelper = ctx.forRoom(roomId);
roomHelper.getRoom();
roomHelper.getRoomMembers();
Method Description
forRoom(roomIdOrName) Wrapper around room methods
forUser(userIdOrEmail) Wrapper around user methods

Updated