Skip to content

Commit 3f0b6f6

Browse files
committed
task#102 add crm-robots support
1 parent 2c7ec6d commit 3f0b6f6

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

src/classes/bizproc/Robot.php

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
3+
namespace Bitrix24\Bizproc;
4+
5+
use Bitrix24\Bitrix24Entity;
6+
7+
/**
8+
* Class Robot
9+
*
10+
* @package Bitrix24\Placement
11+
*/
12+
class Robot extends Bitrix24Entity
13+
{
14+
/**
15+
* add crm-robot
16+
*
17+
* @param string $code
18+
* @param string $handler
19+
* @param int $userId
20+
* @param array $arName
21+
* @param array $arProps
22+
*
23+
* @return mixed
24+
*
25+
* @see https://dev.1c-bitrix.ru/rest_help/bizproc/bizproc_robot/robotadd.php
26+
*
27+
* @throws \Bitrix24\Exceptions\Bitrix24ApiException
28+
* @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException
29+
* @throws \Bitrix24\Exceptions\Bitrix24Exception
30+
* @throws \Bitrix24\Exceptions\Bitrix24IoException
31+
* @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException
32+
* @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException
33+
* @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException
34+
* @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException
35+
* @throws \Bitrix24\Exceptions\Bitrix24SecurityException
36+
* @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException
37+
* @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException
38+
* @throws \Bitrix24\Exceptions\Bitrix24WrongClientException
39+
*/
40+
public function add($code, $handler, $userId, $arName, $arProps)
41+
{
42+
$arResult = $this->client->call('bizproc.activity.add',
43+
array(
44+
'CODE' => $code,
45+
'HANDLER' => $handler,
46+
'AUTH_USER_ID' => $userId,
47+
'NAME' => $arName,
48+
'PROPERTIES' => $arProps,
49+
));
50+
51+
return $arResult['result'];
52+
}
53+
54+
/**
55+
* delete activity
56+
*
57+
* @param $code string
58+
*
59+
* @see https://dev.1c-bitrix.ru/rest_help/bizproc/bizproc_robot/robotdelete.php
60+
*
61+
* @return array
62+
* @throws \Bitrix24\Exceptions\Bitrix24WrongClientException
63+
* @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException
64+
* @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException
65+
* @throws \Bitrix24\Exceptions\Bitrix24SecurityException
66+
* @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException
67+
* @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException
68+
* @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException
69+
* @throws \Bitrix24\Exceptions\Bitrix24IoException
70+
* @throws \Bitrix24\Exceptions\Bitrix24Exception
71+
* @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException
72+
* @throws \Bitrix24\Exceptions\Bitrix24ApiException
73+
*/
74+
public function delete($code)
75+
{
76+
$arResult = $this->client->call('bizproc.robot.delete',
77+
array(
78+
'code' => $code,
79+
)
80+
);
81+
82+
return $arResult['result'];
83+
}
84+
85+
/**
86+
* get list of robots
87+
*
88+
* @see https://dev.1c-bitrix.ru/rest_help/bizproc/bizproc_robot/robotlist.php
89+
*
90+
* @return mixed
91+
* @throws \Bitrix24\Exceptions\Bitrix24ApiException
92+
* @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException
93+
* @throws \Bitrix24\Exceptions\Bitrix24Exception
94+
* @throws \Bitrix24\Exceptions\Bitrix24IoException
95+
* @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException
96+
* @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException
97+
* @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException
98+
* @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException
99+
* @throws \Bitrix24\Exceptions\Bitrix24SecurityException
100+
* @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException
101+
* @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException
102+
* @throws \Bitrix24\Exceptions\Bitrix24WrongClientException
103+
*/
104+
public function getList()
105+
{
106+
$arResult = $this->client->call('bizproc.robot.list',
107+
array()
108+
);
109+
110+
return $arResult['result'];
111+
}
112+
}

0 commit comments

Comments
 (0)