Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support speech recognition and sms events #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
use Zadarma_API\Webhook\NotifyOutStart;
use Zadarma_API\Webhook\NotifyRecord;
use Zadarma_API\Webhook\NotifyStart;
use Zadarma_API\Webhook\NotifySpeechRecognition;
use Zadarma_API\Webhook\NotifySms;

class Api extends Client
{
Expand Down Expand Up @@ -694,6 +696,14 @@ public function getWebhookEvent($eventFilter = null, $postData = null, $signatur
$notify = new NotifyRecord($postData);
break;

case AbstractNotify::EVENT_SPEECH_RECOGNITION:
$notify = new NotifySpeechRecognition($postData);
break;

case AbstractNotify::EVENT_SMS:
$notify = new NotifySms($postData);
break;

default:
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Webhook/AbstractNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ abstract class AbstractNotify extends \Zadarma_API\Response\Response
const EVENT_OUT_END = 'NOTIFY_OUT_END';
const EVENT_RECORD = 'NOTIFY_RECORD';
const EVENT_IVR = 'NOTIFY_IVR';
const EVENT_SPEECH_RECOGNITION = 'SPEECH_RECOGNITION';
const EVENT_SMS = 'SMS';

public $event;

Expand Down
23 changes: 23 additions & 0 deletions lib/Webhook/NotifySms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Zadarma_API\Webhook;

class NotifySms extends AbstractNotify
{
/** @var string the sender's phone number */
public $caller_id;

/** @var string the receiver's phone number */
public $caller_did;

/** @var string text message */
public $text;

/** @var array text message */
public $result;

public function getSignatureString()
{
return $this->result;
}
}
26 changes: 26 additions & 0 deletions lib/Webhook/NotifySpeechRecognition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Zadarma_API\Webhook;

class NotifySpeechRecognition extends AbstractNotify
{
/** @var string language */
public $lang;

/** @var string recording filename */
public $call_id;

/** @var string the call ID */
public $pbx_call_id;

/** @var string optional flag meaning recording is voicemail */
public $voicemail;

/** @var array recognition result */
public $result;

public function getSignatureString()
{
return $this->result;
}
}