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
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @return array |
19
|
|
|
*/ |
20
|
1 |
|
public function toArray() |
21
|
|
|
{ |
22
|
|
|
return array( |
23
|
|
|
'user' => array( |
24
|
1 |
|
'id' => $this->getId(), |
25
|
1 |
|
'username' => $this->getUserName(), |
26
|
1 |
|
'displayName' => $this->getDisplayName(), |
27
|
1 |
|
'firstName' => $this->getFirstName(), |
28
|
1 |
|
'lastName' => $this->getLastName(), |
29
|
1 |
|
'emailAddress' => $this->getEmailAddress() |
30
|
1 |
|
), |
31
|
1 |
|
'site' => array('name' => $this->getSiteName()) |
32
|
1 |
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param $params |
37
|
|
|
* @return $this |
38
|
|
|
*/ |
39
|
1 |
|
public function exchangeArray($params) |
40
|
|
|
{ |
41
|
1 |
|
$user = $params['user']; |
42
|
|
|
|
43
|
1 |
|
$this->setId($user['id']); |
44
|
1 |
|
$this->setUserName($user['username']); |
45
|
1 |
|
$this->setDisplayName($user['displayName']); |
46
|
1 |
|
$this->setFirstName($user['firstName']); |
47
|
1 |
|
$this->setLastName($user['lastName']); |
48
|
1 |
|
$this->setEmailAddress($user['emailAddress']); |
49
|
1 |
|
$this->setSiteName($params['site']['name']); |
50
|
|
|
|
51
|
1 |
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return mixed |
56
|
|
|
*/ |
57
|
1 |
|
public function getId() |
58
|
|
|
{ |
59
|
1 |
|
return $this->id; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param mixed $id |
64
|
|
|
*/ |
65
|
1 |
|
public function setId($id) |
66
|
|
|
{ |
67
|
1 |
|
$this->id = $id; |
68
|
1 |
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return mixed |
72
|
|
|
*/ |
73
|
1 |
|
public function getUserName() |
74
|
|
|
{ |
75
|
1 |
|
return $this->userName; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param mixed $userName |
80
|
|
|
*/ |
81
|
1 |
|
public function setUserName($userName) |
82
|
|
|
{ |
83
|
1 |
|
$this->userName = $userName; |
84
|
1 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return mixed |
88
|
|
|
*/ |
89
|
1 |
|
public function getDisplayName() |
90
|
|
|
{ |
91
|
1 |
|
return $this->displayName; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param mixed $displayName |
96
|
|
|
*/ |
97
|
1 |
|
public function setDisplayName($displayName) |
98
|
|
|
{ |
99
|
1 |
|
$this->displayName = $displayName; |
100
|
1 |
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return mixed |
104
|
|
|
*/ |
105
|
1 |
|
public function getFirstName() |
106
|
|
|
{ |
107
|
1 |
|
return $this->firstName; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param mixed $firstName |
112
|
|
|
*/ |
113
|
1 |
|
public function setFirstName($firstName) |
114
|
|
|
{ |
115
|
1 |
|
$this->firstName = $firstName; |
116
|
1 |
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return mixed |
120
|
|
|
*/ |
121
|
1 |
|
public function getLastName() |
122
|
|
|
{ |
123
|
1 |
|
return $this->lastName; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param mixed $lastName |
128
|
|
|
*/ |
129
|
1 |
|
public function setLastName($lastName) |
130
|
|
|
{ |
131
|
1 |
|
$this->lastName = $lastName; |
132
|
1 |
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return mixed |
136
|
|
|
*/ |
137
|
1 |
|
public function getEmailAddress() |
138
|
|
|
{ |
139
|
1 |
|
return $this->emailAddress; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param mixed $emailAddress |
144
|
|
|
*/ |
145
|
1 |
|
public function setEmailAddress($emailAddress) |
146
|
|
|
{ |
147
|
1 |
|
$this->emailAddress = $emailAddress; |
148
|
1 |
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return mixed |
152
|
|
|
*/ |
153
|
1 |
|
public function getSiteName() |
154
|
|
|
{ |
155
|
1 |
|
return $this->siteName; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param mixed $siteName |
160
|
|
|
* @return EloquaResourceOwner |
161
|
|
|
*/ |
162
|
1 |
|
public function setSiteName($siteName) |
163
|
|
|
{ |
164
|
1 |
|
$this->siteName = $siteName; |
165
|
1 |
|
return $this; |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
|