1: <?php
2:
3: namespace Cloudflare\User\Billing\Subscriptions;
4:
5: use Cloudflare\Api;
6: use Cloudflare\User;
7: use Cloudflare\User\Billing;
8:
9: /**
10: * CloudFlare API wrapper
11: *
12: * Billing
13: * App Subscription
14: *
15: * @author James Bell <[email protected]>
16: *
17: * @version 1
18: */
19: class Apps extends Api
20: {
21: /**
22: * Default permissions level
23: *
24: * @var array
25: */
26: protected $permission_level = ['read' => '#billing:read', 'edit' => '#billing:edit'];
27:
28: /**
29: * List (permission needed: #billing:read)
30: * List all of your app subscriptions
31: */
32: public function list_apps()
33: {
34: return $this->get('/user/billing/subscriptions/apps');
35: }
36:
37: /**
38: * Search, sort, and paginate (permission needed: #billing:read)
39: * Search, sort, and paginate your subscriptions
40: *
41: * @param int|null $page Page number of paginated results
42: * @param int|null $per_page Number of items per page
43: * @param string|null $order Field to order subscriptions by
44: * @param string|null $status The state of the subscription
45: * @param string|null $price The price of the subscription that will be billed, in US dollars
46: * @param string|null $activated_on When the subscription was activated
47: * @param string|null $expires_on When the subscription will expire
48: * @param string|null $expired_on When the subscription expired
49: * @param string|null $cancelled_on When the subscription was cancelled
50: * @param string|null $renewed_on When the subscription was renewed
51: * @param string|null $direction Direction to order subscriptions
52: * @param string|null $match Whether to match all search requirements or at least one (any)
53: */
54: public function search_sort_paginate($page = null, $per_page = null, $order = null, $status = null, $price = null, $activated_on = null, $expires_on = null, $expired_on = null, $cancelled_on = null, $renewed_on = null, $direction = null, $match = null)
55: {
56: $data = [
57: 'page' => $page,
58: 'per_page' => $per_page,
59: 'order' => $order,
60: 'status' => $status,
61: 'price' => $price,
62: 'activated_on' => $activated_on,
63: 'expires_on' => $expires_on,
64: 'expired_on' => $expired_on,
65: 'cancelled_on' => $cancelled_on,
66: 'renewed_on' => $renewed_on,
67: 'direction' => $direction,
68: 'match' => $match,
69: ];
70:
71: return $this->get('/user/billing/subscriptions/apps', $data);
72: }
73:
74: /**
75: * Info (permission needed: #billing:read)
76: * Billing subscription details
77: *
78: * @param string $identifier
79: */
80: public function info(string $identifier)
81: {
82: return $this->get('/user/billing/subscriptions/apps/'.$identifier);
83: }
84: }
85: