| 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; |
| 12: | |
| 13: | class Client extends \NxSys\Library\Clients\Brex\API\Expenses\Runtime\Client\Client |
| 14: | { |
| 15: | /** |
| 16: | * List expenses under the same account. Admin and bookkeeper have access to any expense, and regular users can only access their own. |
| 17: | * |
| 18: | * @param array $queryParameters { |
| 19: | * |
| 20: | * @var array $expand[] |
| 21: | * @var array $user_id[] |
| 22: | * @var array $parent_expense_id[] |
| 23: | * @var string $cursor |
| 24: | * @var int $limit |
| 25: | * } |
| 26: | * |
| 27: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 28: | * |
| 29: | * @return \NxSys\Library\Clients\Brex\API\Expenses\Model\PageExpandableExpense|\Psr\Http\Message\ResponseInterface|null |
| 30: | * |
| 31: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesBadRequestException |
| 32: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesUnauthorizedException |
| 33: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ListExpensesForbiddenException |
| 34: | */ |
| 35: | public function listExpenses(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) |
| 36: | { |
| 37: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Expenses\Endpoint\ListExpenses($queryParameters), $fetch); |
| 38: | } |
| 39: | |
| 40: | /** |
| 41: | 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. |
| 42: | |
| 43: | 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. |
| 44: | |
| 45: | * |
| 46: | * @param \NxSys\Library\Clients\Brex\API\Expenses\Model\ReceiptMatchRequest $requestBody |
| 47: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 48: | * |
| 49: | * @return \NxSys\Library\Clients\Brex\API\Expenses\Model\CreateAsyncFileUploadResponse|\Psr\Http\Message\ResponseInterface|null |
| 50: | * |
| 51: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptMatchBadRequestException |
| 52: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptMatchUnauthorizedException |
| 53: | */ |
| 54: | public function receiptMatch(Model\ReceiptMatchRequest $requestBody, string $fetch = self::FETCH_OBJECT) |
| 55: | { |
| 56: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Expenses\Endpoint\ReceiptMatch($requestBody), $fetch); |
| 57: | } |
| 58: | |
| 59: | /** |
| 60: | * Get an expense by its ID. |
| 61: | * |
| 62: | * @param array $queryParameters { |
| 63: | * |
| 64: | * @var array $expand[] |
| 65: | * } |
| 66: | * |
| 67: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 68: | * |
| 69: | * @return \NxSys\Library\Clients\Brex\API\Expenses\Model\ExpandableExpense|\Psr\Http\Message\ResponseInterface|null |
| 70: | * |
| 71: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\GetExpenseBadRequestException |
| 72: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\GetExpenseUnauthorizedException |
| 73: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\GetExpenseForbiddenException |
| 74: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\GetExpenseNotFoundException |
| 75: | */ |
| 76: | public function getExpense(string $expenseId, array $queryParameters = [], string $fetch = self::FETCH_OBJECT) |
| 77: | { |
| 78: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Expenses\Endpoint\GetExpense($expenseId, $queryParameters), $fetch); |
| 79: | } |
| 80: | |
| 81: | /** |
| 82: | * Update an expense. Admin and bookkeeper have access to any expense, and regular users can only access their own. |
| 83: | * |
| 84: | * @param \NxSys\Library\Clients\Brex\API\Expenses\Model\UpdateExpenseRequest $requestBody |
| 85: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 86: | * |
| 87: | * @return \NxSys\Library\Clients\Brex\API\Expenses\Model\Expense|\Psr\Http\Message\ResponseInterface|null |
| 88: | * |
| 89: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\UpdateExpenseBadRequestException |
| 90: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\UpdateExpenseUnauthorizedException |
| 91: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\UpdateExpenseForbiddenException |
| 92: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\UpdateExpenseNotFoundException |
| 93: | */ |
| 94: | public function updateExpense(string $expenseId, Model\UpdateExpenseRequest $requestBody, string $fetch = self::FETCH_OBJECT) |
| 95: | { |
| 96: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Expenses\Endpoint\UpdateExpense($expenseId, $requestBody), $fetch); |
| 97: | } |
| 98: | |
| 99: | /** |
| 100: | 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. |
| 101: | |
| 102: | 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. |
| 103: | |
| 104: | * |
| 105: | * @param \NxSys\Library\Clients\Brex\API\Expenses\Model\ReceiptUploadRequest $requestBody |
| 106: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 107: | * |
| 108: | * @return \NxSys\Library\Clients\Brex\API\Expenses\Model\CreateAsyncFileUploadResponse|\Psr\Http\Message\ResponseInterface|null |
| 109: | * |
| 110: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptUploadBadRequestException |
| 111: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptUploadUnauthorizedException |
| 112: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptUploadForbiddenException |
| 113: | * @throws \NxSys\Library\Clients\Brex\API\Expenses\Exception\ReceiptUploadNotFoundException |
| 114: | */ |
| 115: | public function receiptUpload(string $expenseId, Model\ReceiptUploadRequest $requestBody, string $fetch = self::FETCH_OBJECT) |
| 116: | { |
| 117: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Expenses\Endpoint\ReceiptUpload($expenseId, $requestBody), $fetch); |
| 118: | } |
| 119: | |
| 120: | public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) |
| 121: | { |
| 122: | if (null === $httpClient) { |
| 123: | $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); |
| 124: | $plugins = []; |
| 125: | $uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri('https://platform.brexapis.com'); |
| 126: | $plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri); |
| 127: | if (count($additionalPlugins) > 0) { |
| 128: | $plugins = array_merge($plugins, $additionalPlugins); |
| 129: | } |
| 130: | $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); |
| 131: | } |
| 132: | $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); |
| 133: | $streamFactory = \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory(); |
| 134: | $normalizers = [new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(), new \NxSys\Library\Clients\Brex\API\Expenses\Normalizer\JaneObjectNormalizer()]; |
| 135: | if (count($additionalNormalizers) > 0) { |
| 136: | $normalizers = array_merge($normalizers, $additionalNormalizers); |
| 137: | } |
| 138: | $serializer = new \Symfony\Component\Serializer\Serializer($normalizers, [new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode(['json_decode_associative' => true]))]); |
| 139: | |
| 140: | return new static($httpClient, $requestFactory, $serializer, $streamFactory); |
| 141: | } |
| 142: | } |
| 143: |