1 | <?php |
||
18 | class WebHook extends AbstractResource |
||
19 | { |
||
20 | const HOOK_LEVEL_INFO = 'info'; |
||
21 | const HOOK_LEVEL_ERROR = 'error'; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $hookId; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $level = self::HOOK_LEVEL_INFO; |
||
32 | |||
33 | /** |
||
34 | * @var string|null |
||
35 | */ |
||
36 | private $icon; |
||
37 | |||
38 | /** |
||
39 | * WebHook constructor. |
||
40 | * @param Client $client |
||
41 | * @param string $hookId |
||
42 | * @throws \InvalidArgumentException |
||
43 | */ |
||
44 | public function __construct(Client $client, string $hookId) |
||
54 | |||
55 | /** |
||
56 | * @param string $level |
||
57 | * @return WebHook |
||
58 | */ |
||
59 | public function withLevel(string $level): WebHook |
||
65 | |||
66 | /** |
||
67 | * @param string $message |
||
68 | * @return array |
||
69 | * @throws \Throwable |
||
70 | * @throws \GuzzleHttp\Exception\ClientException |
||
71 | * @throws \Exception |
||
72 | * @throws \RuntimeException |
||
73 | * @throws \InvalidArgumentException |
||
74 | */ |
||
75 | public function error(string $message): array |
||
79 | |||
80 | /** |
||
81 | * @param string $message |
||
82 | * @return array |
||
83 | * @throws \Throwable |
||
84 | * @throws \GuzzleHttp\Exception\ClientException |
||
85 | * @throws \Exception |
||
86 | * @throws \RuntimeException |
||
87 | * @throws \InvalidArgumentException |
||
88 | */ |
||
89 | public function info(string $message): array |
||
93 | |||
94 | /** |
||
95 | * @param string $type |
||
96 | * @return $this|WebHook |
||
97 | */ |
||
98 | public function withIcon(string $type): WebHook |
||
104 | |||
105 | /** |
||
106 | * @param string $message |
||
107 | * @return array |
||
108 | * @throws \Throwable |
||
109 | * @throws \GuzzleHttp\Exception\ClientException |
||
110 | * @throws \Exception |
||
111 | * @throws \RuntimeException |
||
112 | * @throws \InvalidArgumentException |
||
113 | */ |
||
114 | public function send(string $message): array |
||
118 | |||
119 | /** |
||
120 | * @param string $message |
||
121 | * @return Route |
||
122 | */ |
||
123 | private function buildRoute(string $message): Route |
||
138 | } |
||
139 |