1 | <?php |
||
19 | final class Subscription extends HttpApi |
||
20 | { |
||
21 | /** |
||
22 | * @throws Exception |
||
23 | */ |
||
24 | 1 | public function get(string $id) |
|
34 | |||
35 | /** |
||
36 | * @throws Exception |
||
37 | */ |
||
38 | 1 | public function all(array $params = []) |
|
48 | |||
49 | /** |
||
50 | * @throws Exception |
||
51 | */ |
||
52 | public function create(array $params) |
||
53 | { |
||
54 | $processor = new Processor(); |
||
55 | $params = $processor->processConfiguration(new Configuration\SubscriptionCreate(), [$params]); |
||
56 | |||
57 | $response = $this->httpPost('/v1/subscriptions', $params); |
||
58 | |||
59 | if (200 !== $response->getStatusCode()) { |
||
60 | $this->handleErrors($response); |
||
61 | } |
||
62 | |||
63 | return $this->hydrator->hydrate($response, SubscriptionModel::class); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @throws Exception |
||
68 | */ |
||
69 | public function cancel(string $id, array $params = []) |
||
70 | { |
||
71 | $processor = new Processor(); |
||
72 | $params = $processor->processConfiguration(new Configuration\SubscriptionCancel(), [$params]); |
||
73 | |||
74 | $response = $this->httpDelete("/v1/subscriptions/$id", $params); |
||
75 | |||
76 | if (200 !== $response->getStatusCode()) { |
||
77 | $this->handleErrors($response); |
||
78 | } |
||
79 | |||
80 | return $this->hydrator->hydrate($response, SubscriptionModel::class); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @throws Exception |
||
85 | */ |
||
86 | 1 | public function getItem(string $id) |
|
96 | |||
97 | /** |
||
98 | * @throws Exception |
||
99 | */ |
||
100 | public function update(string $id, array $params) |
||
113 | } |
||
114 |