diff --git a/src/Core/Credentials/AccessToken.php b/src/Core/Credentials/AccessToken.php index 8cefe7d..338974b 100644 --- a/src/Core/Credentials/AccessToken.php +++ b/src/Core/Credentials/AccessToken.php @@ -6,6 +6,7 @@ use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation; /** * Class AccessToken @@ -78,10 +79,16 @@ public static function initFromArray(array $request): self ); } + public static function initFromRobotRequest(Request $request): self + { + $requestFields = $request->request->all(); + return self::initFromArray($requestFields['auth']); + } + /** - * @throws \Bitrix24\SDK\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ - public static function initFromPlacementRequest(Request $request): self + public static function initFromPlacementRequest(HttpFoundation\Request $request): self { $requestFields = $request->request->all(); if (!array_key_exists('AUTH_ID', $requestFields)) { diff --git a/src/Services/Workflows/Event/Result/EventSendResult.php b/src/Services/Workflows/Event/Result/EventSendResult.php new file mode 100644 index 0000000..c5acfee --- /dev/null +++ b/src/Services/Workflows/Event/Result/EventSendResult.php @@ -0,0 +1,15 @@ +getCoreResponse()->getResponseData()->getResult()[0]; + } +} \ No newline at end of file diff --git a/src/Services/Workflows/Event/Service/Batch.php b/src/Services/Workflows/Event/Service/Batch.php new file mode 100644 index 0000000..feaba61 --- /dev/null +++ b/src/Services/Workflows/Event/Service/Batch.php @@ -0,0 +1,17 @@ +batch = $batch; + } + + /** + * returns output parameters to an activity. Parameters are specified in the activity description. + * + * @param string $eventToken + * @param array $returnValues + * @param string|null $logMessage + * + * @return Workflows\Event\Result\EventSendResult + * @throws BaseException + * @throws TransportException + * @see https://training.bitrix24.com/rest_help/workflows/workflows_events/bizproc_event_send.php + */ + public function send( + string $eventToken, + array $returnValues, + ?string $logMessage = null, + ): Workflows\Event\Result\EventSendResult + { + return new Workflows\Event\Result\EventSendResult($this->core->call( + 'bizproc.event.send', + [ + 'event_token' => $eventToken, + 'return_values' => $returnValues, + 'log_message' => $logMessage + ] + )); + } +} \ No newline at end of file diff --git a/src/Services/Workflows/WorkflowsServiceBuilder.php b/src/Services/Workflows/WorkflowsServiceBuilder.php index 6a86b4c..0ea134c 100644 --- a/src/Services/Workflows/WorkflowsServiceBuilder.php +++ b/src/Services/Workflows/WorkflowsServiceBuilder.php @@ -9,6 +9,19 @@ class WorkflowsServiceBuilder extends AbstractServiceBuilder { + public function event(): Workflows\Event\Service\Event + { + if (!isset($this->serviceCache[__METHOD__])) { + $this->serviceCache[__METHOD__] = new Workflows\Event\Service\Event( + new Workflows\Event\Service\Batch($this->batch, $this->log), + $this->core, + $this->log + ); + } + + return $this->serviceCache[__METHOD__]; + } + public function robot(): Workflows\Robot\Service\Robot { if (!isset($this->serviceCache[__METHOD__])) {