Completed
Push — master ( b736eb...f06be5 )
by Laurens
03:50 queued 01:55
created

PurchaseClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 19
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPurchaseHistory() 0 4 1
A getPurchase() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi;
6
7
use LauLamanApps\IzettleApi\API\Purchase\Purchase;
8
use LauLamanApps\IzettleApi\API\Purchase\PurchaseHistory;
9
use LauLamanApps\IzettleApi\Client\Purchase\PurchaseHistoryParser;
10
use LauLamanApps\IzettleApi\Client\Purchase\PurchaseParser;
11
use Ramsey\Uuid\UuidInterface;
12
13
final class PurchaseClient extends AbstractClient
14
{
15
    const BASE_URL = 'https://purchase.izettle.com';
16
17
    const GET_PURCHASE = self::BASE_URL . '/purchases/v2/%s';
18
    const GET_PURCHASES = self::BASE_URL . '/purchases/v2';
19
20 1
    public function getPurchaseHistory(): PurchaseHistory
21
    {
22 1
        return PurchaseHistoryParser::createFromResponse($this->get(self::GET_PURCHASES));
23
    }
24
25 1
    public function getPurchase(UuidInterface $uuid): Purchase
26
    {
27 1
        $url = sprintf(self::GET_PURCHASE, (string) $uuid);
28
29 1
        return PurchaseParser::createFromResponse($this->get($url));
30
    }
31
}
32