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

PurchaseClient::getPurchase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 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