Skip to content

wearesho-team/evrotel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Evrotel API Integration

Build Status codecov

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 same from 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
}

Contributors

License

MIT