GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( fbdc8e...295bec )
by Ivan
04:40 queued 10s
created

Personal::deleteWebhook()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Monobank\Request;
6
7
use GuzzleHttp\Psr7\Request;
8
use Monobank\Response\ClientInfoResponse;
9
use Monobank\Response\StatementResponse;
10
11
final class Personal extends AbstractRequest
12
{
13
    /**
14
     * @throws \Monobank\Exception\InvalidAccountException
15
     * @throws \Monobank\Exception\InternalErrorException
16
     * @throws \Monobank\Exception\MonobankException
17
     * @throws \Monobank\Exception\TooManyRequestsException
18
     * @throws \Monobank\Exception\UnknownTokenException
19
     */
20
    public function getClientInfo(): ClientInfoResponse
21
    {
22
        $httpResponse = $this->makeRequest(new Request('GET', '/personal/client-info'));
23
24
        return ClientInfoResponse::fromResponse($httpResponse);
25
    }
26
27
    /**
28
     * @throws \Monobank\Exception\InvalidAccountException
29
     * @throws \Monobank\Exception\InternalErrorException
30
     * @throws \Monobank\Exception\MonobankException
31
     * @throws \Monobank\Exception\TooManyRequestsException
32
     * @throws \Monobank\Exception\UnknownTokenException
33
     * @throws \Monobank\Exception\InvalidAccountException
34
     */
35
    public function getStatement(string $account, \DateTime $from, \DateTime $to = null): StatementResponse
36
    {
37
        $httpResponse = $this->makeRequest(
38
            new Request(
39
                'GET',
40
                sprintf('/personal/statement/%s/%s/%s', $account, $from->getTimestamp(), $to ? $to->getTimestamp() : '')
41
            )
42
        );
43
44
        return StatementResponse::fromResponse($httpResponse);
45
    }
46
47
    /**
48
     * @throws \Monobank\Exception\InternalErrorException
49
     * @throws \Monobank\Exception\MonobankException
50
     * @throws \Monobank\Exception\TooManyRequestsException
51
     * @throws \Monobank\Exception\UnknownTokenException
52
     */
53
    public function setWebhook(string $url): bool
54
    {
55
        $httpResponse = $this->makeRequest(
56
            new Request(
57
                'POST',
58
                '/personal/webhook',
59
                ['Content-type' => 'application/json'],
60
                json_encode(['webHookUrl' => $url])
61
            )
62
        );
63
64
        return ($httpResponse['status'] ?? null) === 'ok';
65
    }
66
67
    /**
68
     * @throws \Monobank\Exception\InternalErrorException
69
     * @throws \Monobank\Exception\MonobankException
70
     * @throws \Monobank\Exception\TooManyRequestsException
71
     * @throws \Monobank\Exception\UnknownTokenException
72
     */
73
    public function deleteWebhook(): bool
74
    {
75
        return $this->setWebhook('');
76
    }
77
}
78