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\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: Creates a new card.
19: The `spend_controls` field is required when `limit_type` = `CARD`.
20: The `mailing_address` field is required for physical cards and is the shipping address used to send the card; it is not the same as the billing and mailing address used for online purchases.
21: The first 2 lines of this address must be under 60 characters long. Each user can only have up to 10 active physical cards.
22:
23: *
24: * @param array $headerParameters {
25: *
26: * @var string $Idempotency-Key
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: * {@inheritdoc}
72: *
73: * @return \NxSys\Library\Clients\Brex\API\Team\Model\Card|null
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: