diff --git a/examples/index.php b/examples/index.php index 74d2be0..7dde567 100644 --- a/examples/index.php +++ b/examples/index.php @@ -25,6 +25,7 @@ // pbx methods $result = $api->getPbxInternal(); $result = $api->getPbxStatus($pbx); +$result = $api->getPbxInfo($pbx); $result = $api->getPbxRecord($callId, null); $result = $api->getPbxRedirection($pbx); diff --git a/lib/Api.php b/lib/Api.php index 9b08b97..d187a68 100644 --- a/lib/Api.php +++ b/lib/Api.php @@ -6,6 +6,7 @@ use Zadarma_API\Response\DirectNumber; use Zadarma_API\Response\IncomingCallsStatistics; use Zadarma_API\Response\NumberLookup; +use Zadarma_API\Response\PbxInfo; use Zadarma_API\Response\PbxInternal; use Zadarma_API\Response\PbxRecording; use Zadarma_API\Response\PbxRecordRequest; @@ -210,6 +211,18 @@ public function getPbxStatus($pbxId) return new PbxStatus($data); } + /** + * Return information about the PBX extension number. + * @param $pbxId + * @return PbxInfo + * @throws ApiException + */ + public function getPbxInfo($pbxId) + { + $data = $this->request('pbx/internal/' . self::filterNumber($pbxId) . '/info'); + return new PbxInfo($data); + } + /** * Return call recording file request. * @param string|null $callId Unique call ID, it is specified in the name of the file with the call @@ -418,11 +431,14 @@ public function setSipRedirectionNumber($sipId, $number) * send the recordings to the email address only, "off_email" - disable the option to send the recordings to the * email address only, "on_store" - enable the option to save the recordings to the cloud, "off_store" - disable the * option to save the recordings to the cloud. - * @param string|null $email + * @param string|null $email (optional) change the email address, where the call recordings will be sent. + * You can specify up to 3 email addresses, separated by comma. + * @param string|null $speechRecognition (optional) change the speech recognition settings: "all" - recognize all, + * "optional" - recognize selectively in statistics, "off" - disable. * @return PbxRecording * @throws ApiException */ - public function setPbxRecording($sipId, $status, $email = null) + public function setPbxRecording($sipId, $status, $email = null, $speechRecognition = null) { if (!in_array($status, ['on', 'off', 'on_email', 'off_email', 'on_store', 'off_store'])) { throw new \BadFunctionCallException('Wrong status parameter'); @@ -434,6 +450,12 @@ public function setPbxRecording($sipId, $status, $email = null) if ($email) { $params['email'] = $email; } + if ($speechRecognition && !in_array($status, ['off', 'off_store'])) { + if (!in_array($speechRecognition, ['all', 'optional', 'off'])) { + throw new \BadFunctionCallException('Wrong speechRecognition parameter'); + } + $params['speech_recognition'] = $speechRecognition; + } $data = $this->request('pbx/internal/recording', $params, 'put'); return new PbxRecording($data); } diff --git a/lib/Response/PbxInfo.php b/lib/Response/PbxInfo.php new file mode 100644 index 0000000..021e1f9 --- /dev/null +++ b/lib/Response/PbxInfo.php @@ -0,0 +1,35 @@ +