Passed
Pull Request — main (#58)
by
unknown
02:28
created

WebhookService::setWebhook()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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