1 | <?php |
||
11 | class HeadHunter extends AbstractProvider |
||
12 | { |
||
13 | use BearerAuthorizationTrait; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $urlApi = 'https://api.hh.ru'; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $urlAuthorize = 'https://hh.ru/oauth/authorize'; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $urlAccessToken = 'https://hh.ru/oauth/token'; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $state; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $redirectUri; |
||
39 | |||
40 | /** |
||
41 | * @inheritDoc |
||
42 | */ |
||
43 | 1 | public function getBaseAuthorizationUrl() |
|
47 | |||
48 | /** |
||
49 | * @inheritDoc |
||
50 | */ |
||
51 | 3 | public function getBaseAccessTokenUrl(array $params) |
|
52 | { |
||
53 | 3 | if (empty($params['code'])) { |
|
54 | 1 | $params['code'] = ''; |
|
55 | 1 | } |
|
56 | |||
57 | 3 | return $this->urlAccessToken.'?'. |
|
58 | 3 | $this->buildQueryString($params); |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * @inheritDoc |
||
63 | */ |
||
64 | 1 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
|
65 | { |
||
66 | 1 | return $this->urlApi.'/me?'. |
|
67 | 1 | $this->buildQueryString([ |
|
68 | 1 | 'access_token' => (string) $token, |
|
69 | 1 | ]); |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * @inheritDoc |
||
74 | */ |
||
75 | 1 | protected function getDefaultScopes() |
|
76 | { |
||
77 | 1 | return []; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * @inheritDoc |
||
82 | */ |
||
83 | 1 | protected function getAuthorizationParameters(array $options) |
|
84 | { |
||
85 | 1 | $options['response_type'] = 'code'; |
|
86 | 1 | $options['client_id'] = $this->clientId; |
|
87 | |||
88 | 1 | if (empty($options['state'])) { |
|
89 | 1 | $options['state'] = $this->state; |
|
90 | 1 | } |
|
91 | |||
92 | 1 | if (empty($options['redirect_uri'])) { |
|
93 | 1 | $options['redirect_uri'] = $this->redirectUri; |
|
94 | 1 | } |
|
95 | |||
96 | 1 | return $options; |
|
97 | } |
||
98 | |||
99 | /** |
||
100 | * @inheritDoc |
||
101 | */ |
||
102 | 3 | protected function checkResponse(ResponseInterface $response, $data) |
|
108 | |||
109 | /** |
||
110 | * @inheritDoc |
||
111 | */ |
||
112 | 1 | protected function createResourceOwner(array $response, AccessToken $token) |
|
116 | } |
||
117 |