Webhook   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 5 1
A retrieve() 0 3 1
A revoke() 0 3 1
1
<?php
2
3
namespace tbclla\RevolutMerchant\Resources;
4
5
class Webhook extends Resource
6
{
7
	/**
8
	 * The Revolut merchant web-hook endpoint
9
	 * 
10
	 * @var string
11
	 */
12
	const ENDPOINT = '/webhooks';
13
14
	/**
15
	 * Set the web-hook
16
	 *
17
	 * @param string $url
18
	 * @return array The request body
19
	 * @throws \tbclla\RevolutMerchant\Exceptions\MerchantException
20
	 */
21
	public function set(string $url = null)
22
	{
23
		return $this->client->post(self::ENDPOINT, [
24
			'json' => [
25
				'url' => $url,
26
			]
27
		]);
28
	}
29
30
	/**
31
	 * Revoke the web-hook
32
	 *
33
	 * @return array The request body
34
	 * @throws \tbclla\RevolutMerchant\Exceptions\MerchantException
35
	 */
36
	public function revoke()
37
	{
38
		return $this->set();
39
	}
40
41
	/**
42
	 * Retrieve the web-hooks
43
	 *
44
	 * @return array The request body
45
	 * @throws \tbclla\RevolutMerchant\Exceptions\MerchantException
46
	 */
47
	public function retrieve()
48
	{
49
		return $this->client->get(self::ENDPOINT);
50
	}
51
}
52