0
mirror of https://github.com/valentineus/iii-client.git synced 2025-06-05 07:13:35 +03:00

Release of version 3.0.0.

This commit is contained in:
Valentin Popov 2017-09-29 01:09:32 +04:00
parent 459ab8bae6
commit d27bc8b359
3 changed files with 80 additions and 35 deletions

View File

@ -1,4 +1,10 @@
# Description of releases # Description of releases
## 3.0.0 (29-09-2017)
Features:
- Full code refactoring.
- Added testing system.
- Return to the callbacks and the rejection of Promise in favor of simplicity and lightness.
## 2.1.0 (28-09-2017) ## 2.1.0 (28-09-2017)
Features: Features:
- The assembly system has been reworked, now the package is being assembled for use in browsers. - The assembly system has been reworked, now the package is being assembled for use in browsers.

107
README.md
View File

@ -1,15 +1,41 @@
# III Client # III Client
[![npm](https://img.shields.io/npm/v/iii-client.svg)](https://www.npmjs.com/package/iii-client) <p align="justify">
<a href="https://www.npmjs.com/package/iii-client">
<img alt="NPM" src="https://img.shields.io/npm/v/iii-client.svg">
</a>
<a href="https://travis-ci.org/valentineus/iii-client">
<img alt="Build Status" src="https://travis-ci.org/valentineus/iii-client.svg?branch=master">
</a>
<a href="https://www.codacy.com/app/valentineus/iii-client">
<img alt="Codacy Badge" src="https://api.codacy.com/project/badge/Grade/81b2fdc2f5dd42a6bdc8fdb43640b282">
</a>
<a href="https://www.codacy.com/app/valentineus/iii-client/files">
<img alt="Codacy Coverage Badge" src="https://api.codacy.com/project/badge/Coverage/81b2fdc2f5dd42a6bdc8fdb43640b282">
</a>
<a href="https://david-dm.org/valentineus/iii-client?type=dev">
<img alt="devDependencies Status" src="https://david-dm.org/valentineus/iii-client/dev-status.svg">
</a>
</p>
<p align="justify">
<a href="https://www.libhive.com/providers/npm/packages/iii-client">
<img alt="libhive Badge" src="https://www.libhive.com/providers/npm/packages/iii-client/examples/badge.svg">
</a>
<a href="https://runkit.com/npm/iii-client">
<img alt="RunKit Badge" src="https://badge.runkitcdn.com/stripe.svg">
</a>
<a href="https://gitter.im/iii-client">
<img alt="Gitter Badge" src="https://badges.gitter.im/Join%20Chat.svg">
</a>
</p>
Simple API for communicating with the bot of the \"iii.ru\" service. 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 ## Features
- A small and light library. - A small and light library.
- Receiving and sending messages. - Works, both in NodeJS, and in the browser.
- Installation and processing of sessions. - Getting session ID.
- Sending and receiving messages.
- Does not process incoming errors.
## Installation ## Installation
NodeJS: NodeJS:
@ -20,55 +46,68 @@ npm install --save iii-client
Browser: Browser:
```html ```html
<script src="https://unpkg.com/iii-client@latest/dist/bundle.js"> <script src="https://unpkg.com/iii-client@latest/dist/bundle.js">
/* client - This is the global name for accessing the package */ /* iiiClient - This is the global name for accessing the package */
</script> </script>
``` ```
## Using ## Using
An example of a connection, receiving session identification and sending a bot message: An example of a connection, receiving session identification and sending a bot message:
```javascript ```javascript
import client from 'iii-client'; import { connect, send } from 'iii-client';
const uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd'; var uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd';
const text = 'Hello, World!'; var text = 'Hello, World!';
// We connect to the system and get a session /* We connect to the system and get a session */
client.connect(uuid).then(session => { connect(uuid, (request) => {
// Send the message and process the response console.info(`Session: ${request}`);
client.send(session.cuid, text).then(answer => { /* Send the message and process the response */
console.info(answer); if (request.result) {
}); var cuid = request.result.cuid;
}).catch(error => console.error(error.message)); send(cuid, text, (answer) => {
console.info(`Answer: ${answer}`);
});
}
});
``` ```
## API ## API
### Functions ## Functions
<dl>
<dt>
<a href="#connect">connect(uuid, callback)</a>
</dt>
<dd>
<p>Connection to the service and retrieves the session identifier.</p>
</dd>
<dt>
<a href="#send">send(cuid, text, callback)</a>
</dt>
<dd>
<p>Sends a message to bot and returns a response.</p>
</dd>
</dl>
#### connect(uuid) <a name="connect"></a>
Connects to the server and returns the connection data.
**Promise**: <code>Object</code> Answer from the server. ## connect(uuid, callback)
Connection to the service and retrieves the session identifier.
**Rejects**: <code>Error</code> If there are errors in operation.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |
| uuid | <code>String</code> | The bot ID. | | uuid | <code>String</code> | Bot ID |
| callback | <code>function</code> | Function handler |
#### send(cuid, text) <a name="send"></a>
Send a message to the server and return a response.
**Promise**: <code>Object</code> Answer from the server. ## send(cuid, text, callback)
Sends a message to bot and returns a response.
**Rejects**: <code>Error</code> If there are errors in operation.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |
| cuid | <code>String</code> | Session identifier. | | cuid | <code>String</code> | Session ID |
| text | <code>String</code> | Message text. | | text | <code>String</code> | Send messages |
| callback | <code>function</code> | Function handler |
Found out a mistake or feel a lack of functionality?
[issues](https://github.com/valentineus/iii-client/issues)
## License ## License
[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/eslint/eslint) [![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/eslint/eslint)

View File

@ -1,6 +1,6 @@
{ {
"name": "iii-client", "name": "iii-client",
"version": "2.1.0", "version": "3.0.0",
"description": "Simple API for communicating with the bot of the \"iii.ru\" service.", "description": "Simple API for communicating with the bot of the \"iii.ru\" service.",
"homepage": "https://github.com/valentineus/iii-client", "homepage": "https://github.com/valentineus/iii-client",
"license": "MIT", "license": "MIT",