Passed
Pull Request — 2.x (#41)
by Darío
05:03 queued 02:41
created

SubscriptionsApi   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createSubscription() 0 6 1
A getSubscription() 0 6 1
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Api;
4
5
use PaymentGateway\PayPalSdk\Contracts\PayPalResponse;
6
use PaymentGateway\PayPalSdk\PayPalApi;
7
use PaymentGateway\PayPalSdk\Responses\GetResponse;
8
use PaymentGateway\PayPalSdk\Responses\PostResponse;
9
use PaymentGateway\PayPalSdk\Subscriptions\Requests\StoreSubscriptionRequest;
10
11
class SubscriptionsApi extends PayPalApi
12
{
13 1
    public function getSubscription(string $id): PayPalResponse
14
    {
15 1
        $this->client->prepareRequest('GET', $this->baseUri . '/v1/billing/subscriptions/' . $id);
16 1
        $this->setAuthentication();
17
18 1
        return new GetResponse($this->client->execute());
19
    }
20
21 3
    public function createSubscription(StoreSubscriptionRequest $subscriptionRequest): PayPalResponse
22
    {
23 3
        $this->client->prepareRequest('POST', $this->baseUri . '/v1/billing/subscriptions');
24 3
        $this->setAuthentication()->setJson($subscriptionRequest->toArray());
25
26 3
        return new PostResponse($this->client->execute());
27
    }
28
}
29