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