0
mirror of https://github.com/valentineus/iii-client.git synced 2025-06-04 07:03:34 +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
## 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)
Features:
- 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
[![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.
**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
<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>
```
## Using
An example of a connection, receiving session identification and sending a bot message:
```javascript
import client from 'iii-client';
import { connect, send } from 'iii-client';
const uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd';
const text = 'Hello, World!';
var uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd';
var 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));
/* 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
## 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)
Connects to the server and returns the connection data.
<a name="connect"></a>
**Promise**: <code>Object</code> Answer from the server.
**Rejects**: <code>Error</code> If there are errors in operation.
## connect(uuid, callback)
Connection to the service and retrieves the session identifier.
| 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)
Send a message to the server and return a response.
<a name="send"></a>
**Promise**: <code>Object</code> Answer from the server.
**Rejects**: <code>Error</code> If there are errors in operation.
## send(cuid, text, callback)
Sends a message to bot and returns a response.
| Param | Type | Description |
| --- | --- | --- |
| cuid | <code>String</code> | Session identifier. |
| text | <code>String</code> | Message text. |
Found out a mistake or feel a lack of functionality?
[issues](https://github.com/valentineus/iii-client/issues)
| cuid | <code>String</code> | Session ID |
| text | <code>String</code> | Send messages |
| callback | <code>function</code> | Function handler |
## License
[![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",
"version": "2.1.0",
"version": "3.0.0",
"description": "Simple API for communicating with the bot of the \"iii.ru\" service.",
"homepage": "https://github.com/valentineus/iii-client",
"license": "MIT",