Transactions   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 63
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A __construct() 0 3 1
A getByRequestId() 0 4 1
A cancel() 0 3 1
A all() 0 3 1
1
<?php
2
3
namespace RevolutPHP;
4
5
class Transactions
6
{
7
    const ENDPOINT = 'transaction';
8
9
    /**
10
     * @var Client
11
     */
12
    private $client;
13
14
    /**
15
     * Payments 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-transactions
25
     *
26
     * @param array $filters
27
     * @return mixed
28
     */
29
    public function all($filters = [])
30
    {
31
        return $this->client->get('transactions?'.http_build_query($filters));
32
    }
33
34
    /**
35
     * @see https://revolutdev.github.io/business-api/#cancel-payment
36
     *
37
     * @param string $id
38
     * @return mixed
39
     * @throws \GuzzleHttp\Exception\GuzzleException
40
     */
41
    public function cancel($id)
42
    {
43
        return $this->client->delete(self::ENDPOINT.'/'.$id);
44
    }
45
46
    /**
47
     * @see https://revolutdev.github.io/business-api/#check-payment-status
48
     *
49
     * @param string $id
50
     * @return mixed
51
     * @throws \GuzzleHttp\Exception\GuzzleException
52
     */
53
    public function get(string $id)
54
    {
55
        return $this->client->get(self::ENDPOINT.'/'.$id);
56
    }
57
58
    /**
59
     * @see https://revolutdev.github.io/business-api/#check-payment-status
60
     *
61
     * @param string $requestId
62
     * @return mixed
63
     */
64
    public function getByRequestId(string $requestId)
65
    {
66
        $query = ['id_type' => 'request_id'];
67
        return $this->client->get(self::ENDPOINT.'/'.$requestId.'?'.http_build_query($query));
68
    }
69
}
70