1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
transportaudiocall.php
См. документацию.
1<?php
8
9namespace Bitrix\Sender\Integration\VoxImplant;
10
11use Bitrix\Main\Localization\Loc;
12use Bitrix\Main\Web\HttpClient;
13
14use Bitrix\Sender\Message;
15use Bitrix\Sender\Transport;
16use Bitrix\Sender\Recipient;
17
18Loc::loadMessages(__FILE__);
19
25{
26 const CODE = self::CODE_AUDIO_CALL;
27
29 protected $configuration;
30
32 protected $limiter;
33
35 protected $httpClient = array();
36
37 public function __construct()
38 {
39 $this->configuration = new Message\Configuration();
40 }
41
47 public function getName()
48 {
49 return Loc::getMessage('SENDER_INTEGRATION_AUDIOCALL_TRANSPORT_NAME');
50 }
51
57 public function getCode()
58 {
59 return self::CODE;
60 }
61
68 {
69 return array(Recipient\Type::PHONE);
70 }
71
77 public function loadConfiguration()
78 {
80 }
81
89 {
90 $this->configuration = $configuration;
91 }
92
97 public function start()
98 {
99 $clientOptions = array(
100 'waitResponse' => false,
101 'socketTimeout' => 5,
102 );
103 $this->httpClient = new HttpClient($clientOptions);
104 $this->httpClient->setTimeout(1);
105 }
106
116 public function send(Message\Adapter $message)
117 {
118 $outputNumber = $message->getConfiguration()->get('OUTPUT_NUMBER');
119 $number = $message->getTo();
120 $fileJson = $message->getConfiguration()->get('AUDIO_FILE');
121
122 $audio = (new Audio())
123 ->withJsonString($fileJson)
124 ->withMessageCode($message->getCode());
125
126 $callId = Service::sendFile(
127 $outputNumber,
128 $number,
129 $audio->getFileUrl(true)
130 );
131
132 if ($callId && $message->getRecipientId())
133 {
134 CallLogTable::add(array(
135 'CALL_ID' => $callId,
136 'RECIPIENT_ID' => $message->getRecipientId()
137 ));
138 }
139
140 return !!$callId;
141 }
142
147 public function end()
148 {
149
150 }
151
160 public function getDuration(Message\Adapter $message = null)
161 {
162 $length = 0;
163 $fileJson = $message->getConfiguration()->get('AUDIO_FILE');
164 if ($fileJson)
165 {
166 $audio = (new Audio())
167 ->withJsonString($fileJson)
168 ->withMessageCode($message->getCode());
169
170 $length = $audio->getDuration();
171 }
172 $length = $length ?: 20;
173 $magic = 5;
174 $limit = $this->getCountLimiter()->getLimit();
175
176 return round(($length + $magic) / $limit);
177 }
178
185 public function getLimiters(Message\iBase $message = null)
186 {
187 return array(
188 $this->getCountLimiter(),
189 Transport\TimeLimiter::create()
190 ->withLetter($message)
191 );
192 }
193
198 protected function getCountLimiter()
199 {
200 if ($this->limiter === null)
201 {
202 $this->limiter = new Limiter();
203 }
204
205 return $this->limiter;
206 }
207}
static sendFile($outputNumber, $number, $fileUrl)
Определения service.php:81
getDuration(Message\Adapter $message=null)
Определения transportaudiocall.php:160
getLimiters(Message\iBase $message=null)
Определения transportaudiocall.php:185
saveConfiguration(Message\Configuration $configuration)
Определения transportaudiocall.php:88
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения adapter.php:9
Определения agent.php:8
$message
Определения payment.php:8