1: <?php
2:
3: declare(strict_types=1);
4:
5: /*
6: * This file has been auto generated by Jane,
7: *
8: * Do no edit it directly.
9: */
10:
11: namespace NxSys\Library\Clients\Brex\API\Expenses\Endpoint;
12:
13: class ListExpenses extends \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\Endpoint
14: {
15: use \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\EndpointTrait;
16:
17: /**
18: * List expenses under the same account. Admin and bookkeeper have access to any expense, and regular users can only access their own.
19: *
20: * @param array $queryParameters {
21: *
22: * @var array $expand[]
23: * @var array $user_id[]
24: * @var array $parent_expense_id[]
25: * @var string $cursor
26: * @var int $limit
27: * }
28: */
29: public function __construct(array $queryParameters = [])
30: {
31: $this->queryParameters = $queryParameters;
32: }
33:
34: public function getMethod(): string
35: {
36: return 'GET';
37: }
38:
39: public function getUri(): string
40: {
41: return '/v1/expenses/card';
42: }
43:
44: public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
45: {
46: return [[], null];
47: }
48:
49: public function getExtraHeaders(): array
50: {
51: return ['Accept' => ['application/json']];
52: }
53:
54: protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
55: {
56: $optionsResolver = parent::getQueryOptionsResolver();
57: $optionsResolver->setDefined(['expand', 'user_id', 'parent_expense_id', 'cursor', 'limit']);
58: $optionsResolver->setRequired([]);
59: $optionsResolver->setDefaults([]);
60: $optionsResolver->addAllowedTypes('expand', ['array', 'null']);
61: $optionsResolver->addAllowedTypes('user_id', ['array', 'null']);
62: $optionsResolver->addAllowedTypes('parent_expense_id', ['array', 'null']);
63: $optionsResolver->addAllowedTypes('cursor', ['string', 'null']);
64: $optionsResolver->addAllowedTypes('limit', ['int', 'null']);
65:
66: return $optionsResolver;
67: }
68:
69: /**
70: * {@inheritdoc}
71: *
72: * @return \NxSys\Library\Clients\Brex\API\Expenses\Model\PageExpandableExpense|null
73: *
74: * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesBadRequestException
75: * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesUnauthorizedException
76: * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesForbiddenException
77: */
78: protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
79: {
80: $status = $response->getStatusCode();
81: $body = (string) $response->getBody();
82: if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
83: return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Expenses\\Model\\PageExpandableExpense', 'json');
84: }
85: if (400 === $status) {
86: throw new \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesBadRequestException($response);
87: }
88: if (401 === $status) {
89: throw new \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesUnauthorizedException($response);
90: }
91: if (403 === $status) {
92: throw new \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesForbiddenException($response);
93: }
94: }
95:
96: public function getAuthenticationScopes(): array
97: {
98: return ['oAuth2ClientCredentials', 'OAuth2'];
99: }
100: }
101: