Phonet Api Integration

1.0.1 2019-04-01 18:16 UTC

README

You can receive original docs on phonet site

Installation

composer require wearesho-team/phonet

Configuration

Exist two implementation of configurations:

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();

Authors

License

MIT