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 ListDepartments 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: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | public function __construct(array $queryParameters = []) |
29: | { |
30: | $this->queryParameters = $queryParameters; |
31: | } |
32: | |
33: | public function getMethod(): string |
34: | { |
35: | return 'GET'; |
36: | } |
37: | |
38: | public function getUri(): string |
39: | { |
40: | return '/v2/departments'; |
41: | } |
42: | |
43: | public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array |
44: | { |
45: | return [[], null]; |
46: | } |
47: | |
48: | public function getExtraHeaders(): array |
49: | { |
50: | return ['Accept' => ['application/json']]; |
51: | } |
52: | |
53: | protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver |
54: | { |
55: | $optionsResolver = parent::getQueryOptionsResolver(); |
56: | $optionsResolver->setDefined(['cursor', 'limit', 'name']); |
57: | $optionsResolver->setRequired([]); |
58: | $optionsResolver->setDefaults([]); |
59: | $optionsResolver->addAllowedTypes('cursor', ['string', 'null']); |
60: | $optionsResolver->addAllowedTypes('limit', ['int', 'null']); |
61: | $optionsResolver->addAllowedTypes('name', ['string', 'null']); |
62: | |
63: | return $optionsResolver; |
64: | } |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | |
71: | |
72: | |
73: | |
74: | |
75: | protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
76: | { |
77: | $status = $response->getStatusCode(); |
78: | $body = (string) $response->getBody(); |
79: | if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { |
80: | return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\PageDepartmentResponse', 'json'); |
81: | } |
82: | if (400 === $status) { |
83: | throw new \NxSys\Library\Clients\Brex\API\Team\Exception\ListDepartmentsBadRequestException($response); |
84: | } |
85: | if (401 === $status) { |
86: | throw new \NxSys\Library\Clients\Brex\API\Team\Exception\ListDepartmentsUnauthorizedException($response); |
87: | } |
88: | if (403 === $status) { |
89: | throw new \NxSys\Library\Clients\Brex\API\Team\Exception\ListDepartmentsForbiddenException($response); |
90: | } |
91: | } |
92: | |
93: | public function getAuthenticationScopes(): array |
94: | { |
95: | return ['OAuth2']; |
96: | } |
97: | } |
98: | |