-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathAccountInfo.php
172 lines (154 loc) · 5.02 KB
/
AccountInfo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
declare(strict_types=1);
namespace Upmind\ProvisionProviders\SharedHosting\Data;
use Upmind\ProvisionBase\Provider\DataSet\ResultData;
use Upmind\ProvisionBase\Provider\DataSet\Rules;
/**
* Result set encapsulating the info/data about a created hosting account.
*
* @property-read string|integer|null $customer_id ID of the customer on the hosting platform
* @property-read string|integer|null $subscription_id ID of the subscription on the hosting platform, if any
* @property-read string $username Username of the account
* @property-read string|null $domain Main domain name of the account
* @property-read bool|null $reseller Whether or not the account has reseller privileges
* @property-read string $server_hostname Hostname of the server the account is on
* @property-read string $package_name Account package/plan name/identifier
* @property-read bool $suspended Whether or not the account is suspended
* @property-read string|null $suspend_reason Reason for suspension
* @property-read string|null $ip Account ip address
* @property-read string[]|null $nameservers
* @property-read SoftwareInstallation|null $software
* @property-read string|null $location
*/
class AccountInfo extends ResultData
{
public static function rules(): Rules
{
return new Rules([
'customer_id' => ['nullable'],
'subscription_id' => ['nullable'],
'username' => ['required', 'string'],
'domain' => ['nullable', 'domain_name'],
'reseller' => ['nullable', 'boolean'],
'server_hostname' => ['required', 'domain_name'],
'package_name' => ['required', 'string'],
'suspended' => ['required', 'boolean'],
'suspend_reason' => ['nullable', 'string'],
'ip' => ['nullable', 'ip'],
'nameservers' => ['nullable', 'array'],
'nameservers.*' => ['string'],
'software' => ['nullable', SoftwareInstallation::class],
'location' => ['nullable', 'string'],
]);
}
/**
* @param string $username Username of the account
*/
public function setUsername(string $username): self
{
$this->setValue('username', $username);
return $this;
}
/**
* @param string|int|null $customerId Customer ID on the hosting platform
*/
public function setCustomerId($customerId): self
{
$this->setValue('customer_id', $customerId);
return $this;
}
/**
* @param string|int|null $subscriptionId ID of the subscription on the hosting platform, if any
*/
public function setSubscriptionId($subscriptionId): self
{
$this->setValue('subscription_id', $subscriptionId);
return $this;
}
/**
* @param string|null $domain Main domain name of the account
*/
public function setDomain(?string $domain): self
{
$this->setValue('domain', $domain);
return $this;
}
/**
* @param bool $reseller Whether or not the account has reseller privileges
*/
public function setReseller(?bool $reseller): self
{
$this->setValue('reseller', $reseller);
return $this;
}
/**
* @param string $hostname Configuration server hostname
*/
public function setServerHostname(string $hostname): self
{
$this->setValue('server_hostname', $hostname);
return $this;
}
/**
* @param string $packageName Account package name
*/
public function setPackageName(string $packageName): self
{
$this->setValue('package_name', $packageName);
return $this;
}
/**
* @param bool $suspended Whether or not account is suspended
*/
public function setSuspended(bool $suspended): self
{
$this->setValue('suspended', $suspended);
return $this;
}
/**
* @param string|null $reason Reason for suspension
*/
public function setSuspendReason(?string $reason): self
{
$this->setValue('suspend_reason', $reason);
return $this;
}
/**
* @param string|null $ip Account ip address
*/
public function setIp(?string $ip): self
{
$this->setValue('ip', $ip);
return $this;
}
/**
* @param string[]|null[]|null $nameservers
*/
public function setNameservers(?array $nameservers): self
{
if (is_array($nameservers)) {
// sort, filter and reset array keys
natsort($nameservers);
$nameservers = array_values(array_filter($nameservers));
}
$this->setValue('nameservers', $nameservers);
return $this;
}
/**
* @param SoftwareInstallation|array|null $installation
*/
public function setSoftware($installation): self
{
$this->setValue('software', $installation);
return $this;
}
/**
* @param string|null $location
* @return $this
*/
public function setLocation(?string $location): self
{
$this->setValue('location', $location);
return $this;
}
}