wearesho-team / evrotel
This package is abandoned and no longer maintained.
No replacement package was suggested.
Evrotel API Integration
6.0.0
2019-07-07 20:56 UTC
Requires
- php: >=7.2
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- horat1us/environment-config: ^1.2
- nesbot/carbon: ^1.30
- wearesho-team/base-collection: ^1.0
Requires (Dev)
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ^3.3
- dev-master
- 6.0.0
- 5.0.0
- 4.0.0
- 3.0.0
- 2.0.0
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-RC1
- dev-feature/autodial-disposition
- dev-feature/cghooks
- dev-hotfix/beautify-test-configs
- dev-hotfix/functions-lookup-optimize
- dev-hotfix/receiver-request-validation-optimize
- dev-hotfix/receiver-request-optimize
- dev-hotfix/receiver-optimization
This package is auto-updated.
Last update: 2020-07-03 07:54:58 UTC
README
This library created using API Docs
Installation
composer require wearesho-team/evrotel
Usage
Configuration
You can use Config to configure app. Also, Environment Config available:
- EVROTEL_TOKEN, string - token received from Evrotel manager
- EVROTEL_BILL_CODE, integer - bill code received from Evrotel manager
- EVROTEL_BASE_URL, string, default
http://m01.sipiko.net/
- base url for statistics files - EVROTEL_AUTO_DIAL_URL, string, default
https://autodial.evro-tel.com.ua/autodialapi/call_worker_api.php
, url for auto dial requests.
Statistics
You can use Config to configure statistics client. Also, Environment Config available:
- EVROTEL_STATISTICS_BASE_URL, string, default
https://callme.sipiko.net/
- base url for statistics requests - EVROTEL_STATISTICS_AUTODIAL_NUMBER, string, default
null
- if specified, all statistics call with samefrom
will be marked as auto dials.
Receiver
<?php use Wearesho\Evrotel; /** @var Evrotel\ConfigInterface $config */ $receiver = new Evrotel\Receiver($config); try { $request = $receiver->getRequest(); if($request instanceof Evrotel\Receiver\Request\Start) { /** * You have to return ID in response body * to receive it in call end request */ return 1; } elseif ($request instanceof Evrotel\Receiver\Request\End) { // Do something with call end request return; } } catch (Evrotel\Exceptions\AccessDenied $denied) { // Return 403 } catch(Evrotel\Exceptions\BadRequest $badRequest) { // Return 400 }
Auto Dial
Before call initiating you need to push media file
<?php use Wearesho\Evrotel; /** @var Evrotel\ConfigInterface $config */ /** @var GuzzleHttp\Client $client */ $repository = new Evrotel\AutoDial\MediaRepository($config, $client); $link = 'https://server.com/file.wav'; // Public link to auto dial file, Mono, 16 Bits,8000Hz, wav try { $fileName = $repository->push($link); } catch(Evrotel\Exceptions\AutoDial\PushMedia $media) { // handle errors }
After pushing media you can use your file to make dials:
<?php use Wearesho\Evrotel; /** @var Evrotel\ConfigInterface $config */ /** @var GuzzleHttp\Client $client */ $worker = new Evrotel\AutoDial\Worker($config, $client); /** @var string $fileName returned from MediaRepository */ /** @var string $phone in format 380XXXXXXXXX */ $request = new Evrotel\AutoDial\Request($fileName, $phone); $worker->push($request);
Statistics
<?php use Wearesho\Evrotel; $baseConfig = new Evrotel\Config($token = 'token', $billCode = 6667); $config = new Evrotel\Statistics\Config; /** @var GuzzleHttp\Client $guzzle */ $client = new Evrotel\Statistics\Client($baseConfig, $config, $guzzle); $client->getCalls($isAuto = true);
See Statistics\Call for details.
Initializer
To initialize call you need to use Initializer\Client.
<?php use Wearesho\Evrotel; /** @var Evrotel\Config $config */ /** @var GuzzleHttp\Client $guzzle */ $client = new Evrotel\Initializer\Client($config, $guzzle); $operators = [ '101', '102', ]; try { $client->start('380970000000', $operators); } catch(\RuntimeException $exception) { // Evrotel returned `bad` response }