Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
OAuthService | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
readConfig | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
authenticateWorkstation | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace BO\Zmsclient; |
4 | |
5 | use BO\Zmsentities\Config; |
6 | use BO\Zmsentities\Useraccount; |
7 | |
8 | class OAuthService |
9 | { |
10 | protected Http $http; |
11 | private string $configSecureToken; |
12 | |
13 | public function __construct(Http $http, string $configSecureToken) |
14 | { |
15 | $this->http = $http; |
16 | $this->configSecureToken = $configSecureToken; |
17 | } |
18 | |
19 | /** |
20 | * Retrieve configuration with secure token |
21 | * |
22 | * @return Config |
23 | */ |
24 | public function readConfig(): Config |
25 | { |
26 | return $this->http->readGetResult('/config/', [], $this->configSecureToken)->getEntity(); |
27 | } |
28 | |
29 | /** |
30 | * Authenticate OAuth user with workstation |
31 | * |
32 | * @param Useraccount $ownerInputData |
33 | * @param string|null $state |
34 | * @return mixed |
35 | */ |
36 | public function authenticateWorkstation(Useraccount $ownerInputData, ?string $state = null) |
37 | { |
38 | $headers = []; |
39 | if ($state) { |
40 | $headers['state'] = $state; |
41 | } |
42 | |
43 | return $this->http->readPostResult('/workstation/oauth/', $ownerInputData, $headers)->getEntity(); |
44 | } |
45 | } |