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 CreateCard 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: | |
29: | public function __construct(\NxSys\Library\Clients\Brex\API\Team\Model\CreateCardRequest $requestBody, array $headerParameters = []) |
30: | { |
31: | $this->body = $requestBody; |
32: | $this->headerParameters = $headerParameters; |
33: | } |
34: | |
35: | public function getMethod(): string |
36: | { |
37: | return 'POST'; |
38: | } |
39: | |
40: | public function getUri(): string |
41: | { |
42: | return '/v2/cards'; |
43: | } |
44: | |
45: | public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array |
46: | { |
47: | if ($this->body instanceof \NxSys\Library\Clients\Brex\API\Team\Model\CreateCardRequest) { |
48: | return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')]; |
49: | } |
50: | |
51: | return [[], null]; |
52: | } |
53: | |
54: | public function getExtraHeaders(): array |
55: | { |
56: | return ['Accept' => ['application/json']]; |
57: | } |
58: | |
59: | protected function getHeadersOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver |
60: | { |
61: | $optionsResolver = parent::getHeadersOptionsResolver(); |
62: | $optionsResolver->setDefined(['Idempotency-Key']); |
63: | $optionsResolver->setRequired(['Idempotency-Key']); |
64: | $optionsResolver->setDefaults([]); |
65: | $optionsResolver->addAllowedTypes('Idempotency-Key', ['string']); |
66: | |
67: | return $optionsResolver; |
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\\Card', 'json'); |
81: | } |
82: | } |
83: | |
84: | public function getAuthenticationScopes(): array |
85: | { |
86: | return ['OAuth2']; |
87: | } |
88: | } |
89: | |