WebhookAction::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace CSlant\TelegramGitNotifierApp\Http\Actions;
4
5
use CSlant\TelegramGitNotifier\Exceptions\WebhookException;
6
use CSlant\TelegramGitNotifier\Webhook;
7
8
class WebhookAction
9
{
10
    protected string $token;
11
12
    protected Webhook $webhook;
13
14
    public function __construct()
15
    {
16
        $this->webhook = new Webhook();
17
        $this->webhook->setToken(config('telegram-git-notifier.bot.token'));
18
        $this->webhook->setUrl(config('telegram-git-notifier.app.url'));
19
    }
20
21
    /**
22
     * Set webhook for telegram bot
23
     *
24
     * @return string
25
     * @throws WebhookException
26
     */
27
    public function set(): string
28
    {
29
        return $this->webhook->setWebhook();
30
    }
31
32
    /**
33
     * Delete webhook for telegram bot
34
     *
35
     * @return string
36
     * @throws WebhookException
37
     */
38
    public function delete(): string
39
    {
40
        return $this->webhook->deleteWebHook();
41
    }
42
43
    /**
44
     * Get webhook update
45
     *
46
     * @return string
47
     * @throws WebhookException
48
     */
49
    public function getUpdates(): string
50
    {
51
        return $this->webhook->getUpdates();
52
    }
53
}
54