CoinbaseApiClient::show()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusCoinbasePlugin\ApiClient;
12
13
use CoinbaseCommerce\ApiClient;
14
use CoinbaseCommerce\Resources\Charge;
15
use CoinbaseCommerce\Resources\Event;
16
use CoinbaseCommerce\Util;
17
use CoinbaseCommerce\Webhook;
18
19
class CoinbaseApiClient implements CoinbaseApiClientInterface
20
{
21
    /** @var ApiClient */
22
    private $apiClient;
23
24
    public function initialise(string $apiKey): void
25
    {
26
        $this->apiClient = ApiClient::init($apiKey);
27
    }
28
29
    public function create(array $data): Charge
30
    {
31
        return Charge::create($data);
32
    }
33
34
    public function show(string $paymentId): Charge
35
    {
36
        $response = $this->apiClient->get(sprintf('/charges/%s', $paymentId));
37
38
        return Util::convertToApiObject($response);
39
    }
40
41
    public function buildEvent(string $payload, string $signatureHeader, string $secret): Event
42
    {
43
        return Webhook::buildEvent($payload, $signatureHeader, $secret);
44
    }
45
}
46