Completed
Push — main ( 4f1818...9a2d9f )
by Tan
21s queued 15s
created

WebhookService::deleteWebHook()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
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 = null)
13
    {
14
        $this->webhook = $webhook ?? new 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
     *
24
     * @throws WebhookException
25
     */
26
    public function setWebhook(): string
27
    {
28
        return $this->webhook->setWebhook();
29
    }
30
31
    /**
32
     * Delete webhook for telegram bot.
33
     *
34
     * @return string
35
     *
36
     * @throws WebhookException
37
     */
38
    public function deleteWebHook(): string
39
    {
40
        return $this->webhook->deleteWebHook();
41
    }
42
43
    /**
44
     * Get webhook update.
45
     *
46
     * @return string
47
     *
48
     * @throws WebhookException
49
     */
50
    public function getUpdates(): string
51
    {
52
        return $this->webhook->getUpdates();
53
    }
54
55
    /**
56
     * Get webhook info.
57
     *
58
     * @return string
59
     *
60
     * @throws WebhookException
61
     */
62
    public function getWebHookInfo(): string
63
    {
64
        return $this->webhook->getWebHookInfo();
65
    }
66
}
67