talkjs-node
A Node.js wrapper for the talkjs rest api
Last updated 6 months ago by kevlened .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install talkjs-node 
SYNC missed versions from official npm registry.

talkjs-node

A Node.js wrapper for the talkjs rest api

Install

This library is compatible with Node v10+

npm i talkjs-node

# or

yarn add talkjs-node

Usage

const {TalkJS} = require('talkjs-node');
// or
import {TalkJS} from 'talkjs-node';

const client = new TalkJS({
    appId: 'YOUR_APP_ID',
    apiKey: 'YOUR_API_KEY'
});

(async function main() {
    // List all the users
    for await (const user of client.users.list()) {
        console.log(user.name);
    }
})();

A oneOnOneId generator using the TalkJS recommendation is included to generate a predictable conversation id for two participants.

const {oneOnOneId} = require('talkjs-node');
// or
import {oneOnOneId} from 'talkjs-node';

console.log(oneOnOneId('userId1', 'userId2'));

Methods

The methods match those provided by the TalkJS REST api.

  • oneOnOneId(userId1: string, userId2: string)
  • client.import.conversations.messages({conversationId: string, messages: Array<Message>})
  • client.users.create(userId: string, user: User)
  • client.users.get(userId: string)
  • client.users.update(userId: string, user: User)
  • client.users.list({limit?: number, isOnline?: boolean, startingAfter?: string})
  • client.users.sessions.list({userId: string})
  • client.users.conversations.list({userId: string, limit?: number, startingAfter?: string, lastMessageAfter?: number, lastMessageBefore?: number, unreadsOnly?: boolean})
  • client.conversations.create(conversationId: string, conversation: Conversation)
  • client.conversations.get(conversationId: string)
  • client.conversations.update(conversationId: string, conversation: Conversation)
  • client.conversations.list({limit?: number, startingAfter?: string, lastMessageAfter?: number, lastMessageBefore?: number, filter?: Map<string, any>})
  • client.conversations.notifications.send(conversationId: string, notification: Notification)
  • client.conversations.messages.send({conversationId: string, messages: Array<Message>})
  • client.conversations.messages.get(conversationId: string, messageId: string)
  • client.conversations.messages.update(conversationId: string)
  • client.conversations.messages.list({conversationId: string})
  • client.conversations.participants.add({conversationId: string, userId: string, details: Map<string, any>})
  • client.conversations.participants.update({conversationId: string, userId: string, details: Map<string, any>})
  • client.conversations.participants.remove({conversationId: string, userId: string})

License

MIT

Current Tags

  • 0.2.5                                ...           latest (6 months ago)

10 Versions

  • 0.2.5                                ...           6 months ago
  • 0.2.4                                ...           a year ago
  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |