TransactionAPI::filter()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace PayGo\Transactions\API;
4
5
6
use PayGo\AbstractAPI;
7
use PayGo\Client;
8
use PayGo\Transactions\Contracts\Query\Query;
9
10
/**
11
 * Class TransactionAPI
12
 * @package PayGo\Transactions\API
13
 */
14
class TransactionAPI extends AbstractAPI
15
{
16
17
    /**
18
     * TransactionAPI constructor.
19
     * @param Client|null $client
20
     * @throws \Exception
21
     */
22
    public function __construct(Client $client = null)
23
    {
24
        parent::__construct("/subntk", $client);
25
    }
26
27
    /**
28
     * @param Query $query
29
     * @return \GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|null
30
     * @throws \Exception
31
     */
32
    public function filter(Query $query)
33
    {
34
        try{
35
            return $this->httpClient->post("transactions", [
36
                'body' => json_encode($query)
37
            ]);
38
        }catch (\Exception $ex){
39
            throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
40
        }
41
    }
42
}