1
|
|
|
<?php |
2
|
|
|
namespace Kunnu\Dropbox\Models; |
3
|
|
|
|
4
|
|
|
class Account extends BaseModel |
5
|
|
|
{ |
6
|
|
|
/** |
7
|
|
|
* Account ID |
8
|
|
|
* |
9
|
|
|
* @var string |
10
|
|
|
*/ |
11
|
|
|
protected $account_id; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* User name details |
15
|
|
|
* |
16
|
|
|
* @var array |
17
|
|
|
*/ |
18
|
|
|
protected $name = []; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Account Email |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $email; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Whether the user has verified their e-mail address |
29
|
|
|
* |
30
|
|
|
* @var boolean |
31
|
|
|
*/ |
32
|
|
|
protected $email_verified = false; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Account Profile Pic URL |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $profile_photo_url; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Whether the user has been disabled |
43
|
|
|
* |
44
|
|
|
* @var boolean |
45
|
|
|
*/ |
46
|
|
|
protected $disabled = false; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* User's two-letter country code |
50
|
|
|
* |
51
|
|
|
* @var string |
52
|
|
|
*/ |
53
|
|
|
protected $country; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Language of User's account |
57
|
|
|
* |
58
|
|
|
* @var string |
59
|
|
|
*/ |
60
|
|
|
protected $locale; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* User's referral link |
64
|
|
|
* |
65
|
|
|
* @var string |
66
|
|
|
*/ |
67
|
|
|
protected $referral_link; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Indicates whether a work account is linked |
71
|
|
|
* |
72
|
|
|
* @var boolean |
73
|
|
|
*/ |
74
|
|
|
protected $is_paired = false; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* User's account type |
78
|
|
|
* |
79
|
|
|
* @var string |
80
|
|
|
*/ |
81
|
|
|
protected $account_type; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Create a new Account instance |
85
|
|
|
* |
86
|
|
|
* @param array $data |
87
|
|
|
*/ |
88
|
|
|
public function __construct(array $data) |
89
|
|
|
{ |
90
|
|
|
parent::__construct($data); |
91
|
|
|
|
92
|
|
|
$this->account_id = $this->getDataProperty('account_id'); |
93
|
|
|
$this->name = (array) $this->getDataProperty('name'); |
94
|
|
|
$this->email = $this->getDataProperty('email'); |
95
|
|
|
$this->email_verified = $this->getDataProperty('email_verified'); |
96
|
|
|
$this->disabled = $this->getDataProperty('disabled'); |
97
|
|
|
$this->profile_photo_url = $this->getDataProperty('profile_photo_url'); |
98
|
|
|
$this->locale = $this->getDataProperty('locale'); |
99
|
|
|
$this->country = $this->getDataProperty('country'); |
100
|
|
|
$this->referral_link = $this->getDataProperty('referral_link'); |
101
|
|
|
$this->is_paired = $this->getDataProperty('is_paired'); |
102
|
|
|
|
103
|
|
|
//Account Type |
104
|
|
|
$account_type = $this->getDataProperty('account_type'); |
105
|
|
|
|
106
|
|
|
if (is_array($account_type) && !empty($account_type)) { |
107
|
|
|
$this->account_type = $account_type['.tag']; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Return full contents of API response as JSON |
113
|
|
|
* |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function __toString() |
117
|
|
|
{ |
118
|
|
|
return json_encode($this->getData()); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get Account ID |
123
|
|
|
* |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getAccountId() |
127
|
|
|
{ |
128
|
|
|
return $this->account_id; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Get Account User's Name Details |
133
|
|
|
* |
134
|
|
|
* @return array |
135
|
|
|
*/ |
136
|
|
|
public function getNameDetails() |
137
|
|
|
{ |
138
|
|
|
return $this->name; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Get Display name |
143
|
|
|
* |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
public function getDisplayName() |
147
|
|
|
{ |
148
|
|
|
$name = $this->name; |
149
|
|
|
|
150
|
|
|
if (isset($name['display_name'])) { |
151
|
|
|
return $name['display_name']; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
return ""; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Get Account Email |
159
|
|
|
* |
160
|
|
|
* @return string |
161
|
|
|
*/ |
162
|
|
|
public function getEmail() |
163
|
|
|
{ |
164
|
|
|
return $this->email; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Whether account email is verified |
169
|
|
|
* |
170
|
|
|
* @return boolean |
171
|
|
|
*/ |
172
|
|
|
public function emailIsVerified() |
173
|
|
|
{ |
174
|
|
|
return $this->email_verified ? true : false; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Get Profile Pic URL |
179
|
|
|
* |
180
|
|
|
* @return string |
181
|
|
|
*/ |
182
|
|
|
public function getProfilePhotoUrl() |
183
|
|
|
{ |
184
|
|
|
return $this->profile_photo_url; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Whether acocunt has been disabled |
189
|
|
|
* |
190
|
|
|
* @return boolean |
191
|
|
|
*/ |
192
|
|
|
public function isDisabled() |
193
|
|
|
{ |
194
|
|
|
return $this->disabled ? true : false; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Get User's two-lettered country code |
199
|
|
|
* |
200
|
|
|
* @return string |
201
|
|
|
*/ |
202
|
|
|
public function getCountry() |
203
|
|
|
{ |
204
|
|
|
return $this->country; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Get account language |
209
|
|
|
* |
210
|
|
|
* @return string |
211
|
|
|
*/ |
212
|
|
|
public function getLocale() |
213
|
|
|
{ |
214
|
|
|
return $this->locale; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Get user's referral link |
219
|
|
|
* |
220
|
|
|
* @return string |
221
|
|
|
*/ |
222
|
|
|
public function getReferralLink() |
223
|
|
|
{ |
224
|
|
|
return $this->referral_link; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Whether work account is paired |
229
|
|
|
* |
230
|
|
|
* @return boolean |
231
|
|
|
*/ |
232
|
|
|
public function isPaired() |
233
|
|
|
{ |
234
|
|
|
return $this->is_paired ? true : false; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Get Account Type |
239
|
|
|
* |
240
|
|
|
* @return string |
241
|
|
|
*/ |
242
|
|
|
public function getAccountType() |
243
|
|
|
{ |
244
|
|
|
return $this->account_type; |
245
|
|
|
} |
246
|
|
|
} |
247
|
|
|
|