Skip to content

Commit 0c726b9

Browse files
author
Morten Bak
committed
wip subscriptions resource
1 parent 3f9ca6f commit 0c726b9

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Netbums\Quickpay\Exceptions\Subscriptions;
4+
5+
use Exception;
6+
7+
class FetchSubscriptionsFailed extends Exception
8+
{
9+
10+
}

src/Facades/Quickpay.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
namespace Netbums\Quickpay\Facades;
44

55
use Illuminate\Support\Facades\Facade;
6+
use Netbums\Quickpay\Resources\CardResource;
7+
use Netbums\Quickpay\Resources\FeeResource;
8+
use Netbums\Quickpay\Resources\PaymentResource;
9+
use Netbums\Quickpay\Resources\PayoutResource;
10+
use Netbums\Quickpay\Resources\SubscriptionResource;
11+
612

713
/**
8-
* @see \Netbums\Quickpay\Quickpay
14+
* @method static PaymentResource payments();
15+
* @method static SubscriptionResource subscriptions();
16+
* @method static CardResource cards();
17+
* @method static FeeResource fees();
18+
* @method static PayoutResource payouts();
919
*/
1020
class Quickpay extends Facade
1121
{

src/Resources/SubscriptionResource.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,34 @@
22

33
namespace Netbums\Quickpay\Resources;
44

5+
use Netbums\Quickpay\Exceptions\CardNotAccepted;
6+
use Netbums\Quickpay\Exceptions\QuickPayValidationError;
7+
use Netbums\Quickpay\Exceptions\Subscriptions\FetchSubscriptionsFailed;
58
use Netbums\Quickpay\Resources\Concerns\QuickpayApiConsumer;
9+
use Throwable;
610

711
class SubscriptionResource
812
{
913
use QuickpayApiConsumer;
14+
15+
/**
16+
* @throws CardNotAccepted
17+
* @throws QuickPayValidationError
18+
* @throws FetchSubscriptionsFailed
19+
*/
20+
public function all(): array
21+
{
22+
$this->method = 'get';
23+
$this->endpoint = 'subscriptions';
24+
25+
try {
26+
return $this->request($this->method, $this->endpoint);
27+
} catch (Throwable $exception) {
28+
throw new FetchSubscriptionsFailed(
29+
message: 'The subscriptions could not be fetched.',
30+
code: $exception->getCode(),
31+
previous: $exception
32+
);
33+
}
34+
}
1035
}

0 commit comments

Comments
 (0)