rc-api
Functions to call the Rocket.Chat API
Last updated 6 months ago by jschirrmacher .
MIT · Original npm · Tarball · package.json
$ cnpm install rc-api 
SYNC missed versions from official npm registry.

A Library to access the Rocket.Chat API via functions.

Installation

npm i -S rc-api

Usage

If you, for example, want to assign the pin-message permission to the user role, you can do the following:

const RCApi = require('rc-api');
const api = new RCApi({logger: console, dryRun: false});

api.permissions.addPermission({
    client: {
        url: 'https://my-chat.example.com',
        username: 'admin-user',
        passw: 'my-secret-password'
    },
    permission: 'pin-message',
    role: 'user'
});

The client object, which is given to the API functions, will be modified to contain the access token after the first call which is used in later calls as well. So it is a good idea to re-use the same object, if you do more than one API call.

Options to rc-api constructor

  • logger - the logger you want to use. Defaults to console
  • dryRun - if set true, all API calls are replaced by GET methods

Which API paths are supported?

Currently only those Rocket.Chat API paths are covered, that we needed for our use case, but we would be pleased to receive your PR, if you want to enhance this library. For now, RTFS to know which paths are supported :-)

Current Tags

  • 2.0.0                                ...           latest (6 months ago)

2 Versions

  • 2.0.0                                ...           6 months ago
  • 1.0.0                                ...           6 months ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 3
Dependencies (2)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |