1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Gumroad OAuth2 Provider |
5
|
|
|
* (c) alofoxx |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Alofoxx\OAuth2\Client\Provider; |
12
|
|
|
|
13
|
|
|
use League\OAuth2\Client\Provider\ResourceOwnerInterface; |
14
|
|
|
use League\OAuth2\Client\Tool\ArrayAccessorTrait; |
15
|
|
|
|
16
|
|
|
class GumroadResourceOwner implements ResourceOwnerInterface |
17
|
|
|
{ |
18
|
|
|
use ArrayAccessorTrait; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var array |
22
|
|
|
*/ |
23
|
|
|
protected $response; |
24
|
|
|
|
25
|
3 |
|
public function __construct(array $response = []) |
26
|
|
|
{ |
27
|
3 |
|
$this->response = $response; |
28
|
3 |
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @inheritdoc |
32
|
|
|
*/ |
33
|
3 |
|
public function getId() |
34
|
|
|
{ |
35
|
3 |
|
return $this->getValueByKey($this->response, 'user_id'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Returns email address of the resource owner |
40
|
|
|
* |
41
|
|
|
* @return string|null |
42
|
|
|
*/ |
43
|
3 |
|
public function getEmail() |
44
|
|
|
{ |
45
|
3 |
|
return $this->getValueByKey($this->response, 'email'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Returns full name of the resource owner |
50
|
|
|
* |
51
|
|
|
* @return string|null |
52
|
|
|
*/ |
53
|
3 |
|
public function getName() |
54
|
|
|
{ |
55
|
3 |
|
return $this->getValueByKey($this->response, 'name'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Returns Gumroad bio of the resource owner |
60
|
|
|
* |
61
|
|
|
* @return string|null |
62
|
|
|
*/ |
63
|
3 |
|
public function getBio() |
64
|
|
|
{ |
65
|
3 |
|
return $this->getValueByKey($this->response, 'bio'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Returns identities of the resource owner |
70
|
|
|
* |
71
|
|
|
* @see https://auth0.com/docs/user-profile/user-profile-structure |
72
|
|
|
* @return array|null |
73
|
|
|
*/ |
74
|
|
|
public function getIdentities() |
75
|
|
|
{ |
76
|
|
|
return $this->getValueByKey($this->response, 'identities'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Returns facebook profile of the resource owner |
81
|
|
|
* |
82
|
|
|
* @return string|null |
83
|
|
|
*/ |
84
|
3 |
|
public function getFacebookProfile() |
85
|
|
|
{ |
86
|
3 |
|
return $this->getValueByKey($this->response, 'facebook_profile'); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Returns twitter handle of the resource owner |
91
|
|
|
* |
92
|
|
|
* @return string|null |
93
|
|
|
*/ |
94
|
3 |
|
public function getTwitterHandle() |
95
|
|
|
{ |
96
|
3 |
|
return $this->getValueByKey($this->response, 'twitter_handle'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Returns gumroad profile url of the resource owner |
101
|
|
|
* |
102
|
|
|
* @return string|null |
103
|
|
|
*/ |
104
|
3 |
|
public function getProfileUrl() |
105
|
|
|
{ |
106
|
3 |
|
return $this->getValueByKey($this->response, 'url'); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @inheritdoc |
111
|
|
|
*/ |
112
|
3 |
|
public function toArray() |
113
|
|
|
{ |
114
|
3 |
|
return $this->response; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|