Giter VIP home page Giter VIP logo

glip-client's Introduction

Glip Client

This is a simple Glip client implementation. It currently supports the following features:

  • posts
    • send message
    • receive messages in real time
    • monitor message modification and removal in real time
    • get message(s)
  • groups
    • get group(s)/team(s)
    • monitor group events
  • persons
    • get person
  • companies
    • get company

Requirement

Node.js 4.2 as mimimum.

Installation

yarn add glip-client

or

npm install --save glip-client

Usage

Please check the examples.

Here is a code snippet to help you to get started quickly:

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.

glip-client's People

Contributors

pkvenu avatar tylerlong avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.