Counterparties::create()   A
last analyzed

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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace RevolutPHP;
4
5
class Counterparties
6
{
7
    const ENDPOINT = 'counterparty';
8
9
    /**
10
     * @var Client
11
     */
12
    private $client;
13
14
    /**
15
     * Counterparties constructor.
16
     * @param Client $client
17
     */
18
    public function __construct(Client $client)
19
    {
20
        $this->client = $client;
21
    }
22
23
    /**
24
     * @see https://revolutdev.github.io/business-api/#get-counterparties
25
     *
26
     * @return mixed
27
     * @throws \GuzzleHttp\Exception\GuzzleException
28
     */
29
    public function all()
30
    {
31
        return $this->client->get('counterparties');
32
    }
33
34
    /**
35
     * @see https://revolutdev.github.io/business-api/#get-counterparty
36
     *
37
     * @param string $id
38
     * @return mixed
39
     * @throws \GuzzleHttp\Exception\GuzzleException
40
     */
41
    public function get(string $id)
42
    {
43
        return $this->client->get(self::ENDPOINT.'/'.$id);
44
    }
45
46
    /**
47
     * @see https://revolutdev.github.io/business-api/#add-revolut-counterparty
48
     * @see https://revolutdev.github.io/business-api/#add-non-revolut-counterparty
49
     *
50
     * @param array $json
51
     * @return mixed
52
     * @throws \GuzzleHttp\Exception\GuzzleException
53
     */
54
    public function create(array $json)
55
    {
56
        return $this->client->post(self::ENDPOINT, $json);
57
    }
58
59
    /**
60
     * @see https://revolutdev.github.io/business-api/#delete-counterparty
61
     *
62
     * @param string $id
63
     * @return mixed
64
     * @throws \GuzzleHttp\Exception\GuzzleException
65
     */
66
    public function delete($id)
67
    {
68
        return $this->client->delete(self::ENDPOINT.'/'.$id);
69
    }
70
}
71