https://github.com/tylerlong/glip-client
A simple Glip client implementation
https://github.com/tylerlong/glip-client
glip glip-client
Last synced: about 1 month ago
JSON representation
A simple Glip client implementation
- Host: GitHub
- URL: https://github.com/tylerlong/glip-client
- Owner: tylerlong
- Created: 2016-12-14T08:00:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-26T01:25:28.000Z (about 7 years ago)
- Last Synced: 2024-04-26T22:03:29.089Z (about 1 year ago)
- Topics: glip, glip-client
- Language: JavaScript
- Size: 164 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Glip Client
## Deprecation warning
This project has been deprecated. You should use the [official RingCentral JS SDK](https://github.com/ringcentral/ringcentral-js) instead.
This is a simple Glip client implementation. It currently supports the following features:
- [posts](test/posts.js)
- send message
- receive messages in real time
- monitor message modification and removal in real time
- get message(s)
- [groups](test/groups.js)
- get group(s)/team(s)
- monitor group events
- [persons](test/persons.js)
- get person
- [companies](test/companies.js)
- get company## Requirement
Node.js 4.2 as mimimum.
## Installation
```
yarn add glip-client
```or
```
npm install --save glip-client
```## Usage
Please check the [test](examples).
Here is a code snippet to help you to get started quickly:
```javascript
require('dotenv').config()
const GlipClient = require('glip-client')const gc = new GlipClient({
server: process.env.SERVER, // https://platform.ringcentral.com for production or https://platform.devtest.ringcentral.com for sandbox
appKey: process.env.APP_KEY,
appSecret: process.env.APP_SECRET,
appName: 'My Glip Client',
appVersion: '1.0.0'
})
gc.authorize({
username: process.env.USERNAME,
extension: process.env.EXTENSION,
password: process.env.PASSWORD
}).then((response) => {
console.log('logged in')gc.posts().subscribe((message) => {
if (message.messageType === 'PostAdded') { // receive new messages
console.log(message)
if (message.post.text === 'ping') {
gc.posts().post({ groupId: message.post.groupId, text: 'pong' }).then((response) => { // send message
console.log(response)
})
}
} else { // other message events, such as PostChanged and PostRemoved
console.log(message)
}
})gc.posts().get({ groupId: process.env.GROUP }).then((response) => { // get messages by group id
console.log(`${response.records.length} posts were found.`)
})gc.posts().get({ postId: process.env.POST }).then((response) => { // get message by id
console.log(response)
})
})
```## Login Glip to test
For sandbox, please login https://glip.devtest.ringcentral.com/
For production, please login https://app.glip.com/
## Todo
- support batch operations
- postpone, maybe multipart/mixed will be replaced with JSON array.
- Write real unit testing
- Setup Travis CI and Coveralls