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\Budgets\Endpoint;
12:
13: class CreateBudget extends \NxSys\Library\Clients\Brex\API\Budgets\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Budgets\Runtime\Client\Endpoint
14: {
15: use \NxSys\Library\Clients\Brex\API\Budgets\Runtime\Client\EndpointTrait;
16:
17: /**
18: Creates a Budget
19:
20: *
21: * @param array $headerParameters {
22: *
23: * @var string $Idempotency-Key
24: * }
25: */
26: public function __construct(\NxSys\Library\Clients\Brex\API\Budgets\Model\CreateBudgetRequest $requestBody, array $headerParameters = [])
27: {
28: $this->body = $requestBody;
29: $this->headerParameters = $headerParameters;
30: }
31:
32: public function getMethod(): string
33: {
34: return 'POST';
35: }
36:
37: public function getUri(): string
38: {
39: return '/v1/budgets';
40: }
41:
42: public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
43: {
44: if ($this->body instanceof \NxSys\Library\Clients\Brex\API\Budgets\Model\CreateBudgetRequest) {
45: return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')];
46: }
47:
48: return [[], null];
49: }
50:
51: public function getExtraHeaders(): array
52: {
53: return ['Accept' => ['application/json']];
54: }
55:
56: protected function getHeadersOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
57: {
58: $optionsResolver = parent::getHeadersOptionsResolver();
59: $optionsResolver->setDefined(['Idempotency-Key']);
60: $optionsResolver->setRequired(['Idempotency-Key']);
61: $optionsResolver->setDefaults([]);
62: $optionsResolver->addAllowedTypes('Idempotency-Key', ['string']);
63:
64: return $optionsResolver;
65: }
66:
67: /**
68: * {@inheritdoc}
69: *
70: * @return \NxSys\Library\Clients\Brex\API\Budgets\Model\Budget|null
71: *
72: * @throws \NxSys\Library\Clients\Brex\API\Budgets\Exception\CreateBudgetBadRequestException
73: * @throws \NxSys\Library\Clients\Brex\API\Budgets\Exception\CreateBudgetUnauthorizedException
74: * @throws \NxSys\Library\Clients\Brex\API\Budgets\Exception\CreateBudgetForbiddenException
75: */
76: protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
77: {
78: $status = $response->getStatusCode();
79: $body = (string) $response->getBody();
80: if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
81: return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Budgets\\Model\\Budget', 'json');
82: }
83: if (400 === $status) {
84: throw new \NxSys\Library\Clients\Brex\API\Budgets\Exception\CreateBudgetBadRequestException($response);
85: }
86: if (401 === $status) {
87: throw new \NxSys\Library\Clients\Brex\API\Budgets\Exception\CreateBudgetUnauthorizedException($response);
88: }
89: if (403 === $status) {
90: throw new \NxSys\Library\Clients\Brex\API\Budgets\Exception\CreateBudgetForbiddenException($response);
91: }
92: }
93:
94: public function getAuthenticationScopes(): array
95: {
96: return ['OAuth2'];
97: }
98: }
99: