From 37840bcb7d0448e4c07f715509cdaced2cb554f6 Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Fri, 28 Jun 2019 14:15:30 +0300 Subject: [PATCH] update readme --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 097ed4b..e8212cd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,63 @@ -# mg-bot-api-client-php -PHP client for MG Bot API +[![Build Status](https://img.shields.io/travis/retailcrm/mg-bot-api-client-php/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/mg-bot-api-client-php) +[![Latest stable](https://img.shields.io/packagist/v/retailcrm/mg-bot-api-client-php.svg?style=flat-square)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php) +[![PHP from Packagist](https://img.shields.io/packagist/php-v/mg-bot-retailcrm/api-client-php.svg?style=flat-square)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php) + + +# retailCRM API PHP client + +This is php retailCRM MG Bot API client. + +## Requirements + +* PHP 7.0 and above +* PHP's cURL support +* PHP's JSON support + +## Install + +1) Get [composer](https://getcomposer.org/download/) + +2) Run into your project directory: +```bash +composer require retailcrm/mg-bot-api-client-php ~1.0 +``` + +If you have not used `composer` before, include autoloader into your project. +```php +require 'path/to/vendor/autoload.php'; +``` + +## Usage + +### Assign dialog +```php +use \RetailCrm\Mg\Bot\Client; +use \RetailCrm\Mg\Bot\Model\Request\DialogAssignRequest; + +$client = new Client('https://mg.url.demo', 'T9DMPvuNt7FQJMszHUd', true); + +try { + $request = new DialogAssignRequest(); + $request->setDialogId(60); + $request->setUserId(4); + + $response = $client->dialogAssign($request); +} catch (\RetailCrm\Exception\CurlException $exception) { + echo $exception->getMessage(); +} catch (\RetailCrm\Exception\LimitException $exception) { + echo $exception->getMessage(); +} catch (\InvalidArgumentException $exception) { + echo $exception->getMessage(); +} catch (\Exception $exception) { + echo $exception->getMessage(); +} + +if ($response->isSuccessful()) { + $response->getPreviousResponsible(); +} +``` + +### Documentation + +* [English](http://www.retailcrm.pro/docs/Developers/Index) +* [Russian](https://139810.selcdn.ru/download/doc/mg-bot-api/bot.v1.en.html) \ No newline at end of file