Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | public function authenticate(Credentials $credentials): Token |
||
25 | { |
||
26 | $method = HttpMethod::POST(); |
||
27 | $body = json_encode($credentials); |
||
28 | $url = self::URL_LOGIN; |
||
29 | |||
30 | $response = $this->transport->sendRequest($method, $url, $body); |
||
31 | |||
32 | if ($response->code === 403) { |
||
33 | throw new \Exception("Invalid credentials"); |
||
34 | } |
||
35 | |||
36 | return new Token($response->body->access_token); |
||
37 | } |
||
38 | |||
55 | } |