Passed
Push — main ( 4dc4a3...97513a )
by Stas
14:40 queued 04:40
created

SubscriptionVerificationRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 3 1
A do() 0 12 1
1
<?php
2
3
namespace Huawei\IAP\Request;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
class SubscriptionVerificationRequest extends AbstractVerificationRequest
8
{
9
    const API_VERSION = 'v2';
10
    const VERIFICATION_URL_MASK = '/sub/applications/%s/purchases/get';
11
12
    public function do(): ResponseInterface
13
    {
14
        $url = $this->getUrl();
15
16
        $jsonBody = [
17
            'subscriptionId' => $this->purchaseData->getSubscriptionId(),
18
            'purchaseToken' => $this->purchaseData->getPurchaseToken(),
19
        ];
20
21
        return $this->httpClient->request('POST', $url, [
22
            'headers' => $this->headers,
23
            'json' => $jsonBody,
24
        ]);
25
    }
26
27
    protected function getUrl(): string
28
    {
29
        return sprintf(self::VERIFICATION_URL_MASK, self::API_VERSION);
30
    }
31
}
32