1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cloudflare\User\Billing\Subscriptions; |
4
|
|
|
|
5
|
|
|
use Cloudflare\Api; |
6
|
|
|
use Cloudflare\User; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* CloudFlare API wrapper |
10
|
|
|
* |
11
|
|
|
* Billing |
12
|
|
|
* App Subscription |
13
|
|
|
* |
14
|
|
|
* @author James Bell <[email protected]> |
15
|
|
|
* |
16
|
|
|
* @version 1 |
17
|
|
|
*/ |
18
|
|
View Code Duplication |
class Apps extends Api |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* List (permission needed: #billing:read) |
22
|
|
|
* List all of your app subscriptions |
23
|
|
|
*/ |
24
|
|
|
public function list_apps() |
25
|
|
|
{ |
26
|
|
|
return $this->get('/user/billing/subscriptions/apps'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Search, sort, and paginate (permission needed: #billing:read) |
31
|
|
|
* Search, sort, and paginate your subscriptions |
32
|
|
|
* |
33
|
|
|
* @param int|null $page Page number of paginated results |
34
|
|
|
* @param int|null $per_page Number of items per page |
35
|
|
|
* @param string|null $order Field to order subscriptions by |
36
|
|
|
* @param string|null $status The state of the subscription |
37
|
|
|
* @param string|null $price The price of the subscription that will be billed, in US dollars |
38
|
|
|
* @param string|null $activated_on When the subscription was activated |
39
|
|
|
* @param string|null $expires_on When the subscription will expire |
40
|
|
|
* @param string|null $expired_on When the subscription expired |
41
|
|
|
* @param string|null $cancelled_on When the subscription was cancelled |
42
|
|
|
* @param string|null $renewed_on When the subscription was renewed |
43
|
|
|
* @param string|null $direction Direction to order subscriptions |
44
|
|
|
* @param string|null $match Whether to match all search requirements or at least one (any) |
45
|
|
|
*/ |
46
|
|
|
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) |
47
|
|
|
{ |
48
|
|
|
$data = [ |
49
|
|
|
'page' => $page, |
50
|
|
|
'per_page' => $per_page, |
51
|
|
|
'order' => $order, |
52
|
|
|
'status' => $status, |
53
|
|
|
'price' => $price, |
54
|
|
|
'activated_on' => $activated_on, |
55
|
|
|
'expires_on' => $expires_on, |
56
|
|
|
'expired_on' => $expired_on, |
57
|
|
|
'cancelled_on' => $cancelled_on, |
58
|
|
|
'renewed_on' => $renewed_on, |
59
|
|
|
'direction' => $direction, |
60
|
|
|
'match' => $match, |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
return $this->get('/user/billing/subscriptions/apps', $data); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Info (permission needed: #billing:read) |
68
|
|
|
* Billing subscription details |
69
|
|
|
* |
70
|
|
|
* @param string $identifier |
71
|
|
|
*/ |
72
|
|
|
public function info($identifier) |
73
|
|
|
{ |
74
|
|
|
return $this->get('/user/billing/subscriptions/apps/'.$identifier); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.