| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | namespace NxSys\Library\Clients\Brex\API\Team\Endpoint; |
| 12: | |
| 13: | class GetMe extends \NxSys\Library\Clients\Brex\API\Team\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Team\Runtime\Client\Endpoint |
| 14: | { |
| 15: | use \NxSys\Library\Clients\Brex\API\Team\Runtime\Client\EndpointTrait; |
| 16: | |
| 17: | public function getMethod(): string |
| 18: | { |
| 19: | return 'GET'; |
| 20: | } |
| 21: | |
| 22: | public function getUri(): string |
| 23: | { |
| 24: | return '/v2/users/me'; |
| 25: | } |
| 26: | |
| 27: | public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array |
| 28: | { |
| 29: | return [[], null]; |
| 30: | } |
| 31: | |
| 32: | public function getExtraHeaders(): array |
| 33: | { |
| 34: | return ['Accept' => ['application/json']]; |
| 35: | } |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
| 47: | { |
| 48: | $status = $response->getStatusCode(); |
| 49: | $body = (string) $response->getBody(); |
| 50: | if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { |
| 51: | return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UserResponse', 'json'); |
| 52: | } |
| 53: | if (400 === $status) { |
| 54: | throw new \NxSys\Library\Clients\Brex\API\Team\Exception\GetMeBadRequestException($response); |
| 55: | } |
| 56: | if (401 === $status) { |
| 57: | throw new \NxSys\Library\Clients\Brex\API\Team\Exception\GetMeUnauthorizedException($response); |
| 58: | } |
| 59: | if (403 === $status) { |
| 60: | throw new \NxSys\Library\Clients\Brex\API\Team\Exception\GetMeForbiddenException($response); |
| 61: | } |
| 62: | } |
| 63: | |
| 64: | public function getAuthenticationScopes(): array |
| 65: | { |
| 66: | return ['OAuth2']; |
| 67: | } |
| 68: | } |
| 69: | |