Webhook   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A delete() 0 3 1
1
<?php
2
3
namespace tbclla\Revolut\Resources;
4
5
class Webhook extends Resource
6
{
7
    /**
8
     * The enpoint for webhook requests
9
     * 
10
     * @var string
11
     */
12
    const ENDPOINT = '/webhook';
13
14
    /**
15
     * Create a webhook
16
     * 
17
     * @see https://revolut-engineering.github.io/api-docs/business-api/#web-hooks-setting-up-a-web-hook Official API documentation
18
     * @param string $url call back url of the client system, https is the supported protocol
19
     * @return array The response body
20
     * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
21
     * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
22
     */
23
    public function create(string $url)
24
    {
25
        return $this->client->post(self::ENDPOINT, ['json' => ['url' => $url]]);
26
    }
27
28
    /**
29
     * Delete the webhook
30
     * 
31
     * @see https://revolut-engineering.github.io/api-docs/business-api/#web-hooks-deleting-a-web-hook Official API documentation
32
     * @return void
33
     * @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response
34
     * @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized
35
     */
36
    public function delete() : void
37
    {
38
        $this->client->delete(self::ENDPOINT);
39
    }
40
}
41