Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality to handle Workflow Events
New classes have been added to handle Workflow Events, which support the initialization of the Event Service, handling Robot Requests, and sending events with return values. Modifications have also been done on the AccessToken and WorkflowsServiceBuilder classes to support this new feature. Signed-off-by: mesilov <mesilov.maxim@gmail.com>
- Loading branch information
Showing
5 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bitrix24\SDK\Services\Workflows\Event\Result; | ||
|
||
use Bitrix24\SDK\Core\Result\AbstractResult; | ||
|
||
class EventSendResult extends AbstractResult | ||
{ | ||
public function isSuccess(): bool | ||
{ | ||
return $this->getCoreResponse()->getResponseData()->getResult()[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bitrix24\SDK\Services\Workflows\Event\Service; | ||
|
||
use Bitrix24\SDK\Core\Contracts\BatchOperationsInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
readonly class Batch | ||
{ | ||
public function __construct( | ||
protected BatchOperationsInterface $batch, | ||
protected LoggerInterface $log) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bitrix24\SDK\Services\Workflows\Event\Service; | ||
|
||
use Bitrix24\SDK\Core\Contracts\CoreInterface; | ||
use Bitrix24\SDK\Core\Exceptions\BaseException; | ||
use Bitrix24\SDK\Core\Exceptions\TransportException; | ||
use Bitrix24\SDK\Services\AbstractService; | ||
use Bitrix24\SDK\Services\Workflows; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class Event extends AbstractService | ||
{ | ||
public Batch $batch; | ||
|
||
public function __construct( | ||
Batch $batch, | ||
CoreInterface $core, | ||
LoggerInterface $log | ||
) | ||
{ | ||
parent::__construct($core, $log); | ||
$this->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 | ||
] | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters