CoinbaseApiClient   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initialise() 0 3 1
A show() 0 5 1
A create() 0 3 1
A buildEvent() 0 3 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