1
|
|
|
<?php |
2
|
|
|
namespace Kunnu\Dropbox\Models; |
3
|
|
|
|
4
|
|
|
class AccessToken extends BaseModel |
5
|
|
|
{ |
6
|
|
|
/** |
7
|
|
|
* Access Token |
8
|
|
|
* |
9
|
|
|
* @var string |
10
|
|
|
*/ |
11
|
|
|
protected $token; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Token Type |
15
|
|
|
* |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected $tokenType; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Bearer |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $bearer; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* User ID |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
protected $uid; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Account ID |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $accountId; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Team ID |
43
|
|
|
* |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
protected $teamId; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Refresh token, received when token_access_type = offline |
50
|
|
|
* |
51
|
|
|
* @var string|null |
52
|
|
|
*/ |
53
|
|
|
protected $refreshToken; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Indicate when the token is expired |
57
|
|
|
* |
58
|
|
|
* @var string|null |
59
|
|
|
*/ |
60
|
|
|
protected $tokenExpiresIn; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Create a new AccessToken instance |
64
|
|
|
* |
65
|
|
|
* @param array $data |
66
|
|
|
*/ |
67
|
|
|
public function __construct(array $data) |
68
|
|
|
{ |
69
|
|
|
parent::__construct($data); |
70
|
|
|
|
71
|
|
|
$this->token = $this->getDataProperty('access_token'); |
72
|
|
|
$this->tokenType = $this->getDataProperty('token_type'); |
73
|
|
|
$this->bearer = $this->getDataProperty('bearer'); |
74
|
|
|
$this->uid = $this->getDataProperty('uid'); |
75
|
|
|
$this->accountId = $this->getDataProperty('account_id'); |
76
|
|
|
$this->teamId = $this->getDataProperty('team_id'); |
77
|
|
|
$this->refreshToken = $this->getDataProperty("refresh_token"); |
78
|
|
|
$this->tokenExpiresIn = $this->getDataProperty("expires_in"); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Get Access Token |
83
|
|
|
* |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function getToken() |
87
|
|
|
{ |
88
|
|
|
return $this->token; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get Token Type |
93
|
|
|
* |
94
|
|
|
* @return string |
95
|
|
|
*/ |
96
|
|
|
public function getTokenType() |
97
|
|
|
{ |
98
|
|
|
return $this->tokenType; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Get Bearer |
103
|
|
|
* |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function getBearer() |
107
|
|
|
{ |
108
|
|
|
return $this->bearer; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Get User ID |
113
|
|
|
* |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function getUid() |
117
|
|
|
{ |
118
|
|
|
return $this->uid; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get Account ID |
123
|
|
|
* |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getAccountId() |
127
|
|
|
{ |
128
|
|
|
return $this->accountId; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Get Team ID |
133
|
|
|
* |
134
|
|
|
* @return string |
135
|
|
|
*/ |
136
|
|
|
public function getTeamId() |
137
|
|
|
{ |
138
|
|
|
return $this->teamId; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* if token_access_type was set to offline, then response will include a refresh token. |
143
|
|
|
* This refresh token is long-lived and won't expire automatically. |
144
|
|
|
* It can be stored and re-used multiple times. |
145
|
|
|
* |
146
|
|
|
* @return string|null |
147
|
|
|
*/ |
148
|
|
|
public function getRefreshToken() |
149
|
|
|
{ |
150
|
|
|
return $this->refreshToken; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Get the length of time that the access token will be valid for |
155
|
|
|
* |
156
|
|
|
* @return string|null |
157
|
|
|
*/ |
158
|
|
|
public function getExpiresIn() |
159
|
|
|
{ |
160
|
|
|
return $this->tokenExpiresIn; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
} |
164
|
|
|
|