From d27bc8b359d3c52488c5ba5d01d00a8c0dedb5ff Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 29 Sep 2017 01:09:32 +0400 Subject: Release of version 3.0.0. --- README.md | 115 +++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 38 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index c673c29..629aac4 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,41 @@ # III Client -[![npm](https://img.shields.io/npm/v/iii-client.svg)](https://www.npmjs.com/package/iii-client) +

+ + NPM + + + Build Status + + + Codacy Badge + + + Codacy Coverage Badge + + + devDependencies Status + +

+

+ + libhive Badge + + + RunKit Badge + + + Gitter Badge + +

Simple API for communicating with the bot of the \"iii.ru\" service. -**Attention!** At the moment there are difficulties with the `iii.ru` service, there is a possibility that the service will not be restored. All information on the company's -[forum](http://forum.iii.ru/index.php?showtopic=19886). - ## Features - A small and light library. -- Receiving and sending messages. -- Installation and processing of sessions. +- Works, both in NodeJS, and in the browser. +- Getting session ID. +- Sending and receiving messages. +- Does not process incoming errors. ## Installation NodeJS: @@ -20,55 +46,68 @@ npm install --save iii-client Browser: ```html ``` ## Using An example of a connection, receiving session identification and sending a bot message: ```javascript -import client from 'iii-client'; - -const uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd'; -const text = 'Hello, World!'; - -// We connect to the system and get a session -client.connect(uuid).then(session => { - // Send the message and process the response - client.send(session.cuid, text).then(answer => { - console.info(answer); - }); -}).catch(error => console.error(error.message)); +import { connect, send } from 'iii-client'; + +var uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd'; +var text = 'Hello, World!'; + +/* We connect to the system and get a session */ +connect(uuid, (request) => { + console.info(`Session: ${request}`); + /* Send the message and process the response */ + if (request.result) { + var cuid = request.result.cuid; + send(cuid, text, (answer) => { + console.info(`Answer: ${answer}`); + }); + } +}); ``` ## API -### Functions - -#### connect(uuid) -Connects to the server and returns the connection data. - -**Promise**: Object Answer from the server. - -**Rejects**: Error If there are errors in operation. +## Functions +
+
+ connect(uuid, callback) +
+
+

Connection to the service and retrieves the session identifier.

+
+
+ send(cuid, text, callback) +
+
+

Sends a message to bot and returns a response.

+
+
+ + + +## connect(uuid, callback) +Connection to the service and retrieves the session identifier. | Param | Type | Description | | --- | --- | --- | -| uuid | String | The bot ID. | - -#### send(cuid, text) -Send a message to the server and return a response. +| uuid | String | Bot ID | +| callback | function | Function handler | -**Promise**: Object Answer from the server. + -**Rejects**: Error If there are errors in operation. +## send(cuid, text, callback) +Sends a message to bot and returns a response. | Param | Type | Description | | --- | --- | --- | -| cuid | String | Session identifier. | -| text | String | Message text. | - -Found out a mistake or feel a lack of functionality? -[issues](https://github.com/valentineus/iii-client/issues) +| cuid | String | Session ID | +| text | String | Send messages | +| callback | function | Function handler | ## License [![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/eslint/eslint) -- cgit v1.2.3