Add bird_flash_calls_client implementation with endpoint builder, request schemas, and validator for managing flash call functionality.
This commit is contained in:
@@ -2,12 +2,25 @@
|
||||
|
||||
namespace classes;
|
||||
|
||||
require_once WD . '/interfaces/bird_i.php';
|
||||
require_once WD . '/modules/bird/bird_c.php';
|
||||
require_once WD . '/modules/bird/classes/bird_api_client.php';
|
||||
require_once WD . '/modules/bird/classes/bird_voice_calls_client.php';
|
||||
require_once WD . '/modules/bird/classes/bird_voice_recordings_client.php';
|
||||
require_once WD . '/modules/bird/classes/bird_voice_insights_client.php';
|
||||
require_once WD . '/modules/bird/classes/bird_flash_calls_client.php';
|
||||
|
||||
|
||||
use bird\bird_c;
|
||||
use bird\classes\bird_flash_calls_client;
|
||||
use bird\classes\bird_voice_calls_client;
|
||||
use bird\classes\bird_voice_insights_client;
|
||||
use bird\classes\bird_voice_recordings_client;
|
||||
use Exception;
|
||||
use interfaces\bird_i;
|
||||
use objects\logs_o;
|
||||
|
||||
class bird
|
||||
class bird implements bird_i
|
||||
{
|
||||
public const TEST_OUTBOUND_NUMBER_RAW = '+45 42 33 11 28';
|
||||
public const TEST_OUTBOUND_NUMBER_E164 = '+4542331128';
|
||||
@@ -28,11 +41,48 @@ class bird
|
||||
*/
|
||||
public bird_c $config;
|
||||
|
||||
private ?bird_voice_calls_client $voice_calls_client = null;
|
||||
private ?bird_voice_recordings_client $voice_recordings_client = null;
|
||||
private ?bird_voice_insights_client $voice_insights_client = null;
|
||||
private ?bird_flash_calls_client $flash_calls_client = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = new bird_c();
|
||||
}
|
||||
|
||||
private function voiceCallsClient(): bird_voice_calls_client
|
||||
{
|
||||
if ($this->voice_calls_client === null) {
|
||||
$this->voice_calls_client = new bird_voice_calls_client($this);
|
||||
}
|
||||
return $this->voice_calls_client;
|
||||
}
|
||||
|
||||
private function voiceRecordingsClient(): bird_voice_recordings_client
|
||||
{
|
||||
if ($this->voice_recordings_client === null) {
|
||||
$this->voice_recordings_client = new bird_voice_recordings_client($this);
|
||||
}
|
||||
return $this->voice_recordings_client;
|
||||
}
|
||||
|
||||
private function voiceInsightsClient(): bird_voice_insights_client
|
||||
{
|
||||
if ($this->voice_insights_client === null) {
|
||||
$this->voice_insights_client = new bird_voice_insights_client($this);
|
||||
}
|
||||
return $this->voice_insights_client;
|
||||
}
|
||||
|
||||
private function flashCallsClient(): bird_flash_calls_client
|
||||
{
|
||||
if ($this->flash_calls_client === null) {
|
||||
$this->flash_calls_client = new bird_flash_calls_client($this);
|
||||
}
|
||||
return $this->flash_calls_client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure module is enabled
|
||||
* @throws Exception
|
||||
@@ -279,30 +329,50 @@ class bird
|
||||
|
||||
public function createVoiceCall(string $workspaceId, string $channelId, array $payload): array|object|null
|
||||
{
|
||||
$base = $this->voiceBase($workspaceId, $channelId);
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_CREATE', 'workspace=' . $workspaceId . ' channel=' . $channelId);
|
||||
return $this->sendPostRequest($base, $payload);
|
||||
return $this->voiceCallsClient()->createVoiceCall($workspaceId, $channelId, $payload);
|
||||
}
|
||||
|
||||
public function listVoiceCalls(string $workspaceId, string $channelId, array $query = []): array|object|null
|
||||
{
|
||||
$base = $this->voiceBase($workspaceId, $channelId);
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_LIST', 'workspace=' . $workspaceId . ' channel=' . $channelId);
|
||||
return $this->sendGetRequest($base, $query);
|
||||
return $this->voiceCallsClient()->listVoiceCalls($workspaceId, $channelId, $query);
|
||||
}
|
||||
|
||||
public function getVoiceCall(string $workspaceId, string $channelId, string $callId): array|object|null
|
||||
{
|
||||
$base = $this->voiceBase($workspaceId, $channelId);
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_GET', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->sendGetRequest($base . '/' . rawurlencode($callId));
|
||||
return $this->voiceCallsClient()->getVoiceCall($workspaceId, $channelId, $callId);
|
||||
}
|
||||
|
||||
public function updateVoiceCall(string $workspaceId, string $channelId, string $callId, array $payload): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_UPDATE', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceCallsClient()->updateVoiceCall($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function answerVoiceCall(string $workspaceId, string $channelId, string $callId, array $payload = []): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_ANSWER', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceCallsClient()->answerVoiceCall($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function ringVoiceCall(string $workspaceId, string $channelId, string $callId, array $payload = []): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_RINGING', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceCallsClient()->ringVoiceCall($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function hangupVoiceCall(string $workspaceId, string $channelId, string $callId, array $payload = []): array|object|null
|
||||
{
|
||||
$base = $this->voiceBase($workspaceId, $channelId);
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_HANGUP', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->sendPostRequest($base . '/' . rawurlencode($callId) . '/hangup', $payload);
|
||||
return $this->voiceCallsClient()->hangupVoiceCall($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function playbackVoiceCall(string $workspaceId, string $channelId, string $callId, array $payload): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_PLAYBACK', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceCallsClient()->playbackVoiceCall($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function sayMessage(string $workspaceId, string $channelId, string $callId, array $payload): array|object|null
|
||||
@@ -330,7 +400,7 @@ class bird
|
||||
'timeout' => 1,
|
||||
...$payload,
|
||||
];
|
||||
return $this->sendPostRequest($this->sayBase($workspaceId, $channelId, $callId), $tmp);
|
||||
return $this->voiceCallsClient()->sayVoiceCall($workspaceId, $channelId, $callId, $tmp);
|
||||
}
|
||||
|
||||
public function gatherMessage(string $workspaceId, string $channelId, string $callId, array $payload): array|object|null
|
||||
@@ -383,7 +453,55 @@ class bird
|
||||
'input' => 'dtmf',
|
||||
...$payload,
|
||||
];
|
||||
return $this->sendPostRequest($this->gatherBase($workspaceId, $channelId, $callId), $tmp);
|
||||
return $this->voiceCallsClient()->gatherVoiceCall($workspaceId, $channelId, $callId, $tmp);
|
||||
}
|
||||
|
||||
public function bridgeVoiceCall(string $workspaceId, string $channelId, string $callId, array $payload): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_BRIDGE', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceCallsClient()->bridgeVoiceCall($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function recordVoiceCall(string $workspaceId, string $channelId, string $callId, array $payload): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_RECORD', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceCallsClient()->recordVoiceCall($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function createVoiceCallRecordingSession(string $workspaceId, string $channelId, string $callId, array $payload): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_RECORDING_CREATE', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceRecordingsClient()->createVoiceCallRecordingSession($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function listVoiceCallRecordings(string $workspaceId, string $channelId, string $callId, array $query = []): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_RECORDING_LIST', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceRecordingsClient()->listVoiceCallRecordings($workspaceId, $channelId, $callId, $query);
|
||||
}
|
||||
|
||||
public function getVoiceCallRecording(string $workspaceId, string $channelId, string $callId, string $recordingId): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_RECORDING_GET', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId . ' recording=' . $recordingId);
|
||||
return $this->voiceRecordingsClient()->getVoiceCallRecording($workspaceId, $channelId, $callId, $recordingId);
|
||||
}
|
||||
|
||||
public function updateVoiceCallRecording(string $workspaceId, string $channelId, string $callId, string $recordingId, array $payload): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_RECORDING_UPDATE', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId . ' recording=' . $recordingId);
|
||||
return $this->voiceRecordingsClient()->updateVoiceCallRecording($workspaceId, $channelId, $callId, $recordingId, $payload);
|
||||
}
|
||||
|
||||
public function getVoiceCallInsights(string $workspaceId, string $channelId, string $callId): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_INSIGHTS_GET', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->voiceInsightsClient()->getVoiceCallInsights($workspaceId, $channelId, $callId);
|
||||
}
|
||||
|
||||
public function getVoiceCallsLog(string $workspaceId, array $query = []): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_VOICE_CALL_LOG_LIST', 'workspace=' . $workspaceId);
|
||||
return $this->voiceInsightsClient()->getVoiceCallsLog($workspaceId, $query);
|
||||
}
|
||||
|
||||
public function listNumbers(string $workspaceId, array $query = []): array|object|null
|
||||
@@ -406,16 +524,32 @@ class bird
|
||||
|
||||
public function createFlashCall(string $workspaceId, string $channelId, array $payload): array|object|null
|
||||
{
|
||||
$base = $this->flashBase($workspaceId, $channelId);
|
||||
$this->logBirdAction('BIRD_FLASH_CALL_CREATE', 'workspace=' . $workspaceId . ' channel=' . $channelId);
|
||||
return $this->sendPostRequest($base, $payload);
|
||||
return $this->flashCallsClient()->createFlashCall($workspaceId, $channelId, $payload);
|
||||
}
|
||||
|
||||
public function listFlashCalls(string $workspaceId, string $channelId, array $query = []): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_FLASH_CALL_LIST', 'workspace=' . $workspaceId . ' channel=' . $channelId);
|
||||
return $this->flashCallsClient()->listFlashCalls($workspaceId, $channelId, $query);
|
||||
}
|
||||
|
||||
public function getFlashCall(string $workspaceId, string $channelId, string $callId): array|object|null
|
||||
{
|
||||
$base = $this->flashBase($workspaceId, $channelId);
|
||||
$this->logBirdAction('BIRD_FLASH_CALL_GET', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->sendGetRequest($base . '/' . rawurlencode($callId));
|
||||
return $this->flashCallsClient()->getFlashCall($workspaceId, $channelId, $callId);
|
||||
}
|
||||
|
||||
public function endFlashCall(string $workspaceId, string $channelId, string $callId, array $payload = []): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_FLASH_CALL_END', 'workspace=' . $workspaceId . ' channel=' . $channelId . ' call=' . $callId);
|
||||
return $this->flashCallsClient()->endFlashCall($workspaceId, $channelId, $callId, $payload);
|
||||
}
|
||||
|
||||
public function hangupFlashCall(string $workspaceId, string $channelId, array $payload = []): array|object|null
|
||||
{
|
||||
$this->logBirdAction('BIRD_FLASH_CALL_HANGUP', 'workspace=' . $workspaceId . ' channel=' . $channelId);
|
||||
return $this->flashCallsClient()->hangupFlashCall($workspaceId, $channelId, $payload);
|
||||
}
|
||||
|
||||
public function createOutboundTestCallAndHangupWhenAccepted(string $workspaceId, string $channelId, array $options = []): array
|
||||
|
||||
Reference in New Issue
Block a user