1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | namespace NxSys\Library\Clients\Brex\API\Payments\Endpoint; |
12: | |
13: | class ListTransfers extends \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\Endpoint |
14: | { |
15: | use \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\EndpointTrait; |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | public function __construct(array $queryParameters = []) |
34: | { |
35: | $this->queryParameters = $queryParameters; |
36: | } |
37: | |
38: | public function getMethod(): string |
39: | { |
40: | return 'GET'; |
41: | } |
42: | |
43: | public function getUri(): string |
44: | { |
45: | return '/v1/transfers'; |
46: | } |
47: | |
48: | public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array |
49: | { |
50: | return [[], null]; |
51: | } |
52: | |
53: | public function getExtraHeaders(): array |
54: | { |
55: | return ['Accept' => ['application/json']]; |
56: | } |
57: | |
58: | protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver |
59: | { |
60: | $optionsResolver = parent::getQueryOptionsResolver(); |
61: | $optionsResolver->setDefined(['cursor', 'limit']); |
62: | $optionsResolver->setRequired([]); |
63: | $optionsResolver->setDefaults([]); |
64: | $optionsResolver->addAllowedTypes('cursor', ['string', 'null']); |
65: | $optionsResolver->addAllowedTypes('limit', ['int', 'null']); |
66: | |
67: | return $optionsResolver; |
68: | } |
69: | |
70: | |
71: | |
72: | |
73: | |
74: | |
75: | |
76: | |
77: | |
78: | |
79: | |
80: | protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) |
81: | { |
82: | $status = $response->getStatusCode(); |
83: | $body = (string) $response->getBody(); |
84: | if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { |
85: | return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Payments\\Model\\PageTransfer', 'json'); |
86: | } |
87: | if (400 === $status) { |
88: | throw new \NxSys\Library\Clients\Brex\API\Payments\Exception\ListTransfersBadRequestException($response); |
89: | } |
90: | if (401 === $status) { |
91: | throw new \NxSys\Library\Clients\Brex\API\Payments\Exception\ListTransfersUnauthorizedException($response); |
92: | } |
93: | if (403 === $status) { |
94: | throw new \NxSys\Library\Clients\Brex\API\Payments\Exception\ListTransfersForbiddenException($response); |
95: | } |
96: | if (500 === $status) { |
97: | throw new \NxSys\Library\Clients\Brex\API\Payments\Exception\ListTransfersInternalServerErrorException($response); |
98: | } |
99: | } |
100: | |
101: | public function getAuthenticationScopes(): array |
102: | { |
103: | return ['OAuth2']; |
104: | } |
105: | } |
106: | |