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