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 ListPrimaryCardTransactions 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: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | public function __construct(array $queryParameters = []) |
32: | { |
33: | $this->queryParameters = $queryParameters; |
34: | } |
35: | |
36: | public function getMethod(): string |
37: | { |
38: | return 'GET'; |
39: | } |
40: | |
41: | public function getUri(): string |
42: | { |
43: | return '/v2/transactions/card/primary'; |
44: | } |
45: | |
46: | public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array |
47: | { |
48: | return [[], null]; |
49: | } |
50: | |
51: | public function getExtraHeaders(): array |
52: | { |
53: | return ['Accept' => ['application/json']]; |
54: | } |
55: | |
56: | protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver |
57: | { |
58: | $optionsResolver = parent::getQueryOptionsResolver(); |
59: | $optionsResolver->setDefined(['cursor', 'limit', 'user_ids', 'posted_at_start', 'expand']); |
60: | $optionsResolver->setRequired([]); |
61: | $optionsResolver->setDefaults([]); |
62: | $optionsResolver->addAllowedTypes('cursor', ['string', 'null']); |
63: | $optionsResolver->addAllowedTypes('limit', ['int', 'null']); |
64: | $optionsResolver->addAllowedTypes('user_ids', ['array', 'null']); |
65: | $optionsResolver->addAllowedTypes('posted_at_start', ['string', 'null']); |
66: | $optionsResolver->addAllowedTypes('expand', ['array', 'null']); |
67: | |
68: | return $optionsResolver; |
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\\Transactions\\Model\\PageCardTransaction', 'json'); |
86: | } |
87: | if (400 === $status) { |
88: | throw new \NxSys\Library\Clients\Brex\API\Transactions\Exception\ListPrimaryCardTransactionsBadRequestException($response); |
89: | } |
90: | if (401 === $status) { |
91: | throw new \NxSys\Library\Clients\Brex\API\Transactions\Exception\ListPrimaryCardTransactionsUnauthorizedException($response); |
92: | } |
93: | if (403 === $status) { |
94: | throw new \NxSys\Library\Clients\Brex\API\Transactions\Exception\ListPrimaryCardTransactionsForbiddenException($response); |
95: | } |
96: | } |
97: | |
98: | public function getAuthenticationScopes(): array |
99: | { |
100: | return ['OAuth2']; |
101: | } |
102: | } |
103: | |