1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2019 SURFnet B.V. |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddlewareClient\Identity\Service; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupMiddlewareClient\Exception\AccessDeniedToResourceException; |
22
|
|
|
use Surfnet\StepupMiddlewareClient\Exception\MalformedResponseException; |
23
|
|
|
use Surfnet\StepupMiddlewareClient\Exception\ResourceReadException; |
24
|
|
|
use Surfnet\StepupMiddlewareClient\Identity\Dto\ProfileSearchQuery; |
25
|
|
|
use Surfnet\StepupMiddlewareClient\Service\ApiService; |
26
|
|
|
|
27
|
|
|
class ProfileService |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var ApiService |
31
|
|
|
*/ |
32
|
|
|
private $apiService; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param ApiService $apiService |
36
|
|
|
*/ |
37
|
|
|
public function __construct(ApiService $apiService) |
38
|
|
|
{ |
39
|
|
|
$this->apiService = $apiService; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param ProfileSearchQuery $query |
44
|
|
|
* @return null|array |
45
|
|
|
* @throws AccessDeniedToResourceException When the consumer isn't authorised to access given resource. |
46
|
|
|
* @throws ResourceReadException When the server doesn't respond with the resource. |
47
|
|
|
* @throws MalformedResponseException When the server doesn't respond with (well-formed) JSON. |
48
|
|
|
*/ |
49
|
|
|
public function get(ProfileSearchQuery $query) |
50
|
|
|
{ |
51
|
|
|
return $this->apiService->read('profile/%s', [$query->getIdentityId()], $query); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|