wearesho-team / phonet
Phonet Api Integration
Requires
- php: ^7.2
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- horat1us/environment-config: ^1.3
- myclabs/php-enum: ^1.6
- nesbot/carbon: ^1.36
- psr/simple-cache: ^1.0
- wearesho-team/base-collection: ^1.0
Requires (Dev)
- chillerlan/php-cache: ^1.0
- phpunit/phpunit: ^8
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-10-29 05:28:58 UTC
README
You can receive original docs on phonet site
Installation
composer require wearesho-team/phonet
Configuration
Exist two implementation of configurations:
- Config - custom config
- EnvironmentConfig - based on Horatius\Environment\Config
Available environment variables:
Use ConfigInterface to create your custom config
Usage
Provider
To use Phonet api you must authorize to service. For this exist Authorization\ProviderInterface
<?php use Wearesho\Phonet; $client = new \GuzzleHttp\Client(); $provider = new Phonet\Authorization\Provider($client);
If You want cache your auth data use CacheProvider;
Sender
All api methods used Sender
<?php use Wearesho\Phonet; /** @var Phonet\Authorization\ProviderInterface $provider */ $client = new \GuzzleHttp\Client(); $config = new Phonet\EnvironmentConfig(); $sender = new Phonet\Sender( $client, $config, $provider );
Service
makeCall(string $operatorInternalNumber, string $targetNumber): string
Start new call and return unique uuid of it.
<?php use Wearesho\Phonet; /** @var Phonet\Sender $sender */ $service = new Phonet\Service($sender); $uuid = $service->makeCall( $operatorInternalNumber = '001', // Internal number of operator $callTakerNumber = '380000000002' // Phone number of target );
hangupCall(string $uuid): void
End a call / conversation by unique uuid
<?php use Wearesho\Phonet; /** @var Phonet\Sender $sender */ $service = new Phonet\Service($sender); $service->hangupCall( $uuid = 'uuid' );
Repository
Repository contains methods for searching data in Phonet Service.
activeCalls()
Returns collection of calls that currently taking place.
<?php use Wearesho\Phonet; /** @var Phonet\Sender $sender */ $repository = new Phonet\Repository($sender); $activeCalls = $repository->activeCalls();
missedCalls(...)
Returns a collection of calls to call back.
<?php use Wearesho\Phonet; /** @var Phonet\Sender $sender */ $repository = new Phonet\Repository($sender); $missedCalls = $repository->missedCalls( $from = new DateTime(), $to = new DateTime(), $directions = new Phonet\Call\Direction\Collection([/** @see Phonet\Call\Direction */]), $limit = 10, // count of needs calls $offset = 5 // shift in sample );
companyCalls(...)
Returns a collection of calls made by the company.
<?php use Wearesho\Phonet; /** @var Phonet\Sender $sender */ $repository = new Phonet\Repository($sender); $companyCalls = $repository->companyCalls( $from = new DateTime(), $to = new DateTime(), $directions = new Phonet\Call\Direction\Collection([/** @see Phonet\Call\Direction */]), $limit = 10, // count of needs calls $offset = 5 // shift in sample );
usersCalls()
Returns a collection of calls made by employees.
<?php use Wearesho\Phonet; /** @var Phonet\Sender $sender */ $repository = new Phonet\Repository($sender); $usersCalls = $repository->usersCalls( $from = new DateTime(), $to = new DateTime(), $directions = new Phonet\Call\Direction\Collection([/** @see Phonet\Call\Direction */]), $limit = 10, // count of needs calls $offset = 5 // shift in sample );
users()
Returns a collection of employees of company.
<?php use Wearesho\Phonet; /** @var Phonet\Sender $sender */ $repository = new Phonet\Repository($sender); $users = $repository->users();