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\Expenses\Endpoint;
12:
13: class ReceiptMatch extends \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\Endpoint
14: {
15: use \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\EndpointTrait;
16:
17: /**
18: The `uri` will be a pre-signed S3 URL allowing you to upload the receipt securely. This URL can only be used for a `PUT` operation and expires 30 minutes after its creation. Once your upload is complete, we will try to match the receipt with existing expenses.
19:
20: Refer to these [docs](https://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html) on how to upload to this pre-signed S3 URL. We highly recommend using one of AWS SDKs if they're available for your language to upload these files.
21: */
22: public function __construct(\NxSys\Library\Clients\Brex\API\Expenses\Model\ReceiptMatchRequest $requestBody)
23: {
24: $this->body = $requestBody;
25: }
26:
27: public function getMethod(): string
28: {
29: return 'POST';
30: }
31:
32: public function getUri(): string
33: {
34: return '/v1/expenses/card/receipt_match';
35: }
36:
37: public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
38: {
39: if ($this->body instanceof \NxSys\Library\Clients\Brex\API\Expenses\Model\ReceiptMatchRequest) {
40: return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')];
41: }
42:
43: return [[], null];
44: }
45:
46: public function getExtraHeaders(): array
47: {
48: return ['Accept' => ['application/json']];
49: }
50:
51: /**
52: * {@inheritdoc}
53: *
54: * @return \NxSys\Library\Clients\Brex\API\Expenses\Model\CreateAsyncFileUploadResponse|null
55: *
56: * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptMatchBadRequestException
57: * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptMatchUnauthorizedException
58: */
59: protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
60: {
61: $status = $response->getStatusCode();
62: $body = (string) $response->getBody();
63: if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
64: return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Expenses\\Model\\CreateAsyncFileUploadResponse', 'json');
65: }
66: if (400 === $status) {
67: throw new \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptMatchBadRequestException($response);
68: }
69: if (401 === $status) {
70: throw new \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptMatchUnauthorizedException($response);
71: }
72: }
73:
74: public function getAuthenticationScopes(): array
75: {
76: return ['oAuth2ClientCredentials'];
77: }
78: }
79: