1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Permiakov\OAuth2\Client\Provider; |
4
|
|
|
|
5
|
|
|
use League\OAuth2\Client\Provider\ResourceOwnerInterface; |
6
|
|
|
|
7
|
|
|
class EloquaResourceOwner implements ResourceOwnerInterface |
8
|
|
|
{ |
9
|
|
|
protected $id; |
10
|
|
|
protected $userName; |
11
|
|
|
protected $displayName; |
12
|
|
|
protected $firstName; |
13
|
|
|
protected $lastName; |
14
|
|
|
protected $emailAddress; |
15
|
|
|
protected $siteName; |
16
|
|
|
protected $compositeId; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @return array |
20
|
|
|
*/ |
21
|
1 |
|
public function toArray() |
22
|
|
|
{ |
23
|
|
|
return array( |
24
|
|
|
'user' => array( |
25
|
1 |
|
'id' => $this->getId(), |
26
|
1 |
|
'username' => $this->getUserName(), |
27
|
1 |
|
'displayName' => $this->getDisplayName(), |
28
|
1 |
|
'firstName' => $this->getFirstName(), |
29
|
1 |
|
'lastName' => $this->getLastName(), |
30
|
1 |
|
'emailAddress' => $this->getEmailAddress() |
31
|
1 |
|
), |
32
|
1 |
|
'site' => array('name' => $this->getSiteName()) |
33
|
1 |
|
); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param $params |
38
|
|
|
* @return $this |
39
|
|
|
*/ |
40
|
1 |
|
public function exchangeArray($params) |
41
|
|
|
{ |
42
|
1 |
|
$user = $params['user']; |
43
|
|
|
|
44
|
1 |
|
$this->setId($user['id']); |
45
|
1 |
|
$this->setUserName($user['username']); |
46
|
1 |
|
$this->setDisplayName($user['displayName']); |
47
|
1 |
|
$this->setFirstName($user['firstName']); |
48
|
1 |
|
$this->setLastName($user['lastName']); |
49
|
1 |
|
$this->setEmailAddress($user['emailAddress']); |
50
|
1 |
|
$this->setSiteName($params['site']['name']); |
51
|
1 |
|
$this->setCompositeId(sprintf('%s:%s', $this->getSiteName(), $this->getUserName())); |
52
|
1 |
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return mixed |
57
|
|
|
*/ |
58
|
1 |
|
public function getId() |
59
|
|
|
{ |
60
|
1 |
|
return $this->id; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param mixed $id |
65
|
|
|
*/ |
66
|
1 |
|
public function setId($id) |
67
|
|
|
{ |
68
|
1 |
|
$this->id = $id; |
69
|
1 |
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return mixed |
73
|
|
|
*/ |
74
|
1 |
|
public function getUserName() |
75
|
|
|
{ |
76
|
1 |
|
return $this->userName; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param mixed $userName |
81
|
|
|
*/ |
82
|
1 |
|
public function setUserName($userName) |
83
|
|
|
{ |
84
|
1 |
|
$this->userName = $userName; |
85
|
1 |
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return mixed |
89
|
|
|
*/ |
90
|
1 |
|
public function getDisplayName() |
91
|
|
|
{ |
92
|
1 |
|
return $this->displayName; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param mixed $displayName |
97
|
|
|
*/ |
98
|
1 |
|
public function setDisplayName($displayName) |
99
|
|
|
{ |
100
|
1 |
|
$this->displayName = $displayName; |
101
|
1 |
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return mixed |
105
|
|
|
*/ |
106
|
1 |
|
public function getFirstName() |
107
|
|
|
{ |
108
|
1 |
|
return $this->firstName; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param mixed $firstName |
113
|
|
|
*/ |
114
|
1 |
|
public function setFirstName($firstName) |
115
|
|
|
{ |
116
|
1 |
|
$this->firstName = $firstName; |
117
|
1 |
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return mixed |
121
|
|
|
*/ |
122
|
1 |
|
public function getLastName() |
123
|
|
|
{ |
124
|
1 |
|
return $this->lastName; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param mixed $lastName |
129
|
|
|
*/ |
130
|
1 |
|
public function setLastName($lastName) |
131
|
|
|
{ |
132
|
1 |
|
$this->lastName = $lastName; |
133
|
1 |
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return mixed |
137
|
|
|
*/ |
138
|
1 |
|
public function getEmailAddress() |
139
|
|
|
{ |
140
|
1 |
|
return $this->emailAddress; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param mixed $emailAddress |
145
|
|
|
*/ |
146
|
1 |
|
public function setEmailAddress($emailAddress) |
147
|
|
|
{ |
148
|
1 |
|
$this->emailAddress = $emailAddress; |
149
|
1 |
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return mixed |
153
|
|
|
*/ |
154
|
1 |
|
public function getSiteName() |
155
|
|
|
{ |
156
|
1 |
|
return $this->siteName; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param mixed $siteName |
161
|
|
|
* @return EloquaResourceOwner |
162
|
|
|
*/ |
163
|
1 |
|
public function setSiteName($siteName) |
164
|
|
|
{ |
165
|
1 |
|
$this->siteName = $siteName; |
166
|
1 |
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return mixed |
171
|
|
|
*/ |
172
|
1 |
|
public function getCompositeId() |
173
|
|
|
{ |
174
|
1 |
|
return $this->compositeId; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param mixed $compositeId |
179
|
|
|
* @return EloquaResourceOwner |
180
|
|
|
*/ |
181
|
1 |
|
public function setCompositeId($compositeId) |
182
|
|
|
{ |
183
|
1 |
|
$this->compositeId = $compositeId; |
184
|
1 |
|
return $this; |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|