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 SetUserLimit 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: protected $id;
17:
18: /**
19: This endpoint sets the monthly limit for a user.
20: The limit amount must be non-negative.
21: To unset the monthly limit of the user, just set `monthly_limit` to null.
22:
23: *
24: * @param array $headerParameters {
25: *
26: * @var string $Idempotency-Key
27: * }
28: */
29: public function __construct(string $id, \NxSys\Library\Clients\Brex\API\Team\Model\SetUserLimitRequest $requestBody, array $headerParameters = [])
30: {
31: $this->id = $id;
32: $this->body = $requestBody;
33: $this->headerParameters = $headerParameters;
34: }
35:
36: public function getMethod(): string
37: {
38: return 'POST';
39: }
40:
41: public function getUri(): string
42: {
43: return str_replace(['{id}'], [$this->id], '/v2/users/{id}/limit');
44: }
45:
46: public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
47: {
48: if ($this->body instanceof \NxSys\Library\Clients\Brex\API\Team\Model\SetUserLimitRequest) {
49: return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')];
50: }
51:
52: return [[], null];
53: }
54:
55: public function getExtraHeaders(): array
56: {
57: return ['Accept' => ['application/json']];
58: }
59:
60: protected function getHeadersOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
61: {
62: $optionsResolver = parent::getHeadersOptionsResolver();
63: $optionsResolver->setDefined(['Idempotency-Key']);
64: $optionsResolver->setRequired([]);
65: $optionsResolver->setDefaults([]);
66: $optionsResolver->addAllowedTypes('Idempotency-Key', ['string', 'null']);
67:
68: return $optionsResolver;
69: }
70:
71: /**
72: * {@inheritdoc}
73: *
74: * @return \NxSys\Library\Clients\Brex\API\Team\Model\UserLimitResponse|null
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\\Team\\Model\\UserLimitResponse', 'json');
82: }
83: }
84:
85: public function getAuthenticationScopes(): array
86: {
87: return ['OAuth2'];
88: }
89: }
90: