Add callback for phone calls, not tested yet

This commit is contained in:
osaajani 2021-03-23 17:39:13 +01:00
parent 52a0302dc2
commit 41c3b3b86e
13 changed files with 378 additions and 57 deletions

View file

@ -92,6 +92,16 @@ interface AdapterInterface
* Does the implemented service support mms sending
*/
public static function meta_support_mms_sending(): bool;
/**
* Does the implemented service support inbound call callback
*/
public static function meta_support_inbound_call_callback(): bool;
/**
* Does the implemented service support end call callback
*/
public static function meta_support_end_call_callback(): bool;
/**
* Method called to send a SMS to a number.
@ -162,4 +172,35 @@ interface AdapterInterface
* ]
*/
public static function reception_callback(): array;
/**
* Method called on reception of an inbound_call notification
*
* @return array : [
* bool 'error' => false on success, true on error
* ?string 'error_message' => null on success, error message else
* array 'call' => array [
* string 'uid' : Uid of the call on the adapter plateform
* string 'start' : Start of the call date format Y-m-d H:i:s,
* ?string 'end' : End of the call date format Y-m-d H:i:s. If no known end, NULL
* string 'origin' : Emitter phone call number. International format.
* ]
* ]
*/
public function inbound_call_callback(): array;
/**
* Method called on reception of a end call notification
*
* @return array : [
* bool 'error' => false on success, true on error
* ?string 'error_message' => null on success, error message else
* array 'call' => array [
* string 'uid' : Uid of the call on the adapter plateform. Used to find the raspisms local call to update.
* string 'end' : End of the call date format Y-m-d H:i:s.
* ]
* ]
*/
public function end_call_callback(): array;
}

View file

@ -141,6 +141,16 @@ namespace adapters;
{
return false;
}
public static function meta_support_inbound_call_callback(): bool
{
return false;
}
public static function meta_support_end_call_callback(): bool
{
return false;
}
public function send(string $destination, string $text, bool $flash = false, bool $mms = false, array $medias = []) : array
{
@ -220,4 +230,14 @@ namespace adapters;
{
return true;
}
public function inbound_call_callback(): array
{
return [];
}
public function end_call_callback(): array
{
return [];
}
}

View file

@ -151,6 +151,16 @@ namespace adapters;
{
return false;
}
public static function meta_support_inbound_call_callback(): bool
{
return false;
}
public static function meta_support_end_call_callback(): bool
{
return false;
}
public function send(string $destination, string $text, bool $flash = false, bool $mms = false, array $medias = []) : array
{
@ -296,6 +306,16 @@ namespace adapters;
{
return [];
}
public function inbound_call_callback(): array
{
return [];
}
public function end_call_callback(): array
{
return [];
}
/**
* Function to unlock pin.

View file

@ -188,6 +188,16 @@ class OctopushShortcodeAdapter implements AdapterInterface
{
return false;
}
public static function meta_support_inbound_call_callback(): bool
{
return false;
}
public static function meta_support_end_call_callback(): bool
{
return false;
}
public function send(string $destination, string $text, bool $flash = false, bool $mms = false, array $medias = []) : array
{
@ -407,4 +417,14 @@ class OctopushShortcodeAdapter implements AdapterInterface
return $response;
}
public function inbound_call_callback(): array
{
return [];
}
public function end_call_callback(): array
{
return [];
}
}

View file

@ -193,6 +193,16 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
{
return false;
}
public static function meta_support_inbound_call_callback(): bool
{
return false;
}
public static function meta_support_end_call_callback(): bool
{
return false;
}
public function send(string $destination, string $text, bool $flash = false, bool $mms = false, array $medias = []) : array
{
@ -407,4 +417,14 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
return $response;
}
public function inbound_call_callback(): array
{
return [];
}
public function end_call_callback(): array
{
return [];
}
}

View file

@ -185,6 +185,16 @@ namespace adapters;
{
return false;
}
public static function meta_support_inbound_call_callback(): bool
{
return false;
}
public static function meta_support_end_call_callback(): bool
{
return false;
}
public function send(string $destination, string $text, bool $flash = false, bool $mms = false, array $medias = []) : array
{
@ -359,4 +369,14 @@ namespace adapters;
{
return [];
}
public function inbound_call_callback(): array
{
return [];
}
public function end_call_callback(): array
{
return [];
}
}

View file

@ -196,6 +196,16 @@ namespace adapters;
{
return false;
}
public static function meta_support_inbound_call_callback(): bool
{
return false;
}
public static function meta_support_end_call_callback(): bool
{
return false;
}
public function send(string $destination, string $text, bool $flash = false, bool $mms = false, array $medias = []) : array
{
@ -358,4 +368,14 @@ namespace adapters;
{
return [];
}
public function inbound_call_callback(): array
{
return [];
}
public function end_call_callback(): array
{
return [];
}
}

View file

@ -146,6 +146,16 @@ namespace adapters;
{
return true;
}
public static function meta_support_inbound_call_callback(): bool
{
return false;
}
public static function meta_support_end_call_callback(): bool
{
return false;
}
public function send(string $destination, string $text, bool $flash = false, bool $mms = false, array $medias = []) : array
{
@ -272,4 +282,58 @@ namespace adapters;
{
return [];
}
public function inbound_call_callback(): array
{
$response = [
'error' => false,
'error_message' => null,
'call' => [],
];
$uid = $_POST['uid'] ?? false;
$start = $_POST['start'] ?? false;
$end = $_POST['end'] ?? null;
$origin = $_POST['origin'] ?? false;
if (!$uid || !$start || !$origin)
{
$response['error'] = true;
$response['error_message'] = 'Missing required argument.';
return $response;
}
$response['call']['uid'] = $uid;
$response['call']['start'] = $start;
$response['call']['end'] = $end;
$response['call']['origin'] = $origin;
return $response;
}
public function end_call_callback(): array
{
$response = [
'error' => false,
'error_message' => null,
'call' => [],
];
$uid = $_POST['uid'] ?? false;
$end = $_POST['end'] ?? null;
if (!$uid || !$end)
{
$response['error'] = true;
$response['error_message'] = 'Missing required argument.';
return $response;
}
$response['call']['uid'] = $uid;
$response['call']['end'] = $end;
return $response;
}
}

View file

@ -190,6 +190,16 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
{
return false;
}
public static function meta_support_inbound_call_callback(): bool
{
return false;
}
public static function meta_support_end_call_callback(): bool
{
return false;
}
public function send(string $destination, string $text, bool $flash = false, bool $mms = false, array $medias = []) : array
{
@ -336,4 +346,14 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
{
return [];
}
public function inbound_call_callback(): array
{
return [];
}
public function end_call_callback(): array
{
return [];
}
}