webex-teams-api-wrapper
v1.0.3
Published
Webex Teams API Wrapper written in TypeScript
Downloads
4
Maintainers
Readme
Webex API Service Wrapper
Table Of Contents
Introduction
This wrapper supposed to provied a simple solution to interact with the Webex API in TypeScript projects.
This project is work in progress state. The endpoint modules will be added with time.
Getting started
Downloading the module
The module can be downloaded to your project from the NPM repository by executing the following command:
npm install webex-teams-api-wrapper --save
Importing to your project
When downloaded, the module can be simply imported
In your typescript project:
import Webex from "webex-teams-api-wrapper";
In your javascript project:
const webex = require("webex-teams-api-wrapper").default;
Usage
The endpoint methods can be called from the Webex object after it is instantiated.
Instantiating the Webex object
In your project, after importing the module, you can simply create a new instance with the new
keyword.
const webex = new Webex("<YOUR PERSONAL ACCESS TOKEN>");
For this you will need to provide your Personal Access Token.
Endpoints
The currently implemented endpoints can be used from the Webex
object. The list of these will grow with time.
Every endpoint method will return a promise with the respective responses.
Messages
Messages are how we communicate in a room. In Webex Teams, each message is displayed on its own line along with a timestamp and sender information. Use this API to list, create, and delete messages.
Message can contain plain text, rich text, and a file attachment.
Just like in the Webex Teams app, you must be a member of the room in order to target it with this API.
List Messages
listMessages(query: ListMessagesQuery): Promise<ListMessagesResponse>
Lists all messages in a room. Each message will include content attachments if present.
The list sorts the messages in descending order by creation date.
Long result sets will be split into pages.
List Direct Messages
listDirectMessages(query: ListDirectMessagesQuery): Promise<ListDirectMessagesResponse>
Lists all messages in a 1:1 (direct) room. Use the personId or personEmail query parameter to specify the room. Each message will include content attachments if present.
The list sorts the messages in descending order by creation date.
Create Message
createMessage(query: CreateMessageQuery): Promise<CreateMessageResponse>
Post a plain text or rich text message, and optionally, a file attachment attachment, to a room.
The files
parameter is an array, which accepts multiple values to allow for future expansion, but currently only one file may be included with the message.
Get Message Details
getMessageDetails(messageId: string): Promise<GetMessageDetailsResponse>
Shows details for a message, by message ID.
Specify the message ID in the messageId
parameter in the URI.
Delete Message
deleteMessage(messageId: string): Promise<any>
Deletes a message, by message ID.
Specify the message ID in the messageId
parameter in the URI.
People
People are registered users of Webex Teams. Searching and viewing People requires an auth token with a scope of spark:people_read
. Viewing the list of all People in your Organization requires an administrator auth token with spark-admin:people_read
scope. Adding, updating, and removing People requires an administrator auth token with the spark-admin:people_write scope.
To learn more about managing people in a room see the Memberships API. For information about how to allocate Hybrid Services licenses to people, see the Managing Hybrid Services guide.
List People
listPeople(query: ListPeopleQuery): Promise<ListPeopleResponse>
List people in your organization. For most users, either the email
or displayName
parameter is required. Admin users can omit these fields and list all users in their organization.
Response properties associated with a user's presence status, such as status
or lastActivity
, will only be displayed for people within your organization or an organization you manage. Presence information will not be shown if the authenticated user has disabled status sharing.
Long result sets will be split into pages.
Create a Person
createPerson(query: CreatePersonQuery): Promise<CreatePersonResponse>
Create a new user account for a given organization. Only an admin can create a new user account.
At least one of the following body parameters is required to create a new user: displayName
, firstName
, lastName
.
Currently, users may have only one email address associated with their account. The emails
parameter is an array, which accepts multiple values to allow for future expansion, but currently only one email address will be used for the new user.
Get Person Details
getPersonDetails(query: GetPersonDetailQuery): Promise<GetPersonDetailResponse>
Shows details for a person, by ID.
Response properties associated with a user's presence status, such as status
or lastActivity
, will only be displayed for people within your organization or an organization you manage. Presence information will not be shown if the authenticated user has disabled status sharing.
Specify the person ID in the personId
parameter in the URI.
Update a Person
updatePerson(personId: string, query: UpdatePersonQuery): Promise<UpdatePersonResponse>
Update details for a person, by ID.
Specify the person ID in the personId
parameter in the URI. Only an admin can update a person details.
Include all details for the person. This action expects all user details to be present in the request. A common approach is to first GET the person's details, make changes, then PUT both the changed and unchanged values.
Delete a Person
deletePerson(personId: string)
Remove a person from the system. Only an admin can remove a person.
Specify the person ID in the personId
parameter in the URI.
Get My Own Details
getMyOwnDetails(): Promise<GetMyOwnDetailsResponse>
Show the profile for the authenticated user. This is the same as GET /people/{personId}
using the Person ID associated with your Auth token.
Rooms
Rooms are virtual meeting places where people post messages and collaborate to get work done. This API is used to manage the rooms themselves. Rooms are created and deleted with this API. You can also update a room to change its title, for example.
To create a team room, specify the a teamId in the POST payload. Note that once a room is added to a team, it cannot be moved. To learn more about managing teams, see the Teams API.
To manage people in a room see the Memberships API.
To post content see the Messages API.
List Rooms
listRooms(query: ListRoomsQuery): Promise<ListRoomsResponse>
The title of the room for 1:1 rooms will be the display name of the other person.
By default, lists rooms to which the authenticated user belongs.
Long result sets will be split into pages.
Create a Room
createRoom(query: CreateRoomQuery): Promise<CreateRoomResponse>
Creates a room. The authenticated user is automatically added as a member of the room. See the Memberships API to learn how to add more people to the room.
To create a 1:1 room, use the Create Messages endpoint to send a message directly to another person by using the toPersonId
or toPersonEmail
parameters.
Get Room Details
getRoomDetails(query: GetRoomDetailsQuery): Promise<GetRoomDetailsResponse>
Shows details for a room, by ID.
The title
of the room for 1:1 rooms will be the display name of the other person.
Specify the room ID in the roomId
parameter in the URI.
Get Room Meeting Details
getRoomMeetingDetails(query: GetRoomMeetingDetailsQuery): Promise<GetRoomMeetingDetailsResponse>
Shows Webex meeting details for a room such as the SIP address, meeting URL, toll-free and toll dial-in numbers.
Specify the room ID in the roomId
parameter in the URI.
Update a Room
updateRoom(query: UpdateRoomQuery): Promise<UpdateRoomResponse>
Updates details for a room, by ID.
Specify the room ID in the roomId
parameter in the URI.
Delete a Room
deleteRoom(query: DeleteRoomQuery): Promise<boolean>
Deletes a room, by ID. Deleted rooms cannot be recovered.
Deleting a room that is part of a team will archive the room instead.
Specify the room ID in the roomId
parameter in the URI.
Return Values
Every endpoint method will return a Promise
. Examples will be available later.