diff --git a/.fernignore b/.fernignore new file mode 100644 index 0000000..084a8eb --- /dev/null +++ b/.fernignore @@ -0,0 +1 @@ +# Specify files that shouldn't be modified by Fern diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cf13c1c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: ci + +on: [push] + +jobs: + compile: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up node + uses: actions/setup-node@v3 + + - name: Compile + run: yarn && yarn build + + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up node + uses: actions/setup-node@v3 + + - name: Compile + run: yarn && yarn test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72271e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +.DS_Store +/dist \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..6db0876 --- /dev/null +++ b/.npmignore @@ -0,0 +1,9 @@ +node_modules +src +tests +.gitignore +.github +.fernignore +.prettierrc.yml +tsconfig.json +yarn.lock \ No newline at end of file diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..0c06786 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,2 @@ +tabWidth: 4 +printWidth: 120 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 76d0774..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Monite - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 91e4447..05e720d 100644 --- a/README.md +++ b/README.md @@ -1 +1,149 @@ -# monite-node-client \ No newline at end of file +# Monite TypeScript Library + +[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fteam-monite%2Fmonite-node-client) +[![npm shield](https://img.shields.io/npm/v/)](https://www.npmjs.com/package/) + +The Monite TypeScript library provides convenient access to the Monite API from TypeScript. + +## Documentation + +API reference documentation is available [here](https://docs.monite.com/api). + +## Installation + +```sh +npm i -s +``` + +## Reference + +A full reference for this library is available [here](./reference.md). + +## Usage + +Instantiate and use the client with the following: + +```typescript +import { MoniteClient } from ""; + +const client = new MoniteClient({ + token: "YOUR_TOKEN", + moniteVersion: "YOUR_MONITE_VERSION", + moniteEntityId: "YOUR_MONITE_ENTITY_ID", +}); +await client.products.create({ + name: "name", +}); +``` + +## Request And Response Types + +The SDK exports all request and response types as TypeScript interfaces. Simply import them with the +following namespace: + +```typescript +import { Monite } from "Monite"; + +const request: Monite.ApprovalPoliciesGetRequest = { + ... +}; +``` + +## Exception Handling + +When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error +will be thrown. + +```typescript +import { MoniteError } from "Monite"; + +try { + await client.products.create(...); +} catch (err) { + if (err instanceof MoniteError) { + console.log(err.statusCode); + console.log(err.message); + console.log(err.body); + } +} +``` + +## Advanced + +### Retries + +The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long +as the request is deemed retriable and the number of retry attempts has not grown larger than the configured +retry limit (default: 2). + +A request is deemed retriable when any of the following HTTP status codes is returned: + +- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout) +- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests) +- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors) + +Use the `maxRetries` request option to configure this behavior. + +```typescript +const response = await client.products.create(..., { + maxRetries: 0 // override maxRetries at the request level +}); +``` + +### Timeouts + +The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior. + +```typescript +const response = await client.products.create(..., { + timeoutInSeconds: 30 // override timeout to 30s +}); +``` + +### Aborting Requests + +The SDK allows users to abort requests at any point by passing in an abort signal. + +```typescript +const controller = new AbortController(); +const response = await client.products.create(..., { + abortSignal: controller.signal +}); +controller.abort(); // aborts the request +``` + +### Runtime Compatibility + +The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following +runtimes: + +- Node.js 18+ +- Vercel +- Cloudflare Workers +- Deno v1.25+ +- Bun 1.0+ +- React Native + +### Customizing Fetch Client + +The SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an +unsupported environment, this provides a way for you to break glass and ensure the SDK works. + +```typescript +import { MoniteClient } from "Monite"; + +const client = new MoniteClient({ + ... + fetcher: // provide your implementation here +}); +``` + +## Contributing + +While we value open-source contributions to this SDK, this library is generated programmatically. +Additions made directly to this library would have to be moved over to our generation code, +otherwise they would be overwritten upon the next generated release. Feel free to open a PR as +a proof of concept, but know that we will not be able to merge it as-is. We suggest opening +an issue first to discuss with us! + +On the other hand, contributions to the README are always very welcome! diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..35d6e65 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,5 @@ +/** @type {import('jest').Config} */ +module.exports = { + preset: "ts-jest", + testEnvironment: "node", +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..ae0acf9 --- /dev/null +++ b/package.json @@ -0,0 +1,45 @@ +{ + "name": "", + "version": "0.1.0", + "private": false, + "repository": "https://github.com/team-monite/monite-node-client", + "main": "./index.js", + "types": "./index.d.ts", + "scripts": { + "format": "prettier . --write --ignore-unknown", + "build": "tsc", + "prepack": "cp -rv dist/. .", + "test": "jest" + }, + "dependencies": { + "url-join": "4.0.1", + "form-data": "^4.0.0", + "formdata-node": "^6.0.3", + "node-fetch": "2.7.0", + "qs": "6.11.2", + "readable-stream": "^4.5.2", + "js-base64": "3.7.2", + "form-data-encoder": "^4.0.2" + }, + "devDependencies": { + "@types/url-join": "4.0.1", + "@types/qs": "6.9.8", + "@types/node-fetch": "2.6.9", + "@types/readable-stream": "^4.0.15", + "fetch-mock-jest": "^1.5.1", + "webpack": "^5.94.0", + "ts-loader": "^9.3.1", + "jest": "29.7.0", + "@types/jest": "29.5.5", + "ts-jest": "29.1.1", + "jest-environment-jsdom": "29.7.0", + "@types/node": "17.0.33", + "prettier": "2.7.1", + "typescript": "4.6.4" + }, + "browser": { + "fs": false, + "os": false, + "path": false + } +} diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..9b3515f --- /dev/null +++ b/reference.md @@ -0,0 +1,16997 @@ +# Reference + +## Approval policies + +
client.approvalPolicies.get({ ...params }) -> Monite.ApprovalPolicyResourceList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a list of all approval policies with pagination. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ApprovalPoliciesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `ApprovalPolicies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalPolicies.create({ ...params }) -> Monite.ApprovalPolicyResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new approval policy. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.create({ + name: "name", + description: "description", + script: [true], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ApprovalPolicyCreate` + +
+
+ +
+
+ +**requestOptions:** `ApprovalPolicies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalPolicies.getById(approvalPolicyId) -> Monite.ApprovalPolicyResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a specific approval policy. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.getById("approval_policy_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalPolicyId:** `string` + +
+
+ +
+
+ +**requestOptions:** `ApprovalPolicies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalPolicies.deleteById(approvalPolicyId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an existing approval policy. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.deleteById("approval_policy_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalPolicyId:** `string` + +
+
+ +
+
+ +**requestOptions:** `ApprovalPolicies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalPolicies.updateById(approvalPolicyId, { ...params }) -> Monite.ApprovalPolicyResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an existing approval policy. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.updateById("approval_policy_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalPolicyId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ApprovalPolicyUpdate` + +
+
+ +
+
+ +**requestOptions:** `ApprovalPolicies.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Approval requests + +
client.approvalRequests.get({ ...params }) -> Monite.ApprovalRequestResourceList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalRequests.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ApprovalRequestsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `ApprovalRequests.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalRequests.create({ ...params }) -> Monite.ApprovalRequestResourceWithMetadata +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalRequests.create({ + object_id: "object_id", + object_type: "account", + required_approval_count: 1, + role_ids: ["role_ids"], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ApprovalRequestCreateRequest` + +
+
+ +
+
+ +**requestOptions:** `ApprovalRequests.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalRequests.getById(approvalRequestId) -> Monite.ApprovalRequestResourceWithMetadata +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalRequests.getById("approval_request_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalRequestId:** `string` + +
+
+ +
+
+ +**requestOptions:** `ApprovalRequests.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalRequests.approveById(approvalRequestId) -> Monite.ApprovalRequestResourceWithMetadata +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalRequests.approveById("approval_request_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalRequestId:** `string` + +
+
+ +
+
+ +**requestOptions:** `ApprovalRequests.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalRequests.cancelById(approvalRequestId) -> Monite.ApprovalRequestResourceWithMetadata +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalRequests.cancelById("approval_request_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalRequestId:** `string` + +
+
+ +
+
+ +**requestOptions:** `ApprovalRequests.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalRequests.rejectById(approvalRequestId) -> Monite.ApprovalRequestResourceWithMetadata +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalRequests.rejectById("approval_request_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalRequestId:** `string` + +
+
+ +
+
+ +**requestOptions:** `ApprovalRequests.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Audit logs + +
client.auditLogs.get({ ...params }) -> Monite.LogsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.auditLogs.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.AuditLogsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `AuditLogs.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.auditLogs.getById(logId) -> Monite.LogResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.auditLogs.getById("log_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**logId:** `string` + +
+
+ +
+
+ +**requestOptions:** `AuditLogs.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Access tokens + +
client.accessTokens.revoke({ ...params }) -> Monite.MessageResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Revoke an existing token immediately. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accessTokens.revoke({ + client_id: "client_id", + client_secret: "client_secret", + token: "token", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.RevokeTokenPayload` + +
+
+ +
+
+ +**requestOptions:** `AccessTokens.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accessTokens.create({ ...params }) -> Monite.AccessTokenResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new access token based on client ID and client secret. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accessTokens.create({ + client_id: "client_id", + client_secret: "client_secret", + grant_type: "client_credentials", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ObtainTokenPayload` + +
+
+ +
+
+ +**requestOptions:** `AccessTokens.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Batch payments + +
client.batchPayments.create({ ...params }) -> Monite.PaymentsBatchPaymentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.batchPayments.create({ + payer_bank_account_id: "payer_bank_account_id", + payment_intents: [ + { + object: { + id: "id", + type: "payable", + }, + recipient: { + id: "id", + type: "counterpart", + }, + }, + ], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PaymentsBatchPaymentRequest` + +
+
+ +
+
+ +**requestOptions:** `BatchPayments.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.batchPayments.getById(batchPaymentId) -> Monite.PaymentsBatchPaymentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.batchPayments.getById("batch_payment_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**batchPaymentId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BatchPayments.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Comments + +
client.comments.get({ ...params }) -> Monite.CommentResourceList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get comments + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.comments.get({ + object_type: "payable", + object_id: "object_id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CommentsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Comments.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.comments.create({ ...params }) -> Monite.CommentResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create new comment + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.comments.create({ + object_id: "object_id", + object_type: "object_type", + text: "text", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CommentCreateRequest` + +
+
+ +
+
+ +**requestOptions:** `Comments.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.comments.getById(commentId) -> Monite.CommentResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get comment + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.comments.getById("comment_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**commentId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Comments.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.comments.deleteById(commentId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete comment + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.comments.deleteById("comment_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**commentId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Comments.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.comments.updateById(commentId, { ...params }) -> Monite.CommentResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update comment + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.comments.updateById("comment_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**commentId:** `string` + +
+
+ +
+
+ +**request:** `Monite.CommentUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `Comments.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Counterparts + +
client.counterparts.get({ ...params }) -> Monite.CounterpartPaginationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.get({ + sort_code: "123456", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CounterpartsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Counterparts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.create({ ...params }) -> Monite.CounterpartResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.create({ + type: "individual", + individual: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CounterpartCreatePayload` + +
+
+ +
+
+ +**requestOptions:** `Counterparts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.getById(counterpartId) -> Monite.CounterpartResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.getById("counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Counterparts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.deleteById(counterpartId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.deleteById("counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Counterparts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.updateById(counterpartId, { ...params }) -> Monite.CounterpartResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.updateById("counterpart_id", { + individual: {}, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.CounterpartUpdatePayload` + +
+
+ +
+
+ +**requestOptions:** `Counterparts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.getPartnerMetadataById(counterpartId) -> Monite.PartnerMetadataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.getPartnerMetadataById("counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Counterparts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.updatePartnerMetadataById(counterpartId, { ...params }) -> Monite.PartnerMetadataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.updatePartnerMetadataById("counterpart_id", { + metadata: { + key: "value", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.PartnerMetadata` + +
+
+ +
+
+ +**requestOptions:** `Counterparts.RequestOptions` + +
+
+
+
+ +
+
+
+ +## DataExports + +
client.dataExports.get({ ...params }) -> Monite.AllDocumentExportResponseSchema +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.DataExportsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExports.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.dataExports.create({ ...params }) -> Monite.CreateExportTaskResponseSchema +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.create({ + date_from: "date_from", + date_to: "date_to", + format: "csv", + objects: [ + { + name: "receivable", + statuses: ["draft"], + }, + ], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ExportPayloadSchema` + +
+
+ +
+
+ +**requestOptions:** `DataExports.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.dataExports.getSupportedFormats() -> Monite.SupportedFormatSchema[] +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.getSupportedFormats(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `DataExports.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.dataExports.getById(documentExportId) -> Monite.DocumentExportResponseSchema +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.getById("document_export_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**documentExportId:** `string` + +
+
+ +
+
+ +**requestOptions:** `DataExports.RequestOptions` + +
+
+
+
+ +
+
+
+ +## PDF templates + +
client.pdfTemplates.get() -> Monite.TemplateListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This API call returns all supported templates with language codes. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.pdfTemplates.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `PdfTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.pdfTemplates.getSystem() -> Monite.TemplateListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This API call returns all supported system templates with language codes. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.pdfTemplates.getSystem(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `PdfTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.pdfTemplates.getById(documentTemplateId) -> Monite.TemplateReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.pdfTemplates.getById("document_template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**documentTemplateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PdfTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.pdfTemplates.makeDefaultById(documentTemplateId) -> Monite.TemplateReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.pdfTemplates.makeDefaultById("document_template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**documentTemplateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PdfTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.pdfTemplates.previewById(documentTemplateId) -> stream.Readable +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a sample PDF invoice generated using the specified template. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.pdfTemplates.previewById("string"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**documentTemplateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PdfTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Entities + +
client.entities.get({ ...params }) -> Monite.EntityPaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a list of all entities. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.EntitiesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.create({ ...params }) -> Monite.EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new entity from the specified values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.create({ + address: { + city: "city", + country: "AF", + line1: "line1", + postal_code: "postal_code", + }, + email: "email", + type: "individual", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CreateEntityRequest` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.getEntitiesMe() -> Monite.EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deprecated. Use `GET /entity_users/my_entity` instead. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.getEntitiesMe(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.patchEntitiesMe({ ...params }) -> Monite.EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deprecated. Use `PATCH /entity_users/my_entity` instead. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.patchEntitiesMe({}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.UpdateEntityRequest` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.getById(entityId) -> Monite.EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve an entity by its ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.getById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` — A unique ID to specify the entity. + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.updateById(entityId, { ...params }) -> Monite.EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Change the specified fields with the provided values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.updateById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5", {}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` — A unique ID to specify the entity. + +
+
+ +
+
+ +**request:** `Monite.UpdateEntityRequest` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.uploadLogoById(file, entityId) -> Monite.FileSchema3 +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for example, in PDF documents created by this entity. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.uploadLogoById(fs.createReadStream("/path/to/your/file"), "ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file:** `File | fs.ReadStream | Blob` + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.deleteLogoById(entityId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.deleteLogoById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` — A unique ID to specify the entity. + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.getPartnerMetadataById(entityId) -> Monite.PartnerMetadataResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a metadata object associated with this entity, usually in a JSON format. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.getPartnerMetadataById("entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.updatePartnerMetadataById(entityId, { ...params }) -> Monite.PartnerMetadataResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fully replace the current metadata object with the specified instance. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.updatePartnerMetadataById("entity_id", { + metadata: { + key: "value", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**request:** `Monite.PartnerMetadata` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.getSettingsById(entityId) -> Monite.MergedSettingsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all settings for this entity. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.getSettingsById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` — A unique ID to specify the entity. + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.updateSettingsById(entityId, { ...params }) -> Monite.MergedSettingsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Change the specified fields with the provided values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.updateSettingsById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` — A unique ID to specify the entity. + +
+
+ +
+
+ +**request:** `Monite.PatchSettingsPayload` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.uploadOnboardingDocuments({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Provide files for entity onboarding verification + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.uploadOnboardingDocuments(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.EntityOnboardingDocumentsPayload` + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.getOnboardingRequirements() -> Monite.GetOnboardingRequirementsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get onboarding requirements for the entity + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.getOnboardingRequirements(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Entities.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Entity users + +
client.entityUsers.get({ ...params }) -> Monite.EntityUserPaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a list of all entity users. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.EntityUsersGetRequest` + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.create({ ...params }) -> Monite.EntityUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new entity user from the specified values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.create({ + first_name: "Andrey", + login: "login", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CreateEntityUserRequest` + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.getCurrent() -> Monite.EntityUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve an entity user by its ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.getCurrent(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.updateCurrent({ ...params }) -> Monite.EntityUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Change the specified fields with provided values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.updateCurrent(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.UpdateMeEntityUserRequest` + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.getCurrentEntity() -> Monite.EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves information of an entity, which this entity user belongs to. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.getCurrentEntity(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.updateCurrentEntity({ ...params }) -> Monite.EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update information of an entity, which this entity user belongs to. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.updateCurrentEntity({}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.UpdateEntityRequest` + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.getCurrentRole() -> Monite.RoleResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves information of a role assigned to this entity user. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.getCurrentRole(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.getById(entityUserId) -> Monite.EntityUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve an entity user by its ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.getById("entity_user_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityUserId:** `string` + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.deleteById(entityUserId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.deleteById("entity_user_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityUserId:** `string` + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entityUsers.updateById(entityUserId, { ...params }) -> Monite.EntityUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Change the specified fields with provided values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entityUsers.updateById("entity_user_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityUserId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UpdateEntityUserRequest` + +
+
+ +
+
+ +**requestOptions:** `EntityUsers.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Events + +
client.events.get({ ...params }) -> Monite.EventPaginationResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get events for a given entity. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.events.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.EventsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Events.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.events.getById(eventId) -> Monite.EventResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get event by ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.events.getById("event_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**eventId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Events.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Files + +
client.files.get({ ...params }) -> Monite.FilesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.files.get({ + id__in: "string", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.FilesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Files.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.files.upload(file, { ...params }) -> Monite.FileResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.files.upload(fs.createReadStream("/path/to/your/file"), { + file_type: "ocr_results", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file:** `File | fs.ReadStream | Blob` + +
+
+ +
+
+ +**request:** `Monite.UploadFile` + +
+
+ +
+
+ +**requestOptions:** `Files.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.files.getById(fileId) -> Monite.FileResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.files.getById("file_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**fileId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Files.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.files.delete(fileId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.files.delete("file_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**fileId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Files.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Mail templates + +
client.mailTemplates.get({ ...params }) -> Monite.CustomTemplatesPaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all custom templates + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailTemplates.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.MailTemplatesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `MailTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailTemplates.create({ ...params }) -> Monite.CustomTemplateDataSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create custom template + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailTemplates.create({ + body_template: "body_template", + name: "name", + subject_template: "subject_template", + type: "receivables_quote", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.AddCustomTemplateSchema` + +
+
+ +
+
+ +**requestOptions:** `MailTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailTemplates.preview({ ...params }) -> Monite.PreviewTemplateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Preview rendered template + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailTemplates.preview({ + body: "body", + document_type: "receivables_quote", + language_code: "ab", + subject: "subject", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PreviewTemplateRequest` + +
+
+ +
+
+ +**requestOptions:** `MailTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailTemplates.getSystem() -> Monite.SystemTemplates +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all system templates + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailTemplates.getSystem(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `MailTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailTemplates.getById(templateId) -> Monite.CustomTemplateDataSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get custom template by ID + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailTemplates.getById("template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**templateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `MailTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailTemplates.deleteById(templateId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete custom template bt ID + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailTemplates.deleteById("template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**templateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `MailTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailTemplates.updateById(templateId, { ...params }) -> Monite.CustomTemplateDataSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update custom template by ID + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailTemplates.updateById("template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**templateId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UpdateCustomTemplateSchemaRequest` + +
+
+ +
+
+ +**requestOptions:** `MailTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailTemplates.makeDefaultById(templateId) -> Monite.CustomTemplateDataSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Make template default + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailTemplates.makeDefaultById("template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**templateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `MailTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Mailbox domains + +
client.mailboxDomains.get() -> Monite.DomainListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all domains owned by partner_id + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailboxDomains.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `MailboxDomains.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailboxDomains.create({ ...params }) -> Monite.DomainResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create domain for the partner_id + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailboxDomains.create({ + domain: "domain", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.DomainRequest` + +
+
+ +
+
+ +**requestOptions:** `MailboxDomains.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailboxDomains.deleteById(domainId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete domain for the partner_id + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailboxDomains.deleteById("domain_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**domainId:** `string` + +
+
+ +
+
+ +**requestOptions:** `MailboxDomains.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailboxDomains.verifyById(domainId) -> Monite.VerifyResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Verify domain for the partner_id + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailboxDomains.verifyById("domain_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**domainId:** `string` + +
+
+ +
+
+ +**requestOptions:** `MailboxDomains.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Mailboxes + +
client.mailboxes.get() -> Monite.MailboxDataResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all mailboxes owned by Entity + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailboxes.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Mailboxes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailboxes.create({ ...params }) -> Monite.MailboxResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new mailbox + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailboxes.create({ + mailbox_domain_id: "mailbox_domain_id", + mailbox_name: "mailbox_name", + related_object_type: "payable", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.MailboxDomainRequest` + +
+
+ +
+
+ +**requestOptions:** `Mailboxes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailboxes.search({ ...params }) -> Monite.MailboxDataResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all mailboxes owned by Entity + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailboxes.search({ + entity_ids: ["entity_ids"], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.MailboxMultipleEntitiesRequest` + +
+
+ +
+
+ +**requestOptions:** `Mailboxes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.mailboxes.deleteById(mailboxId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete mailbox + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.mailboxes.deleteById("mailbox_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**mailboxId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Mailboxes.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Measure units + +
client.measureUnits.get() -> Monite.UnitListResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.measureUnits.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `MeasureUnits.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.measureUnits.create({ ...params }) -> Monite.UnitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.measureUnits.create({ + name: "name", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.UnitRequest` + +
+
+ +
+
+ +**requestOptions:** `MeasureUnits.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.measureUnits.getById(unitId) -> Monite.UnitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.measureUnits.getById("unit_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**unitId:** `string` + +
+
+ +
+
+ +**requestOptions:** `MeasureUnits.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.measureUnits.deleteById(unitId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.measureUnits.deleteById("unit_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**unitId:** `string` + +
+
+ +
+
+ +**requestOptions:** `MeasureUnits.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.measureUnits.updateById(unitId, { ...params }) -> Monite.UnitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.measureUnits.updateById("unit_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**unitId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UnitUpdate` + +
+
+ +
+
+ +**requestOptions:** `MeasureUnits.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Onboarding links + +
client.onboardingLinks.create({ ...params }) -> Monite.OnboardingLinkPublicResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.onboardingLinks.create({ + expires_at: "2024-01-15T09:30:00Z", + refresh_url: "refresh_url", + return_url: "return_url", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.OnboardingLinkRequest` + +
+
+ +
+
+ +**requestOptions:** `OnboardingLinks.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Overdue reminders + +
client.overdueReminders.get() -> Monite.AllOverdueRemindersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.overdueReminders.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `OverdueReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.overdueReminders.create({ ...params }) -> Monite.OverdueReminderResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.overdueReminders.create({ + name: "name", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.OverdueReminderRequest` + +
+
+ +
+
+ +**requestOptions:** `OverdueReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.overdueReminders.getById(overdueReminderId) -> Monite.OverdueReminderResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.overdueReminders.getById("overdue_reminder_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**overdueReminderId:** `string` + +
+
+ +
+
+ +**requestOptions:** `OverdueReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.overdueReminders.deleteById(overdueReminderId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.overdueReminders.deleteById("overdue_reminder_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**overdueReminderId:** `string` + +
+
+ +
+
+ +**requestOptions:** `OverdueReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.overdueReminders.updateById(overdueReminderId, { ...params }) -> Monite.OverdueReminderResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.overdueReminders.updateById("overdue_reminder_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**overdueReminderId:** `string` + +
+
+ +
+
+ +**request:** `Monite.OverdueReminderUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `OverdueReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Purchase orders + +
client.purchaseOrders.get({ ...params }) -> Monite.PurchaseOrderPaginationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.purchaseOrders.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PurchaseOrdersGetRequest` + +
+
+ +
+
+ +**requestOptions:** `PurchaseOrders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.purchaseOrders.create({ ...params }) -> Monite.PurchaseOrderResponseSchema +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.purchaseOrders.create({ + counterpart_id: "counterpart_id", + currency: "AED", + items: [ + { + currency: "AED", + name: "name", + price: 1, + quantity: 1, + unit: "unit", + vat_rate: 1, + }, + ], + message: "message", + valid_for_days: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PurchaseOrderPayloadSchema` + +
+
+ +
+
+ +**requestOptions:** `PurchaseOrders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.purchaseOrders.getVariables() -> Monite.VariablesObjectList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a list of placeholders allowed to insert into an email template for customization + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.purchaseOrders.getVariables(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `PurchaseOrders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.purchaseOrders.getById(purchaseOrderId) -> Monite.PurchaseOrderResponseSchema +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.purchaseOrders.getById("purchase_order_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**purchaseOrderId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PurchaseOrders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.purchaseOrders.deleteById(purchaseOrderId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.purchaseOrders.deleteById("purchase_order_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**purchaseOrderId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PurchaseOrders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.purchaseOrders.updateById(purchaseOrderId, { ...params }) -> Monite.PurchaseOrderResponseSchema +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.purchaseOrders.updateById("purchase_order_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**purchaseOrderId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UpdatePurchaseOrderPayloadSchema` + +
+
+ +
+
+ +**requestOptions:** `PurchaseOrders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.purchaseOrders.previewById(purchaseOrderId, { ...params }) -> Monite.PurchaseOrderEmailPreviewResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.purchaseOrders.previewById("purchase_order_id", { + body_text: "body_text", + subject_text: "subject_text", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**purchaseOrderId:** `string` + +
+
+ +
+
+ +**request:** `Monite.PurchaseOrderEmailPreviewRequest` + +
+
+ +
+
+ +**requestOptions:** `PurchaseOrders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.purchaseOrders.sendById(purchaseOrderId, { ...params }) -> Monite.PurchaseOrderEmailSentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.purchaseOrders.sendById("purchase_order_id", { + body_text: "body_text", + subject_text: "subject_text", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**purchaseOrderId:** `string` + +
+
+ +
+
+ +**request:** `Monite.SendPurchaseOrderViaEmailRequest` + +
+
+ +
+
+ +**requestOptions:** `PurchaseOrders.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Payables + +
client.payables.get({ ...params }) -> Monite.PayablePaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists all payables from the connected entity. + +If you already have the data of the payable (amount in [minor units](https://docs.monite.com/docs/currencies#minor-units), currency, vendor information, and other details) +stored somewhere as individual attributes, you can create a payable with these attributes by calling [POST +/payables](https://docs.monite.com/reference/post_payables) and providing the [base64-encoded](https://en.wikipedia.org/wiki/Base64) contents of the original invoice file in the field `base64_encoded_file`. + +A payable is a financial document given by an entity`s supplier itemizing the purchase of a good or a service and +demanding payment. + +The `file_name` field is optional. If omitted, it defaults to “default_file_name”. If the settings are configured +to automatically set `suggested_payment_term`, this object can be omitted from the request body. + +The `id` generated for this payable can be used in other API calls to update the data of this payable or trigger [ +status transitions](https://docs.monite.com/docs/payable-status-transitions), for example. essential data +fields to move from `draft` to `new` + +Related guide: [Create a payable from data](https://docs.monite.com/docs/collect-payables#create-a-payable-from-data) + +See also: + +[Automatic calculation of due date](https://docs.monite.com/docs/collect-payables#automatic-calculation-of-due-date) + +[Suggested payment date](https://docs.monite.com/docs/collect-payables#suggested-payment-date) + +[Attach file](https://docs.monite.com/docs/collect-payables#attach-file) + +[Collect payables by email](https://docs.monite.com/docs/collect-payables#send-payables-by-email) + +[Manage line items](https://docs.monite.com/docs/manage-line-items) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PayablesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.create({ ...params }) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a new payable by providing the amount, currency, vendor name, and other details. +You can provide the base64_encoded contents of the original invoice file in the field `base64_encoded_file`. + +You can use this endpoint to bypass the Monite OCR service and provide the data directly +(for example, if you already have the data in place). + +A newly created payable has the the `draft` [status](https://docs.monite.com/docs/payables-lifecycle). + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.create(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PayableUploadWithDataSchema` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.getAnalytics({ ...params }) -> Monite.PayableAggregatedDataResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve aggregated statistics for payables, including total amount and count, both overall and by status. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.getAnalytics(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PayablesGetAnalyticsRequest` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.uploadFromFile(file) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Upload an incoming invoice (payable) in PDF, PNG, JPEG, or TIFF format and scan its contents. The maximum file size is 10MB. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.uploadFromFile(fs.createReadStream("/path/to/your/file")); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file:** `File | fs.ReadStream | Blob` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.getValidations() -> Monite.PayableValidationsResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get payable validations. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.getValidations(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.updateValidations({ ...params }) -> Monite.PayableValidationsResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update payable validations. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.updateValidations({ + required_fields: ["currency"], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PayableValidationsUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.resetValidations() -> Monite.PayableValidationsResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Reset payable validations to default ones. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.resetValidations(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.getVariables() -> Monite.PayableTemplatesVariablesObjectList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a list of placeholders allowed to insert into an email template for customization + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.getVariables(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.getById(payableId) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves information about a specific payable with the given ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.getById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.deleteById(payableId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deletes a specific payable. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.deleteById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.updateById(payableId, { ...params }) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates the information about a specific payable. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.updateById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.PayableUpdateSchema` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.approvePaymentById(payableId) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Confirms that the payable is ready to be paid. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.approvePaymentById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.attachFileById(file, payableId) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Attach file to payable without existing attachment. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.attachFileById(fs.createReadStream("/path/to/your/file"), "payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file:** `File | fs.ReadStream | Blob` + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.cancelById(payableId) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Cancels the payable that was not confirmed during the review. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.cancelById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.markAsPaidById(payableId, { ...params }) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Mark a payable as paid. + +Payables can be paid using the payment channels offered by Monite or through external payment channels. In the latter +case, the invoice is not automatically marked as paid in the system and needs to be converted to the paid status +manually. + +Optionally, it is possible to pass the `comment` field in the request body, to describe how and when the invoice was +paid. + +Notes: + +- To use this endpoint with an entity user token, this entity user must have a role that includes the `pay` permission + for payables. +- The `amount_to_pay` field is automatically calculated based on the `amount_due` less the percentage described + in the `payment_terms.discount` value. + +Related guide: [Mark a payable as paid](https://docs.monite.com/docs/payable-status-transitions#mark-as-paid) + +See also: + +[Payables lifecycle](https://docs.monite.com/docs/payables-lifecycle) + +[Payables status transitions](https://docs.monite.com/docs/collect-payables#suggested-payment-date) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.markAsPaidById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.CommentPayload` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.markAsPartiallyPaidById(payableId, { ...params }) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Mark a payable as partially paid. + +If the payable is partially paid, its status is moved to `partially_paid`. The value of the `amount_paid` field must be +the sum of all payments made, not only the last one. + +Notes: + +- This endpoint can be used for payables in the `waiting_to_be_paid` status. +- The `amount_paid` must be greater than 0 and less than the total payable amount specified by the `amount` field. +- You can use this endpoint multiple times for the same payable to reflect multiple partial payments, always setting the + sum of all payments made. +- To use this endpoint with an entity user token, this entity user must have a role that includes the `pay` + permission for payables. +- The `amount_to_pay` field is automatically calculated based on the `amount_due` less the percentage described + in the `payment_terms.discount` value. + +Related guide: [Mark a payable as partially paid](https://docs.monite.com/docs/payable-status-transitions#mark-as-partially-paid) + +See also: + +[Payables lifecycle](https://docs.monite.com/docs/payables-lifecycle) + +[Payables status transitions](https://docs.monite.com/docs/collect-payables#suggested-payment-date) + +[Mark a payable as paid](https://docs.monite.com/docs/payable-status-transitions#mark-as-paid) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.markAsPartiallyPaidById("payable_id", { + amount_paid: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.PartiallyPaidPayload` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.rejectById(payableId) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Declines the payable when an approver finds any mismatch or discrepancies. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.rejectById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.reopenById(payableId) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Reset payable state from rejected to new. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.reopenById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.submitForApprovalById(payableId) -> Monite.PayableResponseSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Starts the approval process once the uploaded payable is validated. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.submitForApprovalById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.validateById(payableId) -> Monite.PayableValidationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Check the invoice for compliance with the requirements for movement from draft to new status. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.validateById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Payment intents + +
client.paymentIntents.get({ ...params }) -> Monite.PaymentIntentsListResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentIntents.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PaymentIntentsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `PaymentIntents.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentIntents.getById(paymentIntentId) -> Monite.PaymentIntentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentIntents.getById("payment_intent_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentIntentId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentIntents.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentIntents.updateById(paymentIntentId, { ...params }) -> Monite.PaymentIntentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentIntents.updateById("payment_intent_id", { + amount: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentIntentId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UpdatePaymentIntentPayload` + +
+
+ +
+
+ +**requestOptions:** `PaymentIntents.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentIntents.getHistoryById(paymentIntentId) -> Monite.PaymentIntentHistoryResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentIntents.getHistoryById("payment_intent_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentIntentId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentIntents.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Payment links + +
client.paymentLinks.create({ ...params }) -> Monite.PublicPaymentLinkResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentLinks.create({ + payment_methods: ["sepa_credit"], + recipient: { + id: "id", + type: "entity", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CreatePaymentLinkRequest` + +
+
+ +
+
+ +**requestOptions:** `PaymentLinks.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentLinks.getById(paymentLinkId) -> Monite.PublicPaymentLinkResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentLinks.getById("payment_link_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentLinkId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentLinks.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentLinks.expireById(paymentLinkId) -> Monite.PublicPaymentLinkResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentLinks.expireById("payment_link_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentLinkId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentLinks.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Payment records + +
client.paymentRecords.get({ ...params }) -> Monite.PaymentRecordResponseList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentRecords.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PaymentRecordsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `PaymentRecords.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentRecords.create({ ...params }) -> Monite.PaymentRecordResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentRecords.create({ + amount: 1, + currency: "AED", + object: { + id: "id", + type: "receivable", + }, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PaymentRecordRequest` + +
+
+ +
+
+ +**requestOptions:** `PaymentRecords.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentRecords.getById(paymentRecordId) -> Monite.PaymentRecordResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentRecords.getById("payment_record_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentRecordId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentRecords.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Payment reminders + +
client.paymentReminders.get() -> Monite.GetAllPaymentReminders +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentReminders.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `PaymentReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentReminders.create({ ...params }) -> Monite.PaymentReminderResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentReminders.create({ + name: "name", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PaymentReminder` + +
+
+ +
+
+ +**requestOptions:** `PaymentReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentReminders.getById(paymentReminderId) -> Monite.PaymentReminderResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentReminders.getById("payment_reminder_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentReminderId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentReminders.deleteById(paymentReminderId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentReminders.deleteById("payment_reminder_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentReminderId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentReminders.updateById(paymentReminderId, { ...params }) -> Monite.PaymentReminderResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentReminders.updateById("payment_reminder_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentReminderId:** `string` + +
+
+ +
+
+ +**request:** `Monite.PaymentReminderUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `PaymentReminders.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Payment terms + +
client.paymentTerms.get() -> Monite.PaymentTermsListResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentTerms.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `PaymentTerms.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentTerms.create({ ...params }) -> Monite.PaymentTermsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentTerms.create({ + name: "name", + term_final: { + number_of_days: 1, + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PaymentTermsCreatePayload` + +
+
+ +
+
+ +**requestOptions:** `PaymentTerms.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentTerms.getById(paymentTermsId) -> Monite.PaymentTermsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentTerms.getById("payment_terms_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentTermsId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentTerms.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentTerms.deleteById(paymentTermsId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentTerms.deleteById("payment_terms_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentTermsId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentTerms.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.paymentTerms.updateById(paymentTermsId, { ...params }) -> Monite.PaymentTermsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.paymentTerms.updateById("payment_terms_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**paymentTermsId:** `string` + +
+
+ +
+
+ +**request:** `Monite.PaymentTermsUpdatePayload` + +
+
+ +
+
+ +**requestOptions:** `PaymentTerms.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Products + +
client.products.get({ ...params }) -> Monite.ProductServicePaginationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.products.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ProductsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Products.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.products.create({ ...params }) -> Monite.ProductServiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.products.create({ + name: "name", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ProductServiceRequest` + +
+
+ +
+
+ +**requestOptions:** `Products.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.products.getById(productId) -> Monite.ProductServiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.products.getById("product_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**productId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Products.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.products.deleteById(productId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.products.deleteById("product_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**productId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Products.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.products.updateById(productId, { ...params }) -> Monite.ProductServiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.products.updateById("product_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**productId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ProductServiceUpdate` + +
+
+ +
+
+ +**requestOptions:** `Products.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Projects + +
client.projects.get({ ...params }) -> Monite.ProjectPaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all projects for an entity + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.projects.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ProjectsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Projects.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.projects.create({ ...params }) -> Monite.ProjectResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new project. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.projects.create({ + name: "Marketing", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ProjectCreateRequest` + +
+
+ +
+
+ +**requestOptions:** `Projects.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.projects.getById(projectId) -> Monite.ProjectResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a project with the given ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.projects.getById("project_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**projectId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Projects.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.projects.deleteById(projectId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a project. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.projects.deleteById("project_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**projectId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Projects.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.projects.updateById(projectId, { ...params }) -> Monite.ProjectResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a project. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.projects.updateById("project_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**projectId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ProjectUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `Projects.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Receivables + +
client.receivables.get({ ...params }) -> Monite.ReceivablePaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of [accounts receivable](https://docs.monite.com/accounts-receivable/index) documents - invoices, quotes, and credit notes - of the specified entity. + +Results can be filtered by amount, counterpart, due date, and other criteria. Multiple filters are combined using logical AND unless specified otherwise. If no documents matching the search criteria are found, the endpoint returns a successful response with an empty `data` array. + +This endpoint supports [pagination](https://docs.monite.com/api/concepts/pagination-sorting-filtering) and sorting. By default, results are sorted by the creation date in ascending order (from oldest to newest). + +#### Examples + +##### Invoices + +- Get all overdue invoices: + + ``` + GET /receivables?type=invoice&status=overdue + ``` + +- Get all invoices created for the counterpart named "Solarwind" (case-insensitive): + + ``` + GET /receivables?type=invoice?counterpart_name__icontains=Solarwind + ``` + +- Get invoices whose total amount starts from 500 EUR: + + ``` + GET /receivables?type=invoice&total_amount__gte=50000 + ``` + +- Get invoices that are due for payment in September 2024: + + ``` + GET /receivables?type=invoice&due_date__gte=2024-09-01T00:00:00Z&due_date__lt=2024-10-01T00:00:00Z + ``` + +- Get invoices created on or after September 1, 2024: + + ``` + GET /receivables?type=invoice&created_at__gte=2024-09-01T00:00:00Z + ``` + +- Find an invoice created from a specific quote: + + ``` + GET /receivables?type=invoice?based_on=QUOTE_ID + ``` + +##### Quotes + +- Get the latest created quote: + + ``` + GET /receivables?type=quote&sort=created_at&order=desc&limit=1 + ``` + +- Get the latest issued quote: + + ``` + GET /receivables?type=quote&sort=issue_date&order=desc&limit=1 + ``` + +##### Credit notes + +- Find all credit notes created for a specific invoice: + + ``` + GET /receivables?type=credit_note?based_on=INVOICE_ID + ``` + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ReceivablesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.create({ ...params }) -> Monite.ReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.create({ + counterpart_billing_address_id: "counterpart_billing_address_id", + counterpart_id: "counterpart_id", + currency: "AED", + line_items: [ + { + quantity: 1.1, + }, + ], + type: "quote", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ReceivableFacadeCreatePayload` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.getVariables() -> Monite.ReceivableTemplatesVariablesObjectList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a list of placeholders that can be used in email templates for customization. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.getVariables(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.getById(receivableId) -> Monite.ReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.getById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.deleteById(receivableId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.deleteById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.updateById(receivableId, { ...params }) -> Monite.ReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.updateById("receivable_id", { + quote: {}, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivableUpdatePayload` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.acceptById(receivableId, { ...params }) -> Monite.SuccessResult +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.acceptById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.QuoteAcceptRequest` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.cancelById(receivableId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.cancelById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.cloneById(receivableId) -> Monite.ReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.cloneById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.declineById(receivableId, { ...params }) -> Monite.SuccessResult +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.declineById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivableDeclinePayload` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.getHistory(receivableId, { ...params }) -> Monite.ReceivableHistoryPaginationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.getHistory("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivablesGetHistoryRequest` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.getHistoryById(receivableHistoryId, receivableId) -> Monite.ReceivableHistoryResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.getHistoryById("receivable_history_id", "receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableHistoryId:** `string` + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.issueById(receivableId) -> Monite.ReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.issueById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.updateLineItemsById(receivableId, { ...params }) -> Monite.LineItemsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Replace all line items of an existing invoice or quote with a new list of line items. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.updateLineItemsById("receivable_id", { + data: [ + { + quantity: 1.1, + }, + ], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UpdateLineItems` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.getMails(receivableId, { ...params }) -> Monite.ReceivableMailPaginationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.getMails("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivablesGetMailsRequest` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.getMailById(receivableId, mailId) -> Monite.ReceivableMailResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.getMailById("receivable_id", "mail_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**mailId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.markAsPaidById(receivableId, { ...params }) -> Monite.ReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.markAsPaidById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivablePaidPayload` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.markAsPartiallyPaidById(receivableId, { ...params }) -> Monite.ReceivableResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deprecated. Use `POST /payment_records` to record an invoice payment. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.markAsPartiallyPaidById("receivable_id", { + amount_paid: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivablePartiallyPaidPayload` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.markAsUncollectibleById(receivableId, { ...params }) -> Monite.ReceivableResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.markAsUncollectibleById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivableUncollectiblePayload` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.getPdfLinkById(receivableId) -> Monite.ReceivableFileUrl +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.getPdfLinkById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.previewById(receivableId, { ...params }) -> Monite.ReceivablePreviewResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.previewById("receivable_id", { + body_text: "body_text", + subject_text: "subject_text", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivablePreviewRequest` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.sendById(receivableId, { ...params }) -> Monite.ReceivableSendResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.sendById("receivable_id", { + body_text: "body_text", + subject_text: "subject_text", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivableSendRequest` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.sendTestReminderById(receivableId, { ...params }) -> Monite.ReceivablesSendResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.sendTestReminderById("receivable_id", { + reminder_type: "term_1", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.ReceivableSendTestReminderPayload` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.receivables.verifyById(receivableId) -> Monite.ReceivablesVerifyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.verifyById("receivable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**receivableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Recurrences + +
client.recurrences.get() -> Monite.GetAllRecurrences +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.recurrences.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Recurrences.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.recurrences.create({ ...params }) -> Monite.Recurrence +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.recurrences.create({ + day_of_month: "first_day", + end_month: 1, + end_year: 1, + invoice_id: "invoice_id", + start_month: 1, + start_year: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CreateRecurrencePayload` + +
+
+ +
+
+ +**requestOptions:** `Recurrences.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.recurrences.getById(recurrenceId) -> Monite.Recurrence +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.recurrences.getById("recurrence_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**recurrenceId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Recurrences.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.recurrences.updateById(recurrenceId, { ...params }) -> Monite.Recurrence +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.recurrences.updateById("recurrence_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**recurrenceId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UpdateRecurrencePayload` + +
+
+ +
+
+ +**requestOptions:** `Recurrences.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.recurrences.cancelById(recurrenceId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.recurrences.cancelById("recurrence_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**recurrenceId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Recurrences.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Roles + +
client.roles.get({ ...params }) -> Monite.RolePaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Find all roles that match the search criteria. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.roles.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.RolesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Roles.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.roles.create({ ...params }) -> Monite.RoleResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new role from the specified values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.roles.create({ + name: "name", + permissions: {}, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CreateRoleRequest` + +
+
+ +
+
+ +**requestOptions:** `Roles.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.roles.getById(roleId) -> Monite.RoleResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.roles.getById("role_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**roleId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Roles.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.roles.updateById(roleId, { ...params }) -> Monite.RoleResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Change the specified fields with the provided values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.roles.updateById("role_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**roleId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UpdateRoleRequest` + +
+
+ +
+
+ +**requestOptions:** `Roles.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Partner settings + +
client.partnerSettings.get() -> Monite.PartnerProjectSettingsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all settings for this partner. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.partnerSettings.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `PartnerSettings.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.partnerSettings.update({ ...params }) -> Monite.PartnerProjectSettingsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Change the specified fields with the provided values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.partnerSettings.update(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.PartnerProjectSettingsPayload` + +
+
+ +
+
+ +**requestOptions:** `PartnerSettings.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Tags + +
client.tags.get({ ...params }) -> Monite.TagsPaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a list of all tags. Tags can be assigned to resources to assist with searching and filtering. +Tags can also be used as trigger conditions in payable approval policies. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.tags.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.TagsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.tags.create({ ...params }) -> Monite.TagReadSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new tag. The tag name must be unique. +Tag names are case-sensitive, that is `Marketing` and `marketing` are two different tags. + +The response returns an auto-generated ID assigned to this tag. +To assign this tag to a resource, send the tag ID in the `tag_ids` list when creating or updating a resource. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.tags.create({ + name: "Marketing", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.TagCreateSchema` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.tags.getById(tagId) -> Monite.TagReadSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get information about a tag with the given ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.tags.getById("tag_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**tagId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.tags.deleteById(tagId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a tag with the given ID. This tag will be automatically deleted from all resources where it was used. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.tags.deleteById("tag_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**tagId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.tags.updateById(tagId, { ...params }) -> Monite.TagReadSchema +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Change the tag name. The new name must be unique among existing tags. +Tag names are case-sensitive, that is `Marketing` and `marketing` are two different tags. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.tags.updateById("tag_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**tagId:** `string` + +
+
+ +
+
+ +**request:** `Monite.TagUpdateSchema` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Text templates + +
client.textTemplates.get({ ...params }) -> Monite.TextTemplateResponseList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get text templates + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.textTemplates.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.TextTemplatesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `TextTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.textTemplates.create({ ...params }) -> Monite.TextTemplateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a text template + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.textTemplates.create({ + document_type: "quote", + name: "name", + template: "template", + type: "email_header", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CreateTextTemplatePayload` + +
+
+ +
+
+ +**requestOptions:** `TextTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.textTemplates.getById(textTemplateId) -> Monite.TextTemplateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all custom contents + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.textTemplates.getById("text_template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**textTemplateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `TextTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.textTemplates.deleteById(textTemplateId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete custom content by ID + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.textTemplates.deleteById("text_template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**textTemplateId:** `string` — UUID text_template ID + +
+
+ +
+
+ +**requestOptions:** `TextTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.textTemplates.updateById(textTemplateId, { ...params }) -> Monite.TextTemplateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update custom content by ID + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.textTemplates.updateById("text_template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**textTemplateId:** `string` — UUID text_template ID + +
+
+ +
+
+ +**request:** `Monite.UpdateTextTemplatePayload` + +
+
+ +
+
+ +**requestOptions:** `TextTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.textTemplates.makeDefaultById(textTemplateId) -> Monite.TextTemplateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Make text template default + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.textTemplates.makeDefaultById("text_template_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**textTemplateId:** `string` — UUID text_template ID + +
+
+ +
+
+ +**requestOptions:** `TextTemplates.RequestOptions` + +
+
+
+
+ +
+
+
+ +## VAT rates + +
client.vatRates.get({ ...params }) -> Monite.VatRateListResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.vatRates.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.VatRatesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `VatRates.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Webhook deliveries + +
client.webhookDeliveries.get({ ...params }) -> Monite.WebhookDeliveryPaginationResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookDeliveries.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.WebhookDeliveriesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `WebhookDeliveries.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Webhook subscriptions + +
client.webhookSubscriptions.get({ ...params }) -> Monite.WebhookSubscriptionPaginationResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookSubscriptions.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.WebhookSubscriptionsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `WebhookSubscriptions.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.webhookSubscriptions.create({ ...params }) -> Monite.WebhookSubscriptionResourceWithSecret +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookSubscriptions.create({ + object_type: "account", + url: "url", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CreateWebhookSubscriptionRequest` + +
+
+ +
+
+ +**requestOptions:** `WebhookSubscriptions.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.webhookSubscriptions.getById(webhookSubscriptionId) -> Monite.WebhookSubscriptionResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookSubscriptions.getById("webhook_subscription_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookSubscriptionId:** `string` + +
+
+ +
+
+ +**requestOptions:** `WebhookSubscriptions.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.webhookSubscriptions.deleteById(webhookSubscriptionId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookSubscriptions.deleteById("webhook_subscription_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookSubscriptionId:** `string` + +
+
+ +
+
+ +**requestOptions:** `WebhookSubscriptions.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.webhookSubscriptions.updateById(webhookSubscriptionId, { ...params }) -> Monite.WebhookSubscriptionResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookSubscriptions.updateById("webhook_subscription_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookSubscriptionId:** `string` + +
+
+ +
+
+ +**request:** `Monite.UpdateWebhookSubscriptionRequest` + +
+
+ +
+
+ +**requestOptions:** `WebhookSubscriptions.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.webhookSubscriptions.disableById(webhookSubscriptionId) -> Monite.WebhookSubscriptionResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookSubscriptions.disableById("webhook_subscription_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookSubscriptionId:** `string` + +
+
+ +
+
+ +**requestOptions:** `WebhookSubscriptions.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.webhookSubscriptions.enableById(webhookSubscriptionId) -> Monite.WebhookSubscriptionResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookSubscriptions.enableById("webhook_subscription_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookSubscriptionId:** `string` + +
+
+ +
+
+ +**requestOptions:** `WebhookSubscriptions.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.webhookSubscriptions.regenerateSecretById(webhookSubscriptionId) -> Monite.WebhookSubscriptionResourceWithSecret +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.webhookSubscriptions.regenerateSecretById("webhook_subscription_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookSubscriptionId:** `string` + +
+
+ +
+
+ +**requestOptions:** `WebhookSubscriptions.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Accounting Payables + +
client.accounting.payables.get({ ...params }) -> Monite.AccountingPayableList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of accounts payable invoices (bills) that exist in the entity's accounting system. This requires that an accounting connection has been previously established. Refer to the [Accounting integration guide](https://docs.monite.com/accounting/integration/index) for details. + +This endpoint only provides read-only access to the accounting system's data but does not pull those payables into Monite. You can use it to review the data in the accounting system and find out which of those payables already exist or do not exist in Monite. + +Data is actual as of the date and time of the last accounting synchronization, which is specified by the `last_pull` value in the response from `GET /accounting_connections/{connection_id}`. To make sure you are accessing the most up-to-date accounting data, you can use `POST /accounting_connections/{connection_id}/sync` to trigger on-demand synchronization before getting the list of payables. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.payables.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.accounting.PayablesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.payables.getById(payableId) -> Monite.AccountingPayable +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns information about an individual payable invoice (bill) that exists in the entity's accounting system. This payable may or may not also exist in Monite. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.payables.getById("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` — An internal ID of the payable invoice (bill) in the accounting system. You can get these IDs from `GET /accounting/payables`. + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Accounting Receivables + +
client.accounting.receivables.get({ ...params }) -> Monite.AccountingReceivableList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of invoices that exist in the entity's accounting system. This requires that an accounting connection has been previously established. Refer to the [Accounting integration guide](https://docs.monite.com/accounting/integration/index) for details. + +This endpoint only provides read-only access to the accounting system's data but does not pull those invoices into Monite. You can use it to review the data in the accounting system and find out which of those invoices already exist or do not exist in Monite. + +Data is actual as of the date and time of the last accounting synchronization, which is specified by the `last_pull` value in the response from `GET /accounting_connections/{connection_id}`. To make sure you are accessing the most up-to-date accounting data, you can use `POST /accounting_connections/{connection_id}/sync` to trigger on-demand synchronization before getting the invoice list. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.receivables.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.accounting.ReceivablesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.receivables.getById(invoiceId) -> Monite.AccountingReceivable +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns information about an individual invoice that exists in the entity's accounting system. This invoice may or may not also exist in Monite. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.receivables.getById("invoice_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoiceId:** `string` — An internal ID of the invoice in the accounting system. You can get these IDs from `GET /accounting/receivables`. + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Accounting Connections + +
client.accounting.connections.get() -> Monite.AccountingConnectionList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all connections + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.connections.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Connections.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.connections.create({ ...params }) -> Monite.AccountingConnectionResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create new connection + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.connections.create(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.accounting.AccountingConnectionRequest` + +
+
+ +
+
+ +**requestOptions:** `Connections.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.connections.getById(connectionId) -> Monite.AccountingConnectionResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get connection by id + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.connections.getById("connection_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**connectionId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Connections.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.connections.disconnectById(connectionId) -> Monite.AccountingConnectionResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Disconnect + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.connections.disconnectById("connection_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**connectionId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Connections.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.connections.syncById(connectionId) -> Monite.AccountingMessageResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.connections.syncById("connection_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**connectionId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Connections.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Accounting SyncedRecords + +
client.accounting.syncedRecords.get({ ...params }) -> Monite.SyncRecordResourceList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get synchronized records + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.syncedRecords.get({ + object_type: "product", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.accounting.SyncedRecordsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `SyncedRecords.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.syncedRecords.getById(syncedRecordId) -> Monite.SyncRecordResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get synchronized record by id + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.syncedRecords.getById("synced_record_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**syncedRecordId:** `string` + +
+
+ +
+
+ +**requestOptions:** `SyncedRecords.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.syncedRecords.pushById(syncedRecordId) -> Monite.SyncRecordResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Push object to the accounting system manually + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.syncedRecords.pushById("synced_record_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**syncedRecordId:** `string` + +
+
+ +
+
+ +**requestOptions:** `SyncedRecords.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Accounting TaxRates + +
client.accounting.taxRates.get({ ...params }) -> Monite.AccountingTaxRateListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all tax rate accounts + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.taxRates.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.accounting.TaxRatesGetRequest` + +
+
+ +
+
+ +**requestOptions:** `TaxRates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.taxRates.getById(taxRateId) -> Monite.AccountingTaxRateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get tax rate account by id + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.taxRates.getById("tax_rate_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**taxRateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `TaxRates.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Accounting LedgerAccounts + +
client.accounting.ledgerAccounts.get({ ...params }) -> Monite.LedgerAccountListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all ledger accounts + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.ledgerAccounts.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.accounting.LedgerAccountsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `LedgerAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.accounting.ledgerAccounts.getById(ledgerAccountId) -> Monite.LedgerAccountResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get ledger account by id + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.accounting.ledgerAccounts.getById("ledger_account_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ledgerAccountId:** `string` + +
+
+ +
+
+ +**requestOptions:** `LedgerAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +## ApprovalPolicies Processes + +
client.approvalPolicies.processes.get(approvalPolicyId) -> Monite.ApprovalProcessResourceList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a list of all approval policy processes. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.processes.get("approval_policy_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalPolicyId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Processes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalPolicies.processes.getById(approvalPolicyId, processId) -> Monite.ProcessResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a specific approval policy process. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.processes.getById("approval_policy_id", "process_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalPolicyId:** `string` + +
+
+ +
+
+ +**processId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Processes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalPolicies.processes.cancelById(approvalPolicyId, processId) -> Monite.ProcessResource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Cancel an ongoing approval process for a specific approval policy. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.processes.cancelById("approval_policy_id", "process_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalPolicyId:** `string` + +
+
+ +
+
+ +**processId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Processes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.approvalPolicies.processes.getSteps(approvalPolicyId, processId) -> Monite.ApprovalProcessStepResourceList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a list of approval policy process steps. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.approvalPolicies.processes.getSteps("approval_policy_id", "process_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**approvalPolicyId:** `string` + +
+
+ +
+
+ +**processId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Processes.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Counterparts Addresses + +
client.counterparts.addresses.get(counterpartId) -> Monite.CounterpartAddressResourceList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.addresses.get("counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Addresses.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.addresses.create(counterpartId, { ...params }) -> Monite.CounterpartAddressResponseWithCounterpartId +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.addresses.create("counterpart_id", { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.CounterpartAddress` + +
+
+ +
+
+ +**requestOptions:** `Addresses.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.addresses.getById(addressId, counterpartId) -> Monite.CounterpartAddressResponseWithCounterpartId +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.addresses.getById("address_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**addressId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Addresses.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.addresses.deleteById(addressId, counterpartId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.addresses.deleteById("address_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**addressId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Addresses.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.addresses.updateById(addressId, counterpartId, { ...params }) -> Monite.CounterpartAddressResponseWithCounterpartId +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.addresses.updateById("address_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**addressId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.counterparts.CounterpartUpdateAddress` + +
+
+ +
+
+ +**requestOptions:** `Addresses.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Counterparts BankAccounts + +
client.counterparts.bankAccounts.get(counterpartId) -> Monite.CounterpartBankAccountResourceList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.bankAccounts.get("counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.bankAccounts.create(counterpartId, { ...params }) -> Monite.CounterpartBankAccountResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.bankAccounts.create("counterpart_id", { + country: "AF", + currency: "AED", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.counterparts.CreateCounterpartBankAccount` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.bankAccounts.getById(bankAccountId, counterpartId) -> Monite.CounterpartBankAccountResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.bankAccounts.getById("bank_account_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.bankAccounts.deleteById(bankAccountId, counterpartId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.bankAccounts.deleteById("bank_account_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.bankAccounts.updateById(bankAccountId, counterpartId, { ...params }) -> Monite.CounterpartBankAccountResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.bankAccounts.updateById("bank_account_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.counterparts.UpdateCounterpartBankAccount` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.bankAccounts.makeDefaultById(bankAccountId, counterpartId) -> unknown +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.bankAccounts.makeDefaultById("bank_account_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Counterparts Contacts + +
client.counterparts.contacts.get(counterpartId) -> Monite.CounterpartContactsResourceList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.contacts.get("counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.contacts.create(counterpartId, { ...params }) -> Monite.CounterpartContactResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.contacts.create("counterpart_id", { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + first_name: "Mary", + last_name: "O'Brien", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.counterparts.CreateCounterpartContactPayload` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.contacts.getById(contactId, counterpartId) -> Monite.CounterpartContactResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.contacts.getById("contact_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.contacts.deleteById(contactId, counterpartId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.contacts.deleteById("contact_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.contacts.updateById(contactId, counterpartId, { ...params }) -> Monite.CounterpartContactResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.contacts.updateById("contact_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.counterparts.UpdateCounterpartContactPayload` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.contacts.makeDefaultById(contactId, counterpartId) -> Monite.CounterpartContactResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.contacts.makeDefaultById("contact_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Counterparts VatIds + +
client.counterparts.vatIds.get(counterpartId) -> Monite.CounterpartVatIdResourceList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.vatIds.get("counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.vatIds.create(counterpartId, { ...params }) -> Monite.CounterpartVatIdResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.vatIds.create("counterpart_id", { + value: "123456789", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.counterparts.CounterpartVatId` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.vatIds.getById(vatId, counterpartId) -> Monite.CounterpartVatIdResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.vatIds.getById("vat_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**vatId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.vatIds.deleteById(vatId, counterpartId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.vatIds.deleteById("vat_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**vatId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.counterparts.vatIds.updateById(vatId, counterpartId, { ...params }) -> Monite.CounterpartVatIdResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.counterparts.vatIds.updateById("vat_id", "counterpart_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**vatId:** `string` + +
+
+ +
+
+ +**counterpartId:** `string` + +
+
+ +
+
+ +**request:** `Monite.counterparts.CounterpartUpdateVatId` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +## DataExports ExtraData + +
client.dataExports.extraData.get({ ...params }) -> Monite.ExtraDataResourceList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.extraData.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.dataExports.ExtraDataGetRequest` + +
+
+ +
+
+ +**requestOptions:** `ExtraData.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.dataExports.extraData.create({ ...params }) -> Monite.ExtraDataResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.extraData.create({ + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.dataExports.ExtraDataCreateRequest` + +
+
+ +
+
+ +**requestOptions:** `ExtraData.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.dataExports.extraData.getById(extraDataId) -> Monite.ExtraDataResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.extraData.getById("extra_data_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**extraDataId:** `string` + +
+
+ +
+
+ +**requestOptions:** `ExtraData.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.dataExports.extraData.deleteById(extraDataId) -> Monite.ExtraDataResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.extraData.deleteById("extra_data_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**extraDataId:** `string` + +
+
+ +
+
+ +**requestOptions:** `ExtraData.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.dataExports.extraData.updateById(extraDataId, { ...params }) -> Monite.ExtraDataResource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.dataExports.extraData.updateById("extra_data_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**extraDataId:** `string` + +
+
+ +
+
+ +**request:** `Monite.dataExports.ExtraDataUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `ExtraData.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Entities BankAccounts + +
client.entities.bankAccounts.get() -> Monite.EntityBankAccountPaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all bank accounts of this entity. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.create({ ...params }) -> Monite.EntityBankAccountResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a new bank account for the specified entity. + +The minimum required fields are `currency` and `country`. Other required fields depend on the currency: + +- EUR accounts require `iban`. +- GBP accounts require `account_holder_name`, `account_number`, and `sort_code`. +- USD accounts require `account_holder_name`, `account_number`, and `routing_number`. +- Accounts in other currencies require one of: + - `iban` + - `account_number` and `sort_code` + - `account_number` and `routing_number` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.create({ + country: "AF", + currency: "AED", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.entities.CreateEntityBankAccountRequest` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.completeVerification({ ...params }) -> Monite.CompleteVerificationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.completeVerification({ + airwallex_plaid: { + account: { + id: "id", + mask: "mask", + name: "name", + }, + institution: { + id: "id", + name: "name", + }, + mandate: { + email: "email", + signatory: "signatory", + type: "us_ach_debit", + version: "1.0", + }, + public_token: "public_token", + }, + type: "airwallex_plaid", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.entities.CompleteVerificationRequest` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.startVerification({ ...params }) -> Monite.VerificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Start entity bank account verification. The flow depends on verification type. +For airwallex_plaid it generates Plaid Link token to init the Plaid SDK. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.startVerification({ + airwallex_plaid: { + client_name: "client_name", + redirect_url: "redirect_url", + }, + type: "airwallex_plaid", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.VerificationRequest` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.getById(bankAccountId) -> Monite.EntityBankAccountResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a bank account by its ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.getById("bank_account_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.deleteById(bankAccountId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete the bank account specified by its ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.deleteById("bank_account_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.updateById(bankAccountId, { ...params }) -> Monite.EntityBankAccountResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Change the specified fields with the provided values. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.updateById("bank_account_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**request:** `Monite.entities.UpdateEntityBankAccountRequest` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.completeVerificationById(bankAccountId, { ...params }) -> Monite.CompleteRefreshVerificationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.completeVerificationById("bank_account_id", { + type: "airwallex_plaid", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**request:** `Monite.entities.CompleteRefreshVerificationRequest` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.makeDefaultById(bankAccountId) -> Monite.EntityBankAccountResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Set a bank account as the default for this entity per currency. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.makeDefaultById("bank_account_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.refreshVerificationById(bankAccountId, { ...params }) -> Monite.VerificationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.refreshVerificationById("bank_account_id", { + airwallex_plaid: { + client_name: "client_name", + redirect_url: "redirect_url", + }, + type: "airwallex_plaid", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**request:** `Monite.VerificationRequest` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.bankAccounts.getVerificationsById(bankAccountId) -> Monite.BankAccountVerifications +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.bankAccounts.getVerificationsById("bank_account_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bankAccountId:** `string` + +
+
+ +
+
+ +**requestOptions:** `BankAccounts.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Entities OnboardingData + +
client.entities.onboardingData.get(entityId) -> Monite.EntityOnboardingDataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.onboardingData.get("entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**requestOptions:** `OnboardingData.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.onboardingData.update(entityId, { ...params }) -> Monite.EntityOnboardingDataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.onboardingData.update("entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**request:** `Monite.entities.EntityOnboardingDataRequest` + +
+
+ +
+
+ +**requestOptions:** `OnboardingData.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Entities PaymentMethods + +
client.entities.paymentMethods.get(entityId) -> Monite.OnboardingPaymentMethodsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all enabled payment methods. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.paymentMethods.get("entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**requestOptions:** `PaymentMethods.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.paymentMethods.set(entityId, { ...params }) -> Monite.OnboardingPaymentMethodsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Set which payment methods should be enabled. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.paymentMethods.set("entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**request:** `Monite.entities.EnabledPaymentMethods` + +
+
+ +
+
+ +**requestOptions:** `PaymentMethods.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Entities VatIds + +
client.entities.vatIds.get(entityId) -> Monite.EntityVatIdResourceList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.vatIds.get("entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.vatIds.create(entityId, { ...params }) -> Monite.EntityVatIdResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.vatIds.create("entity_id", { + country: "AF", + value: "123456789", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**request:** `Monite.entities.EntityVatId` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.vatIds.getById(id, entityId) -> Monite.EntityVatIdResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.vatIds.getById("id", "entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `string` + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.vatIds.deleteById(id, entityId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.vatIds.deleteById("id", "entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `string` + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.vatIds.updateById(id, entityId, { ...params }) -> Monite.EntityVatIdResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.vatIds.updateById("id", "entity_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `string` + +
+
+ +
+
+ +**entityId:** `string` + +
+
+ +
+
+ +**request:** `Monite.entities.EntityUpdateVatId` + +
+
+ +
+
+ +**requestOptions:** `VatIds.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Entities Persons + +
client.entities.persons.get() -> Monite.PersonsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.persons.get(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Persons.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.persons.create({ ...params }) -> Monite.PersonResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.persons.create({ + first_name: "first_name", + last_name: "last_name", + email: "email", + relationship: {}, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.entities.PersonRequest` + +
+
+ +
+
+ +**requestOptions:** `Persons.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.persons.getById(personId) -> Monite.PersonResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.persons.getById("person_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**personId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Persons.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.persons.deleteById(personId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.persons.deleteById("person_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**personId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Persons.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.persons.updateById(personId, { ...params }) -> Monite.PersonResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.persons.updateById("person_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**personId:** `string` + +
+
+ +
+
+ +**request:** `Monite.entities.OptionalPersonRequest` + +
+
+ +
+
+ +**requestOptions:** `Persons.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.entities.persons.uploadOnboardingDocuments(personId, { ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Provide files for person onboarding verification + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.entities.persons.uploadOnboardingDocuments("person_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**personId:** `string` + +
+
+ +
+
+ +**request:** `Monite.entities.PersonOnboardingDocumentsPayload` + +
+
+ +
+
+ +**requestOptions:** `Persons.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Payables LineItems + +
client.payables.lineItems.get(payableId, { ...params }) -> Monite.LineItemPaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a list of all line items related to a specific payable. +Related guide: [List all payable line items](https://docs.monite.com/docs/manage-line-items#list-all-line-items-of-a-payable) + +See also: + +[Manage line items](https://docs.monite.com/docs/manage-line-items) + +[Collect payables](https://docs.monite.com/docs/collect-payables) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.lineItems.get("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.payables.LineItemsGetRequest` + +
+
+ +
+
+ +**requestOptions:** `LineItems.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.lineItems.create(payableId, { ...params }) -> Monite.LineItemResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a new line item to a specific payable. + +The `subtotal` and `total` fields of line items are automatically calculated based on the `unit_price`, +`quantity`, and `tax` fields, therefore, are read-only and appear only in the response schema. The field +`ledger_account_id` is required **only** for account integration, otherwise, it is optional. + +Related guide: [Add line items to a payable](https://docs.monite.com/docs/manage-line-items#add-line-items-to-a-payable) + +See also: + +[Manage line items](https://docs.monite.com/docs/manage-line-items) + +[Collect payables](https://docs.monite.com/docs/collect-payables) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.lineItems.create("payable_id", {}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.LineItemRequest` + +
+
+ +
+
+ +**requestOptions:** `LineItems.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.lineItems.replace(payableId, { ...params }) -> Monite.LineItemsReplaceResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Replaces the information of all line items of a specific payable. + +Related guide: [Replace all line items](https://docs.monite.com/docs/manage-line-items#replace-all-line-items) + +See also: + +[Manage line items](https://docs.monite.com/docs/manage-line-items) + +[Collect payables](https://docs.monite.com/docs/collect-payables) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.lineItems.replace("payable_id", { + data: [{}], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.payables.LineItemsReplaceRequest` + +
+
+ +
+
+ +**requestOptions:** `LineItems.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.lineItems.getById(lineItemId, payableId) -> Monite.LineItemResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get information about a specific line item with a given ID. + +Related guide: [Retrieve a line item](https://docs.monite.com/docs/manage-line-items#retrieve-a-line-item) + +See also: + +[Manage line items](https://docs.monite.com/docs/manage-line-items) + +[Collect payables](https://docs.monite.com/docs/collect-payables) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.lineItems.getById("line_item_id", "payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**lineItemId:** `string` + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `LineItems.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.lineItems.deleteById(lineItemId, payableId) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete the line item with the given ID. + +Related guide: [Remove a line item](https://docs.monite.com/docs/manage-line-items#remove-a-line-item) + +See also: + +[Manage line items](https://docs.monite.com/docs/manage-line-items) + +[Collect payables](https://docs.monite.com/docs/collect-payables) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.lineItems.deleteById("line_item_id", "payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**lineItemId:** `string` + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**requestOptions:** `LineItems.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.payables.lineItems.updateById(lineItemId, payableId, { ...params }) -> Monite.LineItemResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Edits the information of a specific line item. + +Related guide: [Update a line item](https://docs.monite.com/docs/manage-line-items#update-a-line-item) + +See also: + +[Manage line items](https://docs.monite.com/docs/manage-line-items) + +[Collect payables](https://docs.monite.com/docs/collect-payables) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.lineItems.updateById("line_item_id", "payable_id", {}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**lineItemId:** `string` + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.LineItemRequest` + +
+
+ +
+
+ +**requestOptions:** `LineItems.RequestOptions` + +
+
+
+
+ +
+
+
diff --git a/src/Client.ts b/src/Client.ts new file mode 100644 index 0000000..8517cfd --- /dev/null +++ b/src/Client.ts @@ -0,0 +1,301 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "./environments"; +import * as core from "./core"; +import { ApprovalPolicies } from "./api/resources/approvalPolicies/client/Client"; +import { ApprovalRequests } from "./api/resources/approvalRequests/client/Client"; +import { AuditLogs } from "./api/resources/auditLogs/client/Client"; +import { AccessTokens } from "./api/resources/accessTokens/client/Client"; +import { BatchPayments } from "./api/resources/batchPayments/client/Client"; +import { Comments } from "./api/resources/comments/client/Client"; +import { Counterparts } from "./api/resources/counterparts/client/Client"; +import { DataExports } from "./api/resources/dataExports/client/Client"; +import { PdfTemplates } from "./api/resources/pdfTemplates/client/Client"; +import { Entities } from "./api/resources/entities/client/Client"; +import { EntityUsers } from "./api/resources/entityUsers/client/Client"; +import { Events } from "./api/resources/events/client/Client"; +import { Files } from "./api/resources/files/client/Client"; +import { MailTemplates } from "./api/resources/mailTemplates/client/Client"; +import { MailboxDomains } from "./api/resources/mailboxDomains/client/Client"; +import { Mailboxes } from "./api/resources/mailboxes/client/Client"; +import { MeasureUnits } from "./api/resources/measureUnits/client/Client"; +import { OnboardingLinks } from "./api/resources/onboardingLinks/client/Client"; +import { OverdueReminders } from "./api/resources/overdueReminders/client/Client"; +import { PurchaseOrders } from "./api/resources/purchaseOrders/client/Client"; +import { Payables } from "./api/resources/payables/client/Client"; +import { PaymentIntents } from "./api/resources/paymentIntents/client/Client"; +import { PaymentLinks } from "./api/resources/paymentLinks/client/Client"; +import { PaymentRecords } from "./api/resources/paymentRecords/client/Client"; +import { PaymentReminders } from "./api/resources/paymentReminders/client/Client"; +import { PaymentTerms } from "./api/resources/paymentTerms/client/Client"; +import { Products } from "./api/resources/products/client/Client"; +import { Projects } from "./api/resources/projects/client/Client"; +import { Receivables } from "./api/resources/receivables/client/Client"; +import { Recurrences } from "./api/resources/recurrences/client/Client"; +import { Roles } from "./api/resources/roles/client/Client"; +import { PartnerSettings } from "./api/resources/partnerSettings/client/Client"; +import { Tags } from "./api/resources/tags/client/Client"; +import { TextTemplates } from "./api/resources/textTemplates/client/Client"; +import { VatRates } from "./api/resources/vatRates/client/Client"; +import { WebhookDeliveries } from "./api/resources/webhookDeliveries/client/Client"; +import { WebhookSubscriptions } from "./api/resources/webhookSubscriptions/client/Client"; +import { Accounting } from "./api/resources/accounting/client/Client"; + +export declare namespace MoniteClient { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class MoniteClient { + constructor(protected readonly _options: MoniteClient.Options) {} + + protected _approvalPolicies: ApprovalPolicies | undefined; + + public get approvalPolicies(): ApprovalPolicies { + return (this._approvalPolicies ??= new ApprovalPolicies(this._options)); + } + + protected _approvalRequests: ApprovalRequests | undefined; + + public get approvalRequests(): ApprovalRequests { + return (this._approvalRequests ??= new ApprovalRequests(this._options)); + } + + protected _auditLogs: AuditLogs | undefined; + + public get auditLogs(): AuditLogs { + return (this._auditLogs ??= new AuditLogs(this._options)); + } + + protected _accessTokens: AccessTokens | undefined; + + public get accessTokens(): AccessTokens { + return (this._accessTokens ??= new AccessTokens(this._options)); + } + + protected _batchPayments: BatchPayments | undefined; + + public get batchPayments(): BatchPayments { + return (this._batchPayments ??= new BatchPayments(this._options)); + } + + protected _comments: Comments | undefined; + + public get comments(): Comments { + return (this._comments ??= new Comments(this._options)); + } + + protected _counterparts: Counterparts | undefined; + + public get counterparts(): Counterparts { + return (this._counterparts ??= new Counterparts(this._options)); + } + + protected _dataExports: DataExports | undefined; + + public get dataExports(): DataExports { + return (this._dataExports ??= new DataExports(this._options)); + } + + protected _pdfTemplates: PdfTemplates | undefined; + + public get pdfTemplates(): PdfTemplates { + return (this._pdfTemplates ??= new PdfTemplates(this._options)); + } + + protected _entities: Entities | undefined; + + public get entities(): Entities { + return (this._entities ??= new Entities(this._options)); + } + + protected _entityUsers: EntityUsers | undefined; + + public get entityUsers(): EntityUsers { + return (this._entityUsers ??= new EntityUsers(this._options)); + } + + protected _events: Events | undefined; + + public get events(): Events { + return (this._events ??= new Events(this._options)); + } + + protected _files: Files | undefined; + + public get files(): Files { + return (this._files ??= new Files(this._options)); + } + + protected _mailTemplates: MailTemplates | undefined; + + public get mailTemplates(): MailTemplates { + return (this._mailTemplates ??= new MailTemplates(this._options)); + } + + protected _mailboxDomains: MailboxDomains | undefined; + + public get mailboxDomains(): MailboxDomains { + return (this._mailboxDomains ??= new MailboxDomains(this._options)); + } + + protected _mailboxes: Mailboxes | undefined; + + public get mailboxes(): Mailboxes { + return (this._mailboxes ??= new Mailboxes(this._options)); + } + + protected _measureUnits: MeasureUnits | undefined; + + public get measureUnits(): MeasureUnits { + return (this._measureUnits ??= new MeasureUnits(this._options)); + } + + protected _onboardingLinks: OnboardingLinks | undefined; + + public get onboardingLinks(): OnboardingLinks { + return (this._onboardingLinks ??= new OnboardingLinks(this._options)); + } + + protected _overdueReminders: OverdueReminders | undefined; + + public get overdueReminders(): OverdueReminders { + return (this._overdueReminders ??= new OverdueReminders(this._options)); + } + + protected _purchaseOrders: PurchaseOrders | undefined; + + public get purchaseOrders(): PurchaseOrders { + return (this._purchaseOrders ??= new PurchaseOrders(this._options)); + } + + protected _payables: Payables | undefined; + + public get payables(): Payables { + return (this._payables ??= new Payables(this._options)); + } + + protected _paymentIntents: PaymentIntents | undefined; + + public get paymentIntents(): PaymentIntents { + return (this._paymentIntents ??= new PaymentIntents(this._options)); + } + + protected _paymentLinks: PaymentLinks | undefined; + + public get paymentLinks(): PaymentLinks { + return (this._paymentLinks ??= new PaymentLinks(this._options)); + } + + protected _paymentRecords: PaymentRecords | undefined; + + public get paymentRecords(): PaymentRecords { + return (this._paymentRecords ??= new PaymentRecords(this._options)); + } + + protected _paymentReminders: PaymentReminders | undefined; + + public get paymentReminders(): PaymentReminders { + return (this._paymentReminders ??= new PaymentReminders(this._options)); + } + + protected _paymentTerms: PaymentTerms | undefined; + + public get paymentTerms(): PaymentTerms { + return (this._paymentTerms ??= new PaymentTerms(this._options)); + } + + protected _products: Products | undefined; + + public get products(): Products { + return (this._products ??= new Products(this._options)); + } + + protected _projects: Projects | undefined; + + public get projects(): Projects { + return (this._projects ??= new Projects(this._options)); + } + + protected _receivables: Receivables | undefined; + + public get receivables(): Receivables { + return (this._receivables ??= new Receivables(this._options)); + } + + protected _recurrences: Recurrences | undefined; + + public get recurrences(): Recurrences { + return (this._recurrences ??= new Recurrences(this._options)); + } + + protected _roles: Roles | undefined; + + public get roles(): Roles { + return (this._roles ??= new Roles(this._options)); + } + + protected _partnerSettings: PartnerSettings | undefined; + + public get partnerSettings(): PartnerSettings { + return (this._partnerSettings ??= new PartnerSettings(this._options)); + } + + protected _tags: Tags | undefined; + + public get tags(): Tags { + return (this._tags ??= new Tags(this._options)); + } + + protected _textTemplates: TextTemplates | undefined; + + public get textTemplates(): TextTemplates { + return (this._textTemplates ??= new TextTemplates(this._options)); + } + + protected _vatRates: VatRates | undefined; + + public get vatRates(): VatRates { + return (this._vatRates ??= new VatRates(this._options)); + } + + protected _webhookDeliveries: WebhookDeliveries | undefined; + + public get webhookDeliveries(): WebhookDeliveries { + return (this._webhookDeliveries ??= new WebhookDeliveries(this._options)); + } + + protected _webhookSubscriptions: WebhookSubscriptions | undefined; + + public get webhookSubscriptions(): WebhookSubscriptions { + return (this._webhookSubscriptions ??= new WebhookSubscriptions(this._options)); + } + + protected _accounting: Accounting | undefined; + + public get accounting(): Accounting { + return (this._accounting ??= new Accounting(this._options)); + } +} diff --git a/src/api/errors/BadRequestError.ts b/src/api/errors/BadRequestError.ts new file mode 100644 index 0000000..410259c --- /dev/null +++ b/src/api/errors/BadRequestError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class BadRequestError extends errors.MoniteError { + constructor(body: Monite.ErrorSchemaResponse) { + super({ + message: "BadRequestError", + statusCode: 400, + body: body, + }); + Object.setPrototypeOf(this, BadRequestError.prototype); + } +} diff --git a/src/api/errors/ConflictError.ts b/src/api/errors/ConflictError.ts new file mode 100644 index 0000000..2710275 --- /dev/null +++ b/src/api/errors/ConflictError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class ConflictError extends errors.MoniteError { + constructor(body: Monite.ErrorSchemaResponse) { + super({ + message: "ConflictError", + statusCode: 409, + body: body, + }); + Object.setPrototypeOf(this, ConflictError.prototype); + } +} diff --git a/src/api/errors/ForbiddenError.ts b/src/api/errors/ForbiddenError.ts new file mode 100644 index 0000000..b3ecaf5 --- /dev/null +++ b/src/api/errors/ForbiddenError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class ForbiddenError extends errors.MoniteError { + constructor(body: Monite.ErrorSchemaResponse) { + super({ + message: "ForbiddenError", + statusCode: 403, + body: body, + }); + Object.setPrototypeOf(this, ForbiddenError.prototype); + } +} diff --git a/src/api/errors/InternalServerError.ts b/src/api/errors/InternalServerError.ts new file mode 100644 index 0000000..32a245c --- /dev/null +++ b/src/api/errors/InternalServerError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class InternalServerError extends errors.MoniteError { + constructor(body: Monite.ErrorSchemaResponse) { + super({ + message: "InternalServerError", + statusCode: 500, + body: body, + }); + Object.setPrototypeOf(this, InternalServerError.prototype); + } +} diff --git a/src/api/errors/NotAcceptableError.ts b/src/api/errors/NotAcceptableError.ts new file mode 100644 index 0000000..fdeefd9 --- /dev/null +++ b/src/api/errors/NotAcceptableError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class NotAcceptableError extends errors.MoniteError { + constructor(body: Monite.ErrorSchemaResponse) { + super({ + message: "NotAcceptableError", + statusCode: 406, + body: body, + }); + Object.setPrototypeOf(this, NotAcceptableError.prototype); + } +} diff --git a/src/api/errors/NotFoundError.ts b/src/api/errors/NotFoundError.ts new file mode 100644 index 0000000..a7e7502 --- /dev/null +++ b/src/api/errors/NotFoundError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class NotFoundError extends errors.MoniteError { + constructor(body: Monite.ErrorSchemaResponse) { + super({ + message: "NotFoundError", + statusCode: 404, + body: body, + }); + Object.setPrototypeOf(this, NotFoundError.prototype); + } +} diff --git a/src/api/errors/RangeNotSatisfiableError.ts b/src/api/errors/RangeNotSatisfiableError.ts new file mode 100644 index 0000000..8669a2d --- /dev/null +++ b/src/api/errors/RangeNotSatisfiableError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class RangeNotSatisfiableError extends errors.MoniteError { + constructor(body: Monite.ErrorSchemaResponse) { + super({ + message: "RangeNotSatisfiableError", + statusCode: 416, + body: body, + }); + Object.setPrototypeOf(this, RangeNotSatisfiableError.prototype); + } +} diff --git a/src/api/errors/UnauthorizedError.ts b/src/api/errors/UnauthorizedError.ts new file mode 100644 index 0000000..137cfea --- /dev/null +++ b/src/api/errors/UnauthorizedError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class UnauthorizedError extends errors.MoniteError { + constructor(body: Monite.ErrorSchemaResponse) { + super({ + message: "UnauthorizedError", + statusCode: 401, + body: body, + }); + Object.setPrototypeOf(this, UnauthorizedError.prototype); + } +} diff --git a/src/api/errors/UnprocessableEntityError.ts b/src/api/errors/UnprocessableEntityError.ts new file mode 100644 index 0000000..c2de2bb --- /dev/null +++ b/src/api/errors/UnprocessableEntityError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Monite from "../index"; + +export class UnprocessableEntityError extends errors.MoniteError { + constructor(body: Monite.HttpValidationError) { + super({ + message: "UnprocessableEntityError", + statusCode: 422, + body: body, + }); + Object.setPrototypeOf(this, UnprocessableEntityError.prototype); + } +} diff --git a/src/api/errors/index.ts b/src/api/errors/index.ts new file mode 100644 index 0000000..95220b9 --- /dev/null +++ b/src/api/errors/index.ts @@ -0,0 +1,9 @@ +export * from "./UnprocessableEntityError"; +export * from "./InternalServerError"; +export * from "./UnauthorizedError"; +export * from "./ConflictError"; +export * from "./BadRequestError"; +export * from "./NotFoundError"; +export * from "./ForbiddenError"; +export * from "./NotAcceptableError"; +export * from "./RangeNotSatisfiableError"; diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..3006072 --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,3 @@ +export * from "./resources"; +export * from "./types"; +export * from "./errors"; diff --git a/src/api/resources/accessTokens/client/Client.ts b/src/api/resources/accessTokens/client/Client.ts new file mode 100644 index 0000000..615e08e --- /dev/null +++ b/src/api/resources/accessTokens/client/Client.ts @@ -0,0 +1,208 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace AccessTokens { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class AccessTokens { + constructor(protected readonly _options: AccessTokens.Options) {} + + /** + * Revoke an existing token immediately. + * + * @param {Monite.RevokeTokenPayload} request + * @param {AccessTokens.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accessTokens.revoke({ + * client_id: "client_id", + * client_secret: "client_secret", + * token: "token" + * }) + */ + public async revoke( + request: Monite.RevokeTokenPayload, + requestOptions?: AccessTokens.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "auth/revoke" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.MessageResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a new access token based on client ID and client secret. + * + * @param {Monite.ObtainTokenPayload} request + * @param {AccessTokens.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accessTokens.create({ + * client_id: "client_id", + * client_secret: "client_secret", + * grant_type: "client_credentials" + * }) + */ + public async create( + request: Monite.ObtainTokenPayload, + requestOptions?: AccessTokens.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "auth/token" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccessTokenResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/accessTokens/client/index.ts b/src/api/resources/accessTokens/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/accessTokens/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/accessTokens/client/requests/ObtainTokenPayload.ts b/src/api/resources/accessTokens/client/requests/ObtainTokenPayload.ts new file mode 100644 index 0000000..7469ff3 --- /dev/null +++ b/src/api/resources/accessTokens/client/requests/ObtainTokenPayload.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * client_id: "client_id", + * client_secret: "client_secret", + * grant_type: "client_credentials" + * } + */ +export interface ObtainTokenPayload { + client_id: string; + client_secret: string; + entity_user_id?: string; + grant_type: Monite.GrantType; +} diff --git a/src/api/resources/accessTokens/client/requests/RevokeTokenPayload.ts b/src/api/resources/accessTokens/client/requests/RevokeTokenPayload.ts new file mode 100644 index 0000000..4517fc1 --- /dev/null +++ b/src/api/resources/accessTokens/client/requests/RevokeTokenPayload.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * client_id: "client_id", + * client_secret: "client_secret", + * token: "token" + * } + */ +export interface RevokeTokenPayload { + client_id: string; + client_secret: string; + token: string; +} diff --git a/src/api/resources/accessTokens/client/requests/index.ts b/src/api/resources/accessTokens/client/requests/index.ts new file mode 100644 index 0000000..bcdd0bc --- /dev/null +++ b/src/api/resources/accessTokens/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type RevokeTokenPayload } from "./RevokeTokenPayload"; +export { type ObtainTokenPayload } from "./ObtainTokenPayload"; diff --git a/src/api/resources/accessTokens/index.ts b/src/api/resources/accessTokens/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/accessTokens/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/accounting/client/Client.ts b/src/api/resources/accounting/client/Client.ts new file mode 100644 index 0000000..fbcfcf7 --- /dev/null +++ b/src/api/resources/accounting/client/Client.ts @@ -0,0 +1,77 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import { Payables } from "../resources/payables/client/Client"; +import { Receivables } from "../resources/receivables/client/Client"; +import { Connections } from "../resources/connections/client/Client"; +import { SyncedRecords } from "../resources/syncedRecords/client/Client"; +import { TaxRates } from "../resources/taxRates/client/Client"; +import { LedgerAccounts } from "../resources/ledgerAccounts/client/Client"; + +export declare namespace Accounting { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Accounting { + constructor(protected readonly _options: Accounting.Options) {} + + protected _payables: Payables | undefined; + + public get payables(): Payables { + return (this._payables ??= new Payables(this._options)); + } + + protected _receivables: Receivables | undefined; + + public get receivables(): Receivables { + return (this._receivables ??= new Receivables(this._options)); + } + + protected _connections: Connections | undefined; + + public get connections(): Connections { + return (this._connections ??= new Connections(this._options)); + } + + protected _syncedRecords: SyncedRecords | undefined; + + public get syncedRecords(): SyncedRecords { + return (this._syncedRecords ??= new SyncedRecords(this._options)); + } + + protected _taxRates: TaxRates | undefined; + + public get taxRates(): TaxRates { + return (this._taxRates ??= new TaxRates(this._options)); + } + + protected _ledgerAccounts: LedgerAccounts | undefined; + + public get ledgerAccounts(): LedgerAccounts { + return (this._ledgerAccounts ??= new LedgerAccounts(this._options)); + } +} diff --git a/src/api/resources/accounting/client/index.ts b/src/api/resources/accounting/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/accounting/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/accounting/index.ts b/src/api/resources/accounting/index.ts new file mode 100644 index 0000000..33a87f1 --- /dev/null +++ b/src/api/resources/accounting/index.ts @@ -0,0 +1,2 @@ +export * from "./client"; +export * from "./resources"; diff --git a/src/api/resources/accounting/resources/connections/client/Client.ts b/src/api/resources/accounting/resources/connections/client/Client.ts new file mode 100644 index 0000000..541c432 --- /dev/null +++ b/src/api/resources/accounting/resources/connections/client/Client.ts @@ -0,0 +1,412 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Connections { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Connections { + constructor(protected readonly _options: Connections.Options) {} + + /** + * Get all connections + * + * @param {Connections.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.connections.get() + */ + public async get(requestOptions?: Connections.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "accounting_connections" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingConnectionList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create new connection + * + * @param {Monite.accounting.AccountingConnectionRequest} request + * @param {Connections.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.connections.create() + */ + public async create( + request: Monite.accounting.AccountingConnectionRequest = {}, + requestOptions?: Connections.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "accounting_connections" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingConnectionResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get connection by id + * + * @param {string} connectionId + * @param {Connections.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.connections.getById("connection_id") + */ + public async getById( + connectionId: string, + requestOptions?: Connections.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `accounting_connections/${encodeURIComponent(connectionId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingConnectionResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Disconnect + * + * @param {string} connectionId + * @param {Connections.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.connections.disconnectById("connection_id") + */ + public async disconnectById( + connectionId: string, + requestOptions?: Connections.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `accounting_connections/${encodeURIComponent(connectionId)}/disconnect` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingConnectionResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} connectionId + * @param {Connections.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.connections.syncById("connection_id") + */ + public async syncById( + connectionId: string, + requestOptions?: Connections.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `accounting_connections/${encodeURIComponent(connectionId)}/sync` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingMessageResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/accounting/resources/connections/client/index.ts b/src/api/resources/accounting/resources/connections/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/accounting/resources/connections/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/accounting/resources/connections/client/requests/AccountingConnectionRequest.ts b/src/api/resources/accounting/resources/connections/client/requests/AccountingConnectionRequest.ts new file mode 100644 index 0000000..9350b33 --- /dev/null +++ b/src/api/resources/accounting/resources/connections/client/requests/AccountingConnectionRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface AccountingConnectionRequest { + platform?: Monite.Platform; +} diff --git a/src/api/resources/accounting/resources/connections/client/requests/index.ts b/src/api/resources/accounting/resources/connections/client/requests/index.ts new file mode 100644 index 0000000..20704a1 --- /dev/null +++ b/src/api/resources/accounting/resources/connections/client/requests/index.ts @@ -0,0 +1 @@ +export { type AccountingConnectionRequest } from "./AccountingConnectionRequest"; diff --git a/src/api/resources/accounting/resources/connections/index.ts b/src/api/resources/accounting/resources/connections/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/accounting/resources/connections/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/accounting/resources/index.ts b/src/api/resources/accounting/resources/index.ts new file mode 100644 index 0000000..9dbb0bc --- /dev/null +++ b/src/api/resources/accounting/resources/index.ts @@ -0,0 +1,12 @@ +export * as payables from "./payables"; +export * as receivables from "./receivables"; +export * as connections from "./connections"; +export * as syncedRecords from "./syncedRecords"; +export * as taxRates from "./taxRates"; +export * as ledgerAccounts from "./ledgerAccounts"; +export * from "./payables/client/requests"; +export * from "./receivables/client/requests"; +export * from "./connections/client/requests"; +export * from "./syncedRecords/client/requests"; +export * from "./taxRates/client/requests"; +export * from "./ledgerAccounts/client/requests"; diff --git a/src/api/resources/accounting/resources/ledgerAccounts/client/Client.ts b/src/api/resources/accounting/resources/ledgerAccounts/client/Client.ts new file mode 100644 index 0000000..39836e9 --- /dev/null +++ b/src/api/resources/accounting/resources/ledgerAccounts/client/Client.ts @@ -0,0 +1,214 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace LedgerAccounts { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class LedgerAccounts { + constructor(protected readonly _options: LedgerAccounts.Options) {} + + /** + * Get all ledger accounts + * + * @param {Monite.accounting.LedgerAccountsGetRequest} request + * @param {LedgerAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.ledgerAccounts.get() + */ + public async get( + request: Monite.accounting.LedgerAccountsGetRequest = {}, + requestOptions?: LedgerAccounts.RequestOptions + ): Promise { + const { order, limit, pagination_token: paginationToken, sort } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "ledger_accounts" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LedgerAccountListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get ledger account by id + * + * @param {string} ledgerAccountId + * @param {LedgerAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.ledgerAccounts.getById("ledger_account_id") + */ + public async getById( + ledgerAccountId: string, + requestOptions?: LedgerAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `ledger_accounts/${encodeURIComponent(ledgerAccountId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LedgerAccountResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/accounting/resources/ledgerAccounts/client/index.ts b/src/api/resources/accounting/resources/ledgerAccounts/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/accounting/resources/ledgerAccounts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/accounting/resources/ledgerAccounts/client/requests/LedgerAccountsGetRequest.ts b/src/api/resources/accounting/resources/ledgerAccounts/client/requests/LedgerAccountsGetRequest.ts new file mode 100644 index 0000000..14b95ea --- /dev/null +++ b/src/api/resources/accounting/resources/ledgerAccounts/client/requests/LedgerAccountsGetRequest.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface LedgerAccountsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.LedgerAccountCursorFields; +} diff --git a/src/api/resources/accounting/resources/ledgerAccounts/client/requests/index.ts b/src/api/resources/accounting/resources/ledgerAccounts/client/requests/index.ts new file mode 100644 index 0000000..f70a0ef --- /dev/null +++ b/src/api/resources/accounting/resources/ledgerAccounts/client/requests/index.ts @@ -0,0 +1 @@ +export { type LedgerAccountsGetRequest } from "./LedgerAccountsGetRequest"; diff --git a/src/api/resources/accounting/resources/ledgerAccounts/index.ts b/src/api/resources/accounting/resources/ledgerAccounts/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/accounting/resources/ledgerAccounts/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/accounting/resources/payables/client/Client.ts b/src/api/resources/accounting/resources/payables/client/Client.ts new file mode 100644 index 0000000..bf6e743 --- /dev/null +++ b/src/api/resources/accounting/resources/payables/client/Client.ts @@ -0,0 +1,210 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Payables { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Payables { + constructor(protected readonly _options: Payables.Options) {} + + /** + * Returns a list of accounts payable invoices (bills) that exist in the entity's accounting system. This requires that an accounting connection has been previously established. Refer to the [Accounting integration guide](https://docs.monite.com/accounting/integration/index) for details. + * + * This endpoint only provides read-only access to the accounting system's data but does not pull those payables into Monite. You can use it to review the data in the accounting system and find out which of those payables already exist or do not exist in Monite. + * + * Data is actual as of the date and time of the last accounting synchronization, which is specified by the `last_pull` value in the response from `GET /accounting_connections/{connection_id}`. To make sure you are accessing the most up-to-date accounting data, you can use `POST /accounting_connections/{connection_id}/sync` to trigger on-demand synchronization before getting the list of payables. + * + * @param {Monite.accounting.PayablesGetRequest} request + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.payables.get() + */ + public async get( + request: Monite.accounting.PayablesGetRequest = {}, + requestOptions?: Payables.RequestOptions + ): Promise { + const { limit, offset } = request; + const _queryParams: Record = {}; + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (offset != null) { + _queryParams["offset"] = offset.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "accounting/payables" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingPayableList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Returns information about an individual payable invoice (bill) that exists in the entity's accounting system. This payable may or may not also exist in Monite. + * + * @param {string} payableId - An internal ID of the payable invoice (bill) in the accounting system. You can get these IDs from `GET /accounting/payables`. + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.payables.getById("payable_id") + */ + public async getById( + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `accounting/payables/${encodeURIComponent(payableId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingPayable; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/accounting/resources/payables/client/index.ts b/src/api/resources/accounting/resources/payables/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/accounting/resources/payables/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/accounting/resources/payables/client/requests/PayablesGetRequest.ts b/src/api/resources/accounting/resources/payables/client/requests/PayablesGetRequest.ts new file mode 100644 index 0000000..9434b0e --- /dev/null +++ b/src/api/resources/accounting/resources/payables/client/requests/PayablesGetRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface PayablesGetRequest { + /** + * Number of results per page. + */ + limit?: number; + /** + * Number of results to skip before selecting items to return. + */ + offset?: number; +} diff --git a/src/api/resources/accounting/resources/payables/client/requests/index.ts b/src/api/resources/accounting/resources/payables/client/requests/index.ts new file mode 100644 index 0000000..ac4bf74 --- /dev/null +++ b/src/api/resources/accounting/resources/payables/client/requests/index.ts @@ -0,0 +1 @@ +export { type PayablesGetRequest } from "./PayablesGetRequest"; diff --git a/src/api/resources/accounting/resources/payables/index.ts b/src/api/resources/accounting/resources/payables/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/accounting/resources/payables/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/accounting/resources/receivables/client/Client.ts b/src/api/resources/accounting/resources/receivables/client/Client.ts new file mode 100644 index 0000000..a21c794 --- /dev/null +++ b/src/api/resources/accounting/resources/receivables/client/Client.ts @@ -0,0 +1,210 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Receivables { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Receivables { + constructor(protected readonly _options: Receivables.Options) {} + + /** + * Returns a list of invoices that exist in the entity's accounting system. This requires that an accounting connection has been previously established. Refer to the [Accounting integration guide](https://docs.monite.com/accounting/integration/index) for details. + * + * This endpoint only provides read-only access to the accounting system's data but does not pull those invoices into Monite. You can use it to review the data in the accounting system and find out which of those invoices already exist or do not exist in Monite. + * + * Data is actual as of the date and time of the last accounting synchronization, which is specified by the `last_pull` value in the response from `GET /accounting_connections/{connection_id}`. To make sure you are accessing the most up-to-date accounting data, you can use `POST /accounting_connections/{connection_id}/sync` to trigger on-demand synchronization before getting the invoice list. + * + * @param {Monite.accounting.ReceivablesGetRequest} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.receivables.get() + */ + public async get( + request: Monite.accounting.ReceivablesGetRequest = {}, + requestOptions?: Receivables.RequestOptions + ): Promise { + const { limit, offset } = request; + const _queryParams: Record = {}; + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (offset != null) { + _queryParams["offset"] = offset.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "accounting/receivables" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingReceivableList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Returns information about an individual invoice that exists in the entity's accounting system. This invoice may or may not also exist in Monite. + * + * @param {string} invoiceId - An internal ID of the invoice in the accounting system. You can get these IDs from `GET /accounting/receivables`. + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.receivables.getById("invoice_id") + */ + public async getById( + invoiceId: string, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `accounting/receivables/${encodeURIComponent(invoiceId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingReceivable; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/accounting/resources/receivables/client/index.ts b/src/api/resources/accounting/resources/receivables/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/accounting/resources/receivables/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/accounting/resources/receivables/client/requests/ReceivablesGetRequest.ts b/src/api/resources/accounting/resources/receivables/client/requests/ReceivablesGetRequest.ts new file mode 100644 index 0000000..8d1bbfa --- /dev/null +++ b/src/api/resources/accounting/resources/receivables/client/requests/ReceivablesGetRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface ReceivablesGetRequest { + /** + * Number of results per page. + */ + limit?: number; + /** + * Number of results to skip before selecting items to return. + */ + offset?: number; +} diff --git a/src/api/resources/accounting/resources/receivables/client/requests/index.ts b/src/api/resources/accounting/resources/receivables/client/requests/index.ts new file mode 100644 index 0000000..3a6d011 --- /dev/null +++ b/src/api/resources/accounting/resources/receivables/client/requests/index.ts @@ -0,0 +1 @@ +export { type ReceivablesGetRequest } from "./ReceivablesGetRequest"; diff --git a/src/api/resources/accounting/resources/receivables/index.ts b/src/api/resources/accounting/resources/receivables/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/accounting/resources/receivables/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/accounting/resources/syncedRecords/client/Client.ts b/src/api/resources/accounting/resources/syncedRecords/client/Client.ts new file mode 100644 index 0000000..168ef97 --- /dev/null +++ b/src/api/resources/accounting/resources/syncedRecords/client/Client.ts @@ -0,0 +1,351 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace SyncedRecords { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class SyncedRecords { + constructor(protected readonly _options: SyncedRecords.Options) {} + + /** + * Get synchronized records + * + * @param {Monite.accounting.SyncedRecordsGetRequest} request + * @param {SyncedRecords.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.syncedRecords.get({ + * object_type: "product" + * }) + */ + public async get( + request: Monite.accounting.SyncedRecordsGetRequest, + requestOptions?: SyncedRecords.RequestOptions + ): Promise { + const { + object_type: objectType, + order, + limit, + pagination_token: paginationToken, + sort, + object_id: objectId, + object_id__in: objectIdIn, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + updated_at__gt: updatedAtGt, + updated_at__lt: updatedAtLt, + updated_at__gte: updatedAtGte, + updated_at__lte: updatedAtLte, + } = request; + const _queryParams: Record = {}; + _queryParams["object_type"] = objectType; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (objectId != null) { + _queryParams["object_id"] = objectId; + } + + if (objectIdIn != null) { + if (Array.isArray(objectIdIn)) { + _queryParams["object_id__in"] = objectIdIn.map((item) => item); + } else { + _queryParams["object_id__in"] = objectIdIn; + } + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (updatedAtGt != null) { + _queryParams["updated_at__gt"] = updatedAtGt; + } + + if (updatedAtLt != null) { + _queryParams["updated_at__lt"] = updatedAtLt; + } + + if (updatedAtGte != null) { + _queryParams["updated_at__gte"] = updatedAtGte; + } + + if (updatedAtLte != null) { + _queryParams["updated_at__lte"] = updatedAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "accounting_synced_records" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.SyncRecordResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get synchronized record by id + * + * @param {string} syncedRecordId + * @param {SyncedRecords.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.syncedRecords.getById("synced_record_id") + */ + public async getById( + syncedRecordId: string, + requestOptions?: SyncedRecords.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `accounting_synced_records/${encodeURIComponent(syncedRecordId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.SyncRecordResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Push object to the accounting system manually + * + * @param {string} syncedRecordId + * @param {SyncedRecords.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.syncedRecords.pushById("synced_record_id") + */ + public async pushById( + syncedRecordId: string, + requestOptions?: SyncedRecords.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `accounting_synced_records/${encodeURIComponent(syncedRecordId)}/push` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.SyncRecordResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/accounting/resources/syncedRecords/client/index.ts b/src/api/resources/accounting/resources/syncedRecords/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/accounting/resources/syncedRecords/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/accounting/resources/syncedRecords/client/requests/SyncedRecordsGetRequest.ts b/src/api/resources/accounting/resources/syncedRecords/client/requests/SyncedRecordsGetRequest.ts new file mode 100644 index 0000000..a2b3d1b --- /dev/null +++ b/src/api/resources/accounting/resources/syncedRecords/client/requests/SyncedRecordsGetRequest.ts @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * object_type: "product" + * } + */ +export interface SyncedRecordsGetRequest { + object_type: Monite.ObjectMatchTypes; + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.SyncRecordCursorFields; + object_id?: string; + object_id__in?: string | string[]; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + updated_at__gt?: string; + updated_at__lt?: string; + updated_at__gte?: string; + updated_at__lte?: string; +} diff --git a/src/api/resources/accounting/resources/syncedRecords/client/requests/index.ts b/src/api/resources/accounting/resources/syncedRecords/client/requests/index.ts new file mode 100644 index 0000000..8bd3725 --- /dev/null +++ b/src/api/resources/accounting/resources/syncedRecords/client/requests/index.ts @@ -0,0 +1 @@ +export { type SyncedRecordsGetRequest } from "./SyncedRecordsGetRequest"; diff --git a/src/api/resources/accounting/resources/syncedRecords/index.ts b/src/api/resources/accounting/resources/syncedRecords/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/accounting/resources/syncedRecords/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/accounting/resources/taxRates/client/Client.ts b/src/api/resources/accounting/resources/taxRates/client/Client.ts new file mode 100644 index 0000000..34424ac --- /dev/null +++ b/src/api/resources/accounting/resources/taxRates/client/Client.ts @@ -0,0 +1,214 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace TaxRates { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class TaxRates { + constructor(protected readonly _options: TaxRates.Options) {} + + /** + * Get all tax rate accounts + * + * @param {Monite.accounting.TaxRatesGetRequest} request + * @param {TaxRates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.taxRates.get() + */ + public async get( + request: Monite.accounting.TaxRatesGetRequest = {}, + requestOptions?: TaxRates.RequestOptions + ): Promise { + const { order, limit, pagination_token: paginationToken, sort } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "accounting_tax_rates" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingTaxRateListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get tax rate account by id + * + * @param {string} taxRateId + * @param {TaxRates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.accounting.taxRates.getById("tax_rate_id") + */ + public async getById( + taxRateId: string, + requestOptions?: TaxRates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `accounting_tax_rates/${encodeURIComponent(taxRateId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AccountingTaxRateResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/accounting/resources/taxRates/client/index.ts b/src/api/resources/accounting/resources/taxRates/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/accounting/resources/taxRates/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/accounting/resources/taxRates/client/requests/TaxRatesGetRequest.ts b/src/api/resources/accounting/resources/taxRates/client/requests/TaxRatesGetRequest.ts new file mode 100644 index 0000000..023078a --- /dev/null +++ b/src/api/resources/accounting/resources/taxRates/client/requests/TaxRatesGetRequest.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface TaxRatesGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.TaxRateAccountCursorFields; +} diff --git a/src/api/resources/accounting/resources/taxRates/client/requests/index.ts b/src/api/resources/accounting/resources/taxRates/client/requests/index.ts new file mode 100644 index 0000000..4f12a9a --- /dev/null +++ b/src/api/resources/accounting/resources/taxRates/client/requests/index.ts @@ -0,0 +1 @@ +export { type TaxRatesGetRequest } from "./TaxRatesGetRequest"; diff --git a/src/api/resources/accounting/resources/taxRates/index.ts b/src/api/resources/accounting/resources/taxRates/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/accounting/resources/taxRates/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/approvalPolicies/client/Client.ts b/src/api/resources/approvalPolicies/client/Client.ts new file mode 100644 index 0000000..e566d94 --- /dev/null +++ b/src/api/resources/approvalPolicies/client/Client.ts @@ -0,0 +1,581 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; +import { Processes } from "../resources/processes/client/Client"; + +export declare namespace ApprovalPolicies { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class ApprovalPolicies { + constructor(protected readonly _options: ApprovalPolicies.Options) {} + + /** + * Retrieve a list of all approval policies with pagination. + * + * @param {Monite.ApprovalPoliciesGetRequest} request + * @param {ApprovalPolicies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.get() + */ + public async get( + request: Monite.ApprovalPoliciesGetRequest = {}, + requestOptions?: ApprovalPolicies.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + id__in: idIn, + status, + status__in: statusIn, + name, + name__contains: nameContains, + name__ncontains: nameNcontains, + created_by: createdBy, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + updated_at__gt: updatedAtGt, + updated_at__lt: updatedAtLt, + updated_at__gte: updatedAtGte, + updated_at__lte: updatedAtLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (statusIn != null) { + if (Array.isArray(statusIn)) { + _queryParams["status__in"] = statusIn.map((item) => item); + } else { + _queryParams["status__in"] = statusIn; + } + } + + if (name != null) { + _queryParams["name"] = name; + } + + if (nameContains != null) { + _queryParams["name__contains"] = nameContains; + } + + if (nameNcontains != null) { + _queryParams["name__ncontains"] = nameNcontains; + } + + if (createdBy != null) { + _queryParams["created_by"] = createdBy; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (updatedAtGt != null) { + _queryParams["updated_at__gt"] = updatedAtGt; + } + + if (updatedAtLt != null) { + _queryParams["updated_at__lt"] = updatedAtLt; + } + + if (updatedAtGte != null) { + _queryParams["updated_at__gte"] = updatedAtGte; + } + + if (updatedAtLte != null) { + _queryParams["updated_at__lte"] = updatedAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "approval_policies" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalPolicyResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a new approval policy. + * + * @param {Monite.ApprovalPolicyCreate} request + * @param {ApprovalPolicies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.create({ + * name: "name", + * description: "description", + * script: [true] + * }) + */ + public async create( + request: Monite.ApprovalPolicyCreate, + requestOptions?: ApprovalPolicies.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "approval_policies" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalPolicyResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a specific approval policy. + * + * @param {string} approvalPolicyId + * @param {ApprovalPolicies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.getById("approval_policy_id") + */ + public async getById( + approvalPolicyId: string, + requestOptions?: ApprovalPolicies.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_policies/${encodeURIComponent(approvalPolicyId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalPolicyResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete an existing approval policy. + * + * @param {string} approvalPolicyId + * @param {ApprovalPolicies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.deleteById("approval_policy_id") + */ + public async deleteById(approvalPolicyId: string, requestOptions?: ApprovalPolicies.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_policies/${encodeURIComponent(approvalPolicyId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update an existing approval policy. + * + * @param {string} approvalPolicyId + * @param {Monite.ApprovalPolicyUpdate} request + * @param {ApprovalPolicies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.updateById("approval_policy_id") + */ + public async updateById( + approvalPolicyId: string, + request: Monite.ApprovalPolicyUpdate = {}, + requestOptions?: ApprovalPolicies.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_policies/${encodeURIComponent(approvalPolicyId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalPolicyResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected _processes: Processes | undefined; + + public get processes(): Processes { + return (this._processes ??= new Processes(this._options)); + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/approvalPolicies/client/index.ts b/src/api/resources/approvalPolicies/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/approvalPolicies/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/approvalPolicies/client/requests/ApprovalPoliciesGetRequest.ts b/src/api/resources/approvalPolicies/client/requests/ApprovalPoliciesGetRequest.ts new file mode 100644 index 0000000..68319e0 --- /dev/null +++ b/src/api/resources/approvalPolicies/client/requests/ApprovalPoliciesGetRequest.ts @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ApprovalPoliciesGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.ApprovalPolicyCursorFields; + id__in?: string | string[]; + status?: Monite.ApprovalPoliciesGetRequestStatus; + status__in?: Monite.ApprovalPoliciesGetRequestStatusInItem | Monite.ApprovalPoliciesGetRequestStatusInItem[]; + name?: string; + name__contains?: string; + name__ncontains?: string; + created_by?: string; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + updated_at__gt?: string; + updated_at__lt?: string; + updated_at__gte?: string; + updated_at__lte?: string; +} diff --git a/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyCreate.ts b/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyCreate.ts new file mode 100644 index 0000000..160a355 --- /dev/null +++ b/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyCreate.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * name: "name", + * description: "description", + * script: [true] + * } + */ +export interface ApprovalPolicyCreate { + /** The name of the approval policy. */ + name: string; + /** A brief description of the approval policy. */ + description: string; + /** A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object. */ + script: Monite.ApprovalPolicyCreateScriptItem[]; + /** A JSON object that represents the trigger for the approval policy. The trigger specifies the event that will trigger the policy to be evaluated. */ + trigger?: Monite.ApprovalPolicyCreateTrigger; +} diff --git a/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyUpdate.ts b/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyUpdate.ts new file mode 100644 index 0000000..47ab434 --- /dev/null +++ b/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyUpdate.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ApprovalPolicyUpdate { + /** The name of the approval policy. */ + name?: string; + /** A brief description of the approval policy. */ + description?: string; + /** A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object. */ + script?: Monite.ApprovalPolicyUpdateScriptItem[]; + /** A JSON object that represents the trigger for the approval policy. The trigger specifies the event that will trigger the policy to be evaluated. */ + trigger?: Monite.ApprovalPolicyUpdateTrigger; + /** A string that represents the current status of the approval policy. */ + status?: Monite.ApprovalPolicyStatus; +} diff --git a/src/api/resources/approvalPolicies/client/requests/index.ts b/src/api/resources/approvalPolicies/client/requests/index.ts new file mode 100644 index 0000000..ea52561 --- /dev/null +++ b/src/api/resources/approvalPolicies/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type ApprovalPoliciesGetRequest } from "./ApprovalPoliciesGetRequest"; +export { type ApprovalPolicyCreate } from "./ApprovalPolicyCreate"; +export { type ApprovalPolicyUpdate } from "./ApprovalPolicyUpdate"; diff --git a/src/api/resources/approvalPolicies/index.ts b/src/api/resources/approvalPolicies/index.ts new file mode 100644 index 0000000..848e75a --- /dev/null +++ b/src/api/resources/approvalPolicies/index.ts @@ -0,0 +1,3 @@ +export * from "./types"; +export * from "./client"; +export * from "./resources"; diff --git a/src/api/resources/approvalPolicies/resources/index.ts b/src/api/resources/approvalPolicies/resources/index.ts new file mode 100644 index 0000000..148fe85 --- /dev/null +++ b/src/api/resources/approvalPolicies/resources/index.ts @@ -0,0 +1 @@ +export * as processes from "./processes"; diff --git a/src/api/resources/approvalPolicies/resources/processes/client/Client.ts b/src/api/resources/approvalPolicies/resources/processes/client/Client.ts new file mode 100644 index 0000000..ae2209b --- /dev/null +++ b/src/api/resources/approvalPolicies/resources/processes/client/Client.ts @@ -0,0 +1,389 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Processes { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Processes { + constructor(protected readonly _options: Processes.Options) {} + + /** + * Retrieve a list of all approval policy processes. + * + * @param {string} approvalPolicyId + * @param {Processes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.processes.get("approval_policy_id") + */ + public async get( + approvalPolicyId: string, + requestOptions?: Processes.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_policies/${encodeURIComponent(approvalPolicyId)}/processes` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalProcessResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a specific approval policy process. + * + * @param {string} approvalPolicyId + * @param {string} processId + * @param {Processes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.processes.getById("approval_policy_id", "process_id") + */ + public async getById( + approvalPolicyId: string, + processId: string, + requestOptions?: Processes.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_policies/${encodeURIComponent(approvalPolicyId)}/processes/${encodeURIComponent(processId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProcessResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Cancel an ongoing approval process for a specific approval policy. + * + * @param {string} approvalPolicyId + * @param {string} processId + * @param {Processes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.processes.cancelById("approval_policy_id", "process_id") + */ + public async cancelById( + approvalPolicyId: string, + processId: string, + requestOptions?: Processes.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_policies/${encodeURIComponent(approvalPolicyId)}/processes/${encodeURIComponent( + processId + )}/cancel` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProcessResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a list of approval policy process steps. + * + * @param {string} approvalPolicyId + * @param {string} processId + * @param {Processes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalPolicies.processes.getSteps("approval_policy_id", "process_id") + */ + public async getSteps( + approvalPolicyId: string, + processId: string, + requestOptions?: Processes.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_policies/${encodeURIComponent(approvalPolicyId)}/processes/${encodeURIComponent( + processId + )}/steps` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalProcessStepResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/approvalPolicies/resources/processes/client/index.ts b/src/api/resources/approvalPolicies/resources/processes/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/approvalPolicies/resources/processes/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/approvalPolicies/resources/processes/index.ts b/src/api/resources/approvalPolicies/resources/processes/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/approvalPolicies/resources/processes/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/approvalPolicies/types/ApprovalPoliciesGetRequestStatus.ts b/src/api/resources/approvalPolicies/types/ApprovalPoliciesGetRequestStatus.ts new file mode 100644 index 0000000..d90aede --- /dev/null +++ b/src/api/resources/approvalPolicies/types/ApprovalPoliciesGetRequestStatus.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalPoliciesGetRequestStatus = "active" | "pending"; + +export const ApprovalPoliciesGetRequestStatus = { + Active: "active", + Pending: "pending", +} as const; diff --git a/src/api/resources/approvalPolicies/types/ApprovalPoliciesGetRequestStatusInItem.ts b/src/api/resources/approvalPolicies/types/ApprovalPoliciesGetRequestStatusInItem.ts new file mode 100644 index 0000000..f0f488b --- /dev/null +++ b/src/api/resources/approvalPolicies/types/ApprovalPoliciesGetRequestStatusInItem.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalPoliciesGetRequestStatusInItem = "active" | "pending"; + +export const ApprovalPoliciesGetRequestStatusInItem = { + Active: "active", + Pending: "pending", +} as const; diff --git a/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateScriptItem.ts b/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateScriptItem.ts new file mode 100644 index 0000000..7317ce5 --- /dev/null +++ b/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateScriptItem.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalPolicyCreateScriptItem = boolean | number | string | unknown[] | Record; diff --git a/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateTrigger.ts b/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateTrigger.ts new file mode 100644 index 0000000..29dda8f --- /dev/null +++ b/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateTrigger.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A JSON object that represents the trigger for the approval policy. The trigger specifies the event that will trigger the policy to be evaluated. + */ +export type ApprovalPolicyCreateTrigger = boolean | number | string | unknown[] | Record; diff --git a/src/api/resources/approvalPolicies/types/ApprovalPolicyUpdateScriptItem.ts b/src/api/resources/approvalPolicies/types/ApprovalPolicyUpdateScriptItem.ts new file mode 100644 index 0000000..ca820cb --- /dev/null +++ b/src/api/resources/approvalPolicies/types/ApprovalPolicyUpdateScriptItem.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalPolicyUpdateScriptItem = boolean | number | string | unknown[] | Record; diff --git a/src/api/resources/approvalPolicies/types/ApprovalPolicyUpdateTrigger.ts b/src/api/resources/approvalPolicies/types/ApprovalPolicyUpdateTrigger.ts new file mode 100644 index 0000000..8296072 --- /dev/null +++ b/src/api/resources/approvalPolicies/types/ApprovalPolicyUpdateTrigger.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A JSON object that represents the trigger for the approval policy. The trigger specifies the event that will trigger the policy to be evaluated. + */ +export type ApprovalPolicyUpdateTrigger = boolean | number | string | unknown[] | Record; diff --git a/src/api/resources/approvalPolicies/types/index.ts b/src/api/resources/approvalPolicies/types/index.ts new file mode 100644 index 0000000..fd8bc1d --- /dev/null +++ b/src/api/resources/approvalPolicies/types/index.ts @@ -0,0 +1,6 @@ +export * from "./ApprovalPoliciesGetRequestStatus"; +export * from "./ApprovalPoliciesGetRequestStatusInItem"; +export * from "./ApprovalPolicyCreateScriptItem"; +export * from "./ApprovalPolicyCreateTrigger"; +export * from "./ApprovalPolicyUpdateScriptItem"; +export * from "./ApprovalPolicyUpdateTrigger"; diff --git a/src/api/resources/approvalRequests/client/Client.ts b/src/api/resources/approvalRequests/client/Client.ts new file mode 100644 index 0000000..4ad2c87 --- /dev/null +++ b/src/api/resources/approvalRequests/client/Client.ts @@ -0,0 +1,693 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace ApprovalRequests { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class ApprovalRequests { + constructor(protected readonly _options: ApprovalRequests.Options) {} + + /** + * @param {Monite.ApprovalRequestsGetRequest} request + * @param {ApprovalRequests.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalRequests.get() + */ + public async get( + request: Monite.ApprovalRequestsGetRequest = {}, + requestOptions?: ApprovalRequests.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + updated_at__gt: updatedAtGt, + updated_at__lt: updatedAtLt, + updated_at__gte: updatedAtGte, + updated_at__lte: updatedAtLte, + object_id: objectId, + object_id__in: objectIdIn, + status, + status__in: statusIn, + user_id: userId, + role_id: roleId, + object_type: objectType, + object_type__in: objectTypeIn, + created_by: createdBy, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (updatedAtGt != null) { + _queryParams["updated_at__gt"] = updatedAtGt; + } + + if (updatedAtLt != null) { + _queryParams["updated_at__lt"] = updatedAtLt; + } + + if (updatedAtGte != null) { + _queryParams["updated_at__gte"] = updatedAtGte; + } + + if (updatedAtLte != null) { + _queryParams["updated_at__lte"] = updatedAtLte; + } + + if (objectId != null) { + _queryParams["object_id"] = objectId; + } + + if (objectIdIn != null) { + if (Array.isArray(objectIdIn)) { + _queryParams["object_id__in"] = objectIdIn.map((item) => item); + } else { + _queryParams["object_id__in"] = objectIdIn; + } + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (statusIn != null) { + if (Array.isArray(statusIn)) { + _queryParams["status__in"] = statusIn.map((item) => item); + } else { + _queryParams["status__in"] = statusIn; + } + } + + if (userId != null) { + _queryParams["user_id"] = userId; + } + + if (roleId != null) { + _queryParams["role_id"] = roleId; + } + + if (objectType != null) { + _queryParams["object_type"] = objectType; + } + + if (objectTypeIn != null) { + if (Array.isArray(objectTypeIn)) { + _queryParams["object_type__in"] = objectTypeIn.map((item) => item); + } else { + _queryParams["object_type__in"] = objectTypeIn; + } + } + + if (createdBy != null) { + _queryParams["created_by"] = createdBy; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "approval_requests" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalRequestResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.ApprovalRequestCreateRequest} request + * @param {ApprovalRequests.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalRequests.create({ + * object_id: "object_id", + * object_type: "account", + * required_approval_count: 1, + * role_ids: ["role_ids"] + * }) + */ + public async create( + request: Monite.ApprovalRequestCreateRequest, + requestOptions?: ApprovalRequests.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "approval_requests" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalRequestResourceWithMetadata; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} approvalRequestId + * @param {ApprovalRequests.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalRequests.getById("approval_request_id") + */ + public async getById( + approvalRequestId: string, + requestOptions?: ApprovalRequests.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_requests/${encodeURIComponent(approvalRequestId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalRequestResourceWithMetadata; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} approvalRequestId + * @param {ApprovalRequests.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalRequests.approveById("approval_request_id") + */ + public async approveById( + approvalRequestId: string, + requestOptions?: ApprovalRequests.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_requests/${encodeURIComponent(approvalRequestId)}/approve` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalRequestResourceWithMetadata; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} approvalRequestId + * @param {ApprovalRequests.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalRequests.cancelById("approval_request_id") + */ + public async cancelById( + approvalRequestId: string, + requestOptions?: ApprovalRequests.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_requests/${encodeURIComponent(approvalRequestId)}/cancel` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalRequestResourceWithMetadata; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} approvalRequestId + * @param {ApprovalRequests.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.approvalRequests.rejectById("approval_request_id") + */ + public async rejectById( + approvalRequestId: string, + requestOptions?: ApprovalRequests.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `approval_requests/${encodeURIComponent(approvalRequestId)}/reject` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ApprovalRequestResourceWithMetadata; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/approvalRequests/client/index.ts b/src/api/resources/approvalRequests/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/approvalRequests/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/approvalRequests/client/requests/ApprovalRequestsGetRequest.ts b/src/api/resources/approvalRequests/client/requests/ApprovalRequestsGetRequest.ts new file mode 100644 index 0000000..bdedacf --- /dev/null +++ b/src/api/resources/approvalRequests/client/requests/ApprovalRequestsGetRequest.ts @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ApprovalRequestsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.ApprovalRequestCursorFields; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + updated_at__gt?: string; + updated_at__lt?: string; + updated_at__gte?: string; + updated_at__lte?: string; + object_id?: string; + object_id__in?: string | string[]; + status?: Monite.ApprovalRequestStatus; + status__in?: Monite.ApprovalRequestStatus | Monite.ApprovalRequestStatus[]; + user_id?: string; + role_id?: string; + object_type?: Monite.ObjectType; + object_type__in?: Monite.ObjectType | Monite.ObjectType[]; + created_by?: string; +} diff --git a/src/api/resources/approvalRequests/client/requests/index.ts b/src/api/resources/approvalRequests/client/requests/index.ts new file mode 100644 index 0000000..884f342 --- /dev/null +++ b/src/api/resources/approvalRequests/client/requests/index.ts @@ -0,0 +1 @@ +export { type ApprovalRequestsGetRequest } from "./ApprovalRequestsGetRequest"; diff --git a/src/api/resources/approvalRequests/index.ts b/src/api/resources/approvalRequests/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/approvalRequests/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/auditLogs/client/Client.ts b/src/api/resources/auditLogs/client/Client.ts new file mode 100644 index 0000000..84b1841 --- /dev/null +++ b/src/api/resources/auditLogs/client/Client.ts @@ -0,0 +1,252 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace AuditLogs { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class AuditLogs { + constructor(protected readonly _options: AuditLogs.Options) {} + + /** + * @param {Monite.AuditLogsGetRequest} request + * @param {AuditLogs.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.auditLogs.get() + */ + public async get( + request: Monite.AuditLogsGetRequest = {}, + requestOptions?: AuditLogs.RequestOptions + ): Promise { + const { + pagination_token: paginationToken, + entity_user_id: entityUserId, + path__contains: pathContains, + type: type_, + method, + status_code: statusCode, + timestamp__gt: timestampGt, + timestamp__lt: timestampLt, + timestamp__gte: timestampGte, + timestamp__lte: timestampLte, + page_size: pageSize, + page_num: pageNum, + } = request; + const _queryParams: Record = {}; + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (entityUserId != null) { + _queryParams["entity_user_id"] = entityUserId; + } + + if (pathContains != null) { + _queryParams["path__contains"] = pathContains; + } + + if (type_ != null) { + _queryParams["type"] = type_; + } + + if (method != null) { + _queryParams["method"] = method; + } + + if (statusCode != null) { + _queryParams["status_code"] = statusCode.toString(); + } + + if (timestampGt != null) { + _queryParams["timestamp__gt"] = timestampGt; + } + + if (timestampLt != null) { + _queryParams["timestamp__lt"] = timestampLt; + } + + if (timestampGte != null) { + _queryParams["timestamp__gte"] = timestampGte; + } + + if (timestampLte != null) { + _queryParams["timestamp__lte"] = timestampLte; + } + + if (pageSize != null) { + _queryParams["page_size"] = pageSize.toString(); + } + + if (pageNum != null) { + _queryParams["page_num"] = pageNum.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "audit_logs" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LogsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} logId + * @param {AuditLogs.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.auditLogs.getById("log_id") + */ + public async getById(logId: string, requestOptions?: AuditLogs.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `audit_logs/${encodeURIComponent(logId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LogResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/auditLogs/client/index.ts b/src/api/resources/auditLogs/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/auditLogs/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/auditLogs/client/requests/AuditLogsGetRequest.ts b/src/api/resources/auditLogs/client/requests/AuditLogsGetRequest.ts new file mode 100644 index 0000000..6a603c4 --- /dev/null +++ b/src/api/resources/auditLogs/client/requests/AuditLogsGetRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface AuditLogsGetRequest { + pagination_token?: string; + entity_user_id?: string; + path__contains?: string; + type?: Monite.LogTypeEnum; + method?: Monite.LogMethodEnum; + status_code?: number; + timestamp__gt?: string; + timestamp__lt?: string; + timestamp__gte?: string; + timestamp__lte?: string; + page_size?: number; + page_num?: number; +} diff --git a/src/api/resources/auditLogs/client/requests/index.ts b/src/api/resources/auditLogs/client/requests/index.ts new file mode 100644 index 0000000..4e89428 --- /dev/null +++ b/src/api/resources/auditLogs/client/requests/index.ts @@ -0,0 +1 @@ +export { type AuditLogsGetRequest } from "./AuditLogsGetRequest"; diff --git a/src/api/resources/auditLogs/index.ts b/src/api/resources/auditLogs/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/auditLogs/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/batchPayments/client/Client.ts b/src/api/resources/batchPayments/client/Client.ts new file mode 100644 index 0000000..d74748e --- /dev/null +++ b/src/api/resources/batchPayments/client/Client.ts @@ -0,0 +1,204 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace BatchPayments { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class BatchPayments { + constructor(protected readonly _options: BatchPayments.Options) {} + + /** + * @param {Monite.PaymentsBatchPaymentRequest} request + * @param {BatchPayments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.batchPayments.create({ + * payer_bank_account_id: "payer_bank_account_id", + * payment_intents: [{ + * object: { + * id: "id", + * type: "payable" + * }, + * recipient: { + * id: "id", + * type: "counterpart" + * } + * }] + * }) + */ + public async create( + request: Monite.PaymentsBatchPaymentRequest, + requestOptions?: BatchPayments.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "batch_payments" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: { ...request, payment_method: "us_ach" }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentsBatchPaymentResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} batchPaymentId + * @param {BatchPayments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.batchPayments.getById("batch_payment_id") + */ + public async getById( + batchPaymentId: string, + requestOptions?: BatchPayments.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `batch_payments/${encodeURIComponent(batchPaymentId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentsBatchPaymentResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/batchPayments/client/index.ts b/src/api/resources/batchPayments/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/batchPayments/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/batchPayments/client/requests/PaymentsBatchPaymentRequest.ts b/src/api/resources/batchPayments/client/requests/PaymentsBatchPaymentRequest.ts new file mode 100644 index 0000000..5f3d658 --- /dev/null +++ b/src/api/resources/batchPayments/client/requests/PaymentsBatchPaymentRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * payer_bank_account_id: "payer_bank_account_id", + * payment_intents: [{ + * object: { + * id: "id", + * type: "payable" + * }, + * recipient: { + * id: "id", + * type: "counterpart" + * } + * }] + * } + */ +export interface PaymentsBatchPaymentRequest { + payer_bank_account_id: string; + payment_intents: Monite.SinglePaymentIntent[]; +} diff --git a/src/api/resources/batchPayments/client/requests/index.ts b/src/api/resources/batchPayments/client/requests/index.ts new file mode 100644 index 0000000..b3e5ba6 --- /dev/null +++ b/src/api/resources/batchPayments/client/requests/index.ts @@ -0,0 +1 @@ +export { type PaymentsBatchPaymentRequest } from "./PaymentsBatchPaymentRequest"; diff --git a/src/api/resources/batchPayments/index.ts b/src/api/resources/batchPayments/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/batchPayments/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/comments/client/Client.ts b/src/api/resources/comments/client/Client.ts new file mode 100644 index 0000000..41d35a7 --- /dev/null +++ b/src/api/resources/comments/client/Client.ts @@ -0,0 +1,527 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Comments { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Comments { + constructor(protected readonly _options: Comments.Options) {} + + /** + * Get comments + * + * @param {Monite.CommentsGetRequest} request + * @param {Comments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.comments.get({ + * object_type: "payable", + * object_id: "object_id" + * }) + */ + public async get( + request: Monite.CommentsGetRequest, + requestOptions?: Comments.RequestOptions + ): Promise { + const { + object_type: objectType, + object_id: objectId, + order, + limit, + pagination_token: paginationToken, + sort, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + } = request; + const _queryParams: Record = {}; + _queryParams["object_type"] = objectType; + _queryParams["object_id"] = objectId; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "comments" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CommentResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create new comment + * + * @param {Monite.CommentCreateRequest} request + * @param {Comments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.comments.create({ + * object_id: "object_id", + * object_type: "object_type", + * text: "text" + * }) + */ + public async create( + request: Monite.CommentCreateRequest, + requestOptions?: Comments.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "comments" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CommentResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get comment + * + * @param {string} commentId + * @param {Comments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.comments.getById("comment_id") + */ + public async getById(commentId: string, requestOptions?: Comments.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `comments/${encodeURIComponent(commentId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CommentResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete comment + * + * @param {string} commentId + * @param {Comments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.comments.deleteById("comment_id") + */ + public async deleteById(commentId: string, requestOptions?: Comments.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `comments/${encodeURIComponent(commentId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update comment + * + * @param {string} commentId + * @param {Monite.CommentUpdateRequest} request + * @param {Comments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.comments.updateById("comment_id") + */ + public async updateById( + commentId: string, + request: Monite.CommentUpdateRequest = {}, + requestOptions?: Comments.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `comments/${encodeURIComponent(commentId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CommentResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/comments/client/index.ts b/src/api/resources/comments/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/comments/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/comments/client/requests/CommentCreateRequest.ts b/src/api/resources/comments/client/requests/CommentCreateRequest.ts new file mode 100644 index 0000000..c165628 --- /dev/null +++ b/src/api/resources/comments/client/requests/CommentCreateRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * object_id: "object_id", + * object_type: "object_type", + * text: "text" + * } + */ +export interface CommentCreateRequest { + object_id: string; + object_type: string; + reply_to_entity_user_id?: string; + text: string; +} diff --git a/src/api/resources/comments/client/requests/CommentUpdateRequest.ts b/src/api/resources/comments/client/requests/CommentUpdateRequest.ts new file mode 100644 index 0000000..24f8cb1 --- /dev/null +++ b/src/api/resources/comments/client/requests/CommentUpdateRequest.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface CommentUpdateRequest { + reply_to_entity_user_id?: string; + text?: string; +} diff --git a/src/api/resources/comments/client/requests/CommentsGetRequest.ts b/src/api/resources/comments/client/requests/CommentsGetRequest.ts new file mode 100644 index 0000000..e2e4987 --- /dev/null +++ b/src/api/resources/comments/client/requests/CommentsGetRequest.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * object_type: "payable", + * object_id: "object_id" + * } + */ +export interface CommentsGetRequest { + object_type: Monite.ObjectTypeAvailableComment; + object_id: string; + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.CommentCursorFields; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; +} diff --git a/src/api/resources/comments/client/requests/index.ts b/src/api/resources/comments/client/requests/index.ts new file mode 100644 index 0000000..abd2be4 --- /dev/null +++ b/src/api/resources/comments/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type CommentsGetRequest } from "./CommentsGetRequest"; +export { type CommentCreateRequest } from "./CommentCreateRequest"; +export { type CommentUpdateRequest } from "./CommentUpdateRequest"; diff --git a/src/api/resources/comments/index.ts b/src/api/resources/comments/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/comments/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/counterparts/client/Client.ts b/src/api/resources/counterparts/client/Client.ts new file mode 100644 index 0000000..361d3aa --- /dev/null +++ b/src/api/resources/counterparts/client/Client.ts @@ -0,0 +1,784 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; +import { Addresses } from "../resources/addresses/client/Client"; +import { BankAccounts } from "../resources/bankAccounts/client/Client"; +import { Contacts } from "../resources/contacts/client/Client"; +import { VatIds } from "../resources/vatIds/client/Client"; + +export declare namespace Counterparts { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Counterparts { + constructor(protected readonly _options: Counterparts.Options) {} + + /** + * @param {Monite.CounterpartsGetRequest} request + * @param {Counterparts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.get({ + * sort_code: "123456" + * }) + */ + public async get( + request: Monite.CounterpartsGetRequest = {}, + requestOptions?: Counterparts.RequestOptions + ): Promise { + const { + iban, + sort_code: sortCode, + account_number: accountNumber, + tax_id: taxId, + vat_id: vatId, + id__in: idIn, + order, + limit, + pagination_token: paginationToken, + sort, + type: type_, + counterpart_name: counterpartName, + counterpart_name__iexact: counterpartNameIexact, + counterpart_name__contains: counterpartNameContains, + counterpart_name__icontains: counterpartNameIcontains, + is_vendor: isVendor, + is_customer: isCustomer, + email, + email__contains: emailContains, + email__icontains: emailIcontains, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + "address.country": addressCountry, + "address.city": addressCity, + "address.postal_code": addressPostalCode, + "address.state": addressState, + "address.line1": addressLine1, + "address.line2": addressLine2, + tag_ids__in: tagIdsIn, + } = request; + const _queryParams: Record = {}; + if (iban != null) { + _queryParams["iban"] = iban; + } + + if (sortCode != null) { + _queryParams["sort_code"] = sortCode; + } + + if (accountNumber != null) { + _queryParams["account_number"] = accountNumber; + } + + if (taxId != null) { + _queryParams["tax_id"] = taxId; + } + + if (vatId != null) { + _queryParams["vat_id"] = vatId; + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (type_ != null) { + _queryParams["type"] = type_; + } + + if (counterpartName != null) { + _queryParams["counterpart_name"] = counterpartName; + } + + if (counterpartNameIexact != null) { + _queryParams["counterpart_name__iexact"] = counterpartNameIexact; + } + + if (counterpartNameContains != null) { + _queryParams["counterpart_name__contains"] = counterpartNameContains; + } + + if (counterpartNameIcontains != null) { + _queryParams["counterpart_name__icontains"] = counterpartNameIcontains; + } + + if (isVendor != null) { + _queryParams["is_vendor"] = isVendor.toString(); + } + + if (isCustomer != null) { + _queryParams["is_customer"] = isCustomer.toString(); + } + + if (email != null) { + _queryParams["email"] = email; + } + + if (emailContains != null) { + _queryParams["email__contains"] = emailContains; + } + + if (emailIcontains != null) { + _queryParams["email__icontains"] = emailIcontains; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (addressCountry != null) { + _queryParams["address.country"] = addressCountry; + } + + if (addressCity != null) { + _queryParams["address.city"] = addressCity; + } + + if (addressPostalCode != null) { + _queryParams["address.postal_code"] = addressPostalCode; + } + + if (addressState != null) { + _queryParams["address.state"] = addressState; + } + + if (addressLine1 != null) { + _queryParams["address.line1"] = addressLine1; + } + + if (addressLine2 != null) { + _queryParams["address.line2"] = addressLine2; + } + + if (tagIdsIn != null) { + if (Array.isArray(tagIdsIn)) { + _queryParams["tag_ids__in"] = tagIdsIn.map((item) => item); + } else { + _queryParams["tag_ids__in"] = tagIdsIn; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "counterparts" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.CounterpartCreatePayload} request + * @param {Counterparts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.create({ + * type: "individual", + * individual: { + * address: { + * city: "Berlin", + * country: "AF", + * line1: "Flughafenstrasse 52", + * postal_code: "10115" + * }, + * first_name: "Adnan", + * is_customer: true, + * is_vendor: true, + * last_name: "Singh" + * } + * }) + */ + public async create( + request: Monite.CounterpartCreatePayload, + requestOptions?: Counterparts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "counterparts" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Counterparts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.getById("counterpart_id") + */ + public async getById( + counterpartId: string, + requestOptions?: Counterparts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Counterparts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.deleteById("counterpart_id") + */ + public async deleteById(counterpartId: string, requestOptions?: Counterparts.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Monite.CounterpartUpdatePayload} request + * @param {Counterparts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.updateById("counterpart_id", { + * individual: {} + * }) + */ + public async updateById( + counterpartId: string, + request: Monite.CounterpartUpdatePayload, + requestOptions?: Counterparts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Counterparts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.getPartnerMetadataById("counterpart_id") + */ + public async getPartnerMetadataById( + counterpartId: string, + requestOptions?: Counterparts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/partner_metadata` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PartnerMetadataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Monite.PartnerMetadata} request + * @param {Counterparts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.updatePartnerMetadataById("counterpart_id", { + * metadata: { + * "key": "value" + * } + * }) + */ + public async updatePartnerMetadataById( + counterpartId: string, + request: Monite.PartnerMetadata, + requestOptions?: Counterparts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/partner_metadata` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PartnerMetadataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected _addresses: Addresses | undefined; + + public get addresses(): Addresses { + return (this._addresses ??= new Addresses(this._options)); + } + + protected _bankAccounts: BankAccounts | undefined; + + public get bankAccounts(): BankAccounts { + return (this._bankAccounts ??= new BankAccounts(this._options)); + } + + protected _contacts: Contacts | undefined; + + public get contacts(): Contacts { + return (this._contacts ??= new Contacts(this._options)); + } + + protected _vatIds: VatIds | undefined; + + public get vatIds(): VatIds { + return (this._vatIds ??= new VatIds(this._options)); + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/counterparts/client/index.ts b/src/api/resources/counterparts/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/counterparts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/counterparts/client/requests/CounterpartsGetRequest.ts b/src/api/resources/counterparts/client/requests/CounterpartsGetRequest.ts new file mode 100644 index 0000000..4009234 --- /dev/null +++ b/src/api/resources/counterparts/client/requests/CounterpartsGetRequest.ts @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * sort_code: "123456" + * } + */ +export interface CounterpartsGetRequest { + /** + * The IBAN of the counterpart's bank account. + */ + iban?: string; + /** + * The bank's sort code. + */ + sort_code?: string; + /** + * The bank account number. Required for US bank accounts to accept ACH payments. US account numbers contain 9 to 12 digits. UK account numbers typically contain 8 digits. + */ + account_number?: string; + /** + * The tax ID of the counterpart. + */ + tax_id?: string; + /** + * The VAT ID of the counterpart. + */ + vat_id?: string; + /** + * A list of counterpart IDs to search through. + */ + id__in?: string | string[]; + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.CounterpartCursorFields; + type?: Monite.CounterpartType; + counterpart_name?: string; + counterpart_name__iexact?: string; + counterpart_name__contains?: string; + counterpart_name__icontains?: string; + is_vendor?: boolean; + is_customer?: boolean; + email?: string; + email__contains?: string; + email__icontains?: string; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + "address.country"?: string; + "address.city"?: string; + "address.postal_code"?: string; + "address.state"?: string; + "address.line1"?: string; + "address.line2"?: string; + tag_ids__in?: string | string[]; +} diff --git a/src/api/resources/counterparts/client/requests/index.ts b/src/api/resources/counterparts/client/requests/index.ts new file mode 100644 index 0000000..1243c04 --- /dev/null +++ b/src/api/resources/counterparts/client/requests/index.ts @@ -0,0 +1 @@ +export { type CounterpartsGetRequest } from "./CounterpartsGetRequest"; diff --git a/src/api/resources/counterparts/index.ts b/src/api/resources/counterparts/index.ts new file mode 100644 index 0000000..33a87f1 --- /dev/null +++ b/src/api/resources/counterparts/index.ts @@ -0,0 +1,2 @@ +export * from "./client"; +export * from "./resources"; diff --git a/src/api/resources/counterparts/resources/addresses/client/Client.ts b/src/api/resources/counterparts/resources/addresses/client/Client.ts new file mode 100644 index 0000000..aec4965 --- /dev/null +++ b/src/api/resources/counterparts/resources/addresses/client/Client.ts @@ -0,0 +1,439 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Addresses { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Addresses { + constructor(protected readonly _options: Addresses.Options) {} + + /** + * @param {string} counterpartId + * @param {Addresses.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.addresses.get("counterpart_id") + */ + public async get( + counterpartId: string, + requestOptions?: Addresses.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/addresses` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartAddressResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Monite.CounterpartAddress} request + * @param {Addresses.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.addresses.create("counterpart_id", { + * city: "Berlin", + * country: "AF", + * line1: "Flughafenstrasse 52", + * postal_code: "10115" + * }) + */ + public async create( + counterpartId: string, + request: Monite.CounterpartAddress, + requestOptions?: Addresses.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/addresses` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartAddressResponseWithCounterpartId; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} addressId + * @param {string} counterpartId + * @param {Addresses.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.addresses.getById("address_id", "counterpart_id") + */ + public async getById( + addressId: string, + counterpartId: string, + requestOptions?: Addresses.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/addresses/${encodeURIComponent(addressId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartAddressResponseWithCounterpartId; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} addressId + * @param {string} counterpartId + * @param {Addresses.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.addresses.deleteById("address_id", "counterpart_id") + */ + public async deleteById( + addressId: string, + counterpartId: string, + requestOptions?: Addresses.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/addresses/${encodeURIComponent(addressId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} addressId + * @param {string} counterpartId + * @param {Monite.counterparts.CounterpartUpdateAddress} request + * @param {Addresses.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.addresses.updateById("address_id", "counterpart_id") + */ + public async updateById( + addressId: string, + counterpartId: string, + request: Monite.counterparts.CounterpartUpdateAddress = {}, + requestOptions?: Addresses.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/addresses/${encodeURIComponent(addressId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartAddressResponseWithCounterpartId; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/counterparts/resources/addresses/client/index.ts b/src/api/resources/counterparts/resources/addresses/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/counterparts/resources/addresses/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/counterparts/resources/addresses/client/requests/CounterpartUpdateAddress.ts b/src/api/resources/counterparts/resources/addresses/client/requests/CounterpartUpdateAddress.ts new file mode 100644 index 0000000..375e2f0 --- /dev/null +++ b/src/api/resources/counterparts/resources/addresses/client/requests/CounterpartUpdateAddress.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface CounterpartUpdateAddress { + /** City name. */ + city?: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country?: Monite.AllowedCountries; + /** Street address. */ + line1?: string; + /** Additional address information (if any). */ + line2?: string; + /** ZIP or postal code. */ + postal_code?: string; + /** State, region, province, or county. */ + state?: string; +} diff --git a/src/api/resources/counterparts/resources/addresses/client/requests/index.ts b/src/api/resources/counterparts/resources/addresses/client/requests/index.ts new file mode 100644 index 0000000..99b2e21 --- /dev/null +++ b/src/api/resources/counterparts/resources/addresses/client/requests/index.ts @@ -0,0 +1 @@ +export { type CounterpartUpdateAddress } from "./CounterpartUpdateAddress"; diff --git a/src/api/resources/counterparts/resources/addresses/index.ts b/src/api/resources/counterparts/resources/addresses/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/counterparts/resources/addresses/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/Client.ts b/src/api/resources/counterparts/resources/bankAccounts/client/Client.ts new file mode 100644 index 0000000..fe5bf59 --- /dev/null +++ b/src/api/resources/counterparts/resources/bankAccounts/client/Client.ts @@ -0,0 +1,510 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace BankAccounts { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class BankAccounts { + constructor(protected readonly _options: BankAccounts.Options) {} + + /** + * @param {string} counterpartId + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.bankAccounts.get("counterpart_id") + */ + public async get( + counterpartId: string, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/bank_accounts` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartBankAccountResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Monite.counterparts.CreateCounterpartBankAccount} request + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.bankAccounts.create("counterpart_id", { + * country: "AF", + * currency: "AED" + * }) + */ + public async create( + counterpartId: string, + request: Monite.counterparts.CreateCounterpartBankAccount, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/bank_accounts` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartBankAccountResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} bankAccountId + * @param {string} counterpartId + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.bankAccounts.getById("bank_account_id", "counterpart_id") + */ + public async getById( + bankAccountId: string, + counterpartId: string, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/bank_accounts/${encodeURIComponent(bankAccountId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartBankAccountResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} bankAccountId + * @param {string} counterpartId + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.bankAccounts.deleteById("bank_account_id", "counterpart_id") + */ + public async deleteById( + bankAccountId: string, + counterpartId: string, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/bank_accounts/${encodeURIComponent(bankAccountId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} bankAccountId + * @param {string} counterpartId + * @param {Monite.counterparts.UpdateCounterpartBankAccount} request + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.bankAccounts.updateById("bank_account_id", "counterpart_id") + */ + public async updateById( + bankAccountId: string, + counterpartId: string, + request: Monite.counterparts.UpdateCounterpartBankAccount = {}, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/bank_accounts/${encodeURIComponent(bankAccountId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartBankAccountResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} bankAccountId + * @param {string} counterpartId + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.bankAccounts.makeDefaultById("bank_account_id", "counterpart_id") + */ + public async makeDefaultById( + bankAccountId: string, + counterpartId: string, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/bank_accounts/${encodeURIComponent( + bankAccountId + )}/make_default` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/index.ts b/src/api/resources/counterparts/resources/bankAccounts/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/counterparts/resources/bankAccounts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/requests/CreateCounterpartBankAccount.ts b/src/api/resources/counterparts/resources/bankAccounts/client/requests/CreateCounterpartBankAccount.ts new file mode 100644 index 0000000..fd236d5 --- /dev/null +++ b/src/api/resources/counterparts/resources/bankAccounts/client/requests/CreateCounterpartBankAccount.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * country: "AF", + * currency: "AED" + * } + */ +export interface CreateCounterpartBankAccount { + /** The name of the person or business that owns this bank account. Required for US bank accounts to accept ACH payments. */ + account_holder_name?: string; + /** The bank account number. Required for US bank accounts to accept ACH payments. US account numbers contain 9 to 12 digits. UK account numbers typically contain 8 digits. */ + account_number?: string; + /** The BIC/SWIFT code of the bank. */ + bic?: string; + country: Monite.AllowedCountries; + currency: Monite.CurrencyEnum; + /** The IBAN of the bank account. */ + iban?: string; + is_default_for_currency?: boolean; + name?: string; + /** Metadata for partner needs. */ + partner_metadata?: Record; + /** The bank's routing transit number (RTN). Required for US bank accounts to accept ACH payments. US routing numbers consist of 9 digits. */ + routing_number?: string; + /** The bank's sort code. */ + sort_code?: string; +} diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/requests/UpdateCounterpartBankAccount.ts b/src/api/resources/counterparts/resources/bankAccounts/client/requests/UpdateCounterpartBankAccount.ts new file mode 100644 index 0000000..c5cea4e --- /dev/null +++ b/src/api/resources/counterparts/resources/bankAccounts/client/requests/UpdateCounterpartBankAccount.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface UpdateCounterpartBankAccount { + /** The name of the person or business that owns this bank account. Required for US bank accounts to accept ACH payments. */ + account_holder_name?: string; + /** The bank account number. Required for US bank accounts to accept ACH payments. US account numbers contain 9 to 12 digits. UK account numbers typically contain 8 digits. */ + account_number?: string; + /** The BIC/SWIFT code of the bank. */ + bic?: string; + country?: Monite.AllowedCountries; + currency?: Monite.CurrencyEnum; + /** The IBAN of the bank account. */ + iban?: string; + name?: string; + /** Metadata for partner needs. */ + partner_metadata?: Record; + /** The bank's routing transit number (RTN). Required for US bank accounts to accept ACH payments. US routing numbers consist of 9 digits. */ + routing_number?: string; + /** The bank's sort code. */ + sort_code?: string; +} diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/requests/index.ts b/src/api/resources/counterparts/resources/bankAccounts/client/requests/index.ts new file mode 100644 index 0000000..a99d6fa --- /dev/null +++ b/src/api/resources/counterparts/resources/bankAccounts/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type CreateCounterpartBankAccount } from "./CreateCounterpartBankAccount"; +export { type UpdateCounterpartBankAccount } from "./UpdateCounterpartBankAccount"; diff --git a/src/api/resources/counterparts/resources/bankAccounts/index.ts b/src/api/resources/counterparts/resources/bankAccounts/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/counterparts/resources/bankAccounts/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/counterparts/resources/contacts/client/Client.ts b/src/api/resources/counterparts/resources/contacts/client/Client.ts new file mode 100644 index 0000000..a67945a --- /dev/null +++ b/src/api/resources/counterparts/resources/contacts/client/Client.ts @@ -0,0 +1,519 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Contacts { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Contacts { + constructor(protected readonly _options: Contacts.Options) {} + + /** + * @param {string} counterpartId + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.contacts.get("counterpart_id") + */ + public async get( + counterpartId: string, + requestOptions?: Contacts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/contacts` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartContactsResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Monite.counterparts.CreateCounterpartContactPayload} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.contacts.create("counterpart_id", { + * address: { + * city: "Berlin", + * country: "AF", + * line1: "Flughafenstrasse 52", + * postal_code: "10115" + * }, + * first_name: "Mary", + * last_name: "O'Brien" + * }) + */ + public async create( + counterpartId: string, + request: Monite.counterparts.CreateCounterpartContactPayload, + requestOptions?: Contacts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/contacts` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartContactResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} contactId + * @param {string} counterpartId + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.contacts.getById("contact_id", "counterpart_id") + */ + public async getById( + contactId: string, + counterpartId: string, + requestOptions?: Contacts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/contacts/${encodeURIComponent(contactId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartContactResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} contactId + * @param {string} counterpartId + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.contacts.deleteById("contact_id", "counterpart_id") + */ + public async deleteById( + contactId: string, + counterpartId: string, + requestOptions?: Contacts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/contacts/${encodeURIComponent(contactId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} contactId + * @param {string} counterpartId + * @param {Monite.counterparts.UpdateCounterpartContactPayload} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.contacts.updateById("contact_id", "counterpart_id") + */ + public async updateById( + contactId: string, + counterpartId: string, + request: Monite.counterparts.UpdateCounterpartContactPayload = {}, + requestOptions?: Contacts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/contacts/${encodeURIComponent(contactId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartContactResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} contactId + * @param {string} counterpartId + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.contacts.makeDefaultById("contact_id", "counterpart_id") + */ + public async makeDefaultById( + contactId: string, + counterpartId: string, + requestOptions?: Contacts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/contacts/${encodeURIComponent( + contactId + )}/make_default` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartContactResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/counterparts/resources/contacts/client/index.ts b/src/api/resources/counterparts/resources/contacts/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/counterparts/resources/contacts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/counterparts/resources/contacts/client/requests/CreateCounterpartContactPayload.ts b/src/api/resources/counterparts/resources/contacts/client/requests/CreateCounterpartContactPayload.ts new file mode 100644 index 0000000..2db3fba --- /dev/null +++ b/src/api/resources/counterparts/resources/contacts/client/requests/CreateCounterpartContactPayload.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * address: { + * city: "Berlin", + * country: "AF", + * line1: "Flughafenstrasse 52", + * postal_code: "10115" + * }, + * first_name: "Mary", + * last_name: "O'Brien" + * } + */ +export interface CreateCounterpartContactPayload { + /** The address of a contact person. */ + address: Monite.CounterpartAddress; + /** The email address of a contact person. */ + email?: string; + /** The first name of a contact person. */ + first_name: string; + /** The last name of a contact person. */ + last_name: string; + /** The phone number of a contact person */ + phone?: string; + /** The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. */ + title?: string; +} diff --git a/src/api/resources/counterparts/resources/contacts/client/requests/UpdateCounterpartContactPayload.ts b/src/api/resources/counterparts/resources/contacts/client/requests/UpdateCounterpartContactPayload.ts new file mode 100644 index 0000000..dc71dbd --- /dev/null +++ b/src/api/resources/counterparts/resources/contacts/client/requests/UpdateCounterpartContactPayload.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface UpdateCounterpartContactPayload { + /** The address of a contact person. */ + address?: Monite.CounterpartAddress; + /** The email address of a contact person. */ + email?: string; + /** The first name of a contact person. */ + first_name?: string; + /** The last name of a contact person. */ + last_name?: string; + /** The phone number of a contact person */ + phone?: string; + /** The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. */ + title?: string; +} diff --git a/src/api/resources/counterparts/resources/contacts/client/requests/index.ts b/src/api/resources/counterparts/resources/contacts/client/requests/index.ts new file mode 100644 index 0000000..af0868f --- /dev/null +++ b/src/api/resources/counterparts/resources/contacts/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type CreateCounterpartContactPayload } from "./CreateCounterpartContactPayload"; +export { type UpdateCounterpartContactPayload } from "./UpdateCounterpartContactPayload"; diff --git a/src/api/resources/counterparts/resources/contacts/index.ts b/src/api/resources/counterparts/resources/contacts/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/counterparts/resources/contacts/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/counterparts/resources/index.ts b/src/api/resources/counterparts/resources/index.ts new file mode 100644 index 0000000..0464014 --- /dev/null +++ b/src/api/resources/counterparts/resources/index.ts @@ -0,0 +1,8 @@ +export * as addresses from "./addresses"; +export * as bankAccounts from "./bankAccounts"; +export * as contacts from "./contacts"; +export * as vatIds from "./vatIds"; +export * from "./addresses/client/requests"; +export * from "./bankAccounts/client/requests"; +export * from "./contacts/client/requests"; +export * from "./vatIds/client/requests"; diff --git a/src/api/resources/counterparts/resources/vatIds/client/Client.ts b/src/api/resources/counterparts/resources/vatIds/client/Client.ts new file mode 100644 index 0000000..3a1bff9 --- /dev/null +++ b/src/api/resources/counterparts/resources/vatIds/client/Client.ts @@ -0,0 +1,433 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace VatIds { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class VatIds { + constructor(protected readonly _options: VatIds.Options) {} + + /** + * @param {string} counterpartId + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.vatIds.get("counterpart_id") + */ + public async get( + counterpartId: string, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/vat_ids` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartVatIdResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} counterpartId + * @param {Monite.counterparts.CounterpartVatId} request + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.vatIds.create("counterpart_id", { + * value: "123456789" + * }) + */ + public async create( + counterpartId: string, + request: Monite.counterparts.CounterpartVatId, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/vat_ids` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartVatIdResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} vatId + * @param {string} counterpartId + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.vatIds.getById("vat_id", "counterpart_id") + */ + public async getById( + vatId: string, + counterpartId: string, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/vat_ids/${encodeURIComponent(vatId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartVatIdResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} vatId + * @param {string} counterpartId + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.vatIds.deleteById("vat_id", "counterpart_id") + */ + public async deleteById( + vatId: string, + counterpartId: string, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/vat_ids/${encodeURIComponent(vatId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} vatId + * @param {string} counterpartId + * @param {Monite.counterparts.CounterpartUpdateVatId} request + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.counterparts.vatIds.updateById("vat_id", "counterpart_id") + */ + public async updateById( + vatId: string, + counterpartId: string, + request: Monite.counterparts.CounterpartUpdateVatId = {}, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `counterparts/${encodeURIComponent(counterpartId)}/vat_ids/${encodeURIComponent(vatId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CounterpartVatIdResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/counterparts/resources/vatIds/client/index.ts b/src/api/resources/counterparts/resources/vatIds/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/counterparts/resources/vatIds/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartUpdateVatId.ts b/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartUpdateVatId.ts new file mode 100644 index 0000000..b9d39e4 --- /dev/null +++ b/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartUpdateVatId.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface CounterpartUpdateVatId { + country?: Monite.AllowedCountries; + type?: Monite.VatIdTypeEnum; + value?: string; +} diff --git a/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartVatId.ts b/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartVatId.ts new file mode 100644 index 0000000..c0d38c5 --- /dev/null +++ b/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartVatId.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * value: "123456789" + * } + */ +export interface CounterpartVatId { + country?: Monite.AllowedCountries; + type?: Monite.VatIdTypeEnum; + value: string; +} diff --git a/src/api/resources/counterparts/resources/vatIds/client/requests/index.ts b/src/api/resources/counterparts/resources/vatIds/client/requests/index.ts new file mode 100644 index 0000000..21c9ada --- /dev/null +++ b/src/api/resources/counterparts/resources/vatIds/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type CounterpartVatId } from "./CounterpartVatId"; +export { type CounterpartUpdateVatId } from "./CounterpartUpdateVatId"; diff --git a/src/api/resources/counterparts/resources/vatIds/index.ts b/src/api/resources/counterparts/resources/vatIds/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/counterparts/resources/vatIds/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/dataExports/client/Client.ts b/src/api/resources/dataExports/client/Client.ts new file mode 100644 index 0000000..48756ec --- /dev/null +++ b/src/api/resources/dataExports/client/Client.ts @@ -0,0 +1,437 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; +import { ExtraData } from "../resources/extraData/client/Client"; + +export declare namespace DataExports { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class DataExports { + constructor(protected readonly _options: DataExports.Options) {} + + /** + * @param {Monite.DataExportsGetRequest} request + * @param {DataExports.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.get() + */ + public async get( + request: Monite.DataExportsGetRequest = {}, + requestOptions?: DataExports.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + created_by_entity_user_id: createdByEntityUserId, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (createdByEntityUserId != null) { + _queryParams["created_by_entity_user_id"] = createdByEntityUserId; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "data_exports" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AllDocumentExportResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.ExportPayloadSchema} request + * @param {DataExports.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.create({ + * date_from: "date_from", + * date_to: "date_to", + * format: "csv", + * objects: [{ + * name: "receivable", + * statuses: ["draft"] + * }] + * }) + */ + public async create( + request: Monite.ExportPayloadSchema, + requestOptions?: DataExports.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "data_exports" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CreateExportTaskResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {DataExports.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.getSupportedFormats() + */ + public async getSupportedFormats( + requestOptions?: DataExports.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "data_exports/supported_formats" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.SupportedFormatSchema[]; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} documentExportId + * @param {DataExports.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.getById("document_export_id") + */ + public async getById( + documentExportId: string, + requestOptions?: DataExports.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `data_exports/${encodeURIComponent(documentExportId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.DocumentExportResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected _extraData: ExtraData | undefined; + + public get extraData(): ExtraData { + return (this._extraData ??= new ExtraData(this._options)); + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/dataExports/client/index.ts b/src/api/resources/dataExports/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/dataExports/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/dataExports/client/requests/DataExportsGetRequest.ts b/src/api/resources/dataExports/client/requests/DataExportsGetRequest.ts new file mode 100644 index 0000000..843f4e9 --- /dev/null +++ b/src/api/resources/dataExports/client/requests/DataExportsGetRequest.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface DataExportsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.DataExportCursorFields; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + created_by_entity_user_id?: string; +} diff --git a/src/api/resources/dataExports/client/requests/ExportPayloadSchema.ts b/src/api/resources/dataExports/client/requests/ExportPayloadSchema.ts new file mode 100644 index 0000000..5609e58 --- /dev/null +++ b/src/api/resources/dataExports/client/requests/ExportPayloadSchema.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * date_from: "date_from", + * date_to: "date_to", + * format: "csv", + * objects: [{ + * name: "receivable", + * statuses: ["draft"] + * }] + * } + */ +export interface ExportPayloadSchema { + date_from: string; + date_to: string; + format: Monite.ExportFormat; + objects: Monite.ExportObjectSchema[]; +} diff --git a/src/api/resources/dataExports/client/requests/index.ts b/src/api/resources/dataExports/client/requests/index.ts new file mode 100644 index 0000000..c27373e --- /dev/null +++ b/src/api/resources/dataExports/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type DataExportsGetRequest } from "./DataExportsGetRequest"; +export { type ExportPayloadSchema } from "./ExportPayloadSchema"; diff --git a/src/api/resources/dataExports/index.ts b/src/api/resources/dataExports/index.ts new file mode 100644 index 0000000..33a87f1 --- /dev/null +++ b/src/api/resources/dataExports/index.ts @@ -0,0 +1,2 @@ +export * from "./client"; +export * from "./resources"; diff --git a/src/api/resources/dataExports/resources/extraData/client/Client.ts b/src/api/resources/dataExports/resources/extraData/client/Client.ts new file mode 100644 index 0000000..45c92aa --- /dev/null +++ b/src/api/resources/dataExports/resources/extraData/client/Client.ts @@ -0,0 +1,539 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace ExtraData { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class ExtraData { + constructor(protected readonly _options: ExtraData.Options) {} + + /** + * @param {Monite.dataExports.ExtraDataGetRequest} request + * @param {ExtraData.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.extraData.get() + */ + public async get( + request: Monite.dataExports.ExtraDataGetRequest = {}, + requestOptions?: ExtraData.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + updated_at__gt: updatedAtGt, + updated_at__lt: updatedAtLt, + updated_at__gte: updatedAtGte, + updated_at__lte: updatedAtLte, + object_id: objectId, + field_name: fieldName, + field_value: fieldValue, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (updatedAtGt != null) { + _queryParams["updated_at__gt"] = updatedAtGt; + } + + if (updatedAtLt != null) { + _queryParams["updated_at__lt"] = updatedAtLt; + } + + if (updatedAtGte != null) { + _queryParams["updated_at__gte"] = updatedAtGte; + } + + if (updatedAtLte != null) { + _queryParams["updated_at__lte"] = updatedAtLte; + } + + if (objectId != null) { + _queryParams["object_id"] = objectId; + } + + if (fieldName != null) { + _queryParams["field_name"] = fieldName; + } + + if (fieldValue != null) { + _queryParams["field_value"] = fieldValue; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "data_exports/extra_data" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ExtraDataResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.dataExports.ExtraDataCreateRequest} request + * @param {ExtraData.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.extraData.create({ + * field_name: "default_account_code", + * field_value: "field_value", + * object_id: "object_id" + * }) + */ + public async create( + request: Monite.dataExports.ExtraDataCreateRequest, + requestOptions?: ExtraData.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "data_exports/extra_data" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: { ...request, object_type: "counterpart" }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ExtraDataResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} extraDataId + * @param {ExtraData.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.extraData.getById("extra_data_id") + */ + public async getById( + extraDataId: string, + requestOptions?: ExtraData.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `data_exports/extra_data/${encodeURIComponent(extraDataId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ExtraDataResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} extraDataId + * @param {ExtraData.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.extraData.deleteById("extra_data_id") + */ + public async deleteById( + extraDataId: string, + requestOptions?: ExtraData.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `data_exports/extra_data/${encodeURIComponent(extraDataId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ExtraDataResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} extraDataId + * @param {Monite.dataExports.ExtraDataUpdateRequest} request + * @param {ExtraData.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.dataExports.extraData.updateById("extra_data_id") + */ + public async updateById( + extraDataId: string, + request: Monite.dataExports.ExtraDataUpdateRequest = {}, + requestOptions?: ExtraData.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `data_exports/extra_data/${encodeURIComponent(extraDataId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ExtraDataResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/dataExports/resources/extraData/client/index.ts b/src/api/resources/dataExports/resources/extraData/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/dataExports/resources/extraData/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataCreateRequest.ts b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataCreateRequest.ts new file mode 100644 index 0000000..7ced08e --- /dev/null +++ b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataCreateRequest.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * field_name: "default_account_code", + * field_value: "field_value", + * object_id: "object_id" + * } + */ +export interface ExtraDataCreateRequest { + field_name: Monite.SupportedFieldNames; + field_value: string; + object_id: string; +} diff --git a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataGetRequest.ts b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataGetRequest.ts new file mode 100644 index 0000000..859d50b --- /dev/null +++ b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataGetRequest.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface ExtraDataGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.ExportSettingCursorFields; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + updated_at__gt?: string; + updated_at__lt?: string; + updated_at__gte?: string; + updated_at__lte?: string; + object_id?: string; + field_name?: string; + field_value?: string; +} diff --git a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataUpdateRequest.ts b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataUpdateRequest.ts new file mode 100644 index 0000000..8893401 --- /dev/null +++ b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataUpdateRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface ExtraDataUpdateRequest { + field_name?: Monite.SupportedFieldNames; + field_value?: string; + object_id?: string; + object_type?: "counterpart"; +} diff --git a/src/api/resources/dataExports/resources/extraData/client/requests/index.ts b/src/api/resources/dataExports/resources/extraData/client/requests/index.ts new file mode 100644 index 0000000..e0f9cfe --- /dev/null +++ b/src/api/resources/dataExports/resources/extraData/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type ExtraDataGetRequest } from "./ExtraDataGetRequest"; +export { type ExtraDataCreateRequest } from "./ExtraDataCreateRequest"; +export { type ExtraDataUpdateRequest } from "./ExtraDataUpdateRequest"; diff --git a/src/api/resources/dataExports/resources/extraData/index.ts b/src/api/resources/dataExports/resources/extraData/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/dataExports/resources/extraData/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/dataExports/resources/index.ts b/src/api/resources/dataExports/resources/index.ts new file mode 100644 index 0000000..075edd4 --- /dev/null +++ b/src/api/resources/dataExports/resources/index.ts @@ -0,0 +1,2 @@ +export * as extraData from "./extraData"; +export * from "./extraData/client/requests"; diff --git a/src/api/resources/entities/client/Client.ts b/src/api/resources/entities/client/Client.ts new file mode 100644 index 0000000..f1717f1 --- /dev/null +++ b/src/api/resources/entities/client/Client.ts @@ -0,0 +1,1267 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; +import * as fs from "fs"; +import { Blob } from "buffer"; +import { BankAccounts } from "../resources/bankAccounts/client/Client"; +import { OnboardingData } from "../resources/onboardingData/client/Client"; +import { PaymentMethods } from "../resources/paymentMethods/client/Client"; +import { VatIds } from "../resources/vatIds/client/Client"; +import { Persons } from "../resources/persons/client/Client"; + +export declare namespace Entities { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Entities { + constructor(protected readonly _options: Entities.Options) {} + + /** + * Retrieve a list of all entities. + * + * @param {Monite.EntitiesGetRequest} request + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.get() + */ + public async get( + request: Monite.EntitiesGetRequest = {}, + requestOptions?: Entities.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + type: type_, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + id__in: idIn, + id__not_in: idNotIn, + email, + email__in: emailIn, + email__not_in: emailNotIn, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (type_ != null) { + _queryParams["type"] = type_; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (idNotIn != null) { + if (Array.isArray(idNotIn)) { + _queryParams["id__not_in"] = idNotIn.map((item) => item); + } else { + _queryParams["id__not_in"] = idNotIn; + } + } + + if (email != null) { + _queryParams["email"] = email; + } + + if (emailIn != null) { + if (Array.isArray(emailIn)) { + _queryParams["email__in"] = emailIn.map((item) => item); + } else { + _queryParams["email__in"] = emailIn; + } + } + + if (emailNotIn != null) { + if (Array.isArray(emailNotIn)) { + _queryParams["email__not_in"] = emailNotIn.map((item) => item); + } else { + _queryParams["email__not_in"] = emailNotIn; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entities" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a new entity from the specified values. + * + * @param {Monite.CreateEntityRequest} request + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.create({ + * address: { + * city: "city", + * country: "AF", + * line1: "line1", + * postal_code: "postal_code" + * }, + * email: "email", + * type: "individual" + * }) + */ + public async create( + request: Monite.CreateEntityRequest, + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entities" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Deprecated. Use `GET /entity_users/my_entity` instead. + * + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.getEntitiesMe() + */ + public async getEntitiesMe(requestOptions?: Entities.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entities/me" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Deprecated. Use `PATCH /entity_users/my_entity` instead. + * + * @param {Monite.UpdateEntityRequest} request + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.patchEntitiesMe({}) + */ + public async patchEntitiesMe( + request: Monite.UpdateEntityRequest, + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entities/me" + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve an entity by its ID. + * + * @param {string} entityId - A unique ID to specify the entity. + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.getById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + */ + public async getById(entityId: string, requestOptions?: Entities.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Change the specified fields with the provided values. + * + * @param {string} entityId - A unique ID to specify the entity. + * @param {Monite.UpdateEntityRequest} request + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.updateById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5", {}) + */ + public async updateById( + entityId: string, + request: Monite.UpdateEntityRequest, + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for example, in PDF documents created by this entity. + * + * @param {File | fs.ReadStream | Blob} file + * @param {string} entityId + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.uploadLogoById(fs.createReadStream("/path/to/your/file"), "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + */ + public async uploadLogoById( + file: File | fs.ReadStream | Blob, + entityId: string, + requestOptions?: Entities.RequestOptions + ): Promise { + const _request = await core.newFormData(); + await _request.appendFile("file", file); + const _maybeEncodedRequest = await _request.getRequest(); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/logo` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ..._maybeEncodedRequest.headers, + }, + requestType: "file", + duplex: _maybeEncodedRequest.duplex, + body: _maybeEncodedRequest.body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.FileSchema3; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} entityId - A unique ID to specify the entity. + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.deleteLogoById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + */ + public async deleteLogoById(entityId: string, requestOptions?: Entities.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/logo` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a metadata object associated with this entity, usually in a JSON format. + * + * @param {string} entityId + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.getPartnerMetadataById("entity_id") + */ + public async getPartnerMetadataById( + entityId: string, + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/partner_metadata` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PartnerMetadataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Fully replace the current metadata object with the specified instance. + * + * @param {string} entityId + * @param {Monite.PartnerMetadata} request + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.updatePartnerMetadataById("entity_id", { + * metadata: { + * "key": "value" + * } + * }) + */ + public async updatePartnerMetadataById( + entityId: string, + request: Monite.PartnerMetadata, + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/partner_metadata` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PartnerMetadataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve all settings for this entity. + * + * @param {string} entityId - A unique ID to specify the entity. + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.getSettingsById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + */ + public async getSettingsById( + entityId: string, + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/settings` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.MergedSettingsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Change the specified fields with the provided values. + * + * @param {string} entityId - A unique ID to specify the entity. + * @param {Monite.PatchSettingsPayload} request + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.updateSettingsById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + */ + public async updateSettingsById( + entityId: string, + request: Monite.PatchSettingsPayload = {}, + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/settings` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.MergedSettingsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Provide files for entity onboarding verification + * + * @param {Monite.EntityOnboardingDocumentsPayload} request + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.uploadOnboardingDocuments() + */ + public async uploadOnboardingDocuments( + request: Monite.EntityOnboardingDocumentsPayload = {}, + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "onboarding_documents" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get onboarding requirements for the entity + * + * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.getOnboardingRequirements() + */ + public async getOnboardingRequirements( + requestOptions?: Entities.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "onboarding_requirements" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.GetOnboardingRequirementsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected _bankAccounts: BankAccounts | undefined; + + public get bankAccounts(): BankAccounts { + return (this._bankAccounts ??= new BankAccounts(this._options)); + } + + protected _onboardingData: OnboardingData | undefined; + + public get onboardingData(): OnboardingData { + return (this._onboardingData ??= new OnboardingData(this._options)); + } + + protected _paymentMethods: PaymentMethods | undefined; + + public get paymentMethods(): PaymentMethods { + return (this._paymentMethods ??= new PaymentMethods(this._options)); + } + + protected _vatIds: VatIds | undefined; + + public get vatIds(): VatIds { + return (this._vatIds ??= new VatIds(this._options)); + } + + protected _persons: Persons | undefined; + + public get persons(): Persons { + return (this._persons ??= new Persons(this._options)); + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/entities/client/index.ts b/src/api/resources/entities/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/entities/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/entities/client/requests/CreateEntityRequest.ts b/src/api/resources/entities/client/requests/CreateEntityRequest.ts new file mode 100644 index 0000000..bad8323 --- /dev/null +++ b/src/api/resources/entities/client/requests/CreateEntityRequest.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * address: { + * city: "city", + * country: "AF", + * line1: "line1", + * postal_code: "postal_code" + * }, + * email: "email", + * type: "individual" + * } + */ +export interface CreateEntityRequest { + /** An address description of the entity */ + address: Monite.EntityAddressSchema; + /** An official email address of the entity */ + email: string; + /** A set of meta data describing the individual */ + individual?: Monite.IndividualSchema; + /** A set of meta data describing the organization */ + organization?: Monite.OrganizationSchema; + /** A phone number of the entity */ + phone?: string; + /** The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. */ + tax_id?: string; + /** A type for an entity */ + type: Monite.EntityTypeEnum; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/resources/entities/client/requests/EntitiesGetRequest.ts b/src/api/resources/entities/client/requests/EntitiesGetRequest.ts new file mode 100644 index 0000000..a784c59 --- /dev/null +++ b/src/api/resources/entities/client/requests/EntitiesGetRequest.ts @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface EntitiesGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.EntityCursorFields; + type?: Monite.EntityTypeEnum; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + id__in?: string | string[]; + id__not_in?: string | string[]; + email?: string; + email__in?: string | string[]; + email__not_in?: string | string[]; +} diff --git a/src/api/resources/entities/client/requests/EntityLogoUploadRequest.ts b/src/api/resources/entities/client/requests/EntityLogoUploadRequest.ts new file mode 100644 index 0000000..8c638b6 --- /dev/null +++ b/src/api/resources/entities/client/requests/EntityLogoUploadRequest.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface EntityLogoUploadRequest {} diff --git a/src/api/resources/entities/client/requests/EntityOnboardingDocumentsPayload.ts b/src/api/resources/entities/client/requests/EntityOnboardingDocumentsPayload.ts new file mode 100644 index 0000000..f3d890f --- /dev/null +++ b/src/api/resources/entities/client/requests/EntityOnboardingDocumentsPayload.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface EntityOnboardingDocumentsPayload { + additional_verification_document_back?: string; + additional_verification_document_front?: string; + bank_account_ownership_verification?: string[]; + company_license?: string[]; + company_memorandum_of_association?: string[]; + company_ministerial_decree?: string[]; + company_registration_verification?: string[]; + company_tax_id_verification?: string[]; + proof_of_registration?: string[]; + verification_document_back?: string; + verification_document_front?: string; +} diff --git a/src/api/resources/entities/client/requests/PatchSettingsPayload.ts b/src/api/resources/entities/client/requests/PatchSettingsPayload.ts new file mode 100644 index 0000000..228d891 --- /dev/null +++ b/src/api/resources/entities/client/requests/PatchSettingsPayload.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PatchSettingsPayload { + language?: Monite.LanguageCodeEnum; + currency?: Monite.CurrencySettings; + reminder?: Monite.RemindersSettings; + /** Defines whether the prices of products in receivables will already include VAT or not. */ + vat_mode?: Monite.VatModeEnum; + /** Payment preferences for entity to automate calculating suggested payment date basing on payment terms and entity preferences */ + payment_priority?: Monite.PaymentPriorityEnum; + /** Automatically attempt to find a corresponding purchase order for all incoming payables. */ + allow_purchase_order_autolinking?: boolean; + receivable_edit_flow?: Monite.ReceivableEditFlow; + document_ids?: Monite.DocumentIDsSettingsRequest; + /** Auto tagging settings for all incoming OCR payable documents. */ + payables_ocr_auto_tagging?: Monite.OcrAutoTaggingSettingsRequest[]; + /** Sets the default behavior of whether a signature is required to accept quotes */ + quote_signature_required?: boolean; + /** If enabled, the paid invoice's PDF will be in a new layout set by the user */ + generate_paid_invoice_pdf?: boolean; +} diff --git a/src/api/resources/entities/client/requests/index.ts b/src/api/resources/entities/client/requests/index.ts new file mode 100644 index 0000000..aa4d51e --- /dev/null +++ b/src/api/resources/entities/client/requests/index.ts @@ -0,0 +1,5 @@ +export { type EntitiesGetRequest } from "./EntitiesGetRequest"; +export { type CreateEntityRequest } from "./CreateEntityRequest"; +export { type EntityLogoUploadRequest } from "./EntityLogoUploadRequest"; +export { type PatchSettingsPayload } from "./PatchSettingsPayload"; +export { type EntityOnboardingDocumentsPayload } from "./EntityOnboardingDocumentsPayload"; diff --git a/src/api/resources/entities/index.ts b/src/api/resources/entities/index.ts new file mode 100644 index 0000000..33a87f1 --- /dev/null +++ b/src/api/resources/entities/index.ts @@ -0,0 +1,2 @@ +export * from "./client"; +export * from "./resources"; diff --git a/src/api/resources/entities/resources/bankAccounts/client/Client.ts b/src/api/resources/entities/resources/bankAccounts/client/Client.ts new file mode 100644 index 0000000..2c7a561 --- /dev/null +++ b/src/api/resources/entities/resources/bankAccounts/client/Client.ts @@ -0,0 +1,938 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace BankAccounts { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class BankAccounts { + constructor(protected readonly _options: BankAccounts.Options) {} + + /** + * Get all bank accounts of this entity. + * + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.get() + */ + public async get( + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "bank_accounts" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityBankAccountPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Add a new bank account for the specified entity. + * + * The minimum required fields are `currency` and `country`. Other required fields depend on the currency: + * + * - EUR accounts require `iban`. + * - GBP accounts require `account_holder_name`, `account_number`, and `sort_code`. + * - USD accounts require `account_holder_name`, `account_number`, and `routing_number`. + * - Accounts in other currencies require one of: + * - `iban` + * - `account_number` and `sort_code` + * - `account_number` and `routing_number` + * + * @param {Monite.entities.CreateEntityBankAccountRequest} request + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.create({ + * country: "AF", + * currency: "AED" + * }) + */ + public async create( + request: Monite.entities.CreateEntityBankAccountRequest, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "bank_accounts" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityBankAccountResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.entities.CompleteVerificationRequest} request + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.completeVerification({ + * airwallex_plaid: { + * account: { + * id: "id", + * mask: "mask", + * name: "name" + * }, + * institution: { + * id: "id", + * name: "name" + * }, + * mandate: { + * email: "email", + * signatory: "signatory", + * type: "us_ach_debit", + * version: "1.0" + * }, + * public_token: "public_token" + * }, + * type: "airwallex_plaid" + * }) + */ + public async completeVerification( + request: Monite.entities.CompleteVerificationRequest, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "bank_accounts/complete_verification" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: { ...request, type: "airwallex_plaid" }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CompleteVerificationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Start entity bank account verification. The flow depends on verification type. + * For airwallex_plaid it generates Plaid Link token to init the Plaid SDK. + * + * @param {Monite.VerificationRequest} request + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.startVerification({ + * airwallex_plaid: { + * client_name: "client_name", + * redirect_url: "redirect_url" + * }, + * type: "airwallex_plaid" + * }) + */ + public async startVerification( + request: Monite.VerificationRequest, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "bank_accounts/start_verification" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.VerificationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a bank account by its ID. + * + * @param {string} bankAccountId + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.getById("bank_account_id") + */ + public async getById( + bankAccountId: string, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `bank_accounts/${encodeURIComponent(bankAccountId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityBankAccountResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete the bank account specified by its ID. + * + * @param {string} bankAccountId + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.deleteById("bank_account_id") + */ + public async deleteById(bankAccountId: string, requestOptions?: BankAccounts.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `bank_accounts/${encodeURIComponent(bankAccountId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Change the specified fields with the provided values. + * + * @param {string} bankAccountId + * @param {Monite.entities.UpdateEntityBankAccountRequest} request + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.updateById("bank_account_id") + */ + public async updateById( + bankAccountId: string, + request: Monite.entities.UpdateEntityBankAccountRequest = {}, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `bank_accounts/${encodeURIComponent(bankAccountId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityBankAccountResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} bankAccountId + * @param {Monite.entities.CompleteRefreshVerificationRequest} request + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.completeVerificationById("bank_account_id", { + * type: "airwallex_plaid" + * }) + */ + public async completeVerificationById( + bankAccountId: string, + request: Monite.entities.CompleteRefreshVerificationRequest, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `bank_accounts/${encodeURIComponent(bankAccountId)}/complete_verification` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: { ...request, type: "airwallex_plaid" }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CompleteRefreshVerificationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Set a bank account as the default for this entity per currency. + * + * @param {string} bankAccountId + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.makeDefaultById("bank_account_id") + */ + public async makeDefaultById( + bankAccountId: string, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `bank_accounts/${encodeURIComponent(bankAccountId)}/make_default` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityBankAccountResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} bankAccountId + * @param {Monite.VerificationRequest} request + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.refreshVerificationById("bank_account_id", { + * airwallex_plaid: { + * client_name: "client_name", + * redirect_url: "redirect_url" + * }, + * type: "airwallex_plaid" + * }) + */ + public async refreshVerificationById( + bankAccountId: string, + request: Monite.VerificationRequest, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `bank_accounts/${encodeURIComponent(bankAccountId)}/refresh_verification` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.VerificationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} bankAccountId + * @param {BankAccounts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.bankAccounts.getVerificationsById("bank_account_id") + */ + public async getVerificationsById( + bankAccountId: string, + requestOptions?: BankAccounts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `bank_accounts/${encodeURIComponent(bankAccountId)}/verifications` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.BankAccountVerifications; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/entities/resources/bankAccounts/client/index.ts b/src/api/resources/entities/resources/bankAccounts/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/entities/resources/bankAccounts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/entities/resources/bankAccounts/client/requests/CompleteRefreshVerificationRequest.ts b/src/api/resources/entities/resources/bankAccounts/client/requests/CompleteRefreshVerificationRequest.ts new file mode 100644 index 0000000..08c3d16 --- /dev/null +++ b/src/api/resources/entities/resources/bankAccounts/client/requests/CompleteRefreshVerificationRequest.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * type: "airwallex_plaid" + * } + */ +export interface CompleteRefreshVerificationRequest {} diff --git a/src/api/resources/entities/resources/bankAccounts/client/requests/CompleteVerificationRequest.ts b/src/api/resources/entities/resources/bankAccounts/client/requests/CompleteVerificationRequest.ts new file mode 100644 index 0000000..6b6c7f9 --- /dev/null +++ b/src/api/resources/entities/resources/bankAccounts/client/requests/CompleteVerificationRequest.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * airwallex_plaid: { + * account: { + * id: "id", + * mask: "mask", + * name: "name" + * }, + * institution: { + * id: "id", + * name: "name" + * }, + * mandate: { + * email: "email", + * signatory: "signatory", + * type: "us_ach_debit", + * version: "1.0" + * }, + * public_token: "public_token" + * }, + * type: "airwallex_plaid" + * } + */ +export interface CompleteVerificationRequest { + airwallex_plaid: Monite.CompleteVerificationAirwallexPlaidRequest; +} diff --git a/src/api/resources/entities/resources/bankAccounts/client/requests/CreateEntityBankAccountRequest.ts b/src/api/resources/entities/resources/bankAccounts/client/requests/CreateEntityBankAccountRequest.ts new file mode 100644 index 0000000..688002c --- /dev/null +++ b/src/api/resources/entities/resources/bankAccounts/client/requests/CreateEntityBankAccountRequest.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * country: "AF", + * currency: "AED" + * } + */ +export interface CreateEntityBankAccountRequest { + /** The name of the person or business that owns this bank account. Required if the account currency is GBP or USD. */ + account_holder_name?: string; + /** The bank account number. Required if the account currency is GBP or USD. UK account numbers typically contain 8 digits. US bank account numbers contain 9 to 12 digits. */ + account_number?: string; + /** The bank name. */ + bank_name?: string; + /** The SWIFT/BIC code of the bank. */ + bic?: string; + /** The country in which the bank account is registered, repsesented as a two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country: Monite.AllowedCountries; + /** The currency of the bank account, represented as a three-letter ISO [currency code](https://docs.monite.com/docs/currencies). */ + currency: Monite.CurrencyEnum; + /** User-defined name of this bank account, such as 'Primary account' or 'Savings account'. */ + display_name?: string; + /** The IBAN of the bank account. Required if the account currency is EUR. */ + iban?: string; + /** If set to `true` or if this is the first bank account added for the given currency, this account becomes the default one for its currency. */ + is_default_for_currency?: boolean; + /** The bank's routing transit number (RTN). Required if the account currency is USD. US routing numbers consist of 9 digits. */ + routing_number?: string; + /** The bank's sort code. Required if the account currency is GBP. */ + sort_code?: string; +} diff --git a/src/api/resources/entities/resources/bankAccounts/client/requests/UpdateEntityBankAccountRequest.ts b/src/api/resources/entities/resources/bankAccounts/client/requests/UpdateEntityBankAccountRequest.ts new file mode 100644 index 0000000..a35c3c2 --- /dev/null +++ b/src/api/resources/entities/resources/bankAccounts/client/requests/UpdateEntityBankAccountRequest.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface UpdateEntityBankAccountRequest { + /** The name of the person or business that owns this bank account. If the account currency is GBP or USD, the holder name cannot be changed to an empty string. */ + account_holder_name?: string; + /** User-defined name of this bank account, such as 'Primary account' or 'Savings account'. */ + display_name?: string; +} diff --git a/src/api/resources/entities/resources/bankAccounts/client/requests/index.ts b/src/api/resources/entities/resources/bankAccounts/client/requests/index.ts new file mode 100644 index 0000000..a615e7d --- /dev/null +++ b/src/api/resources/entities/resources/bankAccounts/client/requests/index.ts @@ -0,0 +1,4 @@ +export { type CreateEntityBankAccountRequest } from "./CreateEntityBankAccountRequest"; +export { type CompleteVerificationRequest } from "./CompleteVerificationRequest"; +export { type UpdateEntityBankAccountRequest } from "./UpdateEntityBankAccountRequest"; +export { type CompleteRefreshVerificationRequest } from "./CompleteRefreshVerificationRequest"; diff --git a/src/api/resources/entities/resources/bankAccounts/index.ts b/src/api/resources/entities/resources/bankAccounts/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/entities/resources/bankAccounts/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/entities/resources/index.ts b/src/api/resources/entities/resources/index.ts new file mode 100644 index 0000000..791b011 --- /dev/null +++ b/src/api/resources/entities/resources/index.ts @@ -0,0 +1,10 @@ +export * as bankAccounts from "./bankAccounts"; +export * as onboardingData from "./onboardingData"; +export * as paymentMethods from "./paymentMethods"; +export * as vatIds from "./vatIds"; +export * as persons from "./persons"; +export * from "./bankAccounts/client/requests"; +export * from "./onboardingData/client/requests"; +export * from "./paymentMethods/client/requests"; +export * from "./vatIds/client/requests"; +export * from "./persons/client/requests"; diff --git a/src/api/resources/entities/resources/onboardingData/client/Client.ts b/src/api/resources/entities/resources/onboardingData/client/Client.ts new file mode 100644 index 0000000..90d8598 --- /dev/null +++ b/src/api/resources/entities/resources/onboardingData/client/Client.ts @@ -0,0 +1,206 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace OnboardingData { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class OnboardingData { + constructor(protected readonly _options: OnboardingData.Options) {} + + /** + * @param {string} entityId + * @param {OnboardingData.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.onboardingData.get("entity_id") + */ + public async get( + entityId: string, + requestOptions?: OnboardingData.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/onboarding_data` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityOnboardingDataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} entityId + * @param {Monite.entities.EntityOnboardingDataRequest} request + * @param {OnboardingData.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.onboardingData.update("entity_id") + */ + public async update( + entityId: string, + request: Monite.entities.EntityOnboardingDataRequest = {}, + requestOptions?: OnboardingData.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/onboarding_data` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityOnboardingDataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/entities/resources/onboardingData/client/index.ts b/src/api/resources/entities/resources/onboardingData/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/entities/resources/onboardingData/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/entities/resources/onboardingData/client/requests/EntityOnboardingDataRequest.ts b/src/api/resources/entities/resources/onboardingData/client/requests/EntityOnboardingDataRequest.ts new file mode 100644 index 0000000..b8cf5ec --- /dev/null +++ b/src/api/resources/entities/resources/onboardingData/client/requests/EntityOnboardingDataRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface EntityOnboardingDataRequest { + /** Business information about the entity. */ + business_profile?: Monite.BusinessProfile; + /** Used to attest that the beneficial owner information provided is both current and correct. */ + ownership_declaration?: Monite.OwnershipDeclaration; + /** Details on the entity's acceptance of the service agreement. */ + tos_acceptance?: Monite.TermsOfServiceAcceptance; +} diff --git a/src/api/resources/entities/resources/onboardingData/client/requests/index.ts b/src/api/resources/entities/resources/onboardingData/client/requests/index.ts new file mode 100644 index 0000000..d7bd248 --- /dev/null +++ b/src/api/resources/entities/resources/onboardingData/client/requests/index.ts @@ -0,0 +1 @@ +export { type EntityOnboardingDataRequest } from "./EntityOnboardingDataRequest"; diff --git a/src/api/resources/entities/resources/onboardingData/index.ts b/src/api/resources/entities/resources/onboardingData/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/entities/resources/onboardingData/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/entities/resources/paymentMethods/client/Client.ts b/src/api/resources/entities/resources/paymentMethods/client/Client.ts new file mode 100644 index 0000000..747bbbc --- /dev/null +++ b/src/api/resources/entities/resources/paymentMethods/client/Client.ts @@ -0,0 +1,198 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace PaymentMethods { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PaymentMethods { + constructor(protected readonly _options: PaymentMethods.Options) {} + + /** + * Get all enabled payment methods. + * + * @param {string} entityId + * @param {PaymentMethods.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.paymentMethods.get("entity_id") + */ + public async get( + entityId: string, + requestOptions?: PaymentMethods.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/payment_methods` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.OnboardingPaymentMethodsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Set which payment methods should be enabled. + * + * @param {string} entityId + * @param {Monite.entities.EnabledPaymentMethods} request + * @param {PaymentMethods.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.paymentMethods.set("entity_id") + */ + public async set( + entityId: string, + request: Monite.entities.EnabledPaymentMethods = {}, + requestOptions?: PaymentMethods.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/payment_methods` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.OnboardingPaymentMethodsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/entities/resources/paymentMethods/client/index.ts b/src/api/resources/entities/resources/paymentMethods/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/entities/resources/paymentMethods/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/entities/resources/paymentMethods/client/requests/EnabledPaymentMethods.ts b/src/api/resources/entities/resources/paymentMethods/client/requests/EnabledPaymentMethods.ts new file mode 100644 index 0000000..fdfe195 --- /dev/null +++ b/src/api/resources/entities/resources/paymentMethods/client/requests/EnabledPaymentMethods.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface EnabledPaymentMethods { + /** Deprecated. Use payment_methods_receive instead. */ + payment_methods?: Monite.MoniteAllPaymentMethodsTypes[]; + /** Enable payment methods to receive money. */ + payment_methods_receive?: Monite.MoniteAllPaymentMethodsTypes[]; + /** Enable payment methods to send money. */ + payment_methods_send?: Monite.MoniteAllPaymentMethodsTypes[]; +} diff --git a/src/api/resources/entities/resources/paymentMethods/client/requests/index.ts b/src/api/resources/entities/resources/paymentMethods/client/requests/index.ts new file mode 100644 index 0000000..21557a9 --- /dev/null +++ b/src/api/resources/entities/resources/paymentMethods/client/requests/index.ts @@ -0,0 +1 @@ +export { type EnabledPaymentMethods } from "./EnabledPaymentMethods"; diff --git a/src/api/resources/entities/resources/paymentMethods/index.ts b/src/api/resources/entities/resources/paymentMethods/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/entities/resources/paymentMethods/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/entities/resources/persons/client/Client.ts b/src/api/resources/entities/resources/persons/client/Client.ts new file mode 100644 index 0000000..e07c698 --- /dev/null +++ b/src/api/resources/entities/resources/persons/client/Client.ts @@ -0,0 +1,501 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Persons { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Persons { + constructor(protected readonly _options: Persons.Options) {} + + /** + * @param {Persons.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.persons.get() + */ + public async get(requestOptions?: Persons.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "persons" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PersonsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.entities.PersonRequest} request + * @param {Persons.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.persons.create({ + * first_name: "first_name", + * last_name: "last_name", + * email: "email", + * relationship: {} + * }) + */ + public async create( + request: Monite.entities.PersonRequest, + requestOptions?: Persons.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "persons" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PersonResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} personId + * @param {Persons.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.persons.getById("person_id") + */ + public async getById(personId: string, requestOptions?: Persons.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `persons/${encodeURIComponent(personId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PersonResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} personId + * @param {Persons.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.persons.deleteById("person_id") + */ + public async deleteById(personId: string, requestOptions?: Persons.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `persons/${encodeURIComponent(personId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} personId + * @param {Monite.entities.OptionalPersonRequest} request + * @param {Persons.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.persons.updateById("person_id") + */ + public async updateById( + personId: string, + request: Monite.entities.OptionalPersonRequest = {}, + requestOptions?: Persons.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `persons/${encodeURIComponent(personId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PersonResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Provide files for person onboarding verification + * + * @param {string} personId + * @param {Monite.entities.PersonOnboardingDocumentsPayload} request + * @param {Persons.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.persons.uploadOnboardingDocuments("person_id") + */ + public async uploadOnboardingDocuments( + personId: string, + request: Monite.entities.PersonOnboardingDocumentsPayload = {}, + requestOptions?: Persons.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `persons/${encodeURIComponent(personId)}/onboarding_documents` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/entities/resources/persons/client/index.ts b/src/api/resources/entities/resources/persons/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/entities/resources/persons/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/entities/resources/persons/client/requests/OptionalPersonRequest.ts b/src/api/resources/entities/resources/persons/client/requests/OptionalPersonRequest.ts new file mode 100644 index 0000000..a04957e --- /dev/null +++ b/src/api/resources/entities/resources/persons/client/requests/OptionalPersonRequest.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface OptionalPersonRequest { + /** The person's address */ + address?: Monite.OptionalPersonAddressRequest; + /** The person's date of birth */ + date_of_birth?: string; + /** The person's first name */ + first_name?: string; + /** The person's last name */ + last_name?: string; + /** The person's email address */ + email?: string; + /** The person's phone number */ + phone?: string; + /** Describes the person's relationship to the entity */ + relationship?: Monite.OptionalPersonRelationship; + /** The person's ID number, as appropriate for their country */ + id_number?: string; + /** The last four digits of the person's Social Security number */ + ssn_last_4?: string; + /** Required for persons of US entities. The country of the person's citizenship, as a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple citizenship, specify any. */ + citizenship?: Monite.AllowedCountries; +} diff --git a/src/api/resources/entities/resources/persons/client/requests/PersonOnboardingDocumentsPayload.ts b/src/api/resources/entities/resources/persons/client/requests/PersonOnboardingDocumentsPayload.ts new file mode 100644 index 0000000..c80a5a7 --- /dev/null +++ b/src/api/resources/entities/resources/persons/client/requests/PersonOnboardingDocumentsPayload.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface PersonOnboardingDocumentsPayload { + additional_verification_document_back?: string; + additional_verification_document_front?: string; + verification_document_back?: string; + verification_document_front?: string; +} diff --git a/src/api/resources/entities/resources/persons/client/requests/PersonRequest.ts b/src/api/resources/entities/resources/persons/client/requests/PersonRequest.ts new file mode 100644 index 0000000..a42c2ce --- /dev/null +++ b/src/api/resources/entities/resources/persons/client/requests/PersonRequest.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * first_name: "first_name", + * last_name: "last_name", + * email: "email", + * relationship: {} + * } + */ +export interface PersonRequest { + /** The person's address */ + address?: Monite.PersonAddressRequest; + /** The person's date of birth */ + date_of_birth?: string; + /** The person's first name */ + first_name: string; + /** The person's last name */ + last_name: string; + /** The person's email address */ + email: string; + /** The person's phone number */ + phone?: string; + /** Describes the person's relationship to the entity */ + relationship: Monite.PersonRelationshipRequest; + /** The person's ID number, as appropriate for their country */ + id_number?: string; + /** The last four digits of the person's Social Security number */ + ssn_last_4?: string; + /** Required for persons of US entities. The country of the person's citizenship, as a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple citizenship, specify any. */ + citizenship?: Monite.AllowedCountries; +} diff --git a/src/api/resources/entities/resources/persons/client/requests/index.ts b/src/api/resources/entities/resources/persons/client/requests/index.ts new file mode 100644 index 0000000..e4f56a0 --- /dev/null +++ b/src/api/resources/entities/resources/persons/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type PersonRequest } from "./PersonRequest"; +export { type OptionalPersonRequest } from "./OptionalPersonRequest"; +export { type PersonOnboardingDocumentsPayload } from "./PersonOnboardingDocumentsPayload"; diff --git a/src/api/resources/entities/resources/persons/index.ts b/src/api/resources/entities/resources/persons/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/entities/resources/persons/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/entities/resources/vatIds/client/Client.ts b/src/api/resources/entities/resources/vatIds/client/Client.ts new file mode 100644 index 0000000..2dbaaf2 --- /dev/null +++ b/src/api/resources/entities/resources/vatIds/client/Client.ts @@ -0,0 +1,430 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace VatIds { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class VatIds { + constructor(protected readonly _options: VatIds.Options) {} + + /** + * @param {string} entityId + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.vatIds.get("entity_id") + */ + public async get( + entityId: string, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/vat_ids` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityVatIdResourceList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} entityId + * @param {Monite.entities.EntityVatId} request + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.vatIds.create("entity_id", { + * country: "AF", + * value: "123456789" + * }) + */ + public async create( + entityId: string, + request: Monite.entities.EntityVatId, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/vat_ids` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityVatIdResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} id + * @param {string} entityId + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.vatIds.getById("id", "entity_id") + */ + public async getById( + id: string, + entityId: string, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/vat_ids/${encodeURIComponent(id)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityVatIdResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} id + * @param {string} entityId + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.vatIds.deleteById("id", "entity_id") + */ + public async deleteById(id: string, entityId: string, requestOptions?: VatIds.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/vat_ids/${encodeURIComponent(id)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} id + * @param {string} entityId + * @param {Monite.entities.EntityUpdateVatId} request + * @param {VatIds.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entities.vatIds.updateById("id", "entity_id") + */ + public async updateById( + id: string, + entityId: string, + request: Monite.entities.EntityUpdateVatId = {}, + requestOptions?: VatIds.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entities/${encodeURIComponent(entityId)}/vat_ids/${encodeURIComponent(id)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityVatIdResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/entities/resources/vatIds/client/index.ts b/src/api/resources/entities/resources/vatIds/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/entities/resources/vatIds/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/entities/resources/vatIds/client/requests/EntityUpdateVatId.ts b/src/api/resources/entities/resources/vatIds/client/requests/EntityUpdateVatId.ts new file mode 100644 index 0000000..2395e79 --- /dev/null +++ b/src/api/resources/entities/resources/vatIds/client/requests/EntityUpdateVatId.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface EntityUpdateVatId { + country?: Monite.AllowedCountries; + type?: Monite.VatIdTypeEnum; + value?: string; +} diff --git a/src/api/resources/entities/resources/vatIds/client/requests/EntityVatId.ts b/src/api/resources/entities/resources/vatIds/client/requests/EntityVatId.ts new file mode 100644 index 0000000..96b5334 --- /dev/null +++ b/src/api/resources/entities/resources/vatIds/client/requests/EntityVatId.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * country: "AF", + * value: "123456789" + * } + */ +export interface EntityVatId { + country: Monite.AllowedCountries; + type?: Monite.VatIdTypeEnum; + value: string; +} diff --git a/src/api/resources/entities/resources/vatIds/client/requests/index.ts b/src/api/resources/entities/resources/vatIds/client/requests/index.ts new file mode 100644 index 0000000..bde42db --- /dev/null +++ b/src/api/resources/entities/resources/vatIds/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type EntityVatId } from "./EntityVatId"; +export { type EntityUpdateVatId } from "./EntityUpdateVatId"; diff --git a/src/api/resources/entities/resources/vatIds/index.ts b/src/api/resources/entities/resources/vatIds/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/entities/resources/vatIds/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/entityUsers/client/Client.ts b/src/api/resources/entityUsers/client/Client.ts new file mode 100644 index 0000000..0da1ecd --- /dev/null +++ b/src/api/resources/entityUsers/client/Client.ts @@ -0,0 +1,906 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace EntityUsers { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class EntityUsers { + constructor(protected readonly _options: EntityUsers.Options) {} + + /** + * Retrieve a list of all entity users. + * + * @param {Monite.EntityUsersGetRequest} request + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.get() + */ + public async get( + request: Monite.EntityUsersGetRequest = {}, + requestOptions?: EntityUsers.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + id__in: idIn, + id__not_in: idNotIn, + role_id: roleId, + role_id__in: roleIdIn, + login, + status, + first_name: firstName, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (idNotIn != null) { + if (Array.isArray(idNotIn)) { + _queryParams["id__not_in"] = idNotIn.map((item) => item); + } else { + _queryParams["id__not_in"] = idNotIn; + } + } + + if (roleId != null) { + _queryParams["role_id"] = roleId; + } + + if (roleIdIn != null) { + if (Array.isArray(roleIdIn)) { + _queryParams["role_id__in"] = roleIdIn.map((item) => item); + } else { + _queryParams["role_id__in"] = roleIdIn; + } + } + + if (login != null) { + _queryParams["login"] = login; + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (firstName != null) { + _queryParams["first_name"] = firstName; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entity_users" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityUserPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a new entity user from the specified values. + * + * @param {Monite.CreateEntityUserRequest} request + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.create({ + * first_name: "Andrey", + * login: "login" + * }) + */ + public async create( + request: Monite.CreateEntityUserRequest, + requestOptions?: EntityUsers.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entity_users" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityUserResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve an entity user by its ID. + * + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.getCurrent() + */ + public async getCurrent(requestOptions?: EntityUsers.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entity_users/me" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityUserResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Change the specified fields with provided values. + * + * @param {Monite.UpdateMeEntityUserRequest} request + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.updateCurrent() + */ + public async updateCurrent( + request: Monite.UpdateMeEntityUserRequest = {}, + requestOptions?: EntityUsers.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entity_users/me" + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityUserResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieves information of an entity, which this entity user belongs to. + * + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.getCurrentEntity() + */ + public async getCurrentEntity(requestOptions?: EntityUsers.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entity_users/my_entity" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update information of an entity, which this entity user belongs to. + * + * @param {Monite.UpdateEntityRequest} request + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.updateCurrentEntity({}) + */ + public async updateCurrentEntity( + request: Monite.UpdateEntityRequest, + requestOptions?: EntityUsers.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entity_users/my_entity" + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieves information of a role assigned to this entity user. + * + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.getCurrentRole() + */ + public async getCurrentRole(requestOptions?: EntityUsers.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "entity_users/my_role" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.RoleResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve an entity user by its ID. + * + * @param {string} entityUserId + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.getById("entity_user_id") + */ + public async getById( + entityUserId: string, + requestOptions?: EntityUsers.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entity_users/${encodeURIComponent(entityUserId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityUserResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} entityUserId + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.deleteById("entity_user_id") + */ + public async deleteById(entityUserId: string, requestOptions?: EntityUsers.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entity_users/${encodeURIComponent(entityUserId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Change the specified fields with provided values. + * + * @param {string} entityUserId + * @param {Monite.UpdateEntityUserRequest} request + * @param {EntityUsers.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.entityUsers.updateById("entity_user_id") + */ + public async updateById( + entityUserId: string, + request: Monite.UpdateEntityUserRequest = {}, + requestOptions?: EntityUsers.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `entity_users/${encodeURIComponent(entityUserId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EntityUserResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/entityUsers/client/index.ts b/src/api/resources/entityUsers/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/entityUsers/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/entityUsers/client/requests/CreateEntityUserRequest.ts b/src/api/resources/entityUsers/client/requests/CreateEntityUserRequest.ts new file mode 100644 index 0000000..8d12dad --- /dev/null +++ b/src/api/resources/entityUsers/client/requests/CreateEntityUserRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * first_name: "Andrey", + * login: "login" + * } + */ +export interface CreateEntityUserRequest { + /** An entity user business email */ + email?: string; + /** First name */ + first_name: string; + /** Last name */ + last_name?: string; + login: string; + /** An entity user phone number in the international format */ + phone?: string; + /** UUID of the role assigned to this entity user */ + role_id?: string; + /** Title */ + title?: string; +} diff --git a/src/api/resources/entityUsers/client/requests/EntityUsersGetRequest.ts b/src/api/resources/entityUsers/client/requests/EntityUsersGetRequest.ts new file mode 100644 index 0000000..6bcc1be --- /dev/null +++ b/src/api/resources/entityUsers/client/requests/EntityUsersGetRequest.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface EntityUsersGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.EntityUserCursorFields; + id__in?: string | string[]; + id__not_in?: string | string[]; + role_id?: string; + role_id__in?: string | string[]; + login?: string; + status?: string; + first_name?: string; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; +} diff --git a/src/api/resources/entityUsers/client/requests/UpdateEntityUserRequest.ts b/src/api/resources/entityUsers/client/requests/UpdateEntityUserRequest.ts new file mode 100644 index 0000000..9138171 --- /dev/null +++ b/src/api/resources/entityUsers/client/requests/UpdateEntityUserRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface UpdateEntityUserRequest { + /** An entity user business email */ + email?: string; + /** First name */ + first_name?: string; + /** Last name */ + last_name?: string; + /** Login */ + login?: string; + /** An entity user phone number in the international format */ + phone?: string; + /** UUID of the role assigned to this entity user */ + role_id?: string; + /** Title */ + title?: string; +} diff --git a/src/api/resources/entityUsers/client/requests/UpdateMeEntityUserRequest.ts b/src/api/resources/entityUsers/client/requests/UpdateMeEntityUserRequest.ts new file mode 100644 index 0000000..1f5b86b --- /dev/null +++ b/src/api/resources/entityUsers/client/requests/UpdateMeEntityUserRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface UpdateMeEntityUserRequest { + /** An entity user business email */ + email?: string; + /** First name */ + first_name?: string; + /** Last name */ + last_name?: string; + /** An entity user phone number in the international format */ + phone?: string; + /** Title */ + title?: string; +} diff --git a/src/api/resources/entityUsers/client/requests/index.ts b/src/api/resources/entityUsers/client/requests/index.ts new file mode 100644 index 0000000..57e3126 --- /dev/null +++ b/src/api/resources/entityUsers/client/requests/index.ts @@ -0,0 +1,4 @@ +export { type EntityUsersGetRequest } from "./EntityUsersGetRequest"; +export { type CreateEntityUserRequest } from "./CreateEntityUserRequest"; +export { type UpdateMeEntityUserRequest } from "./UpdateMeEntityUserRequest"; +export { type UpdateEntityUserRequest } from "./UpdateEntityUserRequest"; diff --git a/src/api/resources/entityUsers/index.ts b/src/api/resources/entityUsers/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/entityUsers/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/events/client/Client.ts b/src/api/resources/events/client/Client.ts new file mode 100644 index 0000000..a97e0f9 --- /dev/null +++ b/src/api/resources/events/client/Client.ts @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Events { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Events { + constructor(protected readonly _options: Events.Options) {} + + /** + * Get events for a given entity. + * + * @param {Monite.EventsGetRequest} request + * @param {Events.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.events.get() + */ + public async get( + request: Monite.EventsGetRequest = {}, + requestOptions?: Events.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + object_type: objectType, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (objectType != null) { + _queryParams["object_type"] = objectType; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "events" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EventPaginationResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get event by ID. + * + * @param {string} eventId + * @param {Events.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.events.getById("event_id") + */ + public async getById(eventId: string, requestOptions?: Events.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `events/${encodeURIComponent(eventId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.EventResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/events/client/index.ts b/src/api/resources/events/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/events/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/events/client/requests/EventsGetRequest.ts b/src/api/resources/events/client/requests/EventsGetRequest.ts new file mode 100644 index 0000000..35726a7 --- /dev/null +++ b/src/api/resources/events/client/requests/EventsGetRequest.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface EventsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.EventCursorFields; + object_type?: Monite.WebhookObjectType; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; +} diff --git a/src/api/resources/events/client/requests/index.ts b/src/api/resources/events/client/requests/index.ts new file mode 100644 index 0000000..757bafd --- /dev/null +++ b/src/api/resources/events/client/requests/index.ts @@ -0,0 +1 @@ +export { type EventsGetRequest } from "./EventsGetRequest"; diff --git a/src/api/resources/events/index.ts b/src/api/resources/events/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/events/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/files/client/Client.ts b/src/api/resources/files/client/Client.ts new file mode 100644 index 0000000..56cb828 --- /dev/null +++ b/src/api/resources/files/client/Client.ts @@ -0,0 +1,354 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; +import * as fs from "fs"; +import { Blob } from "buffer"; + +export declare namespace Files { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Files { + constructor(protected readonly _options: Files.Options) {} + + /** + * @param {Monite.FilesGetRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.files.get({ + * id__in: "string" + * }) + */ + public async get( + request: Monite.FilesGetRequest = {}, + requestOptions?: Files.RequestOptions + ): Promise { + const { id__in: idIn } = request; + const _queryParams: Record = {}; + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "files" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.FilesResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {File | fs.ReadStream | Blob} file + * @param {Monite.UploadFile} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.files.upload(fs.createReadStream("/path/to/your/file"), { + * file_type: "ocr_results" + * }) + */ + public async upload( + file: File | fs.ReadStream | Blob, + request: Monite.UploadFile, + requestOptions?: Files.RequestOptions + ): Promise { + const _request = await core.newFormData(); + await _request.appendFile("file", file); + await _request.append("file_type", request.file_type); + const _maybeEncodedRequest = await _request.getRequest(); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "files" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ..._maybeEncodedRequest.headers, + }, + requestType: "file", + duplex: _maybeEncodedRequest.duplex, + body: _maybeEncodedRequest.body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.FileResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} fileId + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.files.getById("file_id") + */ + public async getById(fileId: string, requestOptions?: Files.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `files/${encodeURIComponent(fileId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.FileResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} fileId + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.files.delete("file_id") + */ + public async delete(fileId: string, requestOptions?: Files.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `files/${encodeURIComponent(fileId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/files/client/index.ts b/src/api/resources/files/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/files/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/files/client/requests/FilesGetRequest.ts b/src/api/resources/files/client/requests/FilesGetRequest.ts new file mode 100644 index 0000000..766a81c --- /dev/null +++ b/src/api/resources/files/client/requests/FilesGetRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id__in: "string" + * } + */ +export interface FilesGetRequest { + id__in?: string | string[]; +} diff --git a/src/api/resources/files/client/requests/UploadFile.ts b/src/api/resources/files/client/requests/UploadFile.ts new file mode 100644 index 0000000..acef852 --- /dev/null +++ b/src/api/resources/files/client/requests/UploadFile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * file_type: "ocr_results" + * } + */ +export interface UploadFile { + file_type: Monite.AllowedFileTypes; +} diff --git a/src/api/resources/files/client/requests/index.ts b/src/api/resources/files/client/requests/index.ts new file mode 100644 index 0000000..0f18cae --- /dev/null +++ b/src/api/resources/files/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type FilesGetRequest } from "./FilesGetRequest"; +export { type UploadFile } from "./UploadFile"; diff --git a/src/api/resources/files/index.ts b/src/api/resources/files/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/files/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts new file mode 100644 index 0000000..bfb97ff --- /dev/null +++ b/src/api/resources/index.ts @@ -0,0 +1,76 @@ +export * as approvalPolicies from "./approvalPolicies"; +export * from "./approvalPolicies/types"; +export * as receivables from "./receivables"; +export * from "./receivables/types"; +export * as approvalRequests from "./approvalRequests"; +export * as auditLogs from "./auditLogs"; +export * as accessTokens from "./accessTokens"; +export * as batchPayments from "./batchPayments"; +export * as comments from "./comments"; +export * as counterparts from "./counterparts"; +export * as dataExports from "./dataExports"; +export * as pdfTemplates from "./pdfTemplates"; +export * as entities from "./entities"; +export * as entityUsers from "./entityUsers"; +export * as events from "./events"; +export * as files from "./files"; +export * as mailTemplates from "./mailTemplates"; +export * as mailboxDomains from "./mailboxDomains"; +export * as mailboxes from "./mailboxes"; +export * as measureUnits from "./measureUnits"; +export * as onboardingLinks from "./onboardingLinks"; +export * as overdueReminders from "./overdueReminders"; +export * as purchaseOrders from "./purchaseOrders"; +export * as payables from "./payables"; +export * as paymentIntents from "./paymentIntents"; +export * as paymentLinks from "./paymentLinks"; +export * as paymentRecords from "./paymentRecords"; +export * as paymentReminders from "./paymentReminders"; +export * as paymentTerms from "./paymentTerms"; +export * as products from "./products"; +export * as projects from "./projects"; +export * as recurrences from "./recurrences"; +export * as roles from "./roles"; +export * as partnerSettings from "./partnerSettings"; +export * as tags from "./tags"; +export * as textTemplates from "./textTemplates"; +export * as vatRates from "./vatRates"; +export * as webhookDeliveries from "./webhookDeliveries"; +export * as webhookSubscriptions from "./webhookSubscriptions"; +export * as accounting from "./accounting"; +export * from "./approvalPolicies/client/requests"; +export * from "./approvalRequests/client/requests"; +export * from "./auditLogs/client/requests"; +export * from "./accessTokens/client/requests"; +export * from "./batchPayments/client/requests"; +export * from "./comments/client/requests"; +export * from "./counterparts/client/requests"; +export * from "./dataExports/client/requests"; +export * from "./entities/client/requests"; +export * from "./entityUsers/client/requests"; +export * from "./events/client/requests"; +export * from "./files/client/requests"; +export * from "./mailTemplates/client/requests"; +export * from "./mailboxDomains/client/requests"; +export * from "./mailboxes/client/requests"; +export * from "./measureUnits/client/requests"; +export * from "./onboardingLinks/client/requests"; +export * from "./overdueReminders/client/requests"; +export * from "./purchaseOrders/client/requests"; +export * from "./payables/client/requests"; +export * from "./paymentIntents/client/requests"; +export * from "./paymentLinks/client/requests"; +export * from "./paymentRecords/client/requests"; +export * from "./paymentReminders/client/requests"; +export * from "./paymentTerms/client/requests"; +export * from "./products/client/requests"; +export * from "./projects/client/requests"; +export * from "./receivables/client/requests"; +export * from "./recurrences/client/requests"; +export * from "./roles/client/requests"; +export * from "./partnerSettings/client/requests"; +export * from "./tags/client/requests"; +export * from "./textTemplates/client/requests"; +export * from "./vatRates/client/requests"; +export * from "./webhookDeliveries/client/requests"; +export * from "./webhookSubscriptions/client/requests"; diff --git a/src/api/resources/mailTemplates/client/Client.ts b/src/api/resources/mailTemplates/client/Client.ts new file mode 100644 index 0000000..44fcb14 --- /dev/null +++ b/src/api/resources/mailTemplates/client/Client.ts @@ -0,0 +1,719 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace MailTemplates { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class MailTemplates { + constructor(protected readonly _options: MailTemplates.Options) {} + + /** + * Get all custom templates + * + * @param {Monite.MailTemplatesGetRequest} request + * @param {MailTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailTemplates.get() + */ + public async get( + request: Monite.MailTemplatesGetRequest = {}, + requestOptions?: MailTemplates.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + type: type_, + type__in: typeIn, + type__not_in: typeNotIn, + is_default: isDefault, + name, + name__iexact: nameIexact, + name__contains: nameContains, + name__icontains: nameIcontains, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (type_ != null) { + _queryParams["type"] = type_; + } + + if (typeIn != null) { + if (Array.isArray(typeIn)) { + _queryParams["type__in"] = typeIn.map((item) => item); + } else { + _queryParams["type__in"] = typeIn; + } + } + + if (typeNotIn != null) { + if (Array.isArray(typeNotIn)) { + _queryParams["type__not_in"] = typeNotIn.map((item) => item); + } else { + _queryParams["type__not_in"] = typeNotIn; + } + } + + if (isDefault != null) { + _queryParams["is_default"] = isDefault.toString(); + } + + if (name != null) { + _queryParams["name"] = name; + } + + if (nameIexact != null) { + _queryParams["name__iexact"] = nameIexact; + } + + if (nameContains != null) { + _queryParams["name__contains"] = nameContains; + } + + if (nameIcontains != null) { + _queryParams["name__icontains"] = nameIcontains; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mail_templates" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CustomTemplatesPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create custom template + * + * @param {Monite.AddCustomTemplateSchema} request + * @param {MailTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailTemplates.create({ + * body_template: "body_template", + * name: "name", + * subject_template: "subject_template", + * type: "receivables_quote" + * }) + */ + public async create( + request: Monite.AddCustomTemplateSchema, + requestOptions?: MailTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mail_templates" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CustomTemplateDataSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Preview rendered template + * + * @param {Monite.PreviewTemplateRequest} request + * @param {MailTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailTemplates.preview({ + * body: "body", + * document_type: "receivables_quote", + * language_code: "ab", + * subject: "subject" + * }) + */ + public async preview( + request: Monite.PreviewTemplateRequest, + requestOptions?: MailTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mail_templates/preview" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PreviewTemplateResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get all system templates + * + * @param {MailTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailTemplates.getSystem() + */ + public async getSystem(requestOptions?: MailTemplates.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mail_templates/system" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.SystemTemplates; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get custom template by ID + * + * @param {string} templateId + * @param {MailTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailTemplates.getById("template_id") + */ + public async getById( + templateId: string, + requestOptions?: MailTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `mail_templates/${encodeURIComponent(templateId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CustomTemplateDataSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete custom template bt ID + * + * @param {string} templateId + * @param {MailTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailTemplates.deleteById("template_id") + */ + public async deleteById(templateId: string, requestOptions?: MailTemplates.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `mail_templates/${encodeURIComponent(templateId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update custom template by ID + * + * @param {string} templateId + * @param {Monite.UpdateCustomTemplateSchemaRequest} request + * @param {MailTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailTemplates.updateById("template_id") + */ + public async updateById( + templateId: string, + request: Monite.UpdateCustomTemplateSchemaRequest = {}, + requestOptions?: MailTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `mail_templates/${encodeURIComponent(templateId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CustomTemplateDataSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Make template default + * + * @param {string} templateId + * @param {MailTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailTemplates.makeDefaultById("template_id") + */ + public async makeDefaultById( + templateId: string, + requestOptions?: MailTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `mail_templates/${encodeURIComponent(templateId)}/make_default` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.CustomTemplateDataSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/mailTemplates/client/index.ts b/src/api/resources/mailTemplates/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/mailTemplates/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/mailTemplates/client/requests/AddCustomTemplateSchema.ts b/src/api/resources/mailTemplates/client/requests/AddCustomTemplateSchema.ts new file mode 100644 index 0000000..3fa01f5 --- /dev/null +++ b/src/api/resources/mailTemplates/client/requests/AddCustomTemplateSchema.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * body_template: "body_template", + * name: "name", + * subject_template: "subject_template", + * type: "receivables_quote" + * } + */ +export interface AddCustomTemplateSchema { + /** Jinja2 compatible string with email body */ + body_template: string; + /** Is default template */ + is_default?: boolean; + /** Lowercase ISO code of language */ + language?: Monite.LanguageCodeEnum; + /** Custom template name */ + name: string; + /** Jinja2 compatible string with email subject */ + subject_template: string; + /** Document type of content */ + type: Monite.DocumentObjectTypeRequestEnum; +} diff --git a/src/api/resources/mailTemplates/client/requests/MailTemplatesGetRequest.ts b/src/api/resources/mailTemplates/client/requests/MailTemplatesGetRequest.ts new file mode 100644 index 0000000..20c1efc --- /dev/null +++ b/src/api/resources/mailTemplates/client/requests/MailTemplatesGetRequest.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface MailTemplatesGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.CustomTemplatesCursorFields; + type?: Monite.DocumentObjectTypeRequestEnum; + type__in?: Monite.DocumentObjectTypeRequestEnum | Monite.DocumentObjectTypeRequestEnum[]; + type__not_in?: Monite.DocumentObjectTypeRequestEnum | Monite.DocumentObjectTypeRequestEnum[]; + is_default?: boolean; + name?: string; + name__iexact?: string; + name__contains?: string; + name__icontains?: string; +} diff --git a/src/api/resources/mailTemplates/client/requests/PreviewTemplateRequest.ts b/src/api/resources/mailTemplates/client/requests/PreviewTemplateRequest.ts new file mode 100644 index 0000000..17308d5 --- /dev/null +++ b/src/api/resources/mailTemplates/client/requests/PreviewTemplateRequest.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * body: "body", + * document_type: "receivables_quote", + * language_code: "ab", + * subject: "subject" + * } + */ +export interface PreviewTemplateRequest { + /** Body text of the template */ + body: string; + /** Document type of content */ + document_type: Monite.DocumentObjectTypeRequestEnum; + /** Lowercase ISO code of language */ + language_code: Monite.LanguageCodeEnum; + /** Subject text of the template */ + subject: string; +} diff --git a/src/api/resources/mailTemplates/client/requests/UpdateCustomTemplateSchemaRequest.ts b/src/api/resources/mailTemplates/client/requests/UpdateCustomTemplateSchemaRequest.ts new file mode 100644 index 0000000..fcc9742 --- /dev/null +++ b/src/api/resources/mailTemplates/client/requests/UpdateCustomTemplateSchemaRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface UpdateCustomTemplateSchemaRequest { + /** Jinja2 compatible string with email body */ + body_template?: string; + /** Lowercase ISO code of language */ + language?: Monite.LanguageCodeEnum; + /** Custom template name */ + name?: string; + /** Jinja2 compatible string with email subject */ + subject_template?: string; +} diff --git a/src/api/resources/mailTemplates/client/requests/index.ts b/src/api/resources/mailTemplates/client/requests/index.ts new file mode 100644 index 0000000..e1ca7ec --- /dev/null +++ b/src/api/resources/mailTemplates/client/requests/index.ts @@ -0,0 +1,4 @@ +export { type MailTemplatesGetRequest } from "./MailTemplatesGetRequest"; +export { type AddCustomTemplateSchema } from "./AddCustomTemplateSchema"; +export { type PreviewTemplateRequest } from "./PreviewTemplateRequest"; +export { type UpdateCustomTemplateSchemaRequest } from "./UpdateCustomTemplateSchemaRequest"; diff --git a/src/api/resources/mailTemplates/index.ts b/src/api/resources/mailTemplates/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/mailTemplates/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/mailboxDomains/client/Client.ts b/src/api/resources/mailboxDomains/client/Client.ts new file mode 100644 index 0000000..bbb4b02 --- /dev/null +++ b/src/api/resources/mailboxDomains/client/Client.ts @@ -0,0 +1,366 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace MailboxDomains { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class MailboxDomains { + constructor(protected readonly _options: MailboxDomains.Options) {} + + /** + * Get all domains owned by partner_id + * + * @param {MailboxDomains.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailboxDomains.get() + */ + public async get(requestOptions?: MailboxDomains.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mailbox_domains" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.DomainListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create domain for the partner_id + * + * @param {Monite.DomainRequest} request + * @param {MailboxDomains.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailboxDomains.create({ + * domain: "domain" + * }) + */ + public async create( + request: Monite.DomainRequest, + requestOptions?: MailboxDomains.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mailbox_domains" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.DomainResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete domain for the partner_id + * + * @param {string} domainId + * @param {MailboxDomains.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailboxDomains.deleteById("domain_id") + */ + public async deleteById(domainId: string, requestOptions?: MailboxDomains.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `mailbox_domains/${encodeURIComponent(domainId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Verify domain for the partner_id + * + * @param {string} domainId + * @param {MailboxDomains.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailboxDomains.verifyById("domain_id") + */ + public async verifyById( + domainId: string, + requestOptions?: MailboxDomains.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `mailbox_domains/${encodeURIComponent(domainId)}/verify` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.VerifyResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/mailboxDomains/client/index.ts b/src/api/resources/mailboxDomains/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/mailboxDomains/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/mailboxDomains/client/requests/DomainRequest.ts b/src/api/resources/mailboxDomains/client/requests/DomainRequest.ts new file mode 100644 index 0000000..d3ab0ec --- /dev/null +++ b/src/api/resources/mailboxDomains/client/requests/DomainRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * domain: "domain" + * } + */ +export interface DomainRequest { + domain: string; +} diff --git a/src/api/resources/mailboxDomains/client/requests/index.ts b/src/api/resources/mailboxDomains/client/requests/index.ts new file mode 100644 index 0000000..6a6caec --- /dev/null +++ b/src/api/resources/mailboxDomains/client/requests/index.ts @@ -0,0 +1 @@ +export { type DomainRequest } from "./DomainRequest"; diff --git a/src/api/resources/mailboxDomains/index.ts b/src/api/resources/mailboxDomains/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/mailboxDomains/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/mailboxes/client/Client.ts b/src/api/resources/mailboxes/client/Client.ts new file mode 100644 index 0000000..ec31f01 --- /dev/null +++ b/src/api/resources/mailboxes/client/Client.ts @@ -0,0 +1,356 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Mailboxes { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Mailboxes { + constructor(protected readonly _options: Mailboxes.Options) {} + + /** + * Get all mailboxes owned by Entity + * + * @param {Mailboxes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailboxes.get() + */ + public async get(requestOptions?: Mailboxes.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mailboxes" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.MailboxDataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a new mailbox + * + * @param {Monite.MailboxDomainRequest} request + * @param {Mailboxes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailboxes.create({ + * mailbox_domain_id: "mailbox_domain_id", + * mailbox_name: "mailbox_name", + * related_object_type: "payable" + * }) + */ + public async create( + request: Monite.MailboxDomainRequest, + requestOptions?: Mailboxes.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mailboxes" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: { ...request, related_object_type: "payable" }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.MailboxResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get all mailboxes owned by Entity + * + * @param {Monite.MailboxMultipleEntitiesRequest} request + * @param {Mailboxes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailboxes.search({ + * entity_ids: ["entity_ids"] + * }) + */ + public async search( + request: Monite.MailboxMultipleEntitiesRequest, + requestOptions?: Mailboxes.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "mailboxes/search" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.MailboxDataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete mailbox + * + * @param {string} mailboxId + * @param {Mailboxes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.mailboxes.deleteById("mailbox_id") + */ + public async deleteById(mailboxId: string, requestOptions?: Mailboxes.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `mailboxes/${encodeURIComponent(mailboxId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/mailboxes/client/index.ts b/src/api/resources/mailboxes/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/mailboxes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/mailboxes/client/requests/MailboxDomainRequest.ts b/src/api/resources/mailboxes/client/requests/MailboxDomainRequest.ts new file mode 100644 index 0000000..03304fe --- /dev/null +++ b/src/api/resources/mailboxes/client/requests/MailboxDomainRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * mailbox_domain_id: "mailbox_domain_id", + * mailbox_name: "mailbox_name", + * related_object_type: "payable" + * } + */ +export interface MailboxDomainRequest { + mailbox_domain_id: string; + mailbox_name: string; +} diff --git a/src/api/resources/mailboxes/client/requests/MailboxMultipleEntitiesRequest.ts b/src/api/resources/mailboxes/client/requests/MailboxMultipleEntitiesRequest.ts new file mode 100644 index 0000000..b4d503d --- /dev/null +++ b/src/api/resources/mailboxes/client/requests/MailboxMultipleEntitiesRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * entity_ids: ["entity_ids"] + * } + */ +export interface MailboxMultipleEntitiesRequest { + entity_ids: string[]; +} diff --git a/src/api/resources/mailboxes/client/requests/index.ts b/src/api/resources/mailboxes/client/requests/index.ts new file mode 100644 index 0000000..e68e9e3 --- /dev/null +++ b/src/api/resources/mailboxes/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type MailboxDomainRequest } from "./MailboxDomainRequest"; +export { type MailboxMultipleEntitiesRequest } from "./MailboxMultipleEntitiesRequest"; diff --git a/src/api/resources/mailboxes/index.ts b/src/api/resources/mailboxes/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/mailboxes/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/measureUnits/client/Client.ts b/src/api/resources/measureUnits/client/Client.ts new file mode 100644 index 0000000..2a5b414 --- /dev/null +++ b/src/api/resources/measureUnits/client/Client.ts @@ -0,0 +1,457 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace MeasureUnits { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class MeasureUnits { + constructor(protected readonly _options: MeasureUnits.Options) {} + + /** + * @param {MeasureUnits.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.measureUnits.get() + */ + public async get(requestOptions?: MeasureUnits.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "measure_units" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.UnitListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.UnitRequest} request + * @param {MeasureUnits.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.measureUnits.create({ + * name: "name" + * }) + */ + public async create( + request: Monite.UnitRequest, + requestOptions?: MeasureUnits.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "measure_units" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.UnitResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} unitId + * @param {MeasureUnits.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.measureUnits.getById("unit_id") + */ + public async getById(unitId: string, requestOptions?: MeasureUnits.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `measure_units/${encodeURIComponent(unitId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.UnitResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} unitId + * @param {MeasureUnits.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.measureUnits.deleteById("unit_id") + */ + public async deleteById(unitId: string, requestOptions?: MeasureUnits.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `measure_units/${encodeURIComponent(unitId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} unitId + * @param {Monite.UnitUpdate} request + * @param {MeasureUnits.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.measureUnits.updateById("unit_id") + */ + public async updateById( + unitId: string, + request: Monite.UnitUpdate = {}, + requestOptions?: MeasureUnits.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `measure_units/${encodeURIComponent(unitId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.UnitResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/measureUnits/client/index.ts b/src/api/resources/measureUnits/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/measureUnits/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/measureUnits/client/requests/UnitUpdate.ts b/src/api/resources/measureUnits/client/requests/UnitUpdate.ts new file mode 100644 index 0000000..b0b4216 --- /dev/null +++ b/src/api/resources/measureUnits/client/requests/UnitUpdate.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface UnitUpdate { + description?: string; + name?: string; +} diff --git a/src/api/resources/measureUnits/client/requests/index.ts b/src/api/resources/measureUnits/client/requests/index.ts new file mode 100644 index 0000000..0159256 --- /dev/null +++ b/src/api/resources/measureUnits/client/requests/index.ts @@ -0,0 +1 @@ +export { type UnitUpdate } from "./UnitUpdate"; diff --git a/src/api/resources/measureUnits/index.ts b/src/api/resources/measureUnits/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/measureUnits/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/onboardingLinks/client/Client.ts b/src/api/resources/onboardingLinks/client/Client.ts new file mode 100644 index 0000000..9b8d58c --- /dev/null +++ b/src/api/resources/onboardingLinks/client/Client.ts @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace OnboardingLinks { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class OnboardingLinks { + constructor(protected readonly _options: OnboardingLinks.Options) {} + + /** + * @param {Monite.OnboardingLinkRequest} request + * @param {OnboardingLinks.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.onboardingLinks.create({ + * expires_at: "2024-01-15T09:30:00Z", + * refresh_url: "refresh_url", + * return_url: "return_url" + * }) + */ + public async create( + request: Monite.OnboardingLinkRequest, + requestOptions?: OnboardingLinks.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "onboarding_links" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.OnboardingLinkPublicResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/onboardingLinks/client/index.ts b/src/api/resources/onboardingLinks/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/onboardingLinks/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/onboardingLinks/client/requests/OnboardingLinkRequest.ts b/src/api/resources/onboardingLinks/client/requests/OnboardingLinkRequest.ts new file mode 100644 index 0000000..66d5f34 --- /dev/null +++ b/src/api/resources/onboardingLinks/client/requests/OnboardingLinkRequest.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * expires_at: "2024-01-15T09:30:00Z", + * refresh_url: "refresh_url", + * return_url: "return_url" + * } + */ +export interface OnboardingLinkRequest { + expires_at: string; + refresh_url: string; + return_url: string; +} diff --git a/src/api/resources/onboardingLinks/client/requests/index.ts b/src/api/resources/onboardingLinks/client/requests/index.ts new file mode 100644 index 0000000..b3c1a40 --- /dev/null +++ b/src/api/resources/onboardingLinks/client/requests/index.ts @@ -0,0 +1 @@ +export { type OnboardingLinkRequest } from "./OnboardingLinkRequest"; diff --git a/src/api/resources/onboardingLinks/index.ts b/src/api/resources/onboardingLinks/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/onboardingLinks/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/overdueReminders/client/Client.ts b/src/api/resources/overdueReminders/client/Client.ts new file mode 100644 index 0000000..67ce69e --- /dev/null +++ b/src/api/resources/overdueReminders/client/Client.ts @@ -0,0 +1,457 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace OverdueReminders { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class OverdueReminders { + constructor(protected readonly _options: OverdueReminders.Options) {} + + /** + * @param {OverdueReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.overdueReminders.get() + */ + public async get(requestOptions?: OverdueReminders.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "overdue_reminders" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.AllOverdueRemindersResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.OverdueReminderRequest} request + * @param {OverdueReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.overdueReminders.create({ + * name: "name" + * }) + */ + public async create( + request: Monite.OverdueReminderRequest, + requestOptions?: OverdueReminders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "overdue_reminders" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.OverdueReminderResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} overdueReminderId + * @param {OverdueReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.overdueReminders.getById("overdue_reminder_id") + */ + public async getById( + overdueReminderId: string, + requestOptions?: OverdueReminders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `overdue_reminders/${encodeURIComponent(overdueReminderId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.OverdueReminderResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} overdueReminderId + * @param {OverdueReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.overdueReminders.deleteById("overdue_reminder_id") + */ + public async deleteById( + overdueReminderId: string, + requestOptions?: OverdueReminders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `overdue_reminders/${encodeURIComponent(overdueReminderId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} overdueReminderId + * @param {Monite.OverdueReminderUpdateRequest} request + * @param {OverdueReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.overdueReminders.updateById("overdue_reminder_id") + */ + public async updateById( + overdueReminderId: string, + request: Monite.OverdueReminderUpdateRequest = {}, + requestOptions?: OverdueReminders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `overdue_reminders/${encodeURIComponent(overdueReminderId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.OverdueReminderResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/overdueReminders/client/index.ts b/src/api/resources/overdueReminders/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/overdueReminders/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/overdueReminders/client/requests/OverdueReminderRequest.ts b/src/api/resources/overdueReminders/client/requests/OverdueReminderRequest.ts new file mode 100644 index 0000000..9089364 --- /dev/null +++ b/src/api/resources/overdueReminders/client/requests/OverdueReminderRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * name: "name" + * } + */ +export interface OverdueReminderRequest { + name: string; + recipients?: Monite.Recipients; + /** Overdue reminder terms to send for payment */ + terms?: Monite.OverdueReminderTerm[]; +} diff --git a/src/api/resources/overdueReminders/client/requests/OverdueReminderUpdateRequest.ts b/src/api/resources/overdueReminders/client/requests/OverdueReminderUpdateRequest.ts new file mode 100644 index 0000000..e3f9577 --- /dev/null +++ b/src/api/resources/overdueReminders/client/requests/OverdueReminderUpdateRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface OverdueReminderUpdateRequest { + name?: string; + recipients?: Monite.Recipients; + /** Overdue reminder terms to send for payment */ + terms?: Monite.OverdueReminderTerm[]; +} diff --git a/src/api/resources/overdueReminders/client/requests/index.ts b/src/api/resources/overdueReminders/client/requests/index.ts new file mode 100644 index 0000000..7f92a07 --- /dev/null +++ b/src/api/resources/overdueReminders/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type OverdueReminderRequest } from "./OverdueReminderRequest"; +export { type OverdueReminderUpdateRequest } from "./OverdueReminderUpdateRequest"; diff --git a/src/api/resources/overdueReminders/index.ts b/src/api/resources/overdueReminders/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/overdueReminders/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/partnerSettings/client/Client.ts b/src/api/resources/partnerSettings/client/Client.ts new file mode 100644 index 0000000..26bfe4d --- /dev/null +++ b/src/api/resources/partnerSettings/client/Client.ts @@ -0,0 +1,198 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace PartnerSettings { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PartnerSettings { + constructor(protected readonly _options: PartnerSettings.Options) {} + + /** + * Retrieve all settings for this partner. + * + * @param {PartnerSettings.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.partnerSettings.get() + */ + public async get(requestOptions?: PartnerSettings.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "settings" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PartnerProjectSettingsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Change the specified fields with the provided values. + * + * @param {Monite.PartnerProjectSettingsPayload} request + * @param {PartnerSettings.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.partnerSettings.update() + */ + public async update( + request: Monite.PartnerProjectSettingsPayload = {}, + requestOptions?: PartnerSettings.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "settings" + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PartnerProjectSettingsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/partnerSettings/client/index.ts b/src/api/resources/partnerSettings/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/partnerSettings/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/partnerSettings/client/requests/PartnerProjectSettingsPayload.ts b/src/api/resources/partnerSettings/client/requests/PartnerProjectSettingsPayload.ts new file mode 100644 index 0000000..43f82ec --- /dev/null +++ b/src/api/resources/partnerSettings/client/requests/PartnerProjectSettingsPayload.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PartnerProjectSettingsPayload { + /** Settings for the accounting module. */ + accounting?: Monite.AccountingSettingsPayload; + /** Default API version for partner. */ + api_version?: Monite.ApiVersion; + /** Commercial conditions for receivables. */ + commercial_conditions?: string[]; + /** Custom currency exchange rates. */ + currency?: Monite.CurrencySettings; + /** A default role to provision upon new entity creation. */ + default_role?: Record; + /** Settings for the e-invoicing module. */ + einvoicing?: Monite.EInvoicingSettingsPayload; + /** Settings for email and mailboxes. */ + mail?: Monite.MailSettingsPayload; + /** Settings for the payables module. */ + payable?: Monite.PayableSettingsPayload; + /** Settings for the payments module. */ + payments?: Monite.PaymentsSettingsPayload; + /** Settings for the receivables module. */ + receivable?: Monite.ReceivableSettingsPayload; + /** Measurement units. */ + units?: Monite.Unit[]; + website?: string; +} diff --git a/src/api/resources/partnerSettings/client/requests/index.ts b/src/api/resources/partnerSettings/client/requests/index.ts new file mode 100644 index 0000000..182e883 --- /dev/null +++ b/src/api/resources/partnerSettings/client/requests/index.ts @@ -0,0 +1 @@ +export { type PartnerProjectSettingsPayload } from "./PartnerProjectSettingsPayload"; diff --git a/src/api/resources/partnerSettings/index.ts b/src/api/resources/partnerSettings/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/partnerSettings/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/payables/client/Client.ts b/src/api/resources/payables/client/Client.ts new file mode 100644 index 0000000..e690559 --- /dev/null +++ b/src/api/resources/payables/client/Client.ts @@ -0,0 +1,2298 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; +import * as fs from "fs"; +import { Blob } from "buffer"; +import { LineItems } from "../resources/lineItems/client/Client"; + +export declare namespace Payables { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Payables { + constructor(protected readonly _options: Payables.Options) {} + + /** + * Lists all payables from the connected entity. + * + * If you already have the data of the payable (amount in [minor units](https://docs.monite.com/docs/currencies#minor-units), currency, vendor information, and other details) + * stored somewhere as individual attributes, you can create a payable with these attributes by calling [POST + * /payables](https://docs.monite.com/reference/post_payables) and providing the [base64-encoded](https://en.wikipedia.org/wiki/Base64) contents of the original invoice file in the field `base64_encoded_file`. + * + * A payable is a financial document given by an entity`s supplier itemizing the purchase of a good or a service and + * demanding payment. + * + * The `file_name` field is optional. If omitted, it defaults to “default_file_name”. If the settings are configured + * to automatically set `suggested_payment_term`, this object can be omitted from the request body. + * + * The `id` generated for this payable can be used in other API calls to update the data of this payable or trigger [ + * status transitions](https://docs.monite.com/docs/payable-status-transitions), for example. essential data + * fields to move from `draft` to `new` + * + * Related guide: [Create a payable from data](https://docs.monite.com/docs/collect-payables#create-a-payable-from-data) + * + * See also: + * + * [Automatic calculation of due date](https://docs.monite.com/docs/collect-payables#automatic-calculation-of-due-date) + * + * [Suggested payment date](https://docs.monite.com/docs/collect-payables#suggested-payment-date) + * + * [Attach file](https://docs.monite.com/docs/collect-payables#attach-file) + * + * [Collect payables by email](https://docs.monite.com/docs/collect-payables#send-payables-by-email) + * + * [Manage line items](https://docs.monite.com/docs/manage-line-items) + * + * @param {Monite.PayablesGetRequest} request + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.get() + */ + public async get( + request: Monite.PayablesGetRequest = {}, + requestOptions?: Payables.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + status, + status__in: statusIn, + id__in: idIn, + total_amount: totalAmount, + total_amount__gt: totalAmountGt, + total_amount__lt: totalAmountLt, + total_amount__gte: totalAmountGte, + total_amount__lte: totalAmountLte, + amount, + amount__gt: amountGt, + amount__lt: amountLt, + amount__gte: amountGte, + amount__lte: amountLte, + currency, + counterpart_name: counterpartName, + counterpart_name__contains: counterpartNameContains, + counterpart_name__icontains: counterpartNameIcontains, + search_text: searchText, + due_date: dueDate, + due_date__gt: dueDateGt, + due_date__lt: dueDateLt, + due_date__gte: dueDateGte, + due_date__lte: dueDateLte, + document_id: documentId, + document_id__contains: documentIdContains, + document_id__icontains: documentIdIcontains, + was_created_by_user_id: wasCreatedByUserId, + counterpart_id: counterpartId, + source_of_payable_data: sourceOfPayableData, + ocr_status: ocrStatus, + line_item_id: lineItemId, + purchase_order_id: purchaseOrderId, + project_id: projectId, + tag_ids: tagIds, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (statusIn != null) { + if (Array.isArray(statusIn)) { + _queryParams["status__in"] = statusIn.map((item) => item); + } else { + _queryParams["status__in"] = statusIn; + } + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (totalAmount != null) { + _queryParams["total_amount"] = totalAmount.toString(); + } + + if (totalAmountGt != null) { + _queryParams["total_amount__gt"] = totalAmountGt.toString(); + } + + if (totalAmountLt != null) { + _queryParams["total_amount__lt"] = totalAmountLt.toString(); + } + + if (totalAmountGte != null) { + _queryParams["total_amount__gte"] = totalAmountGte.toString(); + } + + if (totalAmountLte != null) { + _queryParams["total_amount__lte"] = totalAmountLte.toString(); + } + + if (amount != null) { + _queryParams["amount"] = amount.toString(); + } + + if (amountGt != null) { + _queryParams["amount__gt"] = amountGt.toString(); + } + + if (amountLt != null) { + _queryParams["amount__lt"] = amountLt.toString(); + } + + if (amountGte != null) { + _queryParams["amount__gte"] = amountGte.toString(); + } + + if (amountLte != null) { + _queryParams["amount__lte"] = amountLte.toString(); + } + + if (currency != null) { + _queryParams["currency"] = currency; + } + + if (counterpartName != null) { + _queryParams["counterpart_name"] = counterpartName; + } + + if (counterpartNameContains != null) { + _queryParams["counterpart_name__contains"] = counterpartNameContains; + } + + if (counterpartNameIcontains != null) { + _queryParams["counterpart_name__icontains"] = counterpartNameIcontains; + } + + if (searchText != null) { + _queryParams["search_text"] = searchText; + } + + if (dueDate != null) { + _queryParams["due_date"] = dueDate; + } + + if (dueDateGt != null) { + _queryParams["due_date__gt"] = dueDateGt; + } + + if (dueDateLt != null) { + _queryParams["due_date__lt"] = dueDateLt; + } + + if (dueDateGte != null) { + _queryParams["due_date__gte"] = dueDateGte; + } + + if (dueDateLte != null) { + _queryParams["due_date__lte"] = dueDateLte; + } + + if (documentId != null) { + _queryParams["document_id"] = documentId; + } + + if (documentIdContains != null) { + _queryParams["document_id__contains"] = documentIdContains; + } + + if (documentIdIcontains != null) { + _queryParams["document_id__icontains"] = documentIdIcontains; + } + + if (wasCreatedByUserId != null) { + _queryParams["was_created_by_user_id"] = wasCreatedByUserId; + } + + if (counterpartId != null) { + _queryParams["counterpart_id"] = counterpartId; + } + + if (sourceOfPayableData != null) { + _queryParams["source_of_payable_data"] = sourceOfPayableData; + } + + if (ocrStatus != null) { + _queryParams["ocr_status"] = ocrStatus; + } + + if (lineItemId != null) { + _queryParams["line_item_id"] = lineItemId; + } + + if (purchaseOrderId != null) { + _queryParams["purchase_order_id"] = purchaseOrderId; + } + + if (projectId != null) { + _queryParams["project_id"] = projectId; + } + + if (tagIds != null) { + if (Array.isArray(tagIds)) { + _queryParams["tag_ids"] = tagIds.map((item) => item); + } else { + _queryParams["tag_ids"] = tagIds; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payables" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayablePaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Add a new payable by providing the amount, currency, vendor name, and other details. + * You can provide the base64_encoded contents of the original invoice file in the field `base64_encoded_file`. + * + * You can use this endpoint to bypass the Monite OCR service and provide the data directly + * (for example, if you already have the data in place). + * + * A newly created payable has the the `draft` [status](https://docs.monite.com/docs/payables-lifecycle). + * + * @param {Monite.PayableUploadWithDataSchema} request + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.create() + */ + public async create( + request: Monite.PayableUploadWithDataSchema = {}, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payables" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve aggregated statistics for payables, including total amount and count, both overall and by status. + * + * @param {Monite.PayablesGetAnalyticsRequest} request + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.getAnalytics() + */ + public async getAnalytics( + request: Monite.PayablesGetAnalyticsRequest = {}, + requestOptions?: Payables.RequestOptions + ): Promise { + const { + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + status, + status__in: statusIn, + id__in: idIn, + total_amount: totalAmount, + total_amount__gt: totalAmountGt, + total_amount__lt: totalAmountLt, + total_amount__gte: totalAmountGte, + total_amount__lte: totalAmountLte, + amount, + amount__gt: amountGt, + amount__lt: amountLt, + amount__gte: amountGte, + amount__lte: amountLte, + currency, + counterpart_name: counterpartName, + counterpart_name__contains: counterpartNameContains, + counterpart_name__icontains: counterpartNameIcontains, + search_text: searchText, + due_date: dueDate, + due_date__gt: dueDateGt, + due_date__lt: dueDateLt, + due_date__gte: dueDateGte, + due_date__lte: dueDateLte, + document_id: documentId, + document_id__contains: documentIdContains, + document_id__icontains: documentIdIcontains, + was_created_by_user_id: wasCreatedByUserId, + counterpart_id: counterpartId, + source_of_payable_data: sourceOfPayableData, + ocr_status: ocrStatus, + line_item_id: lineItemId, + purchase_order_id: purchaseOrderId, + project_id: projectId, + tag_ids: tagIds, + } = request; + const _queryParams: Record = {}; + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (statusIn != null) { + if (Array.isArray(statusIn)) { + _queryParams["status__in"] = statusIn.map((item) => item); + } else { + _queryParams["status__in"] = statusIn; + } + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (totalAmount != null) { + _queryParams["total_amount"] = totalAmount.toString(); + } + + if (totalAmountGt != null) { + _queryParams["total_amount__gt"] = totalAmountGt.toString(); + } + + if (totalAmountLt != null) { + _queryParams["total_amount__lt"] = totalAmountLt.toString(); + } + + if (totalAmountGte != null) { + _queryParams["total_amount__gte"] = totalAmountGte.toString(); + } + + if (totalAmountLte != null) { + _queryParams["total_amount__lte"] = totalAmountLte.toString(); + } + + if (amount != null) { + _queryParams["amount"] = amount.toString(); + } + + if (amountGt != null) { + _queryParams["amount__gt"] = amountGt.toString(); + } + + if (amountLt != null) { + _queryParams["amount__lt"] = amountLt.toString(); + } + + if (amountGte != null) { + _queryParams["amount__gte"] = amountGte.toString(); + } + + if (amountLte != null) { + _queryParams["amount__lte"] = amountLte.toString(); + } + + if (currency != null) { + _queryParams["currency"] = currency; + } + + if (counterpartName != null) { + _queryParams["counterpart_name"] = counterpartName; + } + + if (counterpartNameContains != null) { + _queryParams["counterpart_name__contains"] = counterpartNameContains; + } + + if (counterpartNameIcontains != null) { + _queryParams["counterpart_name__icontains"] = counterpartNameIcontains; + } + + if (searchText != null) { + _queryParams["search_text"] = searchText; + } + + if (dueDate != null) { + _queryParams["due_date"] = dueDate; + } + + if (dueDateGt != null) { + _queryParams["due_date__gt"] = dueDateGt; + } + + if (dueDateLt != null) { + _queryParams["due_date__lt"] = dueDateLt; + } + + if (dueDateGte != null) { + _queryParams["due_date__gte"] = dueDateGte; + } + + if (dueDateLte != null) { + _queryParams["due_date__lte"] = dueDateLte; + } + + if (documentId != null) { + _queryParams["document_id"] = documentId; + } + + if (documentIdContains != null) { + _queryParams["document_id__contains"] = documentIdContains; + } + + if (documentIdIcontains != null) { + _queryParams["document_id__icontains"] = documentIdIcontains; + } + + if (wasCreatedByUserId != null) { + _queryParams["was_created_by_user_id"] = wasCreatedByUserId; + } + + if (counterpartId != null) { + _queryParams["counterpart_id"] = counterpartId; + } + + if (sourceOfPayableData != null) { + _queryParams["source_of_payable_data"] = sourceOfPayableData; + } + + if (ocrStatus != null) { + _queryParams["ocr_status"] = ocrStatus; + } + + if (lineItemId != null) { + _queryParams["line_item_id"] = lineItemId; + } + + if (purchaseOrderId != null) { + _queryParams["purchase_order_id"] = purchaseOrderId; + } + + if (projectId != null) { + _queryParams["project_id"] = projectId; + } + + if (tagIds != null) { + if (Array.isArray(tagIds)) { + _queryParams["tag_ids"] = tagIds.map((item) => item); + } else { + _queryParams["tag_ids"] = tagIds; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payables/analytics" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableAggregatedDataResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Upload an incoming invoice (payable) in PDF, PNG, JPEG, or TIFF format and scan its contents. The maximum file size is 10MB. + * + * @param {File | fs.ReadStream | Blob} file + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.uploadFromFile(fs.createReadStream("/path/to/your/file")) + */ + public async uploadFromFile( + file: File | fs.ReadStream | Blob, + requestOptions?: Payables.RequestOptions + ): Promise { + const _request = await core.newFormData(); + await _request.appendFile("file", file); + const _maybeEncodedRequest = await _request.getRequest(); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payables/upload_from_file" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ..._maybeEncodedRequest.headers, + }, + requestType: "file", + duplex: _maybeEncodedRequest.duplex, + body: _maybeEncodedRequest.body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get payable validations. + * + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.getValidations() + */ + public async getValidations(requestOptions?: Payables.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payables/validations" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableValidationsResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update payable validations. + * + * @param {Monite.PayableValidationsUpdateRequest} request + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.updateValidations({ + * required_fields: ["currency"] + * }) + */ + public async updateValidations( + request: Monite.PayableValidationsUpdateRequest, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payables/validations" + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableValidationsResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Reset payable validations to default ones. + * + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.resetValidations() + */ + public async resetValidations( + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payables/validations/reset" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableValidationsResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get a list of placeholders allowed to insert into an email template for customization + * + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.getVariables() + */ + public async getVariables( + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payables/variables" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableTemplatesVariablesObjectList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieves information about a specific payable with the given ID. + * + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.getById("payable_id") + */ + public async getById( + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Deletes a specific payable. + * + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.deleteById("payable_id") + */ + public async deleteById(payableId: string, requestOptions?: Payables.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Updates the information about a specific payable. + * + * @param {string} payableId + * @param {Monite.PayableUpdateSchema} request + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.updateById("payable_id") + */ + public async updateById( + payableId: string, + request: Monite.PayableUpdateSchema = {}, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Confirms that the payable is ready to be paid. + * + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.approvePaymentById("payable_id") + */ + public async approvePaymentById( + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/approve_payment_operation` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Attach file to payable without existing attachment. + * + * @param {File | fs.ReadStream | Blob} file + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.attachFileById(fs.createReadStream("/path/to/your/file"), "payable_id") + */ + public async attachFileById( + file: File | fs.ReadStream | Blob, + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _request = await core.newFormData(); + await _request.appendFile("file", file); + const _maybeEncodedRequest = await _request.getRequest(); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/attach_file` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ..._maybeEncodedRequest.headers, + }, + requestType: "file", + duplex: _maybeEncodedRequest.duplex, + body: _maybeEncodedRequest.body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Cancels the payable that was not confirmed during the review. + * + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.cancelById("payable_id") + */ + public async cancelById( + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/cancel` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Mark a payable as paid. + * + * Payables can be paid using the payment channels offered by Monite or through external payment channels. In the latter + * case, the invoice is not automatically marked as paid in the system and needs to be converted to the paid status + * manually. + * + * Optionally, it is possible to pass the `comment` field in the request body, to describe how and when the invoice was + * paid. + * + * Notes: + * + * - To use this endpoint with an entity user token, this entity user must have a role that includes the `pay` permission + * for payables. + * - The `amount_to_pay` field is automatically calculated based on the `amount_due` less the percentage described + * in the `payment_terms.discount` value. + * + * Related guide: [Mark a payable as paid](https://docs.monite.com/docs/payable-status-transitions#mark-as-paid) + * + * See also: + * + * [Payables lifecycle](https://docs.monite.com/docs/payables-lifecycle) + * + * [Payables status transitions](https://docs.monite.com/docs/collect-payables#suggested-payment-date) + * + * @param {string} payableId + * @param {Monite.CommentPayload} request + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.markAsPaidById("payable_id") + */ + public async markAsPaidById( + payableId: string, + request: Monite.CommentPayload = {}, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/mark_as_paid` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Mark a payable as partially paid. + * + * If the payable is partially paid, its status is moved to `partially_paid`. The value of the `amount_paid` field must be + * the sum of all payments made, not only the last one. + * + * Notes: + * + * - This endpoint can be used for payables in the `waiting_to_be_paid` status. + * - The `amount_paid` must be greater than 0 and less than the total payable amount specified by the `amount` field. + * - You can use this endpoint multiple times for the same payable to reflect multiple partial payments, always setting the + * sum of all payments made. + * - To use this endpoint with an entity user token, this entity user must have a role that includes the `pay` + * permission for payables. + * - The `amount_to_pay` field is automatically calculated based on the `amount_due` less the percentage described + * in the `payment_terms.discount` value. + * + * Related guide: [Mark a payable as partially paid](https://docs.monite.com/docs/payable-status-transitions#mark-as-partially-paid) + * + * See also: + * + * [Payables lifecycle](https://docs.monite.com/docs/payables-lifecycle) + * + * [Payables status transitions](https://docs.monite.com/docs/collect-payables#suggested-payment-date) + * + * [Mark a payable as paid](https://docs.monite.com/docs/payable-status-transitions#mark-as-paid) + * + * @param {string} payableId + * @param {Monite.PartiallyPaidPayload} request + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.markAsPartiallyPaidById("payable_id", { + * amount_paid: 1 + * }) + */ + public async markAsPartiallyPaidById( + payableId: string, + request: Monite.PartiallyPaidPayload, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/mark_as_partially_paid` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Declines the payable when an approver finds any mismatch or discrepancies. + * + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.rejectById("payable_id") + */ + public async rejectById( + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/reject` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Reset payable state from rejected to new. + * + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.reopenById("payable_id") + */ + public async reopenById( + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/reopen` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Starts the approval process once the uploaded payable is validated. + * + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.submitForApprovalById("payable_id") + */ + public async submitForApprovalById( + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/submit_for_approval` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Check the invoice for compliance with the requirements for movement from draft to new status. + * + * @param {string} payableId + * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.validateById("payable_id") + */ + public async validateById( + payableId: string, + requestOptions?: Payables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/validate` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PayableValidationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected _lineItems: LineItems | undefined; + + public get lineItems(): LineItems { + return (this._lineItems ??= new LineItems(this._options)); + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/payables/client/index.ts b/src/api/resources/payables/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/payables/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/payables/client/requests/CommentPayload.ts b/src/api/resources/payables/client/requests/CommentPayload.ts new file mode 100644 index 0000000..778e693 --- /dev/null +++ b/src/api/resources/payables/client/requests/CommentPayload.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface CommentPayload { + /** An arbitrary comment that describes how and when this payable was paid. */ + comment?: string; +} diff --git a/src/api/resources/payables/client/requests/PartiallyPaidPayload.ts b/src/api/resources/payables/client/requests/PartiallyPaidPayload.ts new file mode 100644 index 0000000..bb4d1e8 --- /dev/null +++ b/src/api/resources/payables/client/requests/PartiallyPaidPayload.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * amount_paid: 1 + * } + */ +export interface PartiallyPaidPayload { + /** How much was paid on the invoice (in minor units). */ + amount_paid: number; +} diff --git a/src/api/resources/payables/client/requests/PayableAttachFile.ts b/src/api/resources/payables/client/requests/PayableAttachFile.ts new file mode 100644 index 0000000..468109b --- /dev/null +++ b/src/api/resources/payables/client/requests/PayableAttachFile.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface PayableAttachFile {} diff --git a/src/api/resources/payables/client/requests/PayableUpdateSchema.ts b/src/api/resources/payables/client/requests/PayableUpdateSchema.ts new file mode 100644 index 0000000..3833c43 --- /dev/null +++ b/src/api/resources/payables/client/requests/PayableUpdateSchema.ts @@ -0,0 +1,54 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PayableUpdateSchema { + /** The ID of counterpart address object stored in counterparts service */ + counterpart_address_id?: string; + /** The ID of counterpart bank account object stored in counterparts service */ + counterpart_bank_account_id?: string; + /** The ID of the counterpart object that represents the vendor or supplier. */ + counterpart_id?: string; + /** Allows to fix some data in counterpart recognised fields to correct them in order to make autolinking happen. */ + counterpart_raw_data?: Monite.CounterpartRawDataUpdateRequest; + /** The ID of counterpart VAT ID object stored in counterparts service */ + counterpart_vat_id_id?: string; + /** The [currency code](https://docs.monite.com/docs/currencies) of the currency used in the payable. */ + currency?: Monite.CurrencyEnum; + /** An arbitrary description of this payable. */ + description?: string; + /** A unique invoice number assigned by the invoice issuer for payment tracking purposes. */ + document_id?: string; + /** The date by which the payable must be paid, in the YYYY-MM-DD format. If the payable specifies payment terms with early payment discounts, this is the final payment date. */ + due_date?: string; + /** The date when the payable was issued, in the YYYY-MM-DD format. */ + issued_at?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** The number of days to pay with potential discount for options shorter than due_date */ + payment_terms?: Monite.PayablePaymentTermsCreatePayload; + /** The project ID of the payable. */ + project_id?: string; + /** The identifier of the purchase order to which this payable belongs. */ + purchase_order_id?: string; + /** The email address from which the invoice was sent to the entity. */ + sender?: string; + /** The subtotal amount to be paid, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + subtotal?: number; + /** The suggested date and corresponding discount in which payable could be paid. The date is in the YYYY-MM-DD format. The discount is calculated as X * (10^-4) - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on the payment terms and may even be equal to the due date with discount 0. */ + suggested_payment_term?: Monite.SuggestedPaymentTerm; + /** A list of IDs of user-defined tags (labels) assigned to this payable. Tags can be used to trigger a specific approval policy for this payable. */ + tag_ids?: string[]; + /** Registered tax percentage applied for a service price in minor units, e.g. 200 means 2%, 1050 means 10.5%. */ + tax?: number; + /** Tax amount in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + tax_amount?: number; + /** The total amount to be paid, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + total_amount?: number; +} diff --git a/src/api/resources/payables/client/requests/PayableUploadFile.ts b/src/api/resources/payables/client/requests/PayableUploadFile.ts new file mode 100644 index 0000000..562ec39 --- /dev/null +++ b/src/api/resources/payables/client/requests/PayableUploadFile.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface PayableUploadFile {} diff --git a/src/api/resources/payables/client/requests/PayableUploadWithDataSchema.ts b/src/api/resources/payables/client/requests/PayableUploadWithDataSchema.ts new file mode 100644 index 0000000..f099fb5 --- /dev/null +++ b/src/api/resources/payables/client/requests/PayableUploadWithDataSchema.ts @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PayableUploadWithDataSchema { + /** + * Base64-encoded contents of the original issued payable. The file is provided for reference purposes as the original source of the data. + * + * Any file formats are allowed. The most common formats are PDF, PNG, JPEG, TIFF. + */ + base64_encoded_file?: string; + /** The ID of counterpart address object stored in counterparts service */ + counterpart_address_id?: string; + /** The ID of counterpart bank account object stored in counterparts service */ + counterpart_bank_account_id?: string; + /** The ID of the counterpart object that represents the vendor or supplier. */ + counterpart_id?: string; + /** The ID of counterpart VAT ID object stored in counterparts service */ + counterpart_vat_id_id?: string; + /** The [currency code](https://docs.monite.com/docs/currencies) of the currency used in the payable. */ + currency?: Monite.CurrencyEnum; + /** An arbitrary description of this payable. */ + description?: string; + /** A unique invoice number assigned by the invoice issuer for payment tracking purposes. */ + document_id?: string; + /** The date by which the payable must be paid, in the YYYY-MM-DD format. If the payable specifies payment terms with early payment discounts, this is the final payment date. */ + due_date?: string; + /** The original file name. */ + file_name?: string; + /** The date when the payable was issued, in the YYYY-MM-DD format. */ + issued_at?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** The number of days to pay with potential discount for options shorter than due_date */ + payment_terms?: Monite.PayablePaymentTermsCreatePayload; + /** The ID of a project */ + project_id?: string; + /** The identifier of the purchase order to which this payable belongs. */ + purchase_order_id?: string; + /** The email address from which the invoice was sent to the entity. */ + sender?: string; + /** The subtotal amount to be paid, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + subtotal?: number; + /** The suggested date and corresponding discount in which payable could be paid. The date is in the YYYY-MM-DD format. The discount is calculated as X * (10^-4) - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on the payment terms and may even be equal to the due date with discount 0. */ + suggested_payment_term?: Monite.SuggestedPaymentTerm; + /** A list of IDs of user-defined tags (labels) assigned to this payable. Tags can be used to trigger a specific approval policy for this payable. */ + tag_ids?: string[]; + /** Registered tax percentage applied for a service price in minor units, e.g. 200 means 2%. 1050 means 10.5%. */ + tax?: number; + /** Tax amount in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + tax_amount?: number; + /** The total amount to be paid, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + total_amount?: number; +} diff --git a/src/api/resources/payables/client/requests/PayableValidationsUpdateRequest.ts b/src/api/resources/payables/client/requests/PayableValidationsUpdateRequest.ts new file mode 100644 index 0000000..aa0c600 --- /dev/null +++ b/src/api/resources/payables/client/requests/PayableValidationsUpdateRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * required_fields: ["currency"] + * } + */ +export interface PayableValidationsUpdateRequest { + required_fields: Monite.PayablesFieldsAllowedForValidate[]; +} diff --git a/src/api/resources/payables/client/requests/PayablesGetAnalyticsRequest.ts b/src/api/resources/payables/client/requests/PayablesGetAnalyticsRequest.ts new file mode 100644 index 0000000..650b4a5 --- /dev/null +++ b/src/api/resources/payables/client/requests/PayablesGetAnalyticsRequest.ts @@ -0,0 +1,62 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PayablesGetAnalyticsRequest { + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + status?: Monite.PayableStateEnum; + status__in?: Monite.PayableStateEnum | Monite.PayableStateEnum[]; + id__in?: string | string[]; + total_amount?: number; + total_amount__gt?: number; + total_amount__lt?: number; + total_amount__gte?: number; + total_amount__lte?: number; + amount?: number; + amount__gt?: number; + amount__lt?: number; + amount__gte?: number; + amount__lte?: number; + currency?: Monite.CurrencyEnum; + counterpart_name?: string; + counterpart_name__contains?: string; + counterpart_name__icontains?: string; + search_text?: string; + due_date?: string; + due_date__gt?: string; + due_date__lt?: string; + due_date__gte?: string; + due_date__lte?: string; + document_id?: string; + document_id__contains?: string; + document_id__icontains?: string; + was_created_by_user_id?: string; + counterpart_id?: string; + source_of_payable_data?: Monite.SourceOfPayableDataEnum; + ocr_status?: Monite.OcrStatusEnum; + /** + * Search for a payable by the identifier of the line item associated with it. + */ + line_item_id?: string; + /** + * Search for a payable by the identifier of the purchase order associated with it. + */ + purchase_order_id?: string; + /** + * Search for a payable by the identifier of the project associated with it. + */ + project_id?: string; + /** + * Search for a payable by the identifiers of the tags associated with it. + */ + tag_ids?: string | string[]; +} diff --git a/src/api/resources/payables/client/requests/PayablesGetRequest.ts b/src/api/resources/payables/client/requests/PayablesGetRequest.ts new file mode 100644 index 0000000..4ef2fd4 --- /dev/null +++ b/src/api/resources/payables/client/requests/PayablesGetRequest.ts @@ -0,0 +1,78 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PayablesGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.PayableCursorFields; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + status?: Monite.PayableStateEnum; + status__in?: Monite.PayableStateEnum | Monite.PayableStateEnum[]; + id__in?: string | string[]; + total_amount?: number; + total_amount__gt?: number; + total_amount__lt?: number; + total_amount__gte?: number; + total_amount__lte?: number; + amount?: number; + amount__gt?: number; + amount__lt?: number; + amount__gte?: number; + amount__lte?: number; + currency?: Monite.CurrencyEnum; + counterpart_name?: string; + counterpart_name__contains?: string; + counterpart_name__icontains?: string; + search_text?: string; + due_date?: string; + due_date__gt?: string; + due_date__lt?: string; + due_date__gte?: string; + due_date__lte?: string; + document_id?: string; + document_id__contains?: string; + document_id__icontains?: string; + was_created_by_user_id?: string; + counterpart_id?: string; + source_of_payable_data?: Monite.SourceOfPayableDataEnum; + ocr_status?: Monite.OcrStatusEnum; + /** + * Search for a payable by the identifier of the line item associated with it. + */ + line_item_id?: string; + /** + * Search for a payable by the identifier of the purchase order associated with it. + */ + purchase_order_id?: string; + /** + * Search for a payable by the identifier of the project associated with it. + */ + project_id?: string; + /** + * Search for a payable by the identifiers of the tags associated with it. + */ + tag_ids?: string | string[]; +} diff --git a/src/api/resources/payables/client/requests/index.ts b/src/api/resources/payables/client/requests/index.ts new file mode 100644 index 0000000..bbdf792 --- /dev/null +++ b/src/api/resources/payables/client/requests/index.ts @@ -0,0 +1,9 @@ +export { type PayablesGetRequest } from "./PayablesGetRequest"; +export { type PayableUploadWithDataSchema } from "./PayableUploadWithDataSchema"; +export { type PayablesGetAnalyticsRequest } from "./PayablesGetAnalyticsRequest"; +export { type PayableUploadFile } from "./PayableUploadFile"; +export { type PayableValidationsUpdateRequest } from "./PayableValidationsUpdateRequest"; +export { type PayableUpdateSchema } from "./PayableUpdateSchema"; +export { type PayableAttachFile } from "./PayableAttachFile"; +export { type CommentPayload } from "./CommentPayload"; +export { type PartiallyPaidPayload } from "./PartiallyPaidPayload"; diff --git a/src/api/resources/payables/index.ts b/src/api/resources/payables/index.ts new file mode 100644 index 0000000..33a87f1 --- /dev/null +++ b/src/api/resources/payables/index.ts @@ -0,0 +1,2 @@ +export * from "./client"; +export * from "./resources"; diff --git a/src/api/resources/payables/resources/index.ts b/src/api/resources/payables/resources/index.ts new file mode 100644 index 0000000..020e0d8 --- /dev/null +++ b/src/api/resources/payables/resources/index.ts @@ -0,0 +1,2 @@ +export * as lineItems from "./lineItems"; +export * from "./lineItems/client/requests"; diff --git a/src/api/resources/payables/resources/lineItems/client/Client.ts b/src/api/resources/payables/resources/lineItems/client/Client.ts new file mode 100644 index 0000000..e953d27 --- /dev/null +++ b/src/api/resources/payables/resources/lineItems/client/Client.ts @@ -0,0 +1,677 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Monite from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace LineItems { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class LineItems { + constructor(protected readonly _options: LineItems.Options) {} + + /** + * Get a list of all line items related to a specific payable. + * Related guide: [List all payable line items](https://docs.monite.com/docs/manage-line-items#list-all-line-items-of-a-payable) + * + * See also: + * + * [Manage line items](https://docs.monite.com/docs/manage-line-items) + * + * [Collect payables](https://docs.monite.com/docs/collect-payables) + * + * @param {string} payableId + * @param {Monite.payables.LineItemsGetRequest} request + * @param {LineItems.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.lineItems.get("payable_id") + */ + public async get( + payableId: string, + request: Monite.payables.LineItemsGetRequest = {}, + requestOptions?: LineItems.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + was_created_by_user_id: wasCreatedByUserId, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (wasCreatedByUserId != null) { + _queryParams["was_created_by_user_id"] = wasCreatedByUserId; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/line_items` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LineItemPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Add a new line item to a specific payable. + * + * The `subtotal` and `total` fields of line items are automatically calculated based on the `unit_price`, + * `quantity`, and `tax` fields, therefore, are read-only and appear only in the response schema. The field + * `ledger_account_id` is required **only** for account integration, otherwise, it is optional. + * + * Related guide: [Add line items to a payable](https://docs.monite.com/docs/manage-line-items#add-line-items-to-a-payable) + * + * See also: + * + * [Manage line items](https://docs.monite.com/docs/manage-line-items) + * + * [Collect payables](https://docs.monite.com/docs/collect-payables) + * + * @param {string} payableId + * @param {Monite.LineItemRequest} request + * @param {LineItems.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.lineItems.create("payable_id", {}) + */ + public async create( + payableId: string, + request: Monite.LineItemRequest, + requestOptions?: LineItems.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/line_items` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LineItemResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Replaces the information of all line items of a specific payable. + * + * Related guide: [Replace all line items](https://docs.monite.com/docs/manage-line-items#replace-all-line-items) + * + * See also: + * + * [Manage line items](https://docs.monite.com/docs/manage-line-items) + * + * [Collect payables](https://docs.monite.com/docs/collect-payables) + * + * @param {string} payableId + * @param {Monite.payables.LineItemsReplaceRequest} request + * @param {LineItems.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.lineItems.replace("payable_id", { + * data: [{}] + * }) + */ + public async replace( + payableId: string, + request: Monite.payables.LineItemsReplaceRequest, + requestOptions?: LineItems.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/line_items` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LineItemsReplaceResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get information about a specific line item with a given ID. + * + * Related guide: [Retrieve a line item](https://docs.monite.com/docs/manage-line-items#retrieve-a-line-item) + * + * See also: + * + * [Manage line items](https://docs.monite.com/docs/manage-line-items) + * + * [Collect payables](https://docs.monite.com/docs/collect-payables) + * + * @param {string} lineItemId + * @param {string} payableId + * @param {LineItems.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.lineItems.getById("line_item_id", "payable_id") + */ + public async getById( + lineItemId: string, + payableId: string, + requestOptions?: LineItems.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/line_items/${encodeURIComponent(lineItemId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LineItemResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete the line item with the given ID. + * + * Related guide: [Remove a line item](https://docs.monite.com/docs/manage-line-items#remove-a-line-item) + * + * See also: + * + * [Manage line items](https://docs.monite.com/docs/manage-line-items) + * + * [Collect payables](https://docs.monite.com/docs/collect-payables) + * + * @param {string} lineItemId + * @param {string} payableId + * @param {LineItems.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.lineItems.deleteById("line_item_id", "payable_id") + */ + public async deleteById( + lineItemId: string, + payableId: string, + requestOptions?: LineItems.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/line_items/${encodeURIComponent(lineItemId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Edits the information of a specific line item. + * + * Related guide: [Update a line item](https://docs.monite.com/docs/manage-line-items#update-a-line-item) + * + * See also: + * + * [Manage line items](https://docs.monite.com/docs/manage-line-items) + * + * [Collect payables](https://docs.monite.com/docs/collect-payables) + * + * @param {string} lineItemId + * @param {string} payableId + * @param {Monite.LineItemRequest} request + * @param {LineItems.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.lineItems.updateById("line_item_id", "payable_id", {}) + */ + public async updateById( + lineItemId: string, + payableId: string, + request: Monite.LineItemRequest, + requestOptions?: LineItems.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/line_items/${encodeURIComponent(lineItemId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LineItemResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/payables/resources/lineItems/client/index.ts b/src/api/resources/payables/resources/lineItems/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/payables/resources/lineItems/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/payables/resources/lineItems/client/requests/LineItemsGetRequest.ts b/src/api/resources/payables/resources/lineItems/client/requests/LineItemsGetRequest.ts new file mode 100644 index 0000000..2d16a59 --- /dev/null +++ b/src/api/resources/payables/resources/lineItems/client/requests/LineItemsGetRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface LineItemsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.LineItemCursorFields; + was_created_by_user_id?: string; +} diff --git a/src/api/resources/payables/resources/lineItems/client/requests/LineItemsReplaceRequest.ts b/src/api/resources/payables/resources/lineItems/client/requests/LineItemsReplaceRequest.ts new file mode 100644 index 0000000..bcf9259 --- /dev/null +++ b/src/api/resources/payables/resources/lineItems/client/requests/LineItemsReplaceRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../../../index"; + +/** + * @example + * { + * data: [{}] + * } + */ +export interface LineItemsReplaceRequest { + data: Monite.LineItemInternalRequest[]; +} diff --git a/src/api/resources/payables/resources/lineItems/client/requests/index.ts b/src/api/resources/payables/resources/lineItems/client/requests/index.ts new file mode 100644 index 0000000..db3449c --- /dev/null +++ b/src/api/resources/payables/resources/lineItems/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type LineItemsGetRequest } from "./LineItemsGetRequest"; +export { type LineItemsReplaceRequest } from "./LineItemsReplaceRequest"; diff --git a/src/api/resources/payables/resources/lineItems/index.ts b/src/api/resources/payables/resources/lineItems/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/payables/resources/lineItems/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/paymentIntents/client/Client.ts b/src/api/resources/paymentIntents/client/Client.ts new file mode 100644 index 0000000..11e7bbe --- /dev/null +++ b/src/api/resources/paymentIntents/client/Client.ts @@ -0,0 +1,363 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace PaymentIntents { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PaymentIntents { + constructor(protected readonly _options: PaymentIntents.Options) {} + + /** + * @param {Monite.PaymentIntentsGetRequest} request + * @param {PaymentIntents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentIntents.get() + */ + public async get( + request: Monite.PaymentIntentsGetRequest = {}, + requestOptions?: PaymentIntents.RequestOptions + ): Promise { + const { order, limit, pagination_token: paginationToken, sort, object_id: objectId } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (objectId != null) { + _queryParams["object_id"] = objectId; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payment_intents" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentIntentsListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentIntentId + * @param {PaymentIntents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentIntents.getById("payment_intent_id") + */ + public async getById( + paymentIntentId: string, + requestOptions?: PaymentIntents.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_intents/${encodeURIComponent(paymentIntentId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentIntentResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentIntentId + * @param {Monite.UpdatePaymentIntentPayload} request + * @param {PaymentIntents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentIntents.updateById("payment_intent_id", { + * amount: 1 + * }) + */ + public async updateById( + paymentIntentId: string, + request: Monite.UpdatePaymentIntentPayload, + requestOptions?: PaymentIntents.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_intents/${encodeURIComponent(paymentIntentId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentIntentResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentIntentId + * @param {PaymentIntents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentIntents.getHistoryById("payment_intent_id") + */ + public async getHistoryById( + paymentIntentId: string, + requestOptions?: PaymentIntents.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_intents/${encodeURIComponent(paymentIntentId)}/history` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentIntentHistoryResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/paymentIntents/client/index.ts b/src/api/resources/paymentIntents/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/paymentIntents/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/paymentIntents/client/requests/PaymentIntentsGetRequest.ts b/src/api/resources/paymentIntents/client/requests/PaymentIntentsGetRequest.ts new file mode 100644 index 0000000..acb544f --- /dev/null +++ b/src/api/resources/paymentIntents/client/requests/PaymentIntentsGetRequest.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PaymentIntentsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.PaymentIntentCursorFields; + /** + * ID of a payable or receivable invoice. If provided, returns only payment intents associated with the specified invoice. + */ + object_id?: string; +} diff --git a/src/api/resources/paymentIntents/client/requests/UpdatePaymentIntentPayload.ts b/src/api/resources/paymentIntents/client/requests/UpdatePaymentIntentPayload.ts new file mode 100644 index 0000000..6727b4f --- /dev/null +++ b/src/api/resources/paymentIntents/client/requests/UpdatePaymentIntentPayload.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * amount: 1 + * } + */ +export interface UpdatePaymentIntentPayload { + amount: number; +} diff --git a/src/api/resources/paymentIntents/client/requests/index.ts b/src/api/resources/paymentIntents/client/requests/index.ts new file mode 100644 index 0000000..a54c95c --- /dev/null +++ b/src/api/resources/paymentIntents/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type PaymentIntentsGetRequest } from "./PaymentIntentsGetRequest"; +export { type UpdatePaymentIntentPayload } from "./UpdatePaymentIntentPayload"; diff --git a/src/api/resources/paymentIntents/index.ts b/src/api/resources/paymentIntents/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/paymentIntents/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/paymentLinks/client/Client.ts b/src/api/resources/paymentLinks/client/Client.ts new file mode 100644 index 0000000..e479175 --- /dev/null +++ b/src/api/resources/paymentLinks/client/Client.ts @@ -0,0 +1,270 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace PaymentLinks { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PaymentLinks { + constructor(protected readonly _options: PaymentLinks.Options) {} + + /** + * @param {Monite.CreatePaymentLinkRequest} request + * @param {PaymentLinks.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentLinks.create({ + * payment_methods: ["sepa_credit"], + * recipient: { + * id: "id", + * type: "entity" + * } + * }) + */ + public async create( + request: Monite.CreatePaymentLinkRequest, + requestOptions?: PaymentLinks.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payment_links" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PublicPaymentLinkResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentLinkId + * @param {PaymentLinks.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentLinks.getById("payment_link_id") + */ + public async getById( + paymentLinkId: string, + requestOptions?: PaymentLinks.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_links/${encodeURIComponent(paymentLinkId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PublicPaymentLinkResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentLinkId + * @param {PaymentLinks.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentLinks.expireById("payment_link_id") + */ + public async expireById( + paymentLinkId: string, + requestOptions?: PaymentLinks.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_links/${encodeURIComponent(paymentLinkId)}/expire` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PublicPaymentLinkResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/paymentLinks/client/index.ts b/src/api/resources/paymentLinks/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/paymentLinks/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/paymentLinks/client/requests/CreatePaymentLinkRequest.ts b/src/api/resources/paymentLinks/client/requests/CreatePaymentLinkRequest.ts new file mode 100644 index 0000000..b3c4227 --- /dev/null +++ b/src/api/resources/paymentLinks/client/requests/CreatePaymentLinkRequest.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * payment_methods: ["sepa_credit"], + * recipient: { + * id: "id", + * type: "entity" + * } + * } + */ +export interface CreatePaymentLinkRequest { + /** The payment amount in [minor units](https://docs.monite.com/docs/currencies#minor-units). Required if `object` is not specified. */ + amount?: number; + /** The payment currency. Required if `object` is not specified. */ + currency?: Monite.CurrencyEnum; + expires_at?: string; + /** An object containing information about the invoice being paid. Used only if `object` is not specified. */ + invoice?: Monite.Invoice; + /** If the invoice being paid is a payable or receivable stored in Monite, provide the `object` object containing the invoice type and ID. Otherwise, use the `amount`, `currency`, `payment_reference`, and (optionally) `invoice` fields to specify the invoice-related data. */ + object?: Monite.PaymentObject; + payment_methods: Monite.MoniteAllPaymentMethodsTypes[]; + /** A payment reference number that the recipient can use to identify the payer or purpose of the transaction. Required if `object` is not specified. */ + payment_reference?: string; + recipient: Monite.PaymentAccountObject; + return_url?: string; +} diff --git a/src/api/resources/paymentLinks/client/requests/index.ts b/src/api/resources/paymentLinks/client/requests/index.ts new file mode 100644 index 0000000..5219eed --- /dev/null +++ b/src/api/resources/paymentLinks/client/requests/index.ts @@ -0,0 +1 @@ +export { type CreatePaymentLinkRequest } from "./CreatePaymentLinkRequest"; diff --git a/src/api/resources/paymentLinks/index.ts b/src/api/resources/paymentLinks/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/paymentLinks/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/paymentRecords/client/Client.ts b/src/api/resources/paymentRecords/client/Client.ts new file mode 100644 index 0000000..fbdd812 --- /dev/null +++ b/src/api/resources/paymentRecords/client/Client.ts @@ -0,0 +1,370 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace PaymentRecords { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PaymentRecords { + constructor(protected readonly _options: PaymentRecords.Options) {} + + /** + * @param {Monite.PaymentRecordsGetRequest} request + * @param {PaymentRecords.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.RangeNotSatisfiableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentRecords.get() + */ + public async get( + request: Monite.PaymentRecordsGetRequest = {}, + requestOptions?: PaymentRecords.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + is_external: isExternal, + object_id: objectId, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (isExternal != null) { + _queryParams["is_external"] = isExternal.toString(); + } + + if (objectId != null) { + _queryParams["object_id"] = objectId; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payment_records" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentRecordResponseList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 416: + throw new Monite.RangeNotSatisfiableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.PaymentRecordRequest} request + * @param {PaymentRecords.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.RangeNotSatisfiableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentRecords.create({ + * amount: 1, + * currency: "AED", + * object: { + * id: "id", + * type: "receivable" + * }, + * paid_at: "2024-01-15T09:30:00Z", + * payment_intent_id: "payment_intent_id" + * }) + */ + public async create( + request: Monite.PaymentRecordRequest, + requestOptions?: PaymentRecords.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payment_records" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentRecordResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 416: + throw new Monite.RangeNotSatisfiableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentRecordId + * @param {PaymentRecords.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.RangeNotSatisfiableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentRecords.getById("payment_record_id") + */ + public async getById( + paymentRecordId: string, + requestOptions?: PaymentRecords.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_records/${encodeURIComponent(paymentRecordId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentRecordResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 416: + throw new Monite.RangeNotSatisfiableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/paymentRecords/client/index.ts b/src/api/resources/paymentRecords/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/paymentRecords/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/paymentRecords/client/requests/PaymentRecordRequest.ts b/src/api/resources/paymentRecords/client/requests/PaymentRecordRequest.ts new file mode 100644 index 0000000..84c656b --- /dev/null +++ b/src/api/resources/paymentRecords/client/requests/PaymentRecordRequest.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * amount: 1, + * currency: "AED", + * object: { + * id: "id", + * type: "receivable" + * }, + * paid_at: "2024-01-15T09:30:00Z", + * payment_intent_id: "payment_intent_id" + * } + */ +export interface PaymentRecordRequest { + amount: number; + currency: Monite.CurrencyEnum; + entity_user_id?: string; + object: Monite.PaymentRecordObjectRequest; + paid_at: string; + payment_intent_id: string; +} diff --git a/src/api/resources/paymentRecords/client/requests/PaymentRecordsGetRequest.ts b/src/api/resources/paymentRecords/client/requests/PaymentRecordsGetRequest.ts new file mode 100644 index 0000000..e94a5df --- /dev/null +++ b/src/api/resources/paymentRecords/client/requests/PaymentRecordsGetRequest.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PaymentRecordsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.PaymentRecordCursorFields; + is_external?: boolean; + object_id?: string; +} diff --git a/src/api/resources/paymentRecords/client/requests/index.ts b/src/api/resources/paymentRecords/client/requests/index.ts new file mode 100644 index 0000000..e57ac37 --- /dev/null +++ b/src/api/resources/paymentRecords/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type PaymentRecordsGetRequest } from "./PaymentRecordsGetRequest"; +export { type PaymentRecordRequest } from "./PaymentRecordRequest"; diff --git a/src/api/resources/paymentRecords/index.ts b/src/api/resources/paymentRecords/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/paymentRecords/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/paymentReminders/client/Client.ts b/src/api/resources/paymentReminders/client/Client.ts new file mode 100644 index 0000000..5c7c014 --- /dev/null +++ b/src/api/resources/paymentReminders/client/Client.ts @@ -0,0 +1,457 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace PaymentReminders { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PaymentReminders { + constructor(protected readonly _options: PaymentReminders.Options) {} + + /** + * @param {PaymentReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentReminders.get() + */ + public async get(requestOptions?: PaymentReminders.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payment_reminders" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.GetAllPaymentReminders; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.PaymentReminder} request + * @param {PaymentReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentReminders.create({ + * name: "name" + * }) + */ + public async create( + request: Monite.PaymentReminder, + requestOptions?: PaymentReminders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payment_reminders" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentReminderResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentReminderId + * @param {PaymentReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentReminders.getById("payment_reminder_id") + */ + public async getById( + paymentReminderId: string, + requestOptions?: PaymentReminders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_reminders/${encodeURIComponent(paymentReminderId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentReminderResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentReminderId + * @param {PaymentReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentReminders.deleteById("payment_reminder_id") + */ + public async deleteById( + paymentReminderId: string, + requestOptions?: PaymentReminders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_reminders/${encodeURIComponent(paymentReminderId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentReminderId + * @param {Monite.PaymentReminderUpdateRequest} request + * @param {PaymentReminders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentReminders.updateById("payment_reminder_id") + */ + public async updateById( + paymentReminderId: string, + request: Monite.PaymentReminderUpdateRequest = {}, + requestOptions?: PaymentReminders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_reminders/${encodeURIComponent(paymentReminderId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentReminderResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/paymentReminders/client/index.ts b/src/api/resources/paymentReminders/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/paymentReminders/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/paymentReminders/client/requests/PaymentReminder.ts b/src/api/resources/paymentReminders/client/requests/PaymentReminder.ts new file mode 100644 index 0000000..4e52460 --- /dev/null +++ b/src/api/resources/paymentReminders/client/requests/PaymentReminder.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * name: "name" + * } + */ +export interface PaymentReminder { + name: string; + recipients?: Monite.Recipients; + /** Reminder to send for first payment term */ + term_1_reminder?: Monite.Reminder; + /** Reminder to send for second payment term */ + term_2_reminder?: Monite.Reminder; + /** Reminder to send for final payment term */ + term_final_reminder?: Monite.Reminder; +} diff --git a/src/api/resources/paymentReminders/client/requests/PaymentReminderUpdateRequest.ts b/src/api/resources/paymentReminders/client/requests/PaymentReminderUpdateRequest.ts new file mode 100644 index 0000000..a875af7 --- /dev/null +++ b/src/api/resources/paymentReminders/client/requests/PaymentReminderUpdateRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PaymentReminderUpdateRequest { + name?: string; + recipients?: Monite.Recipients; + /** Reminder to send for first payment term */ + term_1_reminder?: Monite.Reminder; + /** Reminder to send for second payment term */ + term_2_reminder?: Monite.Reminder; + /** Reminder to send for final payment term */ + term_final_reminder?: Monite.Reminder; +} diff --git a/src/api/resources/paymentReminders/client/requests/index.ts b/src/api/resources/paymentReminders/client/requests/index.ts new file mode 100644 index 0000000..18adbb3 --- /dev/null +++ b/src/api/resources/paymentReminders/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type PaymentReminder } from "./PaymentReminder"; +export { type PaymentReminderUpdateRequest } from "./PaymentReminderUpdateRequest"; diff --git a/src/api/resources/paymentReminders/index.ts b/src/api/resources/paymentReminders/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/paymentReminders/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/paymentTerms/client/Client.ts b/src/api/resources/paymentTerms/client/Client.ts new file mode 100644 index 0000000..611aadf --- /dev/null +++ b/src/api/resources/paymentTerms/client/Client.ts @@ -0,0 +1,457 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace PaymentTerms { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PaymentTerms { + constructor(protected readonly _options: PaymentTerms.Options) {} + + /** + * @param {PaymentTerms.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentTerms.get() + */ + public async get(requestOptions?: PaymentTerms.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payment_terms" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentTermsListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.PaymentTermsCreatePayload} request + * @param {PaymentTerms.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentTerms.create({ + * name: "name", + * term_final: { + * number_of_days: 1 + * } + * }) + */ + public async create( + request: Monite.PaymentTermsCreatePayload, + requestOptions?: PaymentTerms.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payment_terms" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentTermsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentTermsId + * @param {PaymentTerms.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentTerms.getById("payment_terms_id") + */ + public async getById( + paymentTermsId: string, + requestOptions?: PaymentTerms.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_terms/${encodeURIComponent(paymentTermsId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentTermsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentTermsId + * @param {PaymentTerms.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentTerms.deleteById("payment_terms_id") + */ + public async deleteById(paymentTermsId: string, requestOptions?: PaymentTerms.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_terms/${encodeURIComponent(paymentTermsId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} paymentTermsId + * @param {Monite.PaymentTermsUpdatePayload} request + * @param {PaymentTerms.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.paymentTerms.updateById("payment_terms_id") + */ + public async updateById( + paymentTermsId: string, + request: Monite.PaymentTermsUpdatePayload = {}, + requestOptions?: PaymentTerms.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payment_terms/${encodeURIComponent(paymentTermsId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PaymentTermsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/paymentTerms/client/index.ts b/src/api/resources/paymentTerms/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/paymentTerms/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/paymentTerms/client/requests/PaymentTermsCreatePayload.ts b/src/api/resources/paymentTerms/client/requests/PaymentTermsCreatePayload.ts new file mode 100644 index 0000000..8233657 --- /dev/null +++ b/src/api/resources/paymentTerms/client/requests/PaymentTermsCreatePayload.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * name: "name", + * term_final: { + * number_of_days: 1 + * } + * } + */ +export interface PaymentTermsCreatePayload { + description?: string; + name: string; + /** The first tier of the payment term. Represents the terms of the first early discount. */ + term_1?: Monite.PaymentTermDiscount; + /** The second tier of the payment term. Defines the terms of the second early discount. */ + term_2?: Monite.PaymentTermDiscount; + /** The final tier of the payment term. Defines the invoice due date. */ + term_final: Monite.PaymentTerm; +} diff --git a/src/api/resources/paymentTerms/client/requests/PaymentTermsUpdatePayload.ts b/src/api/resources/paymentTerms/client/requests/PaymentTermsUpdatePayload.ts new file mode 100644 index 0000000..2619870 --- /dev/null +++ b/src/api/resources/paymentTerms/client/requests/PaymentTermsUpdatePayload.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PaymentTermsUpdatePayload { + description?: string; + name?: string; + /** The first tier of the payment term. Represents the terms of the first early discount. */ + term_1?: Monite.PaymentTermDiscount; + /** The second tier of the payment term. Defines the terms of the second early discount. */ + term_2?: Monite.PaymentTermDiscount; + /** The final tier of the payment term. Defines the invoice due date. */ + term_final?: Monite.PaymentTerm; +} diff --git a/src/api/resources/paymentTerms/client/requests/index.ts b/src/api/resources/paymentTerms/client/requests/index.ts new file mode 100644 index 0000000..5b11436 --- /dev/null +++ b/src/api/resources/paymentTerms/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type PaymentTermsCreatePayload } from "./PaymentTermsCreatePayload"; +export { type PaymentTermsUpdatePayload } from "./PaymentTermsUpdatePayload"; diff --git a/src/api/resources/paymentTerms/index.ts b/src/api/resources/paymentTerms/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/paymentTerms/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/pdfTemplates/client/Client.ts b/src/api/resources/pdfTemplates/client/Client.ts new file mode 100644 index 0000000..91d3069 --- /dev/null +++ b/src/api/resources/pdfTemplates/client/Client.ts @@ -0,0 +1,400 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; +import * as stream from "stream"; + +export declare namespace PdfTemplates { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PdfTemplates { + constructor(protected readonly _options: PdfTemplates.Options) {} + + /** + * This API call returns all supported templates with language codes. + * + * @param {PdfTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.pdfTemplates.get() + */ + public async get(requestOptions?: PdfTemplates.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "document_templates" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TemplateListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * This API call returns all supported system templates with language codes. + * + * @param {PdfTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.pdfTemplates.getSystem() + */ + public async getSystem(requestOptions?: PdfTemplates.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "document_templates/system" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TemplateListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} documentTemplateId + * @param {PdfTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.pdfTemplates.getById("document_template_id") + */ + public async getById( + documentTemplateId: string, + requestOptions?: PdfTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `document_templates/${encodeURIComponent(documentTemplateId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TemplateReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} documentTemplateId + * @param {PdfTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.pdfTemplates.makeDefaultById("document_template_id") + */ + public async makeDefaultById( + documentTemplateId: string, + requestOptions?: PdfTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `document_templates/${encodeURIComponent(documentTemplateId)}/make_default` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TemplateReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Returns a sample PDF invoice generated using the specified template. + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + */ + public async previewById( + documentTemplateId: string, + requestOptions?: PdfTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `document_templates/${encodeURIComponent(documentTemplateId)}/preview` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + responseType: "streaming", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/pdfTemplates/client/index.ts b/src/api/resources/pdfTemplates/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/pdfTemplates/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/pdfTemplates/index.ts b/src/api/resources/pdfTemplates/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/pdfTemplates/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/products/client/Client.ts b/src/api/resources/products/client/Client.ts new file mode 100644 index 0000000..c78457d --- /dev/null +++ b/src/api/resources/products/client/Client.ts @@ -0,0 +1,581 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Products { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Products { + constructor(protected readonly _options: Products.Options) {} + + /** + * @param {Monite.ProductsGetRequest} request + * @param {Products.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.products.get() + */ + public async get( + request: Monite.ProductsGetRequest = {}, + requestOptions?: Products.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + id__in: idIn, + name, + name__contains: nameContains, + name__icontains: nameIcontains, + type: type_, + price, + price__gt: priceGt, + price__lt: priceLt, + price__gte: priceGte, + price__lte: priceLte, + currency, + currency__in: currencyIn, + measure_unit_id: measureUnitId, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (name != null) { + _queryParams["name"] = name; + } + + if (nameContains != null) { + _queryParams["name__contains"] = nameContains; + } + + if (nameIcontains != null) { + _queryParams["name__icontains"] = nameIcontains; + } + + if (type_ != null) { + _queryParams["type"] = type_; + } + + if (price != null) { + _queryParams["price"] = price.toString(); + } + + if (priceGt != null) { + _queryParams["price__gt"] = priceGt.toString(); + } + + if (priceLt != null) { + _queryParams["price__lt"] = priceLt.toString(); + } + + if (priceGte != null) { + _queryParams["price__gte"] = priceGte.toString(); + } + + if (priceLte != null) { + _queryParams["price__lte"] = priceLte.toString(); + } + + if (currency != null) { + _queryParams["currency"] = currency; + } + + if (currencyIn != null) { + if (Array.isArray(currencyIn)) { + _queryParams["currency__in"] = currencyIn.map((item) => item); + } else { + _queryParams["currency__in"] = currencyIn; + } + } + + if (measureUnitId != null) { + _queryParams["measure_unit_id"] = measureUnitId; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "products" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProductServicePaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.ProductServiceRequest} request + * @param {Products.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.products.create({ + * name: "name" + * }) + */ + public async create( + request: Monite.ProductServiceRequest, + requestOptions?: Products.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "products" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProductServiceResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} productId + * @param {Products.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.products.getById("product_id") + */ + public async getById( + productId: string, + requestOptions?: Products.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `products/${encodeURIComponent(productId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProductServiceResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} productId + * @param {Products.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.products.deleteById("product_id") + */ + public async deleteById(productId: string, requestOptions?: Products.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `products/${encodeURIComponent(productId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} productId + * @param {Monite.ProductServiceUpdate} request + * @param {Products.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.products.updateById("product_id") + */ + public async updateById( + productId: string, + request: Monite.ProductServiceUpdate = {}, + requestOptions?: Products.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `products/${encodeURIComponent(productId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProductServiceResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/products/client/index.ts b/src/api/resources/products/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/products/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/products/client/requests/ProductServiceRequest.ts b/src/api/resources/products/client/requests/ProductServiceRequest.ts new file mode 100644 index 0000000..d87e8c6 --- /dev/null +++ b/src/api/resources/products/client/requests/ProductServiceRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * name: "name" + * } + */ +export interface ProductServiceRequest { + /** Description of the product. */ + description?: string; + ledger_account_id?: string; + /** The unique ID reference of the unit used to measure the quantity of this product (e.g. items, meters, kilograms). */ + measure_unit_id?: string; + /** Name of the product. */ + name: string; + price?: Monite.Price; + /** The smallest amount allowed for this product. */ + smallest_amount?: number; + /** Specifies whether this offering is a product or service. This may affect the applicable tax rates. */ + type?: Monite.ProductServiceTypeEnum; +} diff --git a/src/api/resources/products/client/requests/ProductServiceUpdate.ts b/src/api/resources/products/client/requests/ProductServiceUpdate.ts new file mode 100644 index 0000000..94f6545 --- /dev/null +++ b/src/api/resources/products/client/requests/ProductServiceUpdate.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ProductServiceUpdate { + /** Description of the product. */ + description?: string; + ledger_account_id?: string; + /** The unique ID reference of the unit used to measure the quantity of this product (e.g. items, meters, kilograms). */ + measure_unit_id?: string; + /** Name of the product. */ + name?: string; + price?: Monite.Price; + /** The smallest amount allowed for this product. */ + smallest_amount?: number; + /** Specifies whether this offering is a product or service. This may affect the applicable tax rates. */ + type?: Monite.ProductServiceTypeEnum; +} diff --git a/src/api/resources/products/client/requests/ProductsGetRequest.ts b/src/api/resources/products/client/requests/ProductsGetRequest.ts new file mode 100644 index 0000000..0e993db --- /dev/null +++ b/src/api/resources/products/client/requests/ProductsGetRequest.ts @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ProductsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum3; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.ProductCursorFields; + id__in?: string | string[]; + name?: string; + name__contains?: string; + name__icontains?: string; + type?: Monite.ProductServiceTypeEnum; + price?: number; + price__gt?: number; + price__lt?: number; + price__gte?: number; + price__lte?: number; + currency?: Monite.CurrencyEnum; + currency__in?: Monite.CurrencyEnum | Monite.CurrencyEnum[]; + measure_unit_id?: string; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; +} diff --git a/src/api/resources/products/client/requests/index.ts b/src/api/resources/products/client/requests/index.ts new file mode 100644 index 0000000..27f3d75 --- /dev/null +++ b/src/api/resources/products/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type ProductsGetRequest } from "./ProductsGetRequest"; +export { type ProductServiceRequest } from "./ProductServiceRequest"; +export { type ProductServiceUpdate } from "./ProductServiceUpdate"; diff --git a/src/api/resources/products/index.ts b/src/api/resources/products/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/products/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/projects/client/Client.ts b/src/api/resources/projects/client/Client.ts new file mode 100644 index 0000000..9d02117 --- /dev/null +++ b/src/api/resources/projects/client/Client.ts @@ -0,0 +1,601 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Projects { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Projects { + constructor(protected readonly _options: Projects.Options) {} + + /** + * Get all projects for an entity + * + * @param {Monite.ProjectsGetRequest} request + * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.projects.get() + */ + public async get( + request: Monite.ProjectsGetRequest = {}, + requestOptions?: Projects.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + start_date: startDate, + start_date__gt: startDateGt, + start_date__lt: startDateLt, + start_date__gte: startDateGte, + start_date__lte: startDateLte, + end_date: endDate, + end_date__gt: endDateGt, + end_date__lt: endDateLt, + end_date__gte: endDateGte, + end_date__lte: endDateLte, + name, + name__iexact: nameIexact, + name__contains: nameContains, + name__icontains: nameIcontains, + code, + created_by_entity_user_id: createdByEntityUserId, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (startDate != null) { + _queryParams["start_date"] = startDate; + } + + if (startDateGt != null) { + _queryParams["start_date__gt"] = startDateGt; + } + + if (startDateLt != null) { + _queryParams["start_date__lt"] = startDateLt; + } + + if (startDateGte != null) { + _queryParams["start_date__gte"] = startDateGte; + } + + if (startDateLte != null) { + _queryParams["start_date__lte"] = startDateLte; + } + + if (endDate != null) { + _queryParams["end_date"] = endDate; + } + + if (endDateGt != null) { + _queryParams["end_date__gt"] = endDateGt; + } + + if (endDateLt != null) { + _queryParams["end_date__lt"] = endDateLt; + } + + if (endDateGte != null) { + _queryParams["end_date__gte"] = endDateGte; + } + + if (endDateLte != null) { + _queryParams["end_date__lte"] = endDateLte; + } + + if (name != null) { + _queryParams["name"] = name; + } + + if (nameIexact != null) { + _queryParams["name__iexact"] = nameIexact; + } + + if (nameContains != null) { + _queryParams["name__contains"] = nameContains; + } + + if (nameIcontains != null) { + _queryParams["name__icontains"] = nameIcontains; + } + + if (code != null) { + _queryParams["code"] = code; + } + + if (createdByEntityUserId != null) { + _queryParams["created_by_entity_user_id"] = createdByEntityUserId; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "projects" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProjectPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a new project. + * + * @param {Monite.ProjectCreateRequest} request + * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.projects.create({ + * name: "Marketing" + * }) + */ + public async create( + request: Monite.ProjectCreateRequest, + requestOptions?: Projects.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "projects" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProjectResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get a project with the given ID. + * + * @param {string} projectId + * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.projects.getById("project_id") + */ + public async getById(projectId: string, requestOptions?: Projects.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `projects/${encodeURIComponent(projectId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProjectResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete a project. + * + * @param {string} projectId + * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.projects.deleteById("project_id") + */ + public async deleteById(projectId: string, requestOptions?: Projects.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `projects/${encodeURIComponent(projectId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update a project. + * + * @param {string} projectId + * @param {Monite.ProjectUpdateRequest} request + * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.projects.updateById("project_id") + */ + public async updateById( + projectId: string, + request: Monite.ProjectUpdateRequest = {}, + requestOptions?: Projects.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `projects/${encodeURIComponent(projectId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ProjectResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/projects/client/index.ts b/src/api/resources/projects/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/projects/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/projects/client/requests/ProjectCreateRequest.ts b/src/api/resources/projects/client/requests/ProjectCreateRequest.ts new file mode 100644 index 0000000..fdadf05 --- /dev/null +++ b/src/api/resources/projects/client/requests/ProjectCreateRequest.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * name: "Marketing" + * } + */ +export interface ProjectCreateRequest { + /** Project code */ + code?: string; + /** Project color */ + color?: string; + /** Description of project */ + description?: string; + /** Project end date */ + end_date?: string; + /** The project name. */ + name: string; + /** Parent project ID */ + parent_id?: string; + /** Project metadata */ + partner_metadata?: Record; + /** Project start date */ + start_date?: string; + /** A list of IDs of user-defined tags (labels) assigned to this project. */ + tag_ids?: string[]; +} diff --git a/src/api/resources/projects/client/requests/ProjectUpdateRequest.ts b/src/api/resources/projects/client/requests/ProjectUpdateRequest.ts new file mode 100644 index 0000000..b87c58b --- /dev/null +++ b/src/api/resources/projects/client/requests/ProjectUpdateRequest.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface ProjectUpdateRequest { + /** Project code */ + code?: string; + /** Project color */ + color?: string; + /** Description of project */ + description?: string; + /** Project end date */ + end_date?: string; + /** The project name. */ + name?: string; + /** Parent project ID */ + parent_id?: string; + /** Project metadata */ + partner_metadata?: Record; + /** Project start date */ + start_date?: string; + /** A list of IDs of user-defined tags (labels) assigned to this project. */ + tag_ids?: string[]; +} diff --git a/src/api/resources/projects/client/requests/ProjectsGetRequest.ts b/src/api/resources/projects/client/requests/ProjectsGetRequest.ts new file mode 100644 index 0000000..f8d2e3b --- /dev/null +++ b/src/api/resources/projects/client/requests/ProjectsGetRequest.ts @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ProjectsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.ProjectCursorFields; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + start_date?: string; + start_date__gt?: string; + start_date__lt?: string; + start_date__gte?: string; + start_date__lte?: string; + end_date?: string; + end_date__gt?: string; + end_date__lt?: string; + end_date__gte?: string; + end_date__lte?: string; + name?: string; + name__iexact?: string; + name__contains?: string; + name__icontains?: string; + code?: string; + created_by_entity_user_id?: string; +} diff --git a/src/api/resources/projects/client/requests/index.ts b/src/api/resources/projects/client/requests/index.ts new file mode 100644 index 0000000..928294e --- /dev/null +++ b/src/api/resources/projects/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type ProjectsGetRequest } from "./ProjectsGetRequest"; +export { type ProjectCreateRequest } from "./ProjectCreateRequest"; +export { type ProjectUpdateRequest } from "./ProjectUpdateRequest"; diff --git a/src/api/resources/projects/index.ts b/src/api/resources/projects/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/projects/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/purchaseOrders/client/Client.ts b/src/api/resources/purchaseOrders/client/Client.ts new file mode 100644 index 0000000..4c4734d --- /dev/null +++ b/src/api/resources/purchaseOrders/client/Client.ts @@ -0,0 +1,848 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace PurchaseOrders { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class PurchaseOrders { + constructor(protected readonly _options: PurchaseOrders.Options) {} + + /** + * @param {Monite.PurchaseOrdersGetRequest} request + * @param {PurchaseOrders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.purchaseOrders.get() + */ + public async get( + request: Monite.PurchaseOrdersGetRequest = {}, + requestOptions?: PurchaseOrders.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + updated_at__gt: updatedAtGt, + updated_at__lt: updatedAtLt, + updated_at__gte: updatedAtGte, + updated_at__lte: updatedAtLte, + issued_at__gt: issuedAtGt, + issued_at__lt: issuedAtLt, + issued_at__gte: issuedAtGte, + issued_at__lte: issuedAtLte, + status, + document_id: documentId, + document_id__in: documentIdIn, + created_by: createdBy, + counterpart_id: counterpartId, + counterpart_id__in: counterpartIdIn, + "counterpart.name": counterpartName, + currency, + currency__in: currencyIn, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (updatedAtGt != null) { + _queryParams["updated_at__gt"] = updatedAtGt; + } + + if (updatedAtLt != null) { + _queryParams["updated_at__lt"] = updatedAtLt; + } + + if (updatedAtGte != null) { + _queryParams["updated_at__gte"] = updatedAtGte; + } + + if (updatedAtLte != null) { + _queryParams["updated_at__lte"] = updatedAtLte; + } + + if (issuedAtGt != null) { + _queryParams["issued_at__gt"] = issuedAtGt; + } + + if (issuedAtLt != null) { + _queryParams["issued_at__lt"] = issuedAtLt; + } + + if (issuedAtGte != null) { + _queryParams["issued_at__gte"] = issuedAtGte; + } + + if (issuedAtLte != null) { + _queryParams["issued_at__lte"] = issuedAtLte; + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (documentId != null) { + _queryParams["document_id"] = documentId; + } + + if (documentIdIn != null) { + if (Array.isArray(documentIdIn)) { + _queryParams["document_id__in"] = documentIdIn.map((item) => item); + } else { + _queryParams["document_id__in"] = documentIdIn; + } + } + + if (createdBy != null) { + _queryParams["created_by"] = createdBy; + } + + if (counterpartId != null) { + _queryParams["counterpart_id"] = counterpartId; + } + + if (counterpartIdIn != null) { + if (Array.isArray(counterpartIdIn)) { + _queryParams["counterpart_id__in"] = counterpartIdIn.map((item) => item); + } else { + _queryParams["counterpart_id__in"] = counterpartIdIn; + } + } + + if (counterpartName != null) { + _queryParams["counterpart.name"] = counterpartName; + } + + if (currency != null) { + _queryParams["currency"] = currency; + } + + if (currencyIn != null) { + if (Array.isArray(currencyIn)) { + _queryParams["currency__in"] = currencyIn.map((item) => item); + } else { + _queryParams["currency__in"] = currencyIn; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payable_purchase_orders" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PurchaseOrderPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.PurchaseOrderPayloadSchema} request + * @param {PurchaseOrders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.purchaseOrders.create({ + * counterpart_id: "counterpart_id", + * currency: "AED", + * items: [{ + * currency: "AED", + * name: "name", + * price: 1, + * quantity: 1, + * unit: "unit", + * vat_rate: 1 + * }], + * message: "message", + * valid_for_days: 1 + * }) + */ + public async create( + request: Monite.PurchaseOrderPayloadSchema, + requestOptions?: PurchaseOrders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payable_purchase_orders" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PurchaseOrderResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get a list of placeholders allowed to insert into an email template for customization + * + * @param {PurchaseOrders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.purchaseOrders.getVariables() + */ + public async getVariables(requestOptions?: PurchaseOrders.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "payable_purchase_orders/variables" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.VariablesObjectList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} purchaseOrderId + * @param {PurchaseOrders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.purchaseOrders.getById("purchase_order_id") + */ + public async getById( + purchaseOrderId: string, + requestOptions?: PurchaseOrders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payable_purchase_orders/${encodeURIComponent(purchaseOrderId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PurchaseOrderResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} purchaseOrderId + * @param {PurchaseOrders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.purchaseOrders.deleteById("purchase_order_id") + */ + public async deleteById(purchaseOrderId: string, requestOptions?: PurchaseOrders.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payable_purchase_orders/${encodeURIComponent(purchaseOrderId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} purchaseOrderId + * @param {Monite.UpdatePurchaseOrderPayloadSchema} request + * @param {PurchaseOrders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.purchaseOrders.updateById("purchase_order_id") + */ + public async updateById( + purchaseOrderId: string, + request: Monite.UpdatePurchaseOrderPayloadSchema = {}, + requestOptions?: PurchaseOrders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payable_purchase_orders/${encodeURIComponent(purchaseOrderId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PurchaseOrderResponseSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} purchaseOrderId + * @param {Monite.PurchaseOrderEmailPreviewRequest} request + * @param {PurchaseOrders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.purchaseOrders.previewById("purchase_order_id", { + * body_text: "body_text", + * subject_text: "subject_text" + * }) + */ + public async previewById( + purchaseOrderId: string, + request: Monite.PurchaseOrderEmailPreviewRequest, + requestOptions?: PurchaseOrders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payable_purchase_orders/${encodeURIComponent(purchaseOrderId)}/preview` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PurchaseOrderEmailPreviewResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} purchaseOrderId + * @param {Monite.SendPurchaseOrderViaEmailRequest} request + * @param {PurchaseOrders.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.purchaseOrders.sendById("purchase_order_id", { + * body_text: "body_text", + * subject_text: "subject_text" + * }) + */ + public async sendById( + purchaseOrderId: string, + request: Monite.SendPurchaseOrderViaEmailRequest, + requestOptions?: PurchaseOrders.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `payable_purchase_orders/${encodeURIComponent(purchaseOrderId)}/send` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.PurchaseOrderEmailSentResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/purchaseOrders/client/index.ts b/src/api/resources/purchaseOrders/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/purchaseOrders/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/purchaseOrders/client/requests/PurchaseOrderEmailPreviewRequest.ts b/src/api/resources/purchaseOrders/client/requests/PurchaseOrderEmailPreviewRequest.ts new file mode 100644 index 0000000..d15ee05 --- /dev/null +++ b/src/api/resources/purchaseOrders/client/requests/PurchaseOrderEmailPreviewRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * body_text: "body_text", + * subject_text: "subject_text" + * } + */ +export interface PurchaseOrderEmailPreviewRequest { + body_text: string; + subject_text: string; +} diff --git a/src/api/resources/purchaseOrders/client/requests/PurchaseOrderPayloadSchema.ts b/src/api/resources/purchaseOrders/client/requests/PurchaseOrderPayloadSchema.ts new file mode 100644 index 0000000..a13570c --- /dev/null +++ b/src/api/resources/purchaseOrders/client/requests/PurchaseOrderPayloadSchema.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * counterpart_id: "counterpart_id", + * currency: "AED", + * items: [{ + * currency: "AED", + * name: "name", + * price: 1, + * quantity: 1, + * unit: "unit", + * vat_rate: 1 + * }], + * message: "message", + * valid_for_days: 1 + * } + */ +export interface PurchaseOrderPayloadSchema { + /** The ID of counterpart address object stored in counterparts service. If not provided, counterpart's default address is used. */ + counterpart_address_id?: string; + /** Counterpart unique ID. */ + counterpart_id: string; + /** The currency in which the price of the product is set. (all items need to have the same currency) */ + currency: Monite.CurrencyEnum; + /** Entity VAT ID identifier that applied to purchase order */ + entity_vat_id_id?: string; + /** List of item to purchase */ + items: Monite.PurchaseOrderItem[]; + /** Msg which will be send to counterpart for who the purchase order is issued. */ + message: string; + /** Number of days for which purchase order is valid */ + valid_for_days: number; +} diff --git a/src/api/resources/purchaseOrders/client/requests/PurchaseOrdersGetRequest.ts b/src/api/resources/purchaseOrders/client/requests/PurchaseOrdersGetRequest.ts new file mode 100644 index 0000000..6a85a00 --- /dev/null +++ b/src/api/resources/purchaseOrders/client/requests/PurchaseOrdersGetRequest.ts @@ -0,0 +1,49 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface PurchaseOrdersGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.PurchaseOrderCursorFields; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + updated_at__gt?: string; + updated_at__lt?: string; + updated_at__gte?: string; + updated_at__lte?: string; + issued_at__gt?: string; + issued_at__lt?: string; + issued_at__gte?: string; + issued_at__lte?: string; + status?: Monite.PurchaseOrderStatusEnum; + document_id?: string; + document_id__in?: string | string[]; + created_by?: string; + counterpart_id?: string; + counterpart_id__in?: string | string[]; + "counterpart.name"?: string; + currency?: Monite.CurrencyEnum; + currency__in?: Monite.CurrencyEnum | Monite.CurrencyEnum[]; +} diff --git a/src/api/resources/purchaseOrders/client/requests/SendPurchaseOrderViaEmailRequest.ts b/src/api/resources/purchaseOrders/client/requests/SendPurchaseOrderViaEmailRequest.ts new file mode 100644 index 0000000..016cae2 --- /dev/null +++ b/src/api/resources/purchaseOrders/client/requests/SendPurchaseOrderViaEmailRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * body_text: "body_text", + * subject_text: "subject_text" + * } + */ +export interface SendPurchaseOrderViaEmailRequest { + body_text: string; + subject_text: string; +} diff --git a/src/api/resources/purchaseOrders/client/requests/UpdatePurchaseOrderPayloadSchema.ts b/src/api/resources/purchaseOrders/client/requests/UpdatePurchaseOrderPayloadSchema.ts new file mode 100644 index 0000000..d46af09 --- /dev/null +++ b/src/api/resources/purchaseOrders/client/requests/UpdatePurchaseOrderPayloadSchema.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface UpdatePurchaseOrderPayloadSchema { + /** The ID of counterpart address object stored in counterparts service. If not provided, counterpart's default address is used. */ + counterpart_address_id?: string; + /** Counterpart unique ID. */ + counterpart_id?: string; + /** Entity VAT ID identifier that applied to purchase order */ + entity_vat_id_id?: string; + /** List of item to purchase */ + items?: Monite.PurchaseOrderItem[]; + /** Msg which will be send to counterpart for who the purchase order is issued. */ + message?: string; + /** Number of days for which purchase order is valid */ + valid_for_days?: number; +} diff --git a/src/api/resources/purchaseOrders/client/requests/index.ts b/src/api/resources/purchaseOrders/client/requests/index.ts new file mode 100644 index 0000000..b38d4e1 --- /dev/null +++ b/src/api/resources/purchaseOrders/client/requests/index.ts @@ -0,0 +1,5 @@ +export { type PurchaseOrdersGetRequest } from "./PurchaseOrdersGetRequest"; +export { type PurchaseOrderPayloadSchema } from "./PurchaseOrderPayloadSchema"; +export { type UpdatePurchaseOrderPayloadSchema } from "./UpdatePurchaseOrderPayloadSchema"; +export { type PurchaseOrderEmailPreviewRequest } from "./PurchaseOrderEmailPreviewRequest"; +export { type SendPurchaseOrderViaEmailRequest } from "./SendPurchaseOrderViaEmailRequest"; diff --git a/src/api/resources/purchaseOrders/index.ts b/src/api/resources/purchaseOrders/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/purchaseOrders/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/receivables/client/Client.ts b/src/api/resources/receivables/client/Client.ts new file mode 100644 index 0000000..a51fdc8 --- /dev/null +++ b/src/api/resources/receivables/client/Client.ts @@ -0,0 +1,2553 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Receivables { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Receivables { + constructor(protected readonly _options: Receivables.Options) {} + + /** + * Returns a list of [accounts receivable](https://docs.monite.com/accounts-receivable/index) documents - invoices, quotes, and credit notes - of the specified entity. + * + * Results can be filtered by amount, counterpart, due date, and other criteria. Multiple filters are combined using logical AND unless specified otherwise. If no documents matching the search criteria are found, the endpoint returns a successful response with an empty `data` array. + * + * This endpoint supports [pagination](https://docs.monite.com/api/concepts/pagination-sorting-filtering) and sorting. By default, results are sorted by the creation date in ascending order (from oldest to newest). + * + * #### Examples + * + * ##### Invoices + * + * - Get all overdue invoices: + * + * ``` + * GET /receivables?type=invoice&status=overdue + * ``` + * + * - Get all invoices created for the counterpart named "Solarwind" (case-insensitive): + * + * ``` + * GET /receivables?type=invoice?counterpart_name__icontains=Solarwind + * ``` + * + * - Get invoices whose total amount starts from 500 EUR: + * + * ``` + * GET /receivables?type=invoice&total_amount__gte=50000 + * ``` + * + * - Get invoices that are due for payment in September 2024: + * + * ``` + * GET /receivables?type=invoice&due_date__gte=2024-09-01T00:00:00Z&due_date__lt=2024-10-01T00:00:00Z + * ``` + * + * - Get invoices created on or after September 1, 2024: + * + * ``` + * GET /receivables?type=invoice&created_at__gte=2024-09-01T00:00:00Z + * ``` + * + * - Find an invoice created from a specific quote: + * + * ``` + * GET /receivables?type=invoice?based_on=QUOTE_ID + * ``` + * + * ##### Quotes + * + * - Get the latest created quote: + * + * ``` + * GET /receivables?type=quote&sort=created_at&order=desc&limit=1 + * ``` + * + * - Get the latest issued quote: + * + * ``` + * GET /receivables?type=quote&sort=issue_date&order=desc&limit=1 + * ``` + * + * ##### Credit notes + * + * - Find all credit notes created for a specific invoice: + * + * ``` + * GET /receivables?type=credit_note?based_on=INVOICE_ID + * ``` + * + * @param {Monite.ReceivablesGetRequest} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.get() + */ + public async get( + request: Monite.ReceivablesGetRequest = {}, + requestOptions?: Receivables.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + id__in: idIn, + status__in: statusIn, + entity_user_id__in: entityUserIdIn, + sort, + tag_ids__in: tagIdsIn, + type: type_, + document_id: documentId, + document_id__contains: documentIdContains, + document_id__icontains: documentIdIcontains, + issue_date__gt: issueDateGt, + issue_date__lt: issueDateLt, + issue_date__gte: issueDateGte, + issue_date__lte: issueDateLte, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + counterpart_id: counterpartId, + counterpart_name: counterpartName, + counterpart_name__contains: counterpartNameContains, + counterpart_name__icontains: counterpartNameIcontains, + total_amount: totalAmount, + total_amount__gt: totalAmountGt, + total_amount__lt: totalAmountLt, + total_amount__gte: totalAmountGte, + total_amount__lte: totalAmountLte, + status, + entity_user_id: entityUserId, + based_on: basedOn, + due_date__gt: dueDateGt, + due_date__lt: dueDateLt, + due_date__gte: dueDateGte, + due_date__lte: dueDateLte, + project_id: projectId, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (statusIn != null) { + if (Array.isArray(statusIn)) { + _queryParams["status__in"] = statusIn.map((item) => item); + } else { + _queryParams["status__in"] = statusIn; + } + } + + if (entityUserIdIn != null) { + if (Array.isArray(entityUserIdIn)) { + _queryParams["entity_user_id__in"] = entityUserIdIn.map((item) => item); + } else { + _queryParams["entity_user_id__in"] = entityUserIdIn; + } + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (tagIdsIn != null) { + if (Array.isArray(tagIdsIn)) { + _queryParams["tag_ids__in"] = tagIdsIn.map((item) => item); + } else { + _queryParams["tag_ids__in"] = tagIdsIn; + } + } + + if (type_ != null) { + _queryParams["type"] = type_; + } + + if (documentId != null) { + _queryParams["document_id"] = documentId; + } + + if (documentIdContains != null) { + _queryParams["document_id__contains"] = documentIdContains; + } + + if (documentIdIcontains != null) { + _queryParams["document_id__icontains"] = documentIdIcontains; + } + + if (issueDateGt != null) { + _queryParams["issue_date__gt"] = issueDateGt; + } + + if (issueDateLt != null) { + _queryParams["issue_date__lt"] = issueDateLt; + } + + if (issueDateGte != null) { + _queryParams["issue_date__gte"] = issueDateGte; + } + + if (issueDateLte != null) { + _queryParams["issue_date__lte"] = issueDateLte; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + if (counterpartId != null) { + _queryParams["counterpart_id"] = counterpartId; + } + + if (counterpartName != null) { + _queryParams["counterpart_name"] = counterpartName; + } + + if (counterpartNameContains != null) { + _queryParams["counterpart_name__contains"] = counterpartNameContains; + } + + if (counterpartNameIcontains != null) { + _queryParams["counterpart_name__icontains"] = counterpartNameIcontains; + } + + if (totalAmount != null) { + _queryParams["total_amount"] = totalAmount.toString(); + } + + if (totalAmountGt != null) { + _queryParams["total_amount__gt"] = totalAmountGt.toString(); + } + + if (totalAmountLt != null) { + _queryParams["total_amount__lt"] = totalAmountLt.toString(); + } + + if (totalAmountGte != null) { + _queryParams["total_amount__gte"] = totalAmountGte.toString(); + } + + if (totalAmountLte != null) { + _queryParams["total_amount__lte"] = totalAmountLte.toString(); + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (entityUserId != null) { + _queryParams["entity_user_id"] = entityUserId; + } + + if (basedOn != null) { + _queryParams["based_on"] = basedOn; + } + + if (dueDateGt != null) { + _queryParams["due_date__gt"] = dueDateGt; + } + + if (dueDateLt != null) { + _queryParams["due_date__lt"] = dueDateLt; + } + + if (dueDateGte != null) { + _queryParams["due_date__gte"] = dueDateGte; + } + + if (dueDateLte != null) { + _queryParams["due_date__lte"] = dueDateLte; + } + + if (projectId != null) { + _queryParams["project_id"] = projectId; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "receivables" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivablePaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.ReceivableFacadeCreatePayload} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.create({ + * counterpart_billing_address_id: "counterpart_billing_address_id", + * counterpart_id: "counterpart_id", + * currency: "AED", + * line_items: [{ + * quantity: 1.1 + * }], + * type: "quote" + * }) + */ + public async create( + request: Monite.ReceivableFacadeCreatePayload, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "receivables" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get a list of placeholders that can be used in email templates for customization. + * + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.getVariables() + */ + public async getVariables( + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "receivables/variables" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableTemplatesVariablesObjectList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.getById("receivable_id") + */ + public async getById( + receivableId: string, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.deleteById("receivable_id") + */ + public async deleteById(receivableId: string, requestOptions?: Receivables.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivableUpdatePayload} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.updateById("receivable_id", { + * quote: {} + * }) + */ + public async updateById( + receivableId: string, + request: Monite.ReceivableUpdatePayload, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.QuoteAcceptRequest} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.acceptById("receivable_id") + */ + public async acceptById( + receivableId: string, + request: Monite.QuoteAcceptRequest = {}, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/accept` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.SuccessResult; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.cancelById("receivable_id") + */ + public async cancelById(receivableId: string, requestOptions?: Receivables.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/cancel` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.cloneById("receivable_id") + */ + public async cloneById( + receivableId: string, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/clone` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivableDeclinePayload} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.declineById("receivable_id") + */ + public async declineById( + receivableId: string, + request: Monite.ReceivableDeclinePayload = {}, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/decline` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.SuccessResult; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivablesGetHistoryRequest} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.getHistory("receivable_id") + */ + public async getHistory( + receivableId: string, + request: Monite.ReceivablesGetHistoryRequest = {}, + requestOptions?: Receivables.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + event_type__in: eventTypeIn, + entity_user_id__in: entityUserIdIn, + timestamp__gt: timestampGt, + timestamp__lt: timestampLt, + timestamp__gte: timestampGte, + timestamp__lte: timestampLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (eventTypeIn != null) { + if (Array.isArray(eventTypeIn)) { + _queryParams["event_type__in"] = eventTypeIn.map((item) => item); + } else { + _queryParams["event_type__in"] = eventTypeIn; + } + } + + if (entityUserIdIn != null) { + if (Array.isArray(entityUserIdIn)) { + _queryParams["entity_user_id__in"] = entityUserIdIn.map((item) => item); + } else { + _queryParams["entity_user_id__in"] = entityUserIdIn; + } + } + + if (timestampGt != null) { + _queryParams["timestamp__gt"] = timestampGt; + } + + if (timestampLt != null) { + _queryParams["timestamp__lt"] = timestampLt; + } + + if (timestampGte != null) { + _queryParams["timestamp__gte"] = timestampGte; + } + + if (timestampLte != null) { + _queryParams["timestamp__lte"] = timestampLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/history` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableHistoryPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableHistoryId + * @param {string} receivableId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.getHistoryById("receivable_history_id", "receivable_id") + */ + public async getHistoryById( + receivableHistoryId: string, + receivableId: string, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/history/${encodeURIComponent(receivableHistoryId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableHistoryResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.issueById("receivable_id") + */ + public async issueById( + receivableId: string, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/issue` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Replace all line items of an existing invoice or quote with a new list of line items. + * + * @param {string} receivableId + * @param {Monite.UpdateLineItems} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.updateLineItemsById("receivable_id", { + * data: [{ + * quantity: 1.1 + * }] + * }) + */ + public async updateLineItemsById( + receivableId: string, + request: Monite.UpdateLineItems, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/line_items` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.LineItemsResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivablesGetMailsRequest} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.getMails("receivable_id") + */ + public async getMails( + receivableId: string, + request: Monite.ReceivablesGetMailsRequest = {}, + requestOptions?: Receivables.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + status, + status__in: statusIn, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (statusIn != null) { + if (Array.isArray(statusIn)) { + _queryParams["status__in"] = statusIn.map((item) => item); + } else { + _queryParams["status__in"] = statusIn; + } + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/mails` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableMailPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {string} mailId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.getMailById("receivable_id", "mail_id") + */ + public async getMailById( + receivableId: string, + mailId: string, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/mails/${encodeURIComponent(mailId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableMailResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivablePaidPayload} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.markAsPaidById("receivable_id") + */ + public async markAsPaidById( + receivableId: string, + request: Monite.ReceivablePaidPayload = {}, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/mark_as_paid` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Deprecated. Use `POST /payment_records` to record an invoice payment. + * + * @param {string} receivableId + * @param {Monite.ReceivablePartiallyPaidPayload} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.markAsPartiallyPaidById("receivable_id", { + * amount_paid: 1 + * }) + */ + public async markAsPartiallyPaidById( + receivableId: string, + request: Monite.ReceivablePartiallyPaidPayload, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/mark_as_partially_paid` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivableUncollectiblePayload} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.markAsUncollectibleById("receivable_id") + */ + public async markAsUncollectibleById( + receivableId: string, + request: Monite.ReceivableUncollectiblePayload = {}, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/mark_as_uncollectible` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.getPdfLinkById("receivable_id") + */ + public async getPdfLinkById( + receivableId: string, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/pdf_link` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableFileUrl; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivablePreviewRequest} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.previewById("receivable_id", { + * body_text: "body_text", + * subject_text: "subject_text" + * }) + */ + public async previewById( + receivableId: string, + request: Monite.ReceivablePreviewRequest, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/preview` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivablePreviewResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivableSendRequest} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.sendById("receivable_id", { + * body_text: "body_text", + * subject_text: "subject_text" + * }) + */ + public async sendById( + receivableId: string, + request: Monite.ReceivableSendRequest, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/send` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivableSendResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Monite.ReceivableSendTestReminderPayload} request + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.sendTestReminderById("receivable_id", { + * reminder_type: "term_1" + * }) + */ + public async sendTestReminderById( + receivableId: string, + request: Monite.ReceivableSendTestReminderPayload, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/send_test_reminder` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivablesSendResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} receivableId + * @param {Receivables.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.receivables.verifyById("receivable_id") + */ + public async verifyById( + receivableId: string, + requestOptions?: Receivables.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `receivables/${encodeURIComponent(receivableId)}/verify` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.ReceivablesVerifyResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/receivables/client/index.ts b/src/api/resources/receivables/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/receivables/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/receivables/client/requests/QuoteAcceptRequest.ts b/src/api/resources/receivables/client/requests/QuoteAcceptRequest.ts new file mode 100644 index 0000000..108cb57 --- /dev/null +++ b/src/api/resources/receivables/client/requests/QuoteAcceptRequest.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface QuoteAcceptRequest { + /** A digital signature, if required for quote acceptance */ + signature?: Monite.Signature; +} diff --git a/src/api/resources/receivables/client/requests/ReceivableDeclinePayload.ts b/src/api/resources/receivables/client/requests/ReceivableDeclinePayload.ts new file mode 100644 index 0000000..9518d66 --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivableDeclinePayload.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface ReceivableDeclinePayload { + /** Field with a comment on why the client declined this Quote */ + comment?: string; +} diff --git a/src/api/resources/receivables/client/requests/ReceivablePaidPayload.ts b/src/api/resources/receivables/client/requests/ReceivablePaidPayload.ts new file mode 100644 index 0000000..44ca004 --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivablePaidPayload.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface ReceivablePaidPayload { + /** Optional comment explaining how the payment was made. */ + comment?: string; + /** Date and time when the invoice was paid. */ + paid_at?: string; +} diff --git a/src/api/resources/receivables/client/requests/ReceivablePartiallyPaidPayload.ts b/src/api/resources/receivables/client/requests/ReceivablePartiallyPaidPayload.ts new file mode 100644 index 0000000..bc6016c --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivablePartiallyPaidPayload.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * amount_paid: 1 + * } + */ +export interface ReceivablePartiallyPaidPayload { + /** How much has been paid on the invoice (in minor units). */ + amount_paid: number; + /** Optional comment explaining how the payment was made. */ + comment?: string; +} diff --git a/src/api/resources/receivables/client/requests/ReceivablePreviewRequest.ts b/src/api/resources/receivables/client/requests/ReceivablePreviewRequest.ts new file mode 100644 index 0000000..ca7b7d5 --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivablePreviewRequest.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * body_text: "body_text", + * subject_text: "subject_text" + * } + */ +export interface ReceivablePreviewRequest { + /** Body text of the content */ + body_text: string; + /** Language code for localization purposes */ + language?: Monite.LanguageCodeEnum; + /** Subject text of the content */ + subject_text: string; + /** The type of the preview document. */ + type?: Monite.ReceivablesPreviewTypeEnum; +} diff --git a/src/api/resources/receivables/client/requests/ReceivableSendRequest.ts b/src/api/resources/receivables/client/requests/ReceivableSendRequest.ts new file mode 100644 index 0000000..236302b --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivableSendRequest.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * body_text: "body_text", + * subject_text: "subject_text" + * } + */ +export interface ReceivableSendRequest { + /** Body text of the content */ + body_text: string; + /** Lowercase ISO code of language */ + language?: string; + recipients?: Monite.Recipients; + /** Subject text of the content */ + subject_text: string; +} diff --git a/src/api/resources/receivables/client/requests/ReceivableSendTestReminderPayload.ts b/src/api/resources/receivables/client/requests/ReceivableSendTestReminderPayload.ts new file mode 100644 index 0000000..8c29b4c --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivableSendTestReminderPayload.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * reminder_type: "term_1" + * } + */ +export interface ReceivableSendTestReminderPayload { + recipients?: Monite.Recipients; + /** The type of the reminder to be sent. */ + reminder_type: Monite.ReminderTypeEnum; +} diff --git a/src/api/resources/receivables/client/requests/ReceivableUncollectiblePayload.ts b/src/api/resources/receivables/client/requests/ReceivableUncollectiblePayload.ts new file mode 100644 index 0000000..6dad40a --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivableUncollectiblePayload.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface ReceivableUncollectiblePayload { + /** Optional comment explains why the Invoice goes uncollectible. */ + comment?: string; +} diff --git a/src/api/resources/receivables/client/requests/ReceivablesGetHistoryRequest.ts b/src/api/resources/receivables/client/requests/ReceivablesGetHistoryRequest.ts new file mode 100644 index 0000000..700ebf1 --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivablesGetHistoryRequest.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ReceivablesGetHistoryRequest { + /** + * Order by + */ + order?: Monite.OrderEnum3; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.ReceivableHistoryCursorFields; + event_type__in?: Monite.ReceivableHistoryEventTypeEnum | Monite.ReceivableHistoryEventTypeEnum[]; + entity_user_id__in?: string | string[]; + timestamp__gt?: string; + timestamp__lt?: string; + timestamp__gte?: string; + timestamp__lte?: string; +} diff --git a/src/api/resources/receivables/client/requests/ReceivablesGetMailsRequest.ts b/src/api/resources/receivables/client/requests/ReceivablesGetMailsRequest.ts new file mode 100644 index 0000000..a3ad05a --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivablesGetMailsRequest.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ReceivablesGetMailsRequest { + /** + * Order by + */ + order?: Monite.OrderEnum3; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.ReceivableMailCursorFields; + status?: Monite.ReceivableMailStatusEnum; + status__in?: Monite.ReceivableMailStatusEnum | Monite.ReceivableMailStatusEnum[]; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; +} diff --git a/src/api/resources/receivables/client/requests/ReceivablesGetRequest.ts b/src/api/resources/receivables/client/requests/ReceivablesGetRequest.ts new file mode 100644 index 0000000..eee2a0b --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivablesGetRequest.ts @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface ReceivablesGetRequest { + /** + * Sort order (ascending by default). Typically used together with the `sort` parameter. + */ + order?: Monite.OrderEnum2; + /** + * The number of items (0 .. 100) to return in a single page of the response. The response may contain fewer items if it is the last or only page. + * + * When using pagination with a non-default `limit`, you must provide the `limit` value alongside `pagination_token` in all subsequent pagination requests. Unlike other query parameters, `limit` is not inferred from `pagination_token`. + */ + limit?: number; + /** + * A pagination token obtained from a previous call to this endpoint. Use it to get the next or previous page of results for your initial query. If `pagination_token` is specified, all other query parameters except `limit` are ignored and inferred from the initial query. + * + * If not specified, the first page of results will be returned. + */ + pagination_token?: string; + /** + * Return only receivables with the specified IDs. Valid but nonexistent IDs do not raise errors but produce no results. + * + * To specify multiple IDs, repeat this parameter for each value: + * `id__in=&id__in=` + */ + id__in?: string | string[]; + /** + * Return only receivables that have the specified statuses. See the applicable [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and [credit note statuses](https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). + * + * To specify multiple statuses, repeat this parameter for each value: + * `status__in=draft&status__in=issued` + */ + status__in?: Monite.ReceivablesGetRequestStatusInItem | Monite.ReceivablesGetRequestStatusInItem[]; + /** + * Return only receivables created by the entity users with the specified IDs.To specify multiple user IDs, repeat this parameter for each ID: + * `entity_user_id__in=&entity_user_id__in=` + * + * If the request is authenticated using an entity user token, this user must have the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be able to query receivables created by other users. + * + * IDs of deleted users will still produce results here if those users had associated receivables. Valid but nonexistent user IDs do not raise errors but produce no results. + */ + entity_user_id__in?: string | string[]; + /** + * The field to sort the results by. Typically used together with the `order` parameter. + */ + sort?: Monite.ReceivableCursorFields; + /** + * Return only receivables whose [tags](https://docs.monite.com/common/tags) include at least one of the tags with the specified IDs. + * + * For example, given receivables with the following tags: + * + * 1. tagA + * 2. tagB + * 3. tagA, tagB + * 4. tagC + * 5. tagB, tagC + * + * `tag_ids__in=&tag_ids__in=` will return receivables 1, 2, 3, and 5. + * + * Valid but nonexistent tag IDs do not raise errors but produce no results. + */ + tag_ids__in?: string | string[]; + type?: Monite.ReceivableType; + document_id?: string; + document_id__contains?: string; + document_id__icontains?: string; + issue_date__gt?: string; + issue_date__lt?: string; + issue_date__gte?: string; + issue_date__lte?: string; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; + counterpart_id?: string; + counterpart_name?: string; + counterpart_name__contains?: string; + counterpart_name__icontains?: string; + total_amount?: number; + total_amount__gt?: number; + total_amount__lt?: number; + total_amount__gte?: number; + total_amount__lte?: number; + status?: Monite.ReceivablesGetRequestStatus; + entity_user_id?: string; + based_on?: string; + due_date__gt?: string; + due_date__lt?: string; + due_date__gte?: string; + due_date__lte?: string; + project_id?: string; +} diff --git a/src/api/resources/receivables/client/requests/UpdateLineItems.ts b/src/api/resources/receivables/client/requests/UpdateLineItems.ts new file mode 100644 index 0000000..4051ca2 --- /dev/null +++ b/src/api/resources/receivables/client/requests/UpdateLineItems.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * data: [{ + * quantity: 1.1 + * }] + * } + */ +export interface UpdateLineItems { + data: Monite.LineItem[]; +} diff --git a/src/api/resources/receivables/client/requests/index.ts b/src/api/resources/receivables/client/requests/index.ts new file mode 100644 index 0000000..37ffd6e --- /dev/null +++ b/src/api/resources/receivables/client/requests/index.ts @@ -0,0 +1,12 @@ +export { type ReceivablesGetRequest } from "./ReceivablesGetRequest"; +export { type QuoteAcceptRequest } from "./QuoteAcceptRequest"; +export { type ReceivableDeclinePayload } from "./ReceivableDeclinePayload"; +export { type ReceivablesGetHistoryRequest } from "./ReceivablesGetHistoryRequest"; +export { type UpdateLineItems } from "./UpdateLineItems"; +export { type ReceivablesGetMailsRequest } from "./ReceivablesGetMailsRequest"; +export { type ReceivablePaidPayload } from "./ReceivablePaidPayload"; +export { type ReceivablePartiallyPaidPayload } from "./ReceivablePartiallyPaidPayload"; +export { type ReceivableUncollectiblePayload } from "./ReceivableUncollectiblePayload"; +export { type ReceivablePreviewRequest } from "./ReceivablePreviewRequest"; +export { type ReceivableSendRequest } from "./ReceivableSendRequest"; +export { type ReceivableSendTestReminderPayload } from "./ReceivableSendTestReminderPayload"; diff --git a/src/api/resources/receivables/index.ts b/src/api/resources/receivables/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/receivables/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/receivables/types/ReceivablesGetRequestStatus.ts b/src/api/resources/receivables/types/ReceivablesGetRequestStatus.ts new file mode 100644 index 0000000..2006ac2 --- /dev/null +++ b/src/api/resources/receivables/types/ReceivablesGetRequestStatus.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivablesGetRequestStatus = + | "draft" + | "issued" + | "accepted" + | "expired" + | "declined" + | "recurring" + | "partially_paid" + | "paid" + | "overdue" + | "uncollectible" + | "canceled"; + +export const ReceivablesGetRequestStatus = { + Draft: "draft", + Issued: "issued", + Accepted: "accepted", + Expired: "expired", + Declined: "declined", + Recurring: "recurring", + PartiallyPaid: "partially_paid", + Paid: "paid", + Overdue: "overdue", + Uncollectible: "uncollectible", + Canceled: "canceled", +} as const; diff --git a/src/api/resources/receivables/types/ReceivablesGetRequestStatusInItem.ts b/src/api/resources/receivables/types/ReceivablesGetRequestStatusInItem.ts new file mode 100644 index 0000000..132c330 --- /dev/null +++ b/src/api/resources/receivables/types/ReceivablesGetRequestStatusInItem.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivablesGetRequestStatusInItem = + | "draft" + | "issued" + | "accepted" + | "expired" + | "declined" + | "recurring" + | "partially_paid" + | "paid" + | "overdue" + | "uncollectible" + | "canceled"; + +export const ReceivablesGetRequestStatusInItem = { + Draft: "draft", + Issued: "issued", + Accepted: "accepted", + Expired: "expired", + Declined: "declined", + Recurring: "recurring", + PartiallyPaid: "partially_paid", + Paid: "paid", + Overdue: "overdue", + Uncollectible: "uncollectible", + Canceled: "canceled", +} as const; diff --git a/src/api/resources/receivables/types/index.ts b/src/api/resources/receivables/types/index.ts new file mode 100644 index 0000000..8522221 --- /dev/null +++ b/src/api/resources/receivables/types/index.ts @@ -0,0 +1,2 @@ +export * from "./ReceivablesGetRequestStatusInItem"; +export * from "./ReceivablesGetRequestStatus"; diff --git a/src/api/resources/recurrences/client/Client.ts b/src/api/resources/recurrences/client/Client.ts new file mode 100644 index 0000000..5c5b36c --- /dev/null +++ b/src/api/resources/recurrences/client/Client.ts @@ -0,0 +1,474 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Recurrences { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Recurrences { + constructor(protected readonly _options: Recurrences.Options) {} + + /** + * @param {Recurrences.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.recurrences.get() + */ + public async get(requestOptions?: Recurrences.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "recurrences" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.GetAllRecurrences; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.CreateRecurrencePayload} request + * @param {Recurrences.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.recurrences.create({ + * day_of_month: "first_day", + * end_month: 1, + * end_year: 1, + * invoice_id: "invoice_id", + * start_month: 1, + * start_year: 1 + * }) + */ + public async create( + request: Monite.CreateRecurrencePayload, + requestOptions?: Recurrences.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "recurrences" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.Recurrence; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} recurrenceId + * @param {Recurrences.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.recurrences.getById("recurrence_id") + */ + public async getById( + recurrenceId: string, + requestOptions?: Recurrences.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `recurrences/${encodeURIComponent(recurrenceId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.Recurrence; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} recurrenceId + * @param {Monite.UpdateRecurrencePayload} request + * @param {Recurrences.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.recurrences.updateById("recurrence_id") + */ + public async updateById( + recurrenceId: string, + request: Monite.UpdateRecurrencePayload = {}, + requestOptions?: Recurrences.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `recurrences/${encodeURIComponent(recurrenceId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.Recurrence; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} recurrenceId + * @param {Recurrences.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.ConflictError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.recurrences.cancelById("recurrence_id") + */ + public async cancelById(recurrenceId: string, requestOptions?: Recurrences.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `recurrences/${encodeURIComponent(recurrenceId)}/cancel` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/recurrences/client/index.ts b/src/api/resources/recurrences/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/recurrences/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/recurrences/client/requests/CreateRecurrencePayload.ts b/src/api/resources/recurrences/client/requests/CreateRecurrencePayload.ts new file mode 100644 index 0000000..2d75e52 --- /dev/null +++ b/src/api/resources/recurrences/client/requests/CreateRecurrencePayload.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * day_of_month: "first_day", + * end_month: 1, + * end_year: 1, + * invoice_id: "invoice_id", + * start_month: 1, + * start_year: 1 + * } + */ +export interface CreateRecurrencePayload { + day_of_month: Monite.DayOfMonth; + end_month: number; + end_year: number; + invoice_id: string; + start_month: number; + start_year: number; +} diff --git a/src/api/resources/recurrences/client/requests/UpdateRecurrencePayload.ts b/src/api/resources/recurrences/client/requests/UpdateRecurrencePayload.ts new file mode 100644 index 0000000..8a36d2b --- /dev/null +++ b/src/api/resources/recurrences/client/requests/UpdateRecurrencePayload.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface UpdateRecurrencePayload { + day_of_month?: Monite.DayOfMonth; + end_month?: number; + end_year?: number; +} diff --git a/src/api/resources/recurrences/client/requests/index.ts b/src/api/resources/recurrences/client/requests/index.ts new file mode 100644 index 0000000..5d38bf5 --- /dev/null +++ b/src/api/resources/recurrences/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type CreateRecurrencePayload } from "./CreateRecurrencePayload"; +export { type UpdateRecurrencePayload } from "./UpdateRecurrencePayload"; diff --git a/src/api/resources/recurrences/index.ts b/src/api/resources/recurrences/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/recurrences/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/roles/client/Client.ts b/src/api/resources/roles/client/Client.ts new file mode 100644 index 0000000..5c3d87a --- /dev/null +++ b/src/api/resources/roles/client/Client.ts @@ -0,0 +1,429 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Roles { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Roles { + constructor(protected readonly _options: Roles.Options) {} + + /** + * Find all roles that match the search criteria. + * + * @param {Monite.RolesGetRequest} request + * @param {Roles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.roles.get() + */ + public async get( + request: Monite.RolesGetRequest = {}, + requestOptions?: Roles.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + id__in: idIn, + name, + created_at: createdAt, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + if (name != null) { + _queryParams["name"] = name; + } + + if (createdAt != null) { + _queryParams["created_at"] = createdAt; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "roles" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.RolePaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a new role from the specified values. + * + * @param {Monite.CreateRoleRequest} request + * @param {Roles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.roles.create({ + * name: "name", + * permissions: {} + * }) + */ + public async create( + request: Monite.CreateRoleRequest, + requestOptions?: Roles.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "roles" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.RoleResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} roleId + * @param {Roles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.roles.getById("role_id") + */ + public async getById(roleId: string, requestOptions?: Roles.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `roles/${encodeURIComponent(roleId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.RoleResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Change the specified fields with the provided values. + * + * @param {string} roleId + * @param {Monite.UpdateRoleRequest} request + * @param {Roles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.roles.updateById("role_id") + */ + public async updateById( + roleId: string, + request: Monite.UpdateRoleRequest = {}, + requestOptions?: Roles.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `roles/${encodeURIComponent(roleId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.RoleResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/roles/client/index.ts b/src/api/resources/roles/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/roles/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/roles/client/requests/CreateRoleRequest.ts b/src/api/resources/roles/client/requests/CreateRoleRequest.ts new file mode 100644 index 0000000..879555d --- /dev/null +++ b/src/api/resources/roles/client/requests/CreateRoleRequest.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * name: "name", + * permissions: {} + * } + */ +export interface CreateRoleRequest { + /** Role name */ + name: string; + /** Access permissions */ + permissions: Monite.BizObjectsSchema; +} diff --git a/src/api/resources/roles/client/requests/RolesGetRequest.ts b/src/api/resources/roles/client/requests/RolesGetRequest.ts new file mode 100644 index 0000000..984fd77 --- /dev/null +++ b/src/api/resources/roles/client/requests/RolesGetRequest.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface RolesGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.RoleCursorFields; + id__in?: string | string[]; + name?: string; + created_at?: string; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; +} diff --git a/src/api/resources/roles/client/requests/UpdateRoleRequest.ts b/src/api/resources/roles/client/requests/UpdateRoleRequest.ts new file mode 100644 index 0000000..92a7ef4 --- /dev/null +++ b/src/api/resources/roles/client/requests/UpdateRoleRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface UpdateRoleRequest { + /** Role name */ + name?: string; + /** Access permissions */ + permissions?: Monite.BizObjectsSchema; +} diff --git a/src/api/resources/roles/client/requests/index.ts b/src/api/resources/roles/client/requests/index.ts new file mode 100644 index 0000000..2226656 --- /dev/null +++ b/src/api/resources/roles/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type RolesGetRequest } from "./RolesGetRequest"; +export { type CreateRoleRequest } from "./CreateRoleRequest"; +export { type UpdateRoleRequest } from "./UpdateRoleRequest"; diff --git a/src/api/resources/roles/index.ts b/src/api/resources/roles/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/roles/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/tags/client/Client.ts b/src/api/resources/tags/client/Client.ts new file mode 100644 index 0000000..32577f2 --- /dev/null +++ b/src/api/resources/tags/client/Client.ts @@ -0,0 +1,539 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Tags { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class Tags { + constructor(protected readonly _options: Tags.Options) {} + + /** + * Get a list of all tags. Tags can be assigned to resources to assist with searching and filtering. + * Tags can also be used as trigger conditions in payable approval policies. + * + * @param {Monite.TagsGetRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.tags.get() + */ + public async get( + request: Monite.TagsGetRequest = {}, + requestOptions?: Tags.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + created_by_entity_user_id: createdByEntityUserId, + name__in: nameIn, + id__in: idIn, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (createdByEntityUserId != null) { + _queryParams["created_by_entity_user_id"] = createdByEntityUserId; + } + + if (nameIn != null) { + if (Array.isArray(nameIn)) { + _queryParams["name__in"] = nameIn.map((item) => item); + } else { + _queryParams["name__in"] = nameIn; + } + } + + if (idIn != null) { + if (Array.isArray(idIn)) { + _queryParams["id__in"] = idIn.map((item) => item); + } else { + _queryParams["id__in"] = idIn; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "tags" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TagsPaginationResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a new tag. The tag name must be unique. + * Tag names are case-sensitive, that is `Marketing` and `marketing` are two different tags. + * + * The response returns an auto-generated ID assigned to this tag. + * To assign this tag to a resource, send the tag ID in the `tag_ids` list when creating or updating a resource. + * + * @param {Monite.TagCreateSchema} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.tags.create({ + * name: "Marketing" + * }) + */ + public async create( + request: Monite.TagCreateSchema, + requestOptions?: Tags.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "tags" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TagReadSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get information about a tag with the given ID. + * + * @param {string} tagId + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.tags.getById("tag_id") + */ + public async getById(tagId: string, requestOptions?: Tags.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `tags/${encodeURIComponent(tagId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TagReadSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete a tag with the given ID. This tag will be automatically deleted from all resources where it was used. + * + * @param {string} tagId + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.tags.deleteById("tag_id") + */ + public async deleteById(tagId: string, requestOptions?: Tags.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `tags/${encodeURIComponent(tagId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Change the tag name. The new name must be unique among existing tags. + * Tag names are case-sensitive, that is `Marketing` and `marketing` are two different tags. + * + * @param {string} tagId + * @param {Monite.TagUpdateSchema} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.NotAcceptableError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.tags.updateById("tag_id") + */ + public async updateById( + tagId: string, + request: Monite.TagUpdateSchema = {}, + requestOptions?: Tags.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `tags/${encodeURIComponent(tagId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TagReadSchema; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/tags/client/index.ts b/src/api/resources/tags/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/tags/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/tags/client/requests/TagCreateSchema.ts b/src/api/resources/tags/client/requests/TagCreateSchema.ts new file mode 100644 index 0000000..7431b1d --- /dev/null +++ b/src/api/resources/tags/client/requests/TagCreateSchema.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * name: "Marketing" + * } + */ +export interface TagCreateSchema { + /** The tag category. */ + category?: Monite.TagCategory; + /** The tag description. */ + description?: string; + /** The tag name. Must be unique. */ + name: string; +} diff --git a/src/api/resources/tags/client/requests/TagUpdateSchema.ts b/src/api/resources/tags/client/requests/TagUpdateSchema.ts new file mode 100644 index 0000000..47e0dcd --- /dev/null +++ b/src/api/resources/tags/client/requests/TagUpdateSchema.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface TagUpdateSchema { + /** The tag category. */ + category?: Monite.TagCategory; + /** The tag description. */ + description?: string; + /** The tag name. Must be unique. */ + name?: string; +} diff --git a/src/api/resources/tags/client/requests/TagsGetRequest.ts b/src/api/resources/tags/client/requests/TagsGetRequest.ts new file mode 100644 index 0000000..3780d2d --- /dev/null +++ b/src/api/resources/tags/client/requests/TagsGetRequest.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface TagsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.TagCursorFields; + created_by_entity_user_id?: string; + name__in?: string | string[]; + id__in?: string | string[]; +} diff --git a/src/api/resources/tags/client/requests/index.ts b/src/api/resources/tags/client/requests/index.ts new file mode 100644 index 0000000..5fc8dfa --- /dev/null +++ b/src/api/resources/tags/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type TagsGetRequest } from "./TagsGetRequest"; +export { type TagCreateSchema } from "./TagCreateSchema"; +export { type TagUpdateSchema } from "./TagUpdateSchema"; diff --git a/src/api/resources/tags/index.ts b/src/api/resources/tags/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/tags/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/textTemplates/client/Client.ts b/src/api/resources/textTemplates/client/Client.ts new file mode 100644 index 0000000..68467a4 --- /dev/null +++ b/src/api/resources/textTemplates/client/Client.ts @@ -0,0 +1,512 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace TextTemplates { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class TextTemplates { + constructor(protected readonly _options: TextTemplates.Options) {} + + /** + * Get text templates + * + * @param {Monite.TextTemplatesGetRequest} request + * @param {TextTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.textTemplates.get() + */ + public async get( + request: Monite.TextTemplatesGetRequest = {}, + requestOptions?: TextTemplates.RequestOptions + ): Promise { + const { type: type_, document_type: documentType, is_default: isDefault } = request; + const _queryParams: Record = {}; + if (type_ != null) { + _queryParams["type"] = type_; + } + + if (documentType != null) { + _queryParams["document_type"] = documentType; + } + + if (isDefault != null) { + _queryParams["is_default"] = isDefault.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "text_templates" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TextTemplateResponseList; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a text template + * + * @param {Monite.CreateTextTemplatePayload} request + * @param {TextTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.textTemplates.create({ + * document_type: "quote", + * name: "name", + * template: "template", + * type: "email_header" + * }) + */ + public async create( + request: Monite.CreateTextTemplatePayload, + requestOptions?: TextTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "text_templates" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TextTemplateResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get all custom contents + * + * @param {string} textTemplateId + * @param {TextTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.textTemplates.getById("text_template_id") + */ + public async getById( + textTemplateId: string, + requestOptions?: TextTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `text_templates/${encodeURIComponent(textTemplateId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TextTemplateResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete custom content by ID + * + * @param {string} textTemplateId - UUID text_template ID + * @param {TextTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.textTemplates.deleteById("text_template_id") + */ + public async deleteById(textTemplateId: string, requestOptions?: TextTemplates.RequestOptions): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `text_templates/${encodeURIComponent(textTemplateId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update custom content by ID + * + * @param {string} textTemplateId - UUID text_template ID + * @param {Monite.UpdateTextTemplatePayload} request + * @param {TextTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.textTemplates.updateById("text_template_id") + */ + public async updateById( + textTemplateId: string, + request: Monite.UpdateTextTemplatePayload = {}, + requestOptions?: TextTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `text_templates/${encodeURIComponent(textTemplateId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TextTemplateResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Make text template default + * + * @param {string} textTemplateId - UUID text_template ID + * @param {TextTemplates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.textTemplates.makeDefaultById("text_template_id") + */ + public async makeDefaultById( + textTemplateId: string, + requestOptions?: TextTemplates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `text_templates/${encodeURIComponent(textTemplateId)}/make_default` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.TextTemplateResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/textTemplates/client/index.ts b/src/api/resources/textTemplates/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/textTemplates/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/textTemplates/client/requests/CreateTextTemplatePayload.ts b/src/api/resources/textTemplates/client/requests/CreateTextTemplatePayload.ts new file mode 100644 index 0000000..d0e6e28 --- /dev/null +++ b/src/api/resources/textTemplates/client/requests/CreateTextTemplatePayload.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * document_type: "quote", + * name: "name", + * template: "template", + * type: "email_header" + * } + */ +export interface CreateTextTemplatePayload { + document_type: Monite.DocumentTypeEnum; + name: string; + template: string; + type: Monite.TextTemplateType; +} diff --git a/src/api/resources/textTemplates/client/requests/TextTemplatesGetRequest.ts b/src/api/resources/textTemplates/client/requests/TextTemplatesGetRequest.ts new file mode 100644 index 0000000..927cd93 --- /dev/null +++ b/src/api/resources/textTemplates/client/requests/TextTemplatesGetRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface TextTemplatesGetRequest { + type?: Monite.TextTemplateType; + document_type?: Monite.DocumentTypeEnum; + is_default?: boolean; +} diff --git a/src/api/resources/textTemplates/client/requests/UpdateTextTemplatePayload.ts b/src/api/resources/textTemplates/client/requests/UpdateTextTemplatePayload.ts new file mode 100644 index 0000000..520c3ba --- /dev/null +++ b/src/api/resources/textTemplates/client/requests/UpdateTextTemplatePayload.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface UpdateTextTemplatePayload { + name?: string; + template?: string; +} diff --git a/src/api/resources/textTemplates/client/requests/index.ts b/src/api/resources/textTemplates/client/requests/index.ts new file mode 100644 index 0000000..e61936b --- /dev/null +++ b/src/api/resources/textTemplates/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type TextTemplatesGetRequest } from "./TextTemplatesGetRequest"; +export { type CreateTextTemplatePayload } from "./CreateTextTemplatePayload"; +export { type UpdateTextTemplatePayload } from "./UpdateTextTemplatePayload"; diff --git a/src/api/resources/textTemplates/index.ts b/src/api/resources/textTemplates/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/textTemplates/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/vatRates/client/Client.ts b/src/api/resources/vatRates/client/Client.ts new file mode 100644 index 0000000..9f2dcb8 --- /dev/null +++ b/src/api/resources/vatRates/client/Client.ts @@ -0,0 +1,160 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace VatRates { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class VatRates { + constructor(protected readonly _options: VatRates.Options) {} + + /** + * @param {Monite.VatRatesGetRequest} request + * @param {VatRates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.UnauthorizedError} + * @throws {@link Monite.ForbiddenError} + * @throws {@link Monite.NotFoundError} + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.vatRates.get() + */ + public async get( + request: Monite.VatRatesGetRequest = {}, + requestOptions?: VatRates.RequestOptions + ): Promise { + const { + counterpart_address_id: counterpartAddressId, + counterpart_id: counterpartId, + counterpart_vat_id_id: counterpartVatIdId, + entity_vat_id_id: entityVatIdId, + product_type: productType, + } = request; + const _queryParams: Record = {}; + if (counterpartAddressId != null) { + _queryParams["counterpart_address_id"] = counterpartAddressId; + } + + if (counterpartId != null) { + _queryParams["counterpart_id"] = counterpartId; + } + + if (counterpartVatIdId != null) { + _queryParams["counterpart_vat_id_id"] = counterpartVatIdId; + } + + if (entityVatIdId != null) { + _queryParams["entity_vat_id_id"] = entityVatIdId; + } + + if (productType != null) { + _queryParams["product_type"] = productType; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "vat_rates" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.VatRateListResponse; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as Monite.ErrorSchemaResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as Monite.ErrorSchemaResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as Monite.ErrorSchemaResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as Monite.ErrorSchemaResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/vatRates/client/index.ts b/src/api/resources/vatRates/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/vatRates/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/vatRates/client/requests/VatRatesGetRequest.ts b/src/api/resources/vatRates/client/requests/VatRatesGetRequest.ts new file mode 100644 index 0000000..fa8f5b1 --- /dev/null +++ b/src/api/resources/vatRates/client/requests/VatRatesGetRequest.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface VatRatesGetRequest { + counterpart_address_id?: string; + counterpart_id?: string; + counterpart_vat_id_id?: string; + entity_vat_id_id?: string; + product_type?: Monite.ProductServiceTypeEnum; +} diff --git a/src/api/resources/vatRates/client/requests/index.ts b/src/api/resources/vatRates/client/requests/index.ts new file mode 100644 index 0000000..93d6ce1 --- /dev/null +++ b/src/api/resources/vatRates/client/requests/index.ts @@ -0,0 +1 @@ +export { type VatRatesGetRequest } from "./VatRatesGetRequest"; diff --git a/src/api/resources/vatRates/index.ts b/src/api/resources/vatRates/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/vatRates/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/webhookDeliveries/client/Client.ts b/src/api/resources/webhookDeliveries/client/Client.ts new file mode 100644 index 0000000..b29d1c4 --- /dev/null +++ b/src/api/resources/webhookDeliveries/client/Client.ts @@ -0,0 +1,178 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace WebhookDeliveries { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class WebhookDeliveries { + constructor(protected readonly _options: WebhookDeliveries.Options) {} + + /** + * @param {Monite.WebhookDeliveriesGetRequest} request + * @param {WebhookDeliveries.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookDeliveries.get() + */ + public async get( + request: Monite.WebhookDeliveriesGetRequest = {}, + requestOptions?: WebhookDeliveries.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + event_id: eventId, + object_type: objectType, + event_action: eventAction, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (eventId != null) { + _queryParams["event_id"] = eventId; + } + + if (objectType != null) { + _queryParams["object_type"] = objectType; + } + + if (eventAction != null) { + _queryParams["event_action"] = eventAction; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "webhook_deliveries" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.WebhookDeliveryPaginationResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/webhookDeliveries/client/index.ts b/src/api/resources/webhookDeliveries/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/webhookDeliveries/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/webhookDeliveries/client/requests/WebhookDeliveriesGetRequest.ts b/src/api/resources/webhookDeliveries/client/requests/WebhookDeliveriesGetRequest.ts new file mode 100644 index 0000000..a2a6ba2 --- /dev/null +++ b/src/api/resources/webhookDeliveries/client/requests/WebhookDeliveriesGetRequest.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface WebhookDeliveriesGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.WebhookDeliveryCursorFields; + event_id?: string; + object_type?: Monite.WebhookObjectType; + event_action?: string; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; +} diff --git a/src/api/resources/webhookDeliveries/client/requests/index.ts b/src/api/resources/webhookDeliveries/client/requests/index.ts new file mode 100644 index 0000000..339df60 --- /dev/null +++ b/src/api/resources/webhookDeliveries/client/requests/index.ts @@ -0,0 +1 @@ +export { type WebhookDeliveriesGetRequest } from "./WebhookDeliveriesGetRequest"; diff --git a/src/api/resources/webhookDeliveries/index.ts b/src/api/resources/webhookDeliveries/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/webhookDeliveries/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/webhookSubscriptions/client/Client.ts b/src/api/resources/webhookSubscriptions/client/Client.ts new file mode 100644 index 0000000..4f6bc0b --- /dev/null +++ b/src/api/resources/webhookSubscriptions/client/Client.ts @@ -0,0 +1,679 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Monite from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace WebhookSubscriptions { + interface Options { + environment?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Override the x-monite-version header */ + moniteVersion?: string; + /** Override the x-monite-entity-id header */ + moniteEntityId?: string | undefined; + } +} + +export class WebhookSubscriptions { + constructor(protected readonly _options: WebhookSubscriptions.Options) {} + + /** + * @param {Monite.WebhookSubscriptionsGetRequest} request + * @param {WebhookSubscriptions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookSubscriptions.get() + */ + public async get( + request: Monite.WebhookSubscriptionsGetRequest = {}, + requestOptions?: WebhookSubscriptions.RequestOptions + ): Promise { + const { + order, + limit, + pagination_token: paginationToken, + sort, + object_type: objectType, + created_at__gt: createdAtGt, + created_at__lt: createdAtLt, + created_at__gte: createdAtGte, + created_at__lte: createdAtLte, + } = request; + const _queryParams: Record = {}; + if (order != null) { + _queryParams["order"] = order; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (paginationToken != null) { + _queryParams["pagination_token"] = paginationToken; + } + + if (sort != null) { + _queryParams["sort"] = sort; + } + + if (objectType != null) { + _queryParams["object_type"] = objectType; + } + + if (createdAtGt != null) { + _queryParams["created_at__gt"] = createdAtGt; + } + + if (createdAtLt != null) { + _queryParams["created_at__lt"] = createdAtLt; + } + + if (createdAtGte != null) { + _queryParams["created_at__gte"] = createdAtGte; + } + + if (createdAtLte != null) { + _queryParams["created_at__lte"] = createdAtLte; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "webhook_subscriptions" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.WebhookSubscriptionPaginationResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {Monite.CreateWebhookSubscriptionRequest} request + * @param {WebhookSubscriptions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookSubscriptions.create({ + * object_type: "account", + * url: "url" + * }) + */ + public async create( + request: Monite.CreateWebhookSubscriptionRequest, + requestOptions?: WebhookSubscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + "webhook_subscriptions" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.WebhookSubscriptionResourceWithSecret; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} webhookSubscriptionId + * @param {WebhookSubscriptions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookSubscriptions.getById("webhook_subscription_id") + */ + public async getById( + webhookSubscriptionId: string, + requestOptions?: WebhookSubscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `webhook_subscriptions/${encodeURIComponent(webhookSubscriptionId)}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.WebhookSubscriptionResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} webhookSubscriptionId + * @param {WebhookSubscriptions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookSubscriptions.deleteById("webhook_subscription_id") + */ + public async deleteById( + webhookSubscriptionId: string, + requestOptions?: WebhookSubscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `webhook_subscriptions/${encodeURIComponent(webhookSubscriptionId)}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} webhookSubscriptionId + * @param {Monite.UpdateWebhookSubscriptionRequest} request + * @param {WebhookSubscriptions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookSubscriptions.updateById("webhook_subscription_id") + */ + public async updateById( + webhookSubscriptionId: string, + request: Monite.UpdateWebhookSubscriptionRequest = {}, + requestOptions?: WebhookSubscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `webhook_subscriptions/${encodeURIComponent(webhookSubscriptionId)}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.WebhookSubscriptionResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} webhookSubscriptionId + * @param {WebhookSubscriptions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookSubscriptions.disableById("webhook_subscription_id") + */ + public async disableById( + webhookSubscriptionId: string, + requestOptions?: WebhookSubscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `webhook_subscriptions/${encodeURIComponent(webhookSubscriptionId)}/disable` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.WebhookSubscriptionResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} webhookSubscriptionId + * @param {WebhookSubscriptions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookSubscriptions.enableById("webhook_subscription_id") + */ + public async enableById( + webhookSubscriptionId: string, + requestOptions?: WebhookSubscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `webhook_subscriptions/${encodeURIComponent(webhookSubscriptionId)}/enable` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.WebhookSubscriptionResource; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @param {string} webhookSubscriptionId + * @param {WebhookSubscriptions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Monite.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.webhookSubscriptions.regenerateSecretById("webhook_subscription_id") + */ + public async regenerateSecretById( + webhookSubscriptionId: string, + requestOptions?: WebhookSubscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.MoniteEnvironment.Sandbox, + `webhook_subscriptions/${encodeURIComponent(webhookSubscriptionId)}/regenerate_secret` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": await core.Supplier.get(this._options.moniteVersion), + "x-monite-entity-id": + (await core.Supplier.get(this._options.moniteEntityId)) != null + ? await core.Supplier.get(this._options.moniteEntityId) + : undefined, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return _response.body as Monite.WebhookSubscriptionResourceWithSecret; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as Monite.HttpValidationError); + case 500: + throw new Monite.InternalServerError(_response.error.body as Monite.ErrorSchemaResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.MoniteTimeoutError(); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = await core.Supplier.get(this._options.token); + if (bearer != null) { + return `Bearer ${bearer}`; + } + + return undefined; + } +} diff --git a/src/api/resources/webhookSubscriptions/client/index.ts b/src/api/resources/webhookSubscriptions/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/webhookSubscriptions/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/webhookSubscriptions/client/requests/CreateWebhookSubscriptionRequest.ts b/src/api/resources/webhookSubscriptions/client/requests/CreateWebhookSubscriptionRequest.ts new file mode 100644 index 0000000..6487fa9 --- /dev/null +++ b/src/api/resources/webhookSubscriptions/client/requests/CreateWebhookSubscriptionRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * { + * object_type: "account", + * url: "url" + * } + */ +export interface CreateWebhookSubscriptionRequest { + event_types?: string[]; + object_type: Monite.WebhookObjectType; + url: string; +} diff --git a/src/api/resources/webhookSubscriptions/client/requests/UpdateWebhookSubscriptionRequest.ts b/src/api/resources/webhookSubscriptions/client/requests/UpdateWebhookSubscriptionRequest.ts new file mode 100644 index 0000000..8d1df65 --- /dev/null +++ b/src/api/resources/webhookSubscriptions/client/requests/UpdateWebhookSubscriptionRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface UpdateWebhookSubscriptionRequest { + event_types?: string[]; + object_type?: Monite.WebhookObjectType; + url?: string; +} diff --git a/src/api/resources/webhookSubscriptions/client/requests/WebhookSubscriptionsGetRequest.ts b/src/api/resources/webhookSubscriptions/client/requests/WebhookSubscriptionsGetRequest.ts new file mode 100644 index 0000000..7904a71 --- /dev/null +++ b/src/api/resources/webhookSubscriptions/client/requests/WebhookSubscriptionsGetRequest.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index"; + +/** + * @example + * {} + */ +export interface WebhookSubscriptionsGetRequest { + /** + * Order by + */ + order?: Monite.OrderEnum; + /** + * Max is 100 + */ + limit?: number; + /** + * A token, obtained from previous page. Prior over other filters + */ + pagination_token?: string; + /** + * Allowed sort fields + */ + sort?: Monite.WebhookSubscriptionCursorFields; + object_type?: Monite.WebhookObjectType; + created_at__gt?: string; + created_at__lt?: string; + created_at__gte?: string; + created_at__lte?: string; +} diff --git a/src/api/resources/webhookSubscriptions/client/requests/index.ts b/src/api/resources/webhookSubscriptions/client/requests/index.ts new file mode 100644 index 0000000..8c230a7 --- /dev/null +++ b/src/api/resources/webhookSubscriptions/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type WebhookSubscriptionsGetRequest } from "./WebhookSubscriptionsGetRequest"; +export { type CreateWebhookSubscriptionRequest } from "./CreateWebhookSubscriptionRequest"; +export { type UpdateWebhookSubscriptionRequest } from "./UpdateWebhookSubscriptionRequest"; diff --git a/src/api/resources/webhookSubscriptions/index.ts b/src/api/resources/webhookSubscriptions/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/webhookSubscriptions/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/types/AccessTokenResponse.ts b/src/api/types/AccessTokenResponse.ts new file mode 100644 index 0000000..ff093d2 --- /dev/null +++ b/src/api/types/AccessTokenResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccessTokenResponse { + access_token: string; + expires_in: number; + token_type: string; +} diff --git a/src/api/types/AccountDisabledReason.ts b/src/api/types/AccountDisabledReason.ts new file mode 100644 index 0000000..f4b9300 --- /dev/null +++ b/src/api/types/AccountDisabledReason.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AccountDisabledReason = + | "requirements.past_due" + | "requirements.pending_verification" + | "listed" + | "platform_paused" + | "rejected.fraud" + | "rejected.listed" + | "rejected.terms_of_service" + | "rejected.other" + | "under_review" + | "other"; + +export const AccountDisabledReason = { + RequirementsPastDue: "requirements.past_due", + RequirementsPendingVerification: "requirements.pending_verification", + Listed: "listed", + PlatformPaused: "platform_paused", + RejectedFraud: "rejected.fraud", + RejectedListed: "rejected.listed", + RejectedTermsOfService: "rejected.terms_of_service", + RejectedOther: "rejected.other", + UnderReview: "under_review", + Other: "other", +} as const; diff --git a/src/api/types/AccountResponse.ts b/src/api/types/AccountResponse.ts new file mode 100644 index 0000000..95f4c9c --- /dev/null +++ b/src/api/types/AccountResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AccountResponse { + id: string; + bank_accounts?: Monite.BankAccount[]; + type: Monite.PaymentAccountType; +} diff --git a/src/api/types/AccountingConnectionList.ts b/src/api/types/AccountingConnectionList.ts new file mode 100644 index 0000000..79c1cf6 --- /dev/null +++ b/src/api/types/AccountingConnectionList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AccountingConnectionList { + data: Monite.AccountingConnectionResponse[]; +} diff --git a/src/api/types/AccountingConnectionResponse.ts b/src/api/types/AccountingConnectionResponse.ts new file mode 100644 index 0000000..2c452fb --- /dev/null +++ b/src/api/types/AccountingConnectionResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AccountingConnectionResponse { + id: string; + created_at: string; + updated_at: string; + connection_url: string; + errors?: Monite.ErrorSchema[]; + last_pull?: string; + platform?: string; + status?: Monite.ConnectionStatus; +} diff --git a/src/api/types/AccountingCustomerRefObject.ts b/src/api/types/AccountingCustomerRefObject.ts new file mode 100644 index 0000000..6cdc155 --- /dev/null +++ b/src/api/types/AccountingCustomerRefObject.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccountingCustomerRefObject { + /** A unique identifier of the customer in the accounting system. */ + id: string; + /** Customer name in the accounting system. */ + company_name?: string; +} diff --git a/src/api/types/AccountingLineItem.ts b/src/api/types/AccountingLineItem.ts new file mode 100644 index 0000000..782ab75 --- /dev/null +++ b/src/api/types/AccountingLineItem.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Contains the details of an invoice line item retrieved from an accounting system. + */ +export interface AccountingLineItem { + /** The name or description of the product or service being invoiced. */ + description?: string; + /** Discount amount for this line item (if any). */ + discount_amount?: number; + /** Discount percentage for this line item (if any). */ + discount_percentage?: number; + /** ID of the ledger account associated with this line item. You can use `GET /ledger_accounts/{ledger_account_id}` to get further details about this ledger account. */ + ledger_account_id?: string; + /** The quantity of the product or service. */ + quantity?: number; + /** An internal reference to the tax rate in the accounting system that the line item is linked to. */ + tax_rate_ref?: Monite.AccountingRefObject; + /** The cost per unit of the product or service. */ + unit_amount?: number; +} diff --git a/src/api/types/AccountingMessageResponse.ts b/src/api/types/AccountingMessageResponse.ts new file mode 100644 index 0000000..aa648f8 --- /dev/null +++ b/src/api/types/AccountingMessageResponse.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccountingMessageResponse { + message: string; +} diff --git a/src/api/types/AccountingPayable.ts b/src/api/types/AccountingPayable.ts new file mode 100644 index 0000000..61abfbb --- /dev/null +++ b/src/api/types/AccountingPayable.ts @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Details of an accounts payable invoice (bill) retrieved from an accounting system. + */ +export interface AccountingPayable { + /** An internal identifier of the payable in the accounting system. */ + id: string; + /** Remaining amount to be paid. */ + amount_due?: number; + /** ISO-4217 currency code of the payable. */ + currency?: string; + /** Rate to convert the total amount of the transaction into the entity's base currency at the time of the transaction. */ + currency_rate?: number; + /** The payable's due date. */ + due_date?: Monite.AccountingPayableDueDate; + /** Invoice number of the payable. */ + invoice_number?: string; + lines?: Monite.AccountingLineItem[]; + /** Any additional information or business notes about the payable. */ + memo?: string; + /** Date when the payable was added to the accounting service. This may differ from the payable creation date. */ + posted_date?: string; + /** A list of purchase orders linked to the payable, if any. */ + purchase_order_refs?: Monite.AccountingPurchaseOrderRef[]; + /** The status of the payable in the accounting system. Possible values: `open`, `draft`, `partially_paid`, `paid`, `unknown`, `void`. */ + status: string; + /** Amount payable, including discounts but excluding VAT/taxes. */ + subtotal?: number; + /** Total VAT or tax amount. */ + tax_amount?: number; + /** The total amount payable, including discounts and VAT/taxes. */ + total_amount: number; + /** Information about the vendor from whom the payable was received. */ + vendor_ref?: Monite.AccountingVendorRefObject; +} diff --git a/src/api/types/AccountingPayableDueDate.ts b/src/api/types/AccountingPayableDueDate.ts new file mode 100644 index 0000000..99beb7f --- /dev/null +++ b/src/api/types/AccountingPayableDueDate.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The payable's due date. + */ +export type AccountingPayableDueDate = string | string; diff --git a/src/api/types/AccountingPayableList.ts b/src/api/types/AccountingPayableList.ts new file mode 100644 index 0000000..9e35c91 --- /dev/null +++ b/src/api/types/AccountingPayableList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AccountingPayableList { + data: Monite.AccountingPayable[]; +} diff --git a/src/api/types/AccountingPurchaseOrderRef.ts b/src/api/types/AccountingPurchaseOrderRef.ts new file mode 100644 index 0000000..a46ff8c --- /dev/null +++ b/src/api/types/AccountingPurchaseOrderRef.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccountingPurchaseOrderRef { + /** An internal ID of the purchase order in the accounting system. */ + id: string; + /** Reference number of the purchase order. */ + name?: string; +} diff --git a/src/api/types/AccountingReceivable.ts b/src/api/types/AccountingReceivable.ts new file mode 100644 index 0000000..380d062 --- /dev/null +++ b/src/api/types/AccountingReceivable.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Invoice details retrieved from an accounting system. + */ +export interface AccountingReceivable { + /** An internal identifier of the invoice in the accounting system. */ + id?: string; + /** ISO-4217 currency code of the invoice. */ + currency?: string; + /** Rate to convert the total amount of the transaction into the entity's base currency at the time of the transaction. */ + currency_rate?: number; + /** Information about the customer that the invoice was sent to. */ + customer_ref?: Monite.AccountingCustomerRefObject; + /** Invoice due date. */ + due_date?: Monite.AccountingReceivableDueDate; + /** Invoice document number. */ + invoice_number?: string; + lines?: Monite.AccountingLineItem[]; + /** Any additional information or business notes about the invoice. */ + memo?: string; + /** An object containing additional invoice data returned by the accounting system. This sometimes includes custom invoice fields. */ + pass_through?: Record; + /** Date when the invoice was added to the accounting service. This may differ from the invoice creation date. */ + posted_date?: string; +} diff --git a/src/api/types/AccountingReceivableDueDate.ts b/src/api/types/AccountingReceivableDueDate.ts new file mode 100644 index 0000000..75e27df --- /dev/null +++ b/src/api/types/AccountingReceivableDueDate.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Invoice due date. + */ +export type AccountingReceivableDueDate = string | string; diff --git a/src/api/types/AccountingReceivableList.ts b/src/api/types/AccountingReceivableList.ts new file mode 100644 index 0000000..11b071b --- /dev/null +++ b/src/api/types/AccountingReceivableList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AccountingReceivableList { + data: Monite.AccountingReceivable[]; +} diff --git a/src/api/types/AccountingRefObject.ts b/src/api/types/AccountingRefObject.ts new file mode 100644 index 0000000..4a67a1c --- /dev/null +++ b/src/api/types/AccountingRefObject.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccountingRefObject { + /** An internal ID of the tax rate in the accounting system. */ + id?: string; +} diff --git a/src/api/types/AccountingSettingsPayload.ts b/src/api/types/AccountingSettingsPayload.ts new file mode 100644 index 0000000..0483744 --- /dev/null +++ b/src/api/types/AccountingSettingsPayload.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccountingSettingsPayload { + provider: string; + /** Token for the accounting provider (Codat only) */ + token?: string; +} diff --git a/src/api/types/AccountingSettingsResponse.ts b/src/api/types/AccountingSettingsResponse.ts new file mode 100644 index 0000000..d571847 --- /dev/null +++ b/src/api/types/AccountingSettingsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccountingSettingsResponse { + provider: string; + /** Token for the accounting provider (Codat only) */ + token?: string; +} diff --git a/src/api/types/AccountingTaxRateListResponse.ts b/src/api/types/AccountingTaxRateListResponse.ts new file mode 100644 index 0000000..478faf2 --- /dev/null +++ b/src/api/types/AccountingTaxRateListResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AccountingTaxRateListResponse { + data: Monite.AccountingTaxRateResponse[]; + next_pagination_token?: string; + prev_pagination_token?: string; +} diff --git a/src/api/types/AccountingTaxRateResponse.ts b/src/api/types/AccountingTaxRateResponse.ts new file mode 100644 index 0000000..0dbdc9b --- /dev/null +++ b/src/api/types/AccountingTaxRateResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AccountingTaxRateResponse { + id: string; + /** Code for the tax rate from the accounting platform. */ + code?: string; + components?: Monite.TaxComponentResponse[]; + /** Effective tax rate in percent [minor units](https://docs.monite.com/docs/currencies#minor-units). Example: 12.5% is 1250. */ + effective_tax_rate?: number; + name?: string; + status?: string; + /** Total (not compounded) sum of the components of a tax rate in [minor units](https://docs.monite.com/docs/currencies#minor-units). Example: 12.5% is 1250. */ + total_tax_rate?: number; +} diff --git a/src/api/types/AccountingVendorRefObject.ts b/src/api/types/AccountingVendorRefObject.ts new file mode 100644 index 0000000..413f8d1 --- /dev/null +++ b/src/api/types/AccountingVendorRefObject.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccountingVendorRefObject { + /** A unique identifier of the vendor in the accounting system. */ + id: string; + /** Vendor name in the accounting system. */ + name?: string; +} diff --git a/src/api/types/ActionEnum.ts b/src/api/types/ActionEnum.ts new file mode 100644 index 0000000..bcaad94 --- /dev/null +++ b/src/api/types/ActionEnum.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ActionEnum = "create" | "read" | "update" | "delete"; + +export const ActionEnum = { + Create: "create", + Read: "read", + Update: "update", + Delete: "delete", +} as const; diff --git a/src/api/types/ActionSchema.ts b/src/api/types/ActionSchema.ts new file mode 100644 index 0000000..d1478e6 --- /dev/null +++ b/src/api/types/ActionSchema.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ActionSchema { + /** Action name */ + action_name?: Monite.ActionEnum; + /** Permission type */ + permission?: Monite.PermissionEnum; +} diff --git a/src/api/types/AirwallexMandate.ts b/src/api/types/AirwallexMandate.ts new file mode 100644 index 0000000..acff632 --- /dev/null +++ b/src/api/types/AirwallexMandate.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AirwallexMandate { + /** PDF copy of mandate will be sent to the email by Airwallex */ + email: string; + /** Name of the person signed the mandate, must be a bank account owner */ + signatory: string; + type: Monite.AirwallexMandateType; + version: Monite.AirwallexMandateVersion; +} diff --git a/src/api/types/AirwallexMandateType.ts b/src/api/types/AirwallexMandateType.ts new file mode 100644 index 0000000..455edd3 --- /dev/null +++ b/src/api/types/AirwallexMandateType.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AirwallexMandateType = "us_ach_debit"; diff --git a/src/api/types/AirwallexMandateVersion.ts b/src/api/types/AirwallexMandateVersion.ts new file mode 100644 index 0000000..ef933a0 --- /dev/null +++ b/src/api/types/AirwallexMandateVersion.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AirwallexMandateVersion = "1.0"; diff --git a/src/api/types/AirwallexPlaidAccount.ts b/src/api/types/AirwallexPlaidAccount.ts new file mode 100644 index 0000000..b8d8b4b --- /dev/null +++ b/src/api/types/AirwallexPlaidAccount.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AirwallexPlaidAccount { + /** Plaid`s unique identifier for the account */ + id: string; + /** The last 2-4 alphanumeric characters of an account's official account number */ + mask: string; + /** The name of the account, either assigned by the user or by the financial institution itself */ + name: string; +} diff --git a/src/api/types/AirwallexPlaidBankAccountVerificationStatus.ts b/src/api/types/AirwallexPlaidBankAccountVerificationStatus.ts new file mode 100644 index 0000000..7673488 --- /dev/null +++ b/src/api/types/AirwallexPlaidBankAccountVerificationStatus.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AirwallexPlaidBankAccountVerificationStatus = "verified" | "expired" | "suspended"; + +export const AirwallexPlaidBankAccountVerificationStatus = { + Verified: "verified", + Expired: "expired", + Suspended: "suspended", +} as const; diff --git a/src/api/types/AirwallexPlaidInstitution.ts b/src/api/types/AirwallexPlaidInstitution.ts new file mode 100644 index 0000000..fb21c2b --- /dev/null +++ b/src/api/types/AirwallexPlaidInstitution.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AirwallexPlaidInstitution { + /** The institution identifier assigned by Plaid */ + id: string; + /** The full financial institution name */ + name: string; +} diff --git a/src/api/types/AirwallexPlaidVerification.ts b/src/api/types/AirwallexPlaidVerification.ts new file mode 100644 index 0000000..4ab4d93 --- /dev/null +++ b/src/api/types/AirwallexPlaidVerification.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AirwallexPlaidVerification { + /** Status of the bank account verification */ + status: Monite.AirwallexPlaidBankAccountVerificationStatus; +} diff --git a/src/api/types/AllDocumentExportResponseSchema.ts b/src/api/types/AllDocumentExportResponseSchema.ts new file mode 100644 index 0000000..de6d533 --- /dev/null +++ b/src/api/types/AllDocumentExportResponseSchema.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AllDocumentExportResponseSchema { + /** A set of export objects returned per page. */ + data: Monite.DocumentExportResponseSchema[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results. If there is no next page, i.e. you have reached the last page, the value is `null`. */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results. If there is no previous page, i.e. you have reached the first page, the value is `null`. */ + prev_pagination_token?: string; +} diff --git a/src/api/types/AllOverdueRemindersResponse.ts b/src/api/types/AllOverdueRemindersResponse.ts new file mode 100644 index 0000000..97fbfda --- /dev/null +++ b/src/api/types/AllOverdueRemindersResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface AllOverdueRemindersResponse { + data: Monite.OverdueReminderResponse[]; +} diff --git a/src/api/types/AllowedCountries.ts b/src/api/types/AllowedCountries.ts new file mode 100644 index 0000000..e2fd71f --- /dev/null +++ b/src/api/types/AllowedCountries.ts @@ -0,0 +1,512 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AllowedCountries = + | "AF" + | "AX" + | "AL" + | "DZ" + | "AS" + | "AD" + | "AO" + | "AI" + | "AQ" + | "AG" + | "AR" + | "AM" + | "AW" + | "AU" + | "AT" + | "AZ" + | "BS" + | "BH" + | "BD" + | "BB" + | "BY" + | "BE" + | "BZ" + | "BJ" + | "BM" + | "BT" + | "BO" + | "BA" + | "BW" + | "BV" + | "BR" + | "IO" + | "BN" + | "BG" + | "BF" + | "BI" + | "KH" + | "CM" + | "CA" + | "IC" + | "CV" + | "KY" + | "CF" + | "EA" + | "TD" + | "CL" + | "CN" + | "CX" + | "CC" + | "CO" + | "KM" + | "CG" + | "CD" + | "CK" + | "CR" + | "CI" + | "HR" + | "CU" + | "CY" + | "CZ" + | "DK" + | "DJ" + | "DM" + | "DO" + | "EC" + | "EG" + | "SV" + | "GQ" + | "ER" + | "EE" + | "SZ" + | "ET" + | "FK" + | "FO" + | "FJ" + | "FI" + | "FR" + | "GF" + | "PF" + | "TF" + | "GA" + | "GM" + | "GE" + | "DE" + | "GH" + | "GI" + | "GR" + | "GL" + | "GD" + | "GP" + | "GU" + | "GT" + | "GG" + | "GN" + | "GW" + | "GY" + | "HT" + | "HM" + | "VA" + | "HN" + | "HK" + | "HU" + | "IS" + | "IN" + | "ID" + | "IR" + | "IQ" + | "IE" + | "IM" + | "IL" + | "IT" + | "JM" + | "JP" + | "JE" + | "JO" + | "KZ" + | "KE" + | "KI" + | "KP" + | "KR" + | "KW" + | "KG" + | "LA" + | "LV" + | "LB" + | "LS" + | "LR" + | "LY" + | "LI" + | "LT" + | "LU" + | "MO" + | "MG" + | "MW" + | "MY" + | "MV" + | "ML" + | "MT" + | "MH" + | "MQ" + | "MR" + | "MU" + | "YT" + | "MX" + | "FM" + | "MD" + | "MC" + | "MN" + | "ME" + | "MS" + | "MA" + | "MZ" + | "MM" + | "NA" + | "NR" + | "NP" + | "NL" + | "AN" + | "NC" + | "NZ" + | "NI" + | "NE" + | "NG" + | "NU" + | "NF" + | "MP" + | "MK" + | "NO" + | "OM" + | "PK" + | "PW" + | "PS" + | "PA" + | "PG" + | "PY" + | "PE" + | "PH" + | "PN" + | "PL" + | "PT" + | "PR" + | "QA" + | "RE" + | "RO" + | "RU" + | "RW" + | "SH" + | "KN" + | "LC" + | "PM" + | "VC" + | "WS" + | "SM" + | "ST" + | "SA" + | "SN" + | "RS" + | "SC" + | "SL" + | "SG" + | "SK" + | "SI" + | "SB" + | "SO" + | "ZA" + | "SS" + | "GS" + | "ES" + | "LK" + | "SD" + | "SR" + | "SJ" + | "SE" + | "CH" + | "SY" + | "TW" + | "TJ" + | "TZ" + | "TH" + | "TL" + | "TG" + | "TK" + | "TO" + | "TT" + | "TN" + | "TR" + | "TM" + | "TC" + | "TV" + | "UG" + | "UA" + | "AE" + | "GB" + | "US" + | "UM" + | "UY" + | "UZ" + | "VU" + | "VE" + | "VN" + | "VG" + | "VI" + | "WF" + | "EH" + | "YE" + | "ZM" + | "ZW" + | "BL" + | "BQ" + | "CW" + | "MF" + | "SX"; + +export const AllowedCountries = { + Af: "AF", + Ax: "AX", + Al: "AL", + Dz: "DZ", + As: "AS", + Ad: "AD", + Ao: "AO", + Ai: "AI", + Aq: "AQ", + Ag: "AG", + Ar: "AR", + Am: "AM", + Aw: "AW", + Au: "AU", + At: "AT", + Az: "AZ", + Bs: "BS", + Bh: "BH", + Bd: "BD", + Bb: "BB", + By: "BY", + Be: "BE", + Bz: "BZ", + Bj: "BJ", + Bm: "BM", + Bt: "BT", + Bo: "BO", + Ba: "BA", + Bw: "BW", + Bv: "BV", + Br: "BR", + Io: "IO", + Bn: "BN", + Bg: "BG", + Bf: "BF", + Bi: "BI", + Kh: "KH", + Cm: "CM", + Ca: "CA", + Ic: "IC", + Cv: "CV", + Ky: "KY", + Cf: "CF", + Ea: "EA", + Td: "TD", + Cl: "CL", + Cn: "CN", + Cx: "CX", + Cc: "CC", + Co: "CO", + Km: "KM", + Cg: "CG", + Cd: "CD", + Ck: "CK", + Cr: "CR", + Ci: "CI", + Hr: "HR", + Cu: "CU", + Cy: "CY", + Cz: "CZ", + Dk: "DK", + Dj: "DJ", + Dm: "DM", + Do: "DO", + Ec: "EC", + Eg: "EG", + Sv: "SV", + Gq: "GQ", + Er: "ER", + Ee: "EE", + Sz: "SZ", + Et: "ET", + Fk: "FK", + Fo: "FO", + Fj: "FJ", + Fi: "FI", + Fr: "FR", + Gf: "GF", + Pf: "PF", + Tf: "TF", + Ga: "GA", + Gm: "GM", + Ge: "GE", + De: "DE", + Gh: "GH", + Gi: "GI", + Gr: "GR", + Gl: "GL", + Gd: "GD", + Gp: "GP", + Gu: "GU", + Gt: "GT", + Gg: "GG", + Gn: "GN", + Gw: "GW", + Gy: "GY", + Ht: "HT", + Hm: "HM", + Va: "VA", + Hn: "HN", + Hk: "HK", + Hu: "HU", + Is: "IS", + In: "IN", + Id: "ID", + Ir: "IR", + Iq: "IQ", + Ie: "IE", + Im: "IM", + Il: "IL", + It: "IT", + Jm: "JM", + Jp: "JP", + Je: "JE", + Jo: "JO", + Kz: "KZ", + Ke: "KE", + Ki: "KI", + Kp: "KP", + Kr: "KR", + Kw: "KW", + Kg: "KG", + La: "LA", + Lv: "LV", + Lb: "LB", + Ls: "LS", + Lr: "LR", + Ly: "LY", + Li: "LI", + Lt: "LT", + Lu: "LU", + Mo: "MO", + Mg: "MG", + Mw: "MW", + My: "MY", + Mv: "MV", + Ml: "ML", + Mt: "MT", + Mh: "MH", + Mq: "MQ", + Mr: "MR", + Mu: "MU", + Yt: "YT", + Mx: "MX", + Fm: "FM", + Md: "MD", + Mc: "MC", + Mn: "MN", + Me: "ME", + Ms: "MS", + Ma: "MA", + Mz: "MZ", + Mm: "MM", + Na: "NA", + Nr: "NR", + Np: "NP", + Nl: "NL", + An: "AN", + Nc: "NC", + Nz: "NZ", + Ni: "NI", + Ne: "NE", + Ng: "NG", + Nu: "NU", + Nf: "NF", + Mp: "MP", + Mk: "MK", + No: "NO", + Om: "OM", + Pk: "PK", + Pw: "PW", + Ps: "PS", + Pa: "PA", + Pg: "PG", + Py: "PY", + Pe: "PE", + Ph: "PH", + Pn: "PN", + Pl: "PL", + Pt: "PT", + Pr: "PR", + Qa: "QA", + Re: "RE", + Ro: "RO", + Ru: "RU", + Rw: "RW", + Sh: "SH", + Kn: "KN", + Lc: "LC", + Pm: "PM", + Vc: "VC", + Ws: "WS", + Sm: "SM", + St: "ST", + Sa: "SA", + Sn: "SN", + Rs: "RS", + Sc: "SC", + Sl: "SL", + Sg: "SG", + Sk: "SK", + Si: "SI", + Sb: "SB", + So: "SO", + Za: "ZA", + Ss: "SS", + Gs: "GS", + Es: "ES", + Lk: "LK", + Sd: "SD", + Sr: "SR", + Sj: "SJ", + Se: "SE", + Ch: "CH", + Sy: "SY", + Tw: "TW", + Tj: "TJ", + Tz: "TZ", + Th: "TH", + Tl: "TL", + Tg: "TG", + Tk: "TK", + To: "TO", + Tt: "TT", + Tn: "TN", + Tr: "TR", + Tm: "TM", + Tc: "TC", + Tv: "TV", + Ug: "UG", + Ua: "UA", + Ae: "AE", + Gb: "GB", + Us: "US", + Um: "UM", + Uy: "UY", + Uz: "UZ", + Vu: "VU", + Ve: "VE", + Vn: "VN", + Vg: "VG", + Vi: "VI", + Wf: "WF", + Eh: "EH", + Ye: "YE", + Zm: "ZM", + Zw: "ZW", + Bl: "BL", + Bq: "BQ", + Cw: "CW", + Mf: "MF", + Sx: "SX", +} as const; diff --git a/src/api/types/AllowedFileTypes.ts b/src/api/types/AllowedFileTypes.ts new file mode 100644 index 0000000..40ecf3c --- /dev/null +++ b/src/api/types/AllowedFileTypes.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AllowedFileTypes = + | "ocr_results" + | "ocr_files" + | "payables" + | "receivables" + | "receipts" + | "userpics" + | "entity_logo" + | "companies_logo" + | "zip" + | "identity_documents" + | "additional_identity_documents" + | "receivable_signatures"; + +export const AllowedFileTypes = { + OcrResults: "ocr_results", + OcrFiles: "ocr_files", + Payables: "payables", + Receivables: "receivables", + Receipts: "receipts", + Userpics: "userpics", + EntityLogo: "entity_logo", + CompaniesLogo: "companies_logo", + Zip: "zip", + IdentityDocuments: "identity_documents", + AdditionalIdentityDocuments: "additional_identity_documents", + ReceivableSignatures: "receivable_signatures", +} as const; diff --git a/src/api/types/ApiVersion.ts b/src/api/types/ApiVersion.ts new file mode 100644 index 0000000..e26cd33 --- /dev/null +++ b/src/api/types/ApiVersion.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApiVersion = + | "2024-01-31" + | "2023-09-01" + | "2023-06-04" + | "2023-04-12" + | "2023-03-14" + | "2023-03-01" + | "2023-02-07" + | "2022-11-16"; + +export const ApiVersion = { + TwoThousandTwentyFour0131: "2024-01-31", + TwoThousandTwentyThree0901: "2023-09-01", + TwoThousandTwentyThree0604: "2023-06-04", + TwoThousandTwentyThree0412: "2023-04-12", + TwoThousandTwentyThree0314: "2023-03-14", + TwoThousandTwentyThree0301: "2023-03-01", + TwoThousandTwentyThree0207: "2023-02-07", + TwoThousandTwentyTwo1116: "2022-11-16", +} as const; diff --git a/src/api/types/ApprovalPolicyCursorFields.ts b/src/api/types/ApprovalPolicyCursorFields.ts new file mode 100644 index 0000000..c055867 --- /dev/null +++ b/src/api/types/ApprovalPolicyCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalPolicyCursorFields = "created_at" | "updated_at"; + +export const ApprovalPolicyCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/ApprovalPolicyResource.ts b/src/api/types/ApprovalPolicyResource.ts new file mode 100644 index 0000000..015ec9c --- /dev/null +++ b/src/api/types/ApprovalPolicyResource.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalPolicyResource { + /** The name of the approval policy. */ + name: string; + /** A brief description of the approval policy. */ + description: string; + /** A list of JSON objects that represents the approval policy script. The script contains the logic that determines whether an action should be sent to approval. This field is required, and it should contain at least one script object. */ + script: Monite.ApprovalPolicyResourceScriptItem[]; + /** A JSON object that represents the trigger for the approval policy. The trigger specifies the event that will trigger the policy to be evaluated. */ + trigger?: Monite.ApprovalPolicyResourceTrigger; + id: string; + /** The current status of the approval policy. */ + status: Monite.ApprovalPolicyResourceStatus; + created_at: string; + updated_at: string; + created_by: string; + updated_by?: string; +} diff --git a/src/api/types/ApprovalPolicyResourceList.ts b/src/api/types/ApprovalPolicyResourceList.ts new file mode 100644 index 0000000..800a301 --- /dev/null +++ b/src/api/types/ApprovalPolicyResourceList.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalPolicyResourceList { + data: Monite.ApprovalPolicyResource[]; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; +} diff --git a/src/api/types/ApprovalPolicyResourceScriptItem.ts b/src/api/types/ApprovalPolicyResourceScriptItem.ts new file mode 100644 index 0000000..48a1b4e --- /dev/null +++ b/src/api/types/ApprovalPolicyResourceScriptItem.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalPolicyResourceScriptItem = boolean | number | string | unknown[] | Record; diff --git a/src/api/types/ApprovalPolicyResourceStatus.ts b/src/api/types/ApprovalPolicyResourceStatus.ts new file mode 100644 index 0000000..dbf046f --- /dev/null +++ b/src/api/types/ApprovalPolicyResourceStatus.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The current status of the approval policy. + */ +export type ApprovalPolicyResourceStatus = "active" | "pending"; + +export const ApprovalPolicyResourceStatus = { + Active: "active", + Pending: "pending", +} as const; diff --git a/src/api/types/ApprovalPolicyResourceTrigger.ts b/src/api/types/ApprovalPolicyResourceTrigger.ts new file mode 100644 index 0000000..77167f2 --- /dev/null +++ b/src/api/types/ApprovalPolicyResourceTrigger.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A JSON object that represents the trigger for the approval policy. The trigger specifies the event that will trigger the policy to be evaluated. + */ +export type ApprovalPolicyResourceTrigger = boolean | number | string | unknown[] | Record; diff --git a/src/api/types/ApprovalPolicyStatus.ts b/src/api/types/ApprovalPolicyStatus.ts new file mode 100644 index 0000000..789fb12 --- /dev/null +++ b/src/api/types/ApprovalPolicyStatus.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalPolicyStatus = "active" | "deleted" | "pending"; + +export const ApprovalPolicyStatus = { + Active: "active", + Deleted: "deleted", + Pending: "pending", +} as const; diff --git a/src/api/types/ApprovalProcessResourceList.ts b/src/api/types/ApprovalProcessResourceList.ts new file mode 100644 index 0000000..967cf1f --- /dev/null +++ b/src/api/types/ApprovalProcessResourceList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalProcessResourceList { + data: Monite.ProcessResource[]; +} diff --git a/src/api/types/ApprovalProcessStepResource.ts b/src/api/types/ApprovalProcessStepResource.ts new file mode 100644 index 0000000..88879d6 --- /dev/null +++ b/src/api/types/ApprovalProcessStepResource.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalProcessStepResource { + object_id: string; + required_approval_count: number; + status: Monite.ApprovalProcessStepStatus; + user_ids: string[]; + role_ids: string[]; + approved_by: string[]; + rejected_by?: string; +} diff --git a/src/api/types/ApprovalProcessStepResourceList.ts b/src/api/types/ApprovalProcessStepResourceList.ts new file mode 100644 index 0000000..3e48c28 --- /dev/null +++ b/src/api/types/ApprovalProcessStepResourceList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalProcessStepResourceList { + data: Monite.ApprovalProcessStepResource[]; +} diff --git a/src/api/types/ApprovalProcessStepStatus.ts b/src/api/types/ApprovalProcessStepStatus.ts new file mode 100644 index 0000000..fd7b17f --- /dev/null +++ b/src/api/types/ApprovalProcessStepStatus.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalProcessStepStatus = + | "waiting" + | "approved" + | "rejected" + | "canceled" + | "failed" + | "not_started" + | "skipped"; + +export const ApprovalProcessStepStatus = { + Waiting: "waiting", + Approved: "approved", + Rejected: "rejected", + Canceled: "canceled", + Failed: "failed", + NotStarted: "not_started", + Skipped: "skipped", +} as const; diff --git a/src/api/types/ApprovalRequestCreateByRoleRequest.ts b/src/api/types/ApprovalRequestCreateByRoleRequest.ts new file mode 100644 index 0000000..16301d0 --- /dev/null +++ b/src/api/types/ApprovalRequestCreateByRoleRequest.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalRequestCreateByRoleRequest { + object_id: string; + object_type: Monite.ObjectType; + required_approval_count: number; + role_ids: string[]; +} diff --git a/src/api/types/ApprovalRequestCreateByUserRequest.ts b/src/api/types/ApprovalRequestCreateByUserRequest.ts new file mode 100644 index 0000000..17ba956 --- /dev/null +++ b/src/api/types/ApprovalRequestCreateByUserRequest.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalRequestCreateByUserRequest { + object_id: string; + object_type: Monite.ObjectType; + required_approval_count: number; + user_ids: string[]; +} diff --git a/src/api/types/ApprovalRequestCreateRequest.ts b/src/api/types/ApprovalRequestCreateRequest.ts new file mode 100644 index 0000000..98a4044 --- /dev/null +++ b/src/api/types/ApprovalRequestCreateRequest.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type ApprovalRequestCreateRequest = + | Monite.ApprovalRequestCreateByRoleRequest + | Monite.ApprovalRequestCreateByUserRequest; diff --git a/src/api/types/ApprovalRequestCursorFields.ts b/src/api/types/ApprovalRequestCursorFields.ts new file mode 100644 index 0000000..3b2b89f --- /dev/null +++ b/src/api/types/ApprovalRequestCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalRequestCursorFields = "created_at" | "updated_at"; + +export const ApprovalRequestCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/ApprovalRequestResourceList.ts b/src/api/types/ApprovalRequestResourceList.ts new file mode 100644 index 0000000..f969895 --- /dev/null +++ b/src/api/types/ApprovalRequestResourceList.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalRequestResourceList { + data: Monite.ApprovalRequestResourceWithMetadata[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/ApprovalRequestResourceWithMetadata.ts b/src/api/types/ApprovalRequestResourceWithMetadata.ts new file mode 100644 index 0000000..64cb254 --- /dev/null +++ b/src/api/types/ApprovalRequestResourceWithMetadata.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ApprovalRequestResourceWithMetadata { + id: string; + created_at: string; + updated_at: string; + approved_by: string[]; + /** ID of the user who created the approval request */ + created_by: string; + object_id: string; + object_type: Monite.ObjectType; + rejected_by?: string; + required_approval_count: number; + role_ids: string[]; + status: Monite.ApprovalRequestStatus; + user_ids: string[]; +} diff --git a/src/api/types/ApprovalRequestStatus.ts b/src/api/types/ApprovalRequestStatus.ts new file mode 100644 index 0000000..3235138 --- /dev/null +++ b/src/api/types/ApprovalRequestStatus.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ApprovalRequestStatus = "waiting" | "approved" | "rejected" | "canceled"; + +export const ApprovalRequestStatus = { + Waiting: "waiting", + Approved: "approved", + Rejected: "rejected", + Canceled: "canceled", +} as const; diff --git a/src/api/types/BankAccount.ts b/src/api/types/BankAccount.ts new file mode 100644 index 0000000..df4229f --- /dev/null +++ b/src/api/types/BankAccount.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface BankAccount { + id: string; + account_holder_name?: string; + account_number?: string; + bic?: string; + country?: Monite.AllowedCountries; + currency?: Monite.CurrencyEnum; + display_name?: string; + iban?: string; + is_default?: boolean; + /** Display name of a bank account */ + name?: string; + sort_code?: string; + was_created_by_user_id?: string; +} diff --git a/src/api/types/BankAccountVerificationType.ts b/src/api/types/BankAccountVerificationType.ts new file mode 100644 index 0000000..5b955af --- /dev/null +++ b/src/api/types/BankAccountVerificationType.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type BankAccountVerificationType = "airwallex_plaid"; diff --git a/src/api/types/BankAccountVerifications.ts b/src/api/types/BankAccountVerifications.ts new file mode 100644 index 0000000..607649f --- /dev/null +++ b/src/api/types/BankAccountVerifications.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface BankAccountVerifications { + /** Airwallex Plaid verification */ + airwallex_plaid?: Monite.AirwallexPlaidVerification; +} diff --git a/src/api/types/BasedOnReceivableCreatedEventData.ts b/src/api/types/BasedOnReceivableCreatedEventData.ts new file mode 100644 index 0000000..3370cc1 --- /dev/null +++ b/src/api/types/BasedOnReceivableCreatedEventData.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface BasedOnReceivableCreatedEventData { + receivable_id: string; + type: Monite.ReceivableType; +} diff --git a/src/api/types/BasedOnTransitionType.ts b/src/api/types/BasedOnTransitionType.ts new file mode 100644 index 0000000..fa4ee15 --- /dev/null +++ b/src/api/types/BasedOnTransitionType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type BasedOnTransitionType = "invoice" | "credit_note"; + +export const BasedOnTransitionType = { + Invoice: "invoice", + CreditNote: "credit_note", +} as const; diff --git a/src/api/types/BizObjectsSchema.ts b/src/api/types/BizObjectsSchema.ts new file mode 100644 index 0000000..b86d12e --- /dev/null +++ b/src/api/types/BizObjectsSchema.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface BizObjectsSchema { + /** List of objects */ + objects?: Monite.RootSchema[]; +} diff --git a/src/api/types/BusinessProfile.ts b/src/api/types/BusinessProfile.ts new file mode 100644 index 0000000..7491234 --- /dev/null +++ b/src/api/types/BusinessProfile.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface BusinessProfile { + /** Required for US entities. A free-form description of the products the entity sells (whether online or at offline retail stores) or the services it provides to its customers. */ + description_of_goods_or_services?: string; + /** Required for US entities. The approximate revenue that the business generates per month. */ + estimated_monthly_revenue?: Monite.EstimatedMonthlyRevenue; + /** The merchant category code of the entity. MCCs are used to classify businesses based on the goods or services they provide. */ + mcc?: string; + /** Required for US entities. A list of primary countries where the business conducts its operations, such as selling products or providing services. Use two-letter country codes (ISO 3166-2 alpha-2). */ + operating_countries?: Monite.AllowedCountries[]; + /** The business's publicly available website. */ + url?: string; +} diff --git a/src/api/types/ButtonThemePayload.ts b/src/api/types/ButtonThemePayload.ts new file mode 100644 index 0000000..078b5c3 --- /dev/null +++ b/src/api/types/ButtonThemePayload.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ButtonThemePayload { + primary_color?: string; + primary_hover_color?: string; + secondary_color?: string; + secondary_hover_color?: string; +} diff --git a/src/api/types/ButtonThemeResponse.ts b/src/api/types/ButtonThemeResponse.ts new file mode 100644 index 0000000..9aab420 --- /dev/null +++ b/src/api/types/ButtonThemeResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ButtonThemeResponse { + primary_color?: string; + primary_hover_color?: string; + secondary_color?: string; + secondary_hover_color?: string; +} diff --git a/src/api/types/CardThemePayload.ts b/src/api/types/CardThemePayload.ts new file mode 100644 index 0000000..431fd0e --- /dev/null +++ b/src/api/types/CardThemePayload.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CardThemePayload { + background_color?: string; +} diff --git a/src/api/types/CardThemeResponse.ts b/src/api/types/CardThemeResponse.ts new file mode 100644 index 0000000..2c7274e --- /dev/null +++ b/src/api/types/CardThemeResponse.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CardThemeResponse { + background_color?: string; +} diff --git a/src/api/types/CommentCursorFields.ts b/src/api/types/CommentCursorFields.ts new file mode 100644 index 0000000..a0e4e49 --- /dev/null +++ b/src/api/types/CommentCursorFields.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CommentCursorFields = "id"; diff --git a/src/api/types/CommentResource.ts b/src/api/types/CommentResource.ts new file mode 100644 index 0000000..3586915 --- /dev/null +++ b/src/api/types/CommentResource.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CommentResource { + id: string; + created_at?: string; + updated_at?: string; + created_by_entity_user_id: string; + entity_id: string; + object_id: string; + object_type: string; + reply_to_entity_user_id?: string; + status: Monite.StatusEnum; + text: string; +} diff --git a/src/api/types/CommentResourceList.ts b/src/api/types/CommentResourceList.ts new file mode 100644 index 0000000..5264637 --- /dev/null +++ b/src/api/types/CommentResourceList.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CommentResourceList { + data: Monite.CommentResource[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/CommonSchema.ts b/src/api/types/CommonSchema.ts new file mode 100644 index 0000000..e3fd61d --- /dev/null +++ b/src/api/types/CommonSchema.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CommonSchema { + /** List of actions */ + actions?: Monite.ActionSchema[]; +} diff --git a/src/api/types/CompleteRefreshVerificationResponse.ts b/src/api/types/CompleteRefreshVerificationResponse.ts new file mode 100644 index 0000000..370ca9e --- /dev/null +++ b/src/api/types/CompleteRefreshVerificationResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CompleteRefreshVerificationResponse { + verifications: Monite.BankAccountVerifications; +} diff --git a/src/api/types/CompleteVerificationAirwallexPlaidRequest.ts b/src/api/types/CompleteVerificationAirwallexPlaidRequest.ts new file mode 100644 index 0000000..1e54ed3 --- /dev/null +++ b/src/api/types/CompleteVerificationAirwallexPlaidRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CompleteVerificationAirwallexPlaidRequest { + /** The bank account that was selected in the Plaid Modal */ + account: Monite.AirwallexPlaidAccount; + /** The financial institution that was selected in the Plaid Modal */ + institution: Monite.AirwallexPlaidInstitution; + mandate: Monite.AirwallexMandate; + /** The Plaid Public Token */ + public_token: string; +} diff --git a/src/api/types/CompleteVerificationResponse.ts b/src/api/types/CompleteVerificationResponse.ts new file mode 100644 index 0000000..4c0bdd3 --- /dev/null +++ b/src/api/types/CompleteVerificationResponse.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CompleteVerificationResponse { + /** Deprecated. Use bank_account_id instead. */ + id: string; + /** Account holder's name */ + account_holder_name?: string; + /** Account number (required if IBAN is not provided) */ + account_number?: string; + bank_account_id: string; + /** The name of the entity`s bank account. */ + bank_name?: string; + /** The BIC of the entity`s bank account. */ + bic?: string; + country?: Monite.AllowedCountries; + currency?: Monite.CurrencyEnum; + display_name?: string; + /** The IBAN of the entity`s bank account. */ + iban?: string; + /** Marks if a bank account should be used by default for the currency. Only 1 can be True for each currency. */ + is_default: boolean; + /** Routing number (US) */ + routing_number?: string; + /** Sort code (GB) */ + sort_code?: string; + verifications: Monite.BankAccountVerifications; + was_created_by_user_id?: string; +} diff --git a/src/api/types/ConnectionStatus.ts b/src/api/types/ConnectionStatus.ts new file mode 100644 index 0000000..adb0969 --- /dev/null +++ b/src/api/types/ConnectionStatus.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ConnectionStatus = "connected" | "disconnected" | "deauthorized" | "pending_auth"; + +export const ConnectionStatus = { + Connected: "connected", + Disconnected: "disconnected", + Deauthorized: "deauthorized", + PendingAuth: "pending_auth", +} as const; diff --git a/src/api/types/CounterpartAddress.ts b/src/api/types/CounterpartAddress.ts new file mode 100644 index 0000000..84902b2 --- /dev/null +++ b/src/api/types/CounterpartAddress.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Address information. + */ +export interface CounterpartAddress { + /** City name. */ + city: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country: Monite.AllowedCountries; + /** Street address. */ + line1: string; + /** Additional address information (if any). */ + line2?: string; + /** ZIP or postal code. */ + postal_code: string; + /** State, region, province, or county. */ + state?: string; +} diff --git a/src/api/types/CounterpartAddressResourceList.ts b/src/api/types/CounterpartAddressResourceList.ts new file mode 100644 index 0000000..218b5eb --- /dev/null +++ b/src/api/types/CounterpartAddressResourceList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartAddressResourceList { + data: Monite.CounterpartAddressResponseWithCounterpartId[]; +} diff --git a/src/api/types/CounterpartAddressResponseWithCounterpartId.ts b/src/api/types/CounterpartAddressResponseWithCounterpartId.ts new file mode 100644 index 0000000..5eaef3c --- /dev/null +++ b/src/api/types/CounterpartAddressResponseWithCounterpartId.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Address information. + */ +export interface CounterpartAddressResponseWithCounterpartId { + /** Unique ID of the address in the system */ + id: string; + /** City name. */ + city: string; + /** ID of the counterpart that owns the address. */ + counterpart_id: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country: Monite.AllowedCountries; + /** Street address. */ + line1: string; + /** Additional address information (if any). */ + line2?: string; + /** ZIP or postal code. */ + postal_code: string; + /** State, region, province, or county. */ + state?: string; +} diff --git a/src/api/types/CounterpartBankAccountResourceList.ts b/src/api/types/CounterpartBankAccountResourceList.ts new file mode 100644 index 0000000..0697eb5 --- /dev/null +++ b/src/api/types/CounterpartBankAccountResourceList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartBankAccountResourceList { + data: Monite.CounterpartBankAccountResponse[]; +} diff --git a/src/api/types/CounterpartBankAccountResponse.ts b/src/api/types/CounterpartBankAccountResponse.ts new file mode 100644 index 0000000..eda1faa --- /dev/null +++ b/src/api/types/CounterpartBankAccountResponse.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartBankAccountResponse { + id: string; + /** The name of the person or business that owns this bank account. Required for US bank accounts to accept ACH payments. */ + account_holder_name?: string; + /** The bank account number. Required for US bank accounts to accept ACH payments. US account numbers contain 9 to 12 digits. UK account numbers typically contain 8 digits. */ + account_number?: string; + /** The BIC/SWIFT code of the bank. */ + bic?: string; + counterpart_id: string; + country: Monite.AllowedCountries; + currency: Monite.CurrencyEnum; + /** The IBAN of the bank account. */ + iban?: string; + is_default_for_currency?: boolean; + name?: string; + /** Metadata for partner needs. */ + partner_metadata?: Record; + /** The bank's routing transit number (RTN). Required for US bank accounts to accept ACH payments. US routing numbers consist of 9 digits. */ + routing_number?: string; + /** The bank's sort code. */ + sort_code?: string; +} diff --git a/src/api/types/CounterpartContactResponse.ts b/src/api/types/CounterpartContactResponse.ts new file mode 100644 index 0000000..3ffa3b0 --- /dev/null +++ b/src/api/types/CounterpartContactResponse.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * The contact person for an organization. + */ +export interface CounterpartContactResponse { + id: string; + /** The address of a contact person. */ + address: Monite.CounterpartAddress; + counterpart_id: string; + /** The email address of a contact person. */ + email?: string; + /** The first name of a contact person. */ + first_name: string; + is_default: boolean; + /** The last name of a contact person. */ + last_name: string; + /** The phone number of a contact person */ + phone?: string; + /** The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. */ + title?: string; +} diff --git a/src/api/types/CounterpartContactsResourceList.ts b/src/api/types/CounterpartContactsResourceList.ts new file mode 100644 index 0000000..9a7d86f --- /dev/null +++ b/src/api/types/CounterpartContactsResourceList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartContactsResourceList { + data: Monite.CounterpartContactResponse[]; +} diff --git a/src/api/types/CounterpartCreatePayload.ts b/src/api/types/CounterpartCreatePayload.ts new file mode 100644 index 0000000..6859376 --- /dev/null +++ b/src/api/types/CounterpartCreatePayload.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * This schema is used to create new counterparts (either organizations or individuals). + * The counterpart type is specified by the `type` property. Depending on the `type`, + * you need to provide the data for either the `individual` or `organization` property. + */ +export type CounterpartCreatePayload = + | Monite.CounterpartCreatePayload.Organization + | Monite.CounterpartCreatePayload.Individual; + +export declare namespace CounterpartCreatePayload { + interface Organization extends Monite.CounterpartOrganizationRootCreatePayload { + type: "organization"; + } + + interface Individual extends Monite.CounterpartIndividualRootCreatePayload { + type: "individual"; + } +} diff --git a/src/api/types/CounterpartCursorFields.ts b/src/api/types/CounterpartCursorFields.ts new file mode 100644 index 0000000..fa4d50e --- /dev/null +++ b/src/api/types/CounterpartCursorFields.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CounterpartCursorFields = "counterpart_name"; diff --git a/src/api/types/CounterpartIndividualCreatePayload.ts b/src/api/types/CounterpartIndividualCreatePayload.ts new file mode 100644 index 0000000..8180f14 --- /dev/null +++ b/src/api/types/CounterpartIndividualCreatePayload.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are individuals (natural persons). + */ +export interface CounterpartIndividualCreatePayload { + /** The person's address. */ + address: Monite.CounterpartAddress; + /** The person's email address. */ + email?: string; + /** The person's first name. */ + first_name: string; + /** Indicates if the counterpart is a customer. */ + is_customer: boolean; + /** Indicates if the counterpart is a vendor. */ + is_vendor: boolean; + /** The person's last name. */ + last_name: string; + /** The person's phone number. */ + phone?: string; + /** A list of IDs of user-defined tags (labels) assigned to this counterpart. */ + tag_ids?: string[]; + /** The person's title or honorific. Examples: Mr., Ms., Dr., Prof. */ + title?: string; +} diff --git a/src/api/types/CounterpartIndividualResponse.ts b/src/api/types/CounterpartIndividualResponse.ts new file mode 100644 index 0000000..0fb9b22 --- /dev/null +++ b/src/api/types/CounterpartIndividualResponse.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are individuals (natural persons). + */ +export interface CounterpartIndividualResponse { + /** The person's email address. */ + email?: string; + /** The person's first name. */ + first_name: string; + /** Indicates if the counterpart is a customer. */ + is_customer: boolean; + /** Indicates if the counterpart is a vendor. */ + is_vendor: boolean; + /** The person's last name. */ + last_name: string; + /** The person's phone number. */ + phone?: string; + /** The list of tags for this counterpart. */ + tags?: Monite.CounterpartTagSchema[]; + /** The person's title or honorific. Examples: Mr., Ms., Dr., Prof. */ + title?: string; +} diff --git a/src/api/types/CounterpartIndividualRootCreatePayload.ts b/src/api/types/CounterpartIndividualRootCreatePayload.ts new file mode 100644 index 0000000..1910997 --- /dev/null +++ b/src/api/types/CounterpartIndividualRootCreatePayload.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * This schema is used to create counterparts that are individuals (natural persons). + */ +export interface CounterpartIndividualRootCreatePayload { + individual: Monite.CounterpartIndividualCreatePayload; + /** The language used to generate pdf documents for this counterpart. */ + language?: Monite.LanguageCodeEnum; + reminders_enabled?: boolean; + /** The counterpart's taxpayer identification number or tax ID. This field is required for counterparts that are non-VAT registered. */ + tax_id?: string; +} diff --git a/src/api/types/CounterpartIndividualRootResponse.ts b/src/api/types/CounterpartIndividualRootResponse.ts new file mode 100644 index 0000000..8fc8320 --- /dev/null +++ b/src/api/types/CounterpartIndividualRootResponse.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are individuals (natural persons). + */ +export interface CounterpartIndividualRootResponse { + /** Unique ID of the counterpart. */ + id: string; + /** Date and time when the counterpart was created. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + created_at: string; + /** Date and time when the counterpart was last updated. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + updated_at: string; + /** `true` if the counterpart was created automatically by Monite when processing incoming invoices with OCR. `false` if the counterpart was created by the API client. */ + created_automatically?: boolean; + /** ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. */ + default_billing_address_id?: string; + /** ID of the shipping address. */ + default_shipping_address_id?: string; + /** Entity user ID of counterpart creator. */ + created_by_entity_user_id?: string; + individual: Monite.CounterpartIndividualResponse; + /** The language used to generate pdf documents for this counterpart. */ + language?: Monite.LanguageCodeEnum; + reminders_enabled?: boolean; + /** The counterpart's taxpayer identification number or tax ID. This field is required for counterparts that are non-VAT registered. */ + tax_id?: string; + /** The counterpart type: `organization` (juridical person) or `individual` (natural person). */ + type: Monite.CounterpartType; +} diff --git a/src/api/types/CounterpartIndividualRootUpdatePayload.ts b/src/api/types/CounterpartIndividualRootUpdatePayload.ts new file mode 100644 index 0000000..af317d6 --- /dev/null +++ b/src/api/types/CounterpartIndividualRootUpdatePayload.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are individuals (natural persons). + */ +export interface CounterpartIndividualRootUpdatePayload { + /** ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. */ + default_billing_address_id?: string; + /** ID of the shipping address. */ + default_shipping_address_id?: string; + individual: Monite.CounterpartIndividualUpdatePayload; + /** The language used to generate pdf documents for this counterpart. */ + language?: Monite.LanguageCodeEnum; + reminders_enabled?: boolean; + /** The counterpart's taxpayer identification number or tax ID. This field is required for counterparts that are non-VAT registered. */ + tax_id?: string; +} diff --git a/src/api/types/CounterpartIndividualUpdatePayload.ts b/src/api/types/CounterpartIndividualUpdatePayload.ts new file mode 100644 index 0000000..06f4d12 --- /dev/null +++ b/src/api/types/CounterpartIndividualUpdatePayload.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Represents counterparts that are individuals (natural persons). + */ +export interface CounterpartIndividualUpdatePayload { + /** The person's email address. */ + email?: string; + /** The person's first name. */ + first_name?: string; + /** Indicates if the counterpart is a customer. */ + is_customer?: boolean; + /** Indicates if the counterpart is a vendor. */ + is_vendor?: boolean; + /** The person's last name. */ + last_name?: string; + /** The person's phone number. */ + phone?: string; + /** A list of IDs of user-defined tags (labels) assigned to this counterpart. */ + tag_ids?: string[]; + /** The person's title or honorific. Examples: Mr., Ms., Dr., Prof. */ + title?: string; +} diff --git a/src/api/types/CounterpartOrganizationCreatePayload.ts b/src/api/types/CounterpartOrganizationCreatePayload.ts new file mode 100644 index 0000000..50fbcd7 --- /dev/null +++ b/src/api/types/CounterpartOrganizationCreatePayload.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are organizations (juridical persons). + */ +export interface CounterpartOrganizationCreatePayload { + /** The address of the organization. */ + address: Monite.CounterpartAddress; + /** The email address of the organization */ + email?: string; + /** Indicates if the counterpart is a customer. */ + is_customer: boolean; + /** Indicates if the counterpart is a vendor. */ + is_vendor: boolean; + /** The legal name of the organization. */ + legal_name: string; + /** The phone number of the organization */ + phone?: string; + /** A list of IDs of user-defined tags (labels) assigned to this counterpart. */ + tag_ids?: string[]; +} diff --git a/src/api/types/CounterpartOrganizationResponse.ts b/src/api/types/CounterpartOrganizationResponse.ts new file mode 100644 index 0000000..cc8745a --- /dev/null +++ b/src/api/types/CounterpartOrganizationResponse.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are organizations (juridical persons). + */ +export interface CounterpartOrganizationResponse { + /** The email address of the organization */ + email?: string; + /** Indicates if the counterpart is a customer. */ + is_customer: boolean; + /** Indicates if the counterpart is a vendor. */ + is_vendor: boolean; + /** The legal name of the organization. */ + legal_name: string; + /** The phone number of the organization */ + phone?: string; + /** The list of tags for this counterpart. */ + tags?: Monite.CounterpartTagSchema[]; +} diff --git a/src/api/types/CounterpartOrganizationRootCreatePayload.ts b/src/api/types/CounterpartOrganizationRootCreatePayload.ts new file mode 100644 index 0000000..eea8ab4 --- /dev/null +++ b/src/api/types/CounterpartOrganizationRootCreatePayload.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * This schema is used to create counterparts that are organizations (juridical persons). + */ +export interface CounterpartOrganizationRootCreatePayload { + /** The language used to generate pdf documents for this counterpart. */ + language?: Monite.LanguageCodeEnum; + organization: Monite.CounterpartOrganizationCreatePayload; + reminders_enabled?: boolean; + /** The counterpart's taxpayer identification number or tax ID. This field is required for counterparts that are non-VAT registered. */ + tax_id?: string; +} diff --git a/src/api/types/CounterpartOrganizationRootResponse.ts b/src/api/types/CounterpartOrganizationRootResponse.ts new file mode 100644 index 0000000..332f995 --- /dev/null +++ b/src/api/types/CounterpartOrganizationRootResponse.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are organizations (juridical persons). + */ +export interface CounterpartOrganizationRootResponse { + /** Unique ID of the counterpart. */ + id: string; + /** Date and time when the counterpart was created. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + created_at: string; + /** Date and time when the counterpart was last updated. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + updated_at: string; + /** `true` if the counterpart was created automatically by Monite when processing incoming invoices with OCR. `false` if the counterpart was created by the API client. */ + created_automatically?: boolean; + /** ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. */ + default_billing_address_id?: string; + /** ID of the shipping address. */ + default_shipping_address_id?: string; + /** Entity user ID of counterpart creator. */ + created_by_entity_user_id?: string; + /** The language used to generate pdf documents for this counterpart. */ + language?: Monite.LanguageCodeEnum; + organization: Monite.CounterpartOrganizationResponse; + reminders_enabled?: boolean; + /** The counterpart's taxpayer identification number or tax ID. This field is required for counterparts that are non-VAT registered. */ + tax_id?: string; + /** The counterpart type: `organization` (juridical person) or `individual` (natural person). */ + type: Monite.CounterpartType; +} diff --git a/src/api/types/CounterpartOrganizationRootUpdatePayload.ts b/src/api/types/CounterpartOrganizationRootUpdatePayload.ts new file mode 100644 index 0000000..a47ee9f --- /dev/null +++ b/src/api/types/CounterpartOrganizationRootUpdatePayload.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are organizations (juridical persons). + */ +export interface CounterpartOrganizationRootUpdatePayload { + /** ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. */ + default_billing_address_id?: string; + /** ID of the shipping address. */ + default_shipping_address_id?: string; + /** The language used to generate pdf documents for this counterpart. */ + language?: Monite.LanguageCodeEnum; + organization: Monite.CounterpartOrganizationUpdatePayload; + reminders_enabled?: boolean; + /** The counterpart's taxpayer identification number or tax ID. This field is required for counterparts that are non-VAT registered. */ + tax_id?: string; +} diff --git a/src/api/types/CounterpartOrganizationUpdatePayload.ts b/src/api/types/CounterpartOrganizationUpdatePayload.ts new file mode 100644 index 0000000..8763b48 --- /dev/null +++ b/src/api/types/CounterpartOrganizationUpdatePayload.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Represents counterparts that are organizations (juridical persons). + */ +export interface CounterpartOrganizationUpdatePayload { + /** The email address of the organization. */ + email?: string; + /** Indicates if the counterpart is a customer. */ + is_customer?: boolean; + /** Indicates if the counterpart is a vendor. */ + is_vendor?: boolean; + /** The legal name of the organization. */ + legal_name?: string; + /** The phone number of the organization. */ + phone?: string; + /** A list of IDs of user-defined tags (labels) assigned to this counterpart. */ + tag_ids?: string[]; +} diff --git a/src/api/types/CounterpartPaginationResponse.ts b/src/api/types/CounterpartPaginationResponse.ts new file mode 100644 index 0000000..0917756 --- /dev/null +++ b/src/api/types/CounterpartPaginationResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of counterparts + */ +export interface CounterpartPaginationResponse { + data: Monite.CounterpartResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/CounterpartRawAddress.ts b/src/api/types/CounterpartRawAddress.ts new file mode 100644 index 0000000..f5621ad --- /dev/null +++ b/src/api/types/CounterpartRawAddress.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Address information. + */ +export interface CounterpartRawAddress { + /** City name. */ + city?: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country?: Monite.AllowedCountries; + /** Street address. */ + line1?: string; + /** Additional address information (if any). */ + line2?: string; + /** ZIP or postal code. */ + postal_code?: string; + /** State, region, province, or county. */ + state?: string; +} diff --git a/src/api/types/CounterpartRawAddressUpdateRequest.ts b/src/api/types/CounterpartRawAddressUpdateRequest.ts new file mode 100644 index 0000000..badacaf --- /dev/null +++ b/src/api/types/CounterpartRawAddressUpdateRequest.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Address information. + */ +export interface CounterpartRawAddressUpdateRequest { + /** City name. */ + city?: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country?: Monite.AllowedCountries; + /** Street address. */ + line1?: string; + /** Additional address information (if any). */ + line2?: string; + /** ZIP or postal code. */ + postal_code?: string; + /** State, region, province, or county. */ + state?: string; +} diff --git a/src/api/types/CounterpartRawBankAccount.ts b/src/api/types/CounterpartRawBankAccount.ts new file mode 100644 index 0000000..f5203c3 --- /dev/null +++ b/src/api/types/CounterpartRawBankAccount.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CounterpartRawBankAccount { + /** Vendor's bank account name. */ + account_holder_name?: string; + /** Vendor's bank account number, IBAN, or similar (if specified in the payable document). */ + account_number?: string; + /** SWIFT code (BIC) of the vendor's bank. */ + bic?: string; + /** required for non-GB bank accounts */ + iban?: string; + /** required for GB bank accounts */ + sort_code?: string; +} diff --git a/src/api/types/CounterpartRawBankAccountUpdateRequest.ts b/src/api/types/CounterpartRawBankAccountUpdateRequest.ts new file mode 100644 index 0000000..390cb70 --- /dev/null +++ b/src/api/types/CounterpartRawBankAccountUpdateRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CounterpartRawBankAccountUpdateRequest { + /** Vendor's bank account name. */ + account_holder_name?: string; + /** Vendor's bank account number, IBAN, or similar (if specified in the payable document). */ + account_number?: string; + /** SWIFT code (BIC) of the vendor's bank. */ + bic?: string; + /** required for non-GB bank accounts */ + iban?: string; + /** required for GB bank accounts */ + sort_code?: string; +} diff --git a/src/api/types/CounterpartRawData.ts b/src/api/types/CounterpartRawData.ts new file mode 100644 index 0000000..50a101b --- /dev/null +++ b/src/api/types/CounterpartRawData.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartRawData { + /** The address of the vendor or supplier. */ + address?: Monite.CounterpartRawAddress; + /** Object representing counterpart bank account. */ + bank_account?: Monite.CounterpartRawBankAccount; + /** The email address of the organization */ + email?: string; + /** Vendor or supplier name. */ + name?: string; + /** The phone number of the organization */ + phone?: string; + /** The tax id of the counterpart. */ + tax_id?: string; + /** VAT ID of the vendor or supplier which was used in the invoice. */ + vat_id?: Monite.CounterpartRawVatId; +} diff --git a/src/api/types/CounterpartRawDataUpdateRequest.ts b/src/api/types/CounterpartRawDataUpdateRequest.ts new file mode 100644 index 0000000..1d073b9 --- /dev/null +++ b/src/api/types/CounterpartRawDataUpdateRequest.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartRawDataUpdateRequest { + /** The address of the vendor or supplier. */ + address?: Monite.CounterpartRawAddressUpdateRequest; + /** Object representing counterpart bank account. */ + bank_account?: Monite.CounterpartRawBankAccountUpdateRequest; + /** The email address of the organization */ + email?: string; + /** Vendor or supplier name. */ + name?: string; + /** The phone number of the organization */ + phone?: string; + /** The tax id of the counterpart. */ + tax_id?: string; + /** VAT ID of the vendor or supplier which was used in the invoice. */ + vat_id?: Monite.CounterpartRawVatIdUpdateRequest; +} diff --git a/src/api/types/CounterpartRawVatId.ts b/src/api/types/CounterpartRawVatId.ts new file mode 100644 index 0000000..8ecf5dc --- /dev/null +++ b/src/api/types/CounterpartRawVatId.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartRawVatId { + country?: Monite.AllowedCountries; + type?: string; + value?: string; +} diff --git a/src/api/types/CounterpartRawVatIdUpdateRequest.ts b/src/api/types/CounterpartRawVatIdUpdateRequest.ts new file mode 100644 index 0000000..098cb7c --- /dev/null +++ b/src/api/types/CounterpartRawVatIdUpdateRequest.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartRawVatIdUpdateRequest { + country?: Monite.AllowedCountries; + type?: string; + value?: string; +} diff --git a/src/api/types/CounterpartResponse.ts b/src/api/types/CounterpartResponse.ts new file mode 100644 index 0000000..1c12034 --- /dev/null +++ b/src/api/types/CounterpartResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A Counterpart object contains information about an organization (juridical person) or + * individual (natural person) that provides goods and services to or buys them from an + * [SME](https://docs.monite.com/docs/glossary#sme). + */ +export type CounterpartResponse = Monite.CounterpartIndividualRootResponse | Monite.CounterpartOrganizationRootResponse; diff --git a/src/api/types/CounterpartTagCategory.ts b/src/api/types/CounterpartTagCategory.ts new file mode 100644 index 0000000..27328ab --- /dev/null +++ b/src/api/types/CounterpartTagCategory.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CounterpartTagCategory = + | "document_type" + | "department" + | "project" + | "cost_center" + | "vendor_type" + | "payment_method" + | "approval_status"; + +export const CounterpartTagCategory = { + DocumentType: "document_type", + Department: "department", + Project: "project", + CostCenter: "cost_center", + VendorType: "vendor_type", + PaymentMethod: "payment_method", + ApprovalStatus: "approval_status", +} as const; diff --git a/src/api/types/CounterpartTagSchema.ts b/src/api/types/CounterpartTagSchema.ts new file mode 100644 index 0000000..c8c27b8 --- /dev/null +++ b/src/api/types/CounterpartTagSchema.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a user-defined tag that can be assigned to resources to filter them. + */ +export interface CounterpartTagSchema { + /** A unique ID of this tag. */ + id: string; + /** Date and time when the tag was created. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + created_at: string; + /** Date and time when the tag was last updated. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + updated_at: string; + /** The tag category. */ + category?: Monite.CounterpartTagCategory; + /** ID of the user who created the tag */ + created_by_entity_user_id?: string; + /** The tag description. */ + description?: string; + /** The tag name. */ + name: string; +} diff --git a/src/api/types/CounterpartType.ts b/src/api/types/CounterpartType.ts new file mode 100644 index 0000000..44b1c7c --- /dev/null +++ b/src/api/types/CounterpartType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CounterpartType = "individual" | "organization"; + +export const CounterpartType = { + Individual: "individual", + Organization: "organization", +} as const; diff --git a/src/api/types/CounterpartUpdatePayload.ts b/src/api/types/CounterpartUpdatePayload.ts new file mode 100644 index 0000000..4dba3b7 --- /dev/null +++ b/src/api/types/CounterpartUpdatePayload.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * This schema is used to update existing counterparts (organizations or individuals). + */ +export type CounterpartUpdatePayload = + | Monite.CounterpartIndividualRootUpdatePayload + | Monite.CounterpartOrganizationRootUpdatePayload; diff --git a/src/api/types/CounterpartVatIdResourceList.ts b/src/api/types/CounterpartVatIdResourceList.ts new file mode 100644 index 0000000..028549d --- /dev/null +++ b/src/api/types/CounterpartVatIdResourceList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartVatIdResourceList { + data: Monite.CounterpartVatIdResponse[]; +} diff --git a/src/api/types/CounterpartVatIdResponse.ts b/src/api/types/CounterpartVatIdResponse.ts new file mode 100644 index 0000000..4e81578 --- /dev/null +++ b/src/api/types/CounterpartVatIdResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CounterpartVatIdResponse { + id: string; + counterpart_id: string; + country?: Monite.AllowedCountries; + type?: Monite.VatIdTypeEnum; + value: string; +} diff --git a/src/api/types/CreateExportTaskResponseSchema.ts b/src/api/types/CreateExportTaskResponseSchema.ts new file mode 100644 index 0000000..3b0b3d1 --- /dev/null +++ b/src/api/types/CreateExportTaskResponseSchema.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CreateExportTaskResponseSchema { + id: string; +} diff --git a/src/api/types/CreateOnboardingLinkRequest.ts b/src/api/types/CreateOnboardingLinkRequest.ts new file mode 100644 index 0000000..461e335 --- /dev/null +++ b/src/api/types/CreateOnboardingLinkRequest.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CreateOnboardingLinkRequest { + recipient: Monite.Recipient; + refresh_url: string; + return_url: string; +} diff --git a/src/api/types/CreditNoteResponsePayload.ts b/src/api/types/CreditNoteResponsePayload.ts new file mode 100644 index 0000000..9ddcf31 --- /dev/null +++ b/src/api/types/CreditNoteResponsePayload.ts @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CreditNoteResponsePayload { + id: string; + /** Time at which the receivable was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the receivable was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + /** The unique ID of a previous document related to the receivable if applicable. */ + based_on?: string; + /** The unique document ID of a previous document related to the receivable if applicable. */ + based_on_document_id?: string; + /** The commercial terms of the receivable (e.g. The products must be delivered in X days). */ + commercial_condition_description?: string; + /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ + counterpart_billing_address?: Monite.ReceivablesRepresentationOfCounterpartAddress; + /** Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. */ + counterpart_business_type?: string; + /** Additional information about counterpart contacts. */ + counterpart_contact?: Monite.ReceivableCounterpartContact; + /** Unique ID of the counterpart. */ + counterpart_id: string; + /** A legal name of a counterpart it is an organization or first and last name if it is an individual */ + counterpart_name?: string; + /** Address where goods were shipped / where services were provided. */ + counterpart_shipping_address?: Monite.ReceivablesRepresentationOfCounterpartAddress; + /** The VAT/TAX ID of the counterpart. */ + counterpart_tax_id?: string; + /** The type of the counterpart. */ + counterpart_type: Monite.ReceivableCounterpartType; + counterpart_vat_id?: Monite.ReceivableCounterpartVatIdResponse; + /** The currency used in the receivable. */ + currency: Monite.CurrencyEnum; + /** The amount of tax deducted in minor units */ + deduction_amount?: number; + /** A note with additional information about a tax deduction */ + deduction_memo?: string; + /** The discount for a receivable. */ + discount?: Monite.Discount; + /** Total price of the receivable with discounts before taxes [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + discounted_subtotal?: number; + /** The sequential code systematically assigned to invoices. */ + document_id?: string; + /** Optional field representing date until which invoice should be paid */ + due_date?: string; + entity: Monite.CreditNoteResponsePayloadEntity; + entity_address: Monite.ReceivableEntityAddressSchema; + entity_bank_account?: Monite.ReceivablesRepresentationOfEntityBankAccount; + /** The entity user who created this document. */ + entity_user_id?: string; + entity_vat_id?: Monite.ReceivableEntityVatIdResponse; + file?: Monite.ReceivableFileSchema; + /** The language of the customer-facing PDF file (`file_url`). The value matches the counterpart's `language` at the time when this PDF file was generated. */ + file_language: Monite.LanguageCodeEnum; + /** The receivable's PDF URL in the counterpart's default language. */ + file_url?: string; + /** Optional field for the issue of the entry. */ + issue_date?: string; + line_items: Monite.ResponseItem[]; + /** A note with additional information for a receivable. */ + memo?: string; + /** The language of the entity's copy of the PDF file (`original_file_url`). The value matches the entity's `language` at the time when this PDF file was generated. */ + original_file_language: Monite.LanguageCodeEnum; + /** The receivable's PDF URL in the entity's default language. */ + original_file_url?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** A project related to current receivable */ + project_id?: string; + /** Contain purchase order number. */ + purchase_order?: string; + /** The status of the Credit Note inside the receivable workflow. */ + status: Monite.CreditNoteStateEnum; + /** The subtotal (excluding VAT), in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + subtotal?: number; + /** The list of tags for this receivable. */ + tags?: Monite.TagReadSchema[]; + /** Total price of the receivable in [minor units](https://docs.monite.com/docs/currencies#minor-units). Calculated as a subtotal + total_vat_amount. */ + total_amount?: number; + /** The total VAT of all line items, in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + total_vat_amount: number; + /** List of total vat amount for each VAT, presented in receivable */ + total_vat_amounts?: Monite.TotalVatAmountItem[]; + /** Total price of the receivable with tax withheld in minor units */ + total_withholding_tax?: number; + /** Trade name of the entity */ + trade_name?: string; + /** Indicates whether the goods, materials, or services listed in the receivable are exempt from VAT or not. */ + vat_exempt?: boolean; + /** The reason for the VAT exemption, if applicable. */ + vat_exemption_rationale?: string; + /** Defines whether the prices of products in receivable will already include VAT or not. */ + vat_mode?: Monite.VatModeEnum; + /** The amount of tax withheld in percent minor units */ + withholding_tax_rate?: number; +} diff --git a/src/api/types/CreditNoteResponsePayloadEntity.ts b/src/api/types/CreditNoteResponsePayloadEntity.ts new file mode 100644 index 0000000..2671e29 --- /dev/null +++ b/src/api/types/CreditNoteResponsePayloadEntity.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type CreditNoteResponsePayloadEntity = + | Monite.CreditNoteResponsePayloadEntity.Organization + | Monite.CreditNoteResponsePayloadEntity.Individual; + +export declare namespace CreditNoteResponsePayloadEntity { + interface Organization extends Monite.ReceivableEntityOrganization { + type: "organization"; + } + + interface Individual extends Monite.ReceivableEntityIndividual { + type: "individual"; + } +} diff --git a/src/api/types/CreditNoteStateEnum.ts b/src/api/types/CreditNoteStateEnum.ts new file mode 100644 index 0000000..460194e --- /dev/null +++ b/src/api/types/CreditNoteStateEnum.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CreditNoteStateEnum = "draft" | "issued" | "deleted"; + +export const CreditNoteStateEnum = { + Draft: "draft", + Issued: "issued", + Deleted: "deleted", +} as const; diff --git a/src/api/types/CurrencyEnum.ts b/src/api/types/CurrencyEnum.ts new file mode 100644 index 0000000..0792bdd --- /dev/null +++ b/src/api/types/CurrencyEnum.ts @@ -0,0 +1,280 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CurrencyEnum = + | "AED" + | "AFN" + | "ALL" + | "AMD" + | "ANG" + | "AOA" + | "ARS" + | "AUD" + | "AWG" + | "AZN" + | "BAM" + | "BBD" + | "BDT" + | "BGN" + | "BHD" + | "BIF" + | "BND" + | "BOB" + | "BRL" + | "BSD" + | "BWP" + | "BYN" + | "BZD" + | "CAD" + | "CDF" + | "CHF" + | "CLP" + | "CNY" + | "COP" + | "CRC" + | "CVE" + | "CZK" + | "DJF" + | "DKK" + | "DOP" + | "DZD" + | "EGP" + | "ETB" + | "EUR" + | "FJD" + | "GBP" + | "GEL" + | "GIP" + | "GMD" + | "GNF" + | "GTQ" + | "GYD" + | "HKD" + | "HNL" + | "HRK" + | "HTG" + | "HUF" + | "IDR" + | "ILS" + | "INR" + | "ISK" + | "JMD" + | "JOD" + | "JPY" + | "KES" + | "KGS" + | "KHR" + | "KMF" + | "KRW" + | "KWD" + | "KYD" + | "KZT" + | "LAK" + | "LBP" + | "LKR" + | "LRD" + | "LSL" + | "MAD" + | "MDL" + | "MGA" + | "MKD" + | "MMK" + | "MNT" + | "MOP" + | "MUR" + | "MVR" + | "MWK" + | "MXN" + | "MYR" + | "MZN" + | "NAD" + | "NGN" + | "NIO" + | "NOK" + | "NPR" + | "NZD" + | "OMR" + | "PAB" + | "PEN" + | "PGK" + | "PHP" + | "PKR" + | "PLN" + | "PYG" + | "QAR" + | "RON" + | "RSD" + | "RUB" + | "RWF" + | "SAR" + | "SBD" + | "SCR" + | "SEK" + | "SGD" + | "SLL" + | "SOS" + | "SRD" + | "SZL" + | "THB" + | "TJS" + | "TND" + | "TOP" + | "TRY" + | "TTD" + | "TWD" + | "TZS" + | "UAH" + | "UGX" + | "USD" + | "UYU" + | "UZS" + | "VND" + | "VUV" + | "WST" + | "XAF" + | "XCD" + | "XOF" + | "XPF" + | "YER" + | "ZAR" + | "ZMW"; + +export const CurrencyEnum = { + Aed: "AED", + Afn: "AFN", + All: "ALL", + Amd: "AMD", + Ang: "ANG", + Aoa: "AOA", + Ars: "ARS", + Aud: "AUD", + Awg: "AWG", + Azn: "AZN", + Bam: "BAM", + Bbd: "BBD", + Bdt: "BDT", + Bgn: "BGN", + Bhd: "BHD", + Bif: "BIF", + Bnd: "BND", + Bob: "BOB", + Brl: "BRL", + Bsd: "BSD", + Bwp: "BWP", + Byn: "BYN", + Bzd: "BZD", + Cad: "CAD", + Cdf: "CDF", + Chf: "CHF", + Clp: "CLP", + Cny: "CNY", + Cop: "COP", + Crc: "CRC", + Cve: "CVE", + Czk: "CZK", + Djf: "DJF", + Dkk: "DKK", + Dop: "DOP", + Dzd: "DZD", + Egp: "EGP", + Etb: "ETB", + Eur: "EUR", + Fjd: "FJD", + Gbp: "GBP", + Gel: "GEL", + Gip: "GIP", + Gmd: "GMD", + Gnf: "GNF", + Gtq: "GTQ", + Gyd: "GYD", + Hkd: "HKD", + Hnl: "HNL", + Hrk: "HRK", + Htg: "HTG", + Huf: "HUF", + Idr: "IDR", + Ils: "ILS", + Inr: "INR", + Isk: "ISK", + Jmd: "JMD", + Jod: "JOD", + Jpy: "JPY", + Kes: "KES", + Kgs: "KGS", + Khr: "KHR", + Kmf: "KMF", + Krw: "KRW", + Kwd: "KWD", + Kyd: "KYD", + Kzt: "KZT", + Lak: "LAK", + Lbp: "LBP", + Lkr: "LKR", + Lrd: "LRD", + Lsl: "LSL", + Mad: "MAD", + Mdl: "MDL", + Mga: "MGA", + Mkd: "MKD", + Mmk: "MMK", + Mnt: "MNT", + Mop: "MOP", + Mur: "MUR", + Mvr: "MVR", + Mwk: "MWK", + Mxn: "MXN", + Myr: "MYR", + Mzn: "MZN", + Nad: "NAD", + Ngn: "NGN", + Nio: "NIO", + Nok: "NOK", + Npr: "NPR", + Nzd: "NZD", + Omr: "OMR", + Pab: "PAB", + Pen: "PEN", + Pgk: "PGK", + Php: "PHP", + Pkr: "PKR", + Pln: "PLN", + Pyg: "PYG", + Qar: "QAR", + Ron: "RON", + Rsd: "RSD", + Rub: "RUB", + Rwf: "RWF", + Sar: "SAR", + Sbd: "SBD", + Scr: "SCR", + Sek: "SEK", + Sgd: "SGD", + Sll: "SLL", + Sos: "SOS", + Srd: "SRD", + Szl: "SZL", + Thb: "THB", + Tjs: "TJS", + Tnd: "TND", + Top: "TOP", + Try: "TRY", + Ttd: "TTD", + Twd: "TWD", + Tzs: "TZS", + Uah: "UAH", + Ugx: "UGX", + Usd: "USD", + Uyu: "UYU", + Uzs: "UZS", + Vnd: "VND", + Vuv: "VUV", + Wst: "WST", + Xaf: "XAF", + Xcd: "XCD", + Xof: "XOF", + Xpf: "XPF", + Yer: "YER", + Zar: "ZAR", + Zmw: "ZMW", +} as const; diff --git a/src/api/types/CurrencyExchangeSchema.ts b/src/api/types/CurrencyExchangeSchema.ts new file mode 100644 index 0000000..ff777ab --- /dev/null +++ b/src/api/types/CurrencyExchangeSchema.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CurrencyExchangeSchema { + default_currency_code: string; + rate: number; + total: number; +} diff --git a/src/api/types/CurrencySettings.ts b/src/api/types/CurrencySettings.ts new file mode 100644 index 0000000..f7e8279 --- /dev/null +++ b/src/api/types/CurrencySettings.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CurrencySettings { + default: Monite.CurrencyEnum; + exchange_rates?: Monite.ExchangeRate[]; +} diff --git a/src/api/types/CustomTemplateDataSchema.ts b/src/api/types/CustomTemplateDataSchema.ts new file mode 100644 index 0000000..0e56f1e --- /dev/null +++ b/src/api/types/CustomTemplateDataSchema.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CustomTemplateDataSchema { + /** ID of email template */ + id: string; + /** Template created date and time */ + created_at: string; + /** Template updated date and time */ + updated_at: string; + /** Jinja2 compatible email body template */ + body_template: string; + /** Is default template */ + is_default: boolean; + /** Lowercase ISO code of language */ + language: string; + /** Name of the template */ + name: string; + /** Jinja2 compatible email subject template */ + subject_template: string; + /** Document type of content */ + type: string; +} diff --git a/src/api/types/CustomTemplatesCursorFields.ts b/src/api/types/CustomTemplatesCursorFields.ts new file mode 100644 index 0000000..19389e2 --- /dev/null +++ b/src/api/types/CustomTemplatesCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CustomTemplatesCursorFields = "type" | "name"; + +export const CustomTemplatesCursorFields = { + Type: "type", + Name: "name", +} as const; diff --git a/src/api/types/CustomTemplatesPaginationResponse.ts b/src/api/types/CustomTemplatesPaginationResponse.ts new file mode 100644 index 0000000..2232fc5 --- /dev/null +++ b/src/api/types/CustomTemplatesPaginationResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface CustomTemplatesPaginationResponse { + /** All user-defined email templates */ + data: Monite.CustomTemplateDataSchema[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/DataExportCursorFields.ts b/src/api/types/DataExportCursorFields.ts new file mode 100644 index 0000000..55fecab --- /dev/null +++ b/src/api/types/DataExportCursorFields.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DataExportCursorFields = "created_at"; diff --git a/src/api/types/DayOfMonth.ts b/src/api/types/DayOfMonth.ts new file mode 100644 index 0000000..d9b34f7 --- /dev/null +++ b/src/api/types/DayOfMonth.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DayOfMonth = "first_day" | "last_day"; + +export const DayOfMonth = { + FirstDay: "first_day", + LastDay: "last_day", +} as const; diff --git a/src/api/types/Discount.ts b/src/api/types/Discount.ts new file mode 100644 index 0000000..38e0223 --- /dev/null +++ b/src/api/types/Discount.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface Discount { + /** The actual discount of the product in [minor units](https://docs.monite.com/docs/currencies#minor-units) if type field equals amount, else in percent minor units */ + amount: number; + /** The field specifies whether to use product currency or %. */ + type: Monite.DiscountType; +} diff --git a/src/api/types/DiscountType.ts b/src/api/types/DiscountType.ts new file mode 100644 index 0000000..494f0a4 --- /dev/null +++ b/src/api/types/DiscountType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DiscountType = "amount" | "percentage"; + +export const DiscountType = { + Amount: "amount", + Percentage: "percentage", +} as const; diff --git a/src/api/types/DnsRecord.ts b/src/api/types/DnsRecord.ts new file mode 100644 index 0000000..8fc1edf --- /dev/null +++ b/src/api/types/DnsRecord.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface DnsRecord { + is_active: boolean; + name?: string; + /** Purpose of specific entry to distinguish between various TXT entries. */ + record_purpose?: Monite.DnsRecordPurpose; + record_type: Monite.DnsRecordType; + /** Field reflecting validation status by Mailgun. */ + valid: string; + value: string; +} diff --git a/src/api/types/DnsRecordPurpose.ts b/src/api/types/DnsRecordPurpose.ts new file mode 100644 index 0000000..ada1077 --- /dev/null +++ b/src/api/types/DnsRecordPurpose.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DnsRecordPurpose = "DKIM" | "SPF"; + +export const DnsRecordPurpose = { + Dkim: "DKIM", + Spf: "SPF", +} as const; diff --git a/src/api/types/DnsRecordType.ts b/src/api/types/DnsRecordType.ts new file mode 100644 index 0000000..4d2cc5f --- /dev/null +++ b/src/api/types/DnsRecordType.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DnsRecordType = "TXT" | "MX" | "CNAME"; + +export const DnsRecordType = { + Txt: "TXT", + Mx: "MX", + Cname: "CNAME", +} as const; diff --git a/src/api/types/DnsRecords.ts b/src/api/types/DnsRecords.ts new file mode 100644 index 0000000..dc99156 --- /dev/null +++ b/src/api/types/DnsRecords.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface DnsRecords { + /** Set of DNS settings required by Mailgun for domain verification before emails receiving is possible. */ + receiving_dns_records: Monite.DnsRecord[]; + /** Set of DNS settings required by Mailgun for domain verification before emails sending is possible. */ + sending_dns_records: Monite.DnsRecord[]; +} diff --git a/src/api/types/DocumentExportResponseSchema.ts b/src/api/types/DocumentExportResponseSchema.ts new file mode 100644 index 0000000..e9b377a --- /dev/null +++ b/src/api/types/DocumentExportResponseSchema.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface DocumentExportResponseSchema { + id: string; + count: number; + created_by_entity_user_id?: string; + end_datetime?: string; + entity_id: string; + format: string; + language: string; + source_url?: string; + start_datetime?: string; + status: string; +} diff --git a/src/api/types/DocumentIDsSettings.ts b/src/api/types/DocumentIDsSettings.ts new file mode 100644 index 0000000..b4197f4 --- /dev/null +++ b/src/api/types/DocumentIDsSettings.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface DocumentIDsSettings { + /** Optionally add 4-digit of the current year */ + include_date?: boolean; + /** Optional prefix. Does not substitute document_type prefix */ + prefix?: string; + /** Which character should separate each part of the document_id */ + separator?: Monite.DocumentIdSeparators; + /** Prefixes for each document_type */ + document_type_prefix?: Monite.DocumentTypePrefix; + /** Minimal size of number in document ID Number will be left padded with zeros if less */ + min_digits?: number; +} diff --git a/src/api/types/DocumentIDsSettingsNextNumber.ts b/src/api/types/DocumentIDsSettingsNextNumber.ts new file mode 100644 index 0000000..ee6042c --- /dev/null +++ b/src/api/types/DocumentIDsSettingsNextNumber.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface DocumentIDsSettingsNextNumber { + quote?: number; + invoice?: number; + credit_note?: number; + purchase_order?: number; +} diff --git a/src/api/types/DocumentIDsSettingsRequest.ts b/src/api/types/DocumentIDsSettingsRequest.ts new file mode 100644 index 0000000..a137e9a --- /dev/null +++ b/src/api/types/DocumentIDsSettingsRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface DocumentIDsSettingsRequest { + /** Optionally add 4-digit of the current year */ + include_date?: boolean; + /** Optional prefix. Does not substitute document_type prefix */ + prefix?: string; + /** Which character should separate each part of the document_id */ + separator?: Monite.DocumentIdSeparators; + /** Prefixes for each document_type */ + document_type_prefix?: Monite.DocumentTypePrefix; + /** Minimal size of number in document ID Number will be left padded with zeros if less */ + min_digits?: number; + /** Write-only field. Changes which number will be issued next. Can't be less than the last issued document number */ + next_number?: Monite.DocumentIDsSettingsNextNumber; +} diff --git a/src/api/types/DocumentIdSeparators.ts b/src/api/types/DocumentIdSeparators.ts new file mode 100644 index 0000000..6db14ec --- /dev/null +++ b/src/api/types/DocumentIdSeparators.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DocumentIdSeparators = "/" | "-" | "|" | "." | ""; + +export const DocumentIdSeparators = { + Slash: "/", + Hyphen: "-", + Pipe: "|", + Dot: ".", + Empty: "", +} as const; diff --git a/src/api/types/DocumentObjectTypeRequestEnum.ts b/src/api/types/DocumentObjectTypeRequestEnum.ts new file mode 100644 index 0000000..d09138a --- /dev/null +++ b/src/api/types/DocumentObjectTypeRequestEnum.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DocumentObjectTypeRequestEnum = + | "receivables_quote" + | "receivables_invoice" + | "receivables_paid_invoice" + | "receivables_credit_note" + | "receivables_discount_reminder" + | "receivables_final_reminder" + | "payables_purchase_order" + | "payables_notify_approver" + | "payables_notify_payer"; + +export const DocumentObjectTypeRequestEnum = { + ReceivablesQuote: "receivables_quote", + ReceivablesInvoice: "receivables_invoice", + ReceivablesPaidInvoice: "receivables_paid_invoice", + ReceivablesCreditNote: "receivables_credit_note", + ReceivablesDiscountReminder: "receivables_discount_reminder", + ReceivablesFinalReminder: "receivables_final_reminder", + PayablesPurchaseOrder: "payables_purchase_order", + PayablesNotifyApprover: "payables_notify_approver", + PayablesNotifyPayer: "payables_notify_payer", +} as const; diff --git a/src/api/types/DocumentTypeEnum.ts b/src/api/types/DocumentTypeEnum.ts new file mode 100644 index 0000000..6a64c4d --- /dev/null +++ b/src/api/types/DocumentTypeEnum.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DocumentTypeEnum = + | "quote" + | "invoice" + | "credit_note" + | "discount_reminder" + | "final_reminder" + | "payables_purchase_order" + | "overdue_reminder"; + +export const DocumentTypeEnum = { + Quote: "quote", + Invoice: "invoice", + CreditNote: "credit_note", + DiscountReminder: "discount_reminder", + FinalReminder: "final_reminder", + PayablesPurchaseOrder: "payables_purchase_order", + OverdueReminder: "overdue_reminder", +} as const; diff --git a/src/api/types/DocumentTypePrefix.ts b/src/api/types/DocumentTypePrefix.ts new file mode 100644 index 0000000..c227001 --- /dev/null +++ b/src/api/types/DocumentTypePrefix.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface DocumentTypePrefix { + quote?: string; + invoice?: string; + credit_note?: string; + purchase_order?: string; +} diff --git a/src/api/types/DomainListResponse.ts b/src/api/types/DomainListResponse.ts new file mode 100644 index 0000000..bdad4b8 --- /dev/null +++ b/src/api/types/DomainListResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface DomainListResponse { + data: Monite.DomainResponse[]; +} diff --git a/src/api/types/DomainResponse.ts b/src/api/types/DomainResponse.ts new file mode 100644 index 0000000..753d796 --- /dev/null +++ b/src/api/types/DomainResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface DomainResponse { + /** Entry UUID */ + id: string; + /** A dedicated IP address assigned to this mailbox and used to send outgoing email. */ + dedicated_ip?: string; + dns_records: Monite.DomainResponseDnsRecords; + domain: string; + /** The time the domain was updated for the last time */ + last_updated_at?: string; + status: string; +} diff --git a/src/api/types/DomainResponseDnsRecords.ts b/src/api/types/DomainResponseDnsRecords.ts new file mode 100644 index 0000000..4bc4f6e --- /dev/null +++ b/src/api/types/DomainResponseDnsRecords.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type DomainResponseDnsRecords = Monite.DnsRecords | Record; diff --git a/src/api/types/EInvoicingProviderEnum.ts b/src/api/types/EInvoicingProviderEnum.ts new file mode 100644 index 0000000..13a2b6d --- /dev/null +++ b/src/api/types/EInvoicingProviderEnum.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EInvoicingProviderEnum = "avalara"; diff --git a/src/api/types/EInvoicingSettingsPayload.ts b/src/api/types/EInvoicingSettingsPayload.ts new file mode 100644 index 0000000..d0dce01 --- /dev/null +++ b/src/api/types/EInvoicingSettingsPayload.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EInvoicingSettingsPayload { + client_id: string; + client_secret: string; + provider: Monite.EInvoicingProviderEnum; +} diff --git a/src/api/types/EInvoicingSettingsResponse.ts b/src/api/types/EInvoicingSettingsResponse.ts new file mode 100644 index 0000000..4f9ad49 --- /dev/null +++ b/src/api/types/EInvoicingSettingsResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EInvoicingSettingsResponse { + client_id: string; + client_secret: string; + provider: Monite.EInvoicingProviderEnum; +} diff --git a/src/api/types/EntityAddressResponseSchema.ts b/src/api/types/EntityAddressResponseSchema.ts new file mode 100644 index 0000000..fd89523 --- /dev/null +++ b/src/api/types/EntityAddressResponseSchema.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema represents address info of the entity + */ +export interface EntityAddressResponseSchema { + /** A city (a full name) where the entity is registered */ + city: string; + /** A country name (as ISO code) where the entity is registered */ + country: Monite.AllowedCountries; + /** A street where the entity is registered */ + line1: string; + /** An alternative street used by the entity */ + line2?: string; + /** A postal code of the address where the entity is registered */ + postal_code: string; + /** A state in a country where the entity is registered */ + state?: string; +} diff --git a/src/api/types/EntityAddressSchema.ts b/src/api/types/EntityAddressSchema.ts new file mode 100644 index 0000000..c7ec355 --- /dev/null +++ b/src/api/types/EntityAddressSchema.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema represents address info of the entity + */ +export interface EntityAddressSchema { + /** A city (a full name) where the entity is registered */ + city: string; + /** A country name (as ISO code) where the entity is registered */ + country: Monite.AllowedCountries; + /** A street where the entity is registered */ + line1: string; + /** An alternative street used by the entity */ + line2?: string; + /** A postal code of the address where the entity is registered */ + postal_code: string; + /** State, county, province, prefecture, region, or similar component of the entity's address. For US entities, `state` is required and must be a two-letter [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for example, NY or CA. */ + state?: string; +} diff --git a/src/api/types/EntityBankAccountPaginationResponse.ts b/src/api/types/EntityBankAccountPaginationResponse.ts new file mode 100644 index 0000000..6f01cd3 --- /dev/null +++ b/src/api/types/EntityBankAccountPaginationResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of an entity's bank accounts. + */ +export interface EntityBankAccountPaginationResponse { + /** A list of an entity's bank accounts. */ + data: Monite.EntityBankAccountResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/EntityBankAccountResponse.ts b/src/api/types/EntityBankAccountResponse.ts new file mode 100644 index 0000000..3afbbbe --- /dev/null +++ b/src/api/types/EntityBankAccountResponse.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a bank account owned by an entity. + */ +export interface EntityBankAccountResponse { + /** Unique ID of the bank account. */ + id: string; + /** The name of the person or business that owns this bank account. Required if the account currency is GBP or USD. */ + account_holder_name?: string; + /** The bank account number. Required if the account currency is GBP or USD. UK account numbers typically contain 8 digits. US bank account numbers contain 9 to 12 digits. */ + account_number?: string; + /** The bank name. */ + bank_name?: string; + /** The SWIFT/BIC code of the bank. */ + bic?: string; + /** The country in which the bank account is registered, repsesented as a two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country?: Monite.AllowedCountries; + /** The currency of the bank account, represented as a three-letter ISO [currency code](https://docs.monite.com/docs/currencies). */ + currency?: Monite.CurrencyEnum; + /** User-defined name of this bank account, such as 'Primary account' or 'Savings account'. */ + display_name?: string; + /** The IBAN of the bank account. Required if the account currency is EUR. */ + iban?: string; + /** Indicates whether this bank account is the default one for its currency. */ + is_default_for_currency?: boolean; + /** The bank's routing transit number (RTN). Required if the account currency is USD. US routing numbers consist of 9 digits. */ + routing_number?: string; + /** The bank's sort code. Required if the account currency is GBP. */ + sort_code?: string; + /** ID of the entity user who added this bank account, or `null` if it was added using a partner access token. */ + was_created_by_user_id?: string; +} diff --git a/src/api/types/EntityBusinessStructure.ts b/src/api/types/EntityBusinessStructure.ts new file mode 100644 index 0000000..a9f3e68 --- /dev/null +++ b/src/api/types/EntityBusinessStructure.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EntityBusinessStructure = + | "incorporated_partnership" + | "unincorporated_partnership" + | "public_corporation" + | "private_corporation" + | "sole_proprietorship" + | "single_member_llc" + | "multi_member_llc" + | "private_partnership" + | "unincorporated_association" + | "public_partnership"; + +export const EntityBusinessStructure = { + IncorporatedPartnership: "incorporated_partnership", + UnincorporatedPartnership: "unincorporated_partnership", + PublicCorporation: "public_corporation", + PrivateCorporation: "private_corporation", + SoleProprietorship: "sole_proprietorship", + SingleMemberLlc: "single_member_llc", + MultiMemberLlc: "multi_member_llc", + PrivatePartnership: "private_partnership", + UnincorporatedAssociation: "unincorporated_association", + PublicPartnership: "public_partnership", +} as const; diff --git a/src/api/types/EntityCursorFields.ts b/src/api/types/EntityCursorFields.ts new file mode 100644 index 0000000..d0cbeaf --- /dev/null +++ b/src/api/types/EntityCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EntityCursorFields = "created_at" | "updated_at"; + +export const EntityCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/EntityIndividualResponse.ts b/src/api/types/EntityIndividualResponse.ts new file mode 100644 index 0000000..fc11c08 --- /dev/null +++ b/src/api/types/EntityIndividualResponse.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A base for an entity response schema + */ +export interface EntityIndividualResponse { + /** UUID entity ID */ + id: string; + /** UTC datetime */ + created_at: string; + /** UTC datetime */ + updated_at: string; + /** An address description of the entity */ + address: Monite.EntityAddressResponseSchema; + /** An official email address of the entity */ + email?: string; + /** A set of metadata describing an individual */ + individual: Monite.IndividualResponseSchema; + /** A logo image of the entity */ + logo?: Monite.FileSchema4; + /** A phone number of the entity */ + phone?: string; + /** record status, 'active' by default */ + status: Monite.StatusEnum; + /** The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. */ + tax_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/EntityOnboardingDataResponse.ts b/src/api/types/EntityOnboardingDataResponse.ts new file mode 100644 index 0000000..dbea07d --- /dev/null +++ b/src/api/types/EntityOnboardingDataResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EntityOnboardingDataResponse { + /** Business information about the entity. */ + business_profile?: Monite.BusinessProfile; + /** Used to attest that the beneficial owner information provided is both current and correct. */ + ownership_declaration?: Monite.OwnershipDeclaration; + /** Details on the entity's acceptance of the service agreement. */ + tos_acceptance?: Monite.TermsOfServiceAcceptance; +} diff --git a/src/api/types/EntityOnboardingDocuments.ts b/src/api/types/EntityOnboardingDocuments.ts new file mode 100644 index 0000000..56f8e6b --- /dev/null +++ b/src/api/types/EntityOnboardingDocuments.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface EntityOnboardingDocuments { + verification_document_front?: string; + verification_document_back?: string; + additional_verification_document_front?: string; + additional_verification_document_back?: string; + bank_account_ownership_verification?: string[]; + company_license?: string[]; + company_memorandum_of_association?: string[]; + company_ministerial_decree?: string[]; + company_registration_verification?: string[]; + company_tax_id_verification?: string[]; + proof_of_registration?: string[]; +} diff --git a/src/api/types/EntityOrganizationResponse.ts b/src/api/types/EntityOrganizationResponse.ts new file mode 100644 index 0000000..e8562b4 --- /dev/null +++ b/src/api/types/EntityOrganizationResponse.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A base for an entity response schema + */ +export interface EntityOrganizationResponse { + /** UUID entity ID */ + id: string; + /** UTC datetime */ + created_at: string; + /** UTC datetime */ + updated_at: string; + /** An address description of the entity */ + address: Monite.EntityAddressResponseSchema; + /** An official email address of the entity */ + email?: string; + /** A logo image of the entity */ + logo?: Monite.FileSchema4; + /** A set of metadata describing an organization */ + organization: Monite.OrganizationResponseSchema; + /** A phone number of the entity */ + phone?: string; + /** record status, 'active' by default */ + status: Monite.StatusEnum; + /** The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. */ + tax_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/EntityPaginationResponse.ts b/src/api/types/EntityPaginationResponse.ts new file mode 100644 index 0000000..8538313 --- /dev/null +++ b/src/api/types/EntityPaginationResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EntityPaginationResponse { + /** A set of entities of different types returned per page */ + data: Monite.EntityResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/EntityResponse.ts b/src/api/types/EntityResponse.ts new file mode 100644 index 0000000..3319583 --- /dev/null +++ b/src/api/types/EntityResponse.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema for a response after creation of an entity of different types + */ +export type EntityResponse = Monite.EntityResponse.Organization | Monite.EntityResponse.Individual; + +export declare namespace EntityResponse { + interface Organization extends Monite.EntityOrganizationResponse { + type: "organization"; + } + + interface Individual extends Monite.EntityIndividualResponse { + type: "individual"; + } +} diff --git a/src/api/types/EntityTypeEnum.ts b/src/api/types/EntityTypeEnum.ts new file mode 100644 index 0000000..c604e9b --- /dev/null +++ b/src/api/types/EntityTypeEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EntityTypeEnum = "individual" | "organization"; + +export const EntityTypeEnum = { + Individual: "individual", + Organization: "organization", +} as const; diff --git a/src/api/types/EntityUserCursorFields.ts b/src/api/types/EntityUserCursorFields.ts new file mode 100644 index 0000000..81f3762 --- /dev/null +++ b/src/api/types/EntityUserCursorFields.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EntityUserCursorFields = "updated_at"; diff --git a/src/api/types/EntityUserPaginationResponse.ts b/src/api/types/EntityUserPaginationResponse.ts new file mode 100644 index 0000000..4823d78 --- /dev/null +++ b/src/api/types/EntityUserPaginationResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EntityUserPaginationResponse { + /** array of records */ + data: Monite.EntityUserResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/EntityUserResponse.ts b/src/api/types/EntityUserResponse.ts new file mode 100644 index 0000000..853648e --- /dev/null +++ b/src/api/types/EntityUserResponse.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A scheme for validation an entity user additional info + */ +export interface EntityUserResponse { + /** UUID entity user ID */ + id: string; + /** UTC datetime */ + created_at: string; + /** UTC datetime */ + updated_at: string; + /** An entity user business email */ + email?: string; + /** First name */ + first_name?: string; + /** Last name */ + last_name?: string; + /** Login */ + login: string; + /** An entity user phone number in the international format */ + phone?: string; + /** UUID role ID */ + role_id: string; + /** record status, 'active' by default */ + status: Monite.StatusEnum; + userpic_file_id?: string; +} diff --git a/src/api/types/EntityVatIdResourceList.ts b/src/api/types/EntityVatIdResourceList.ts new file mode 100644 index 0000000..119a299 --- /dev/null +++ b/src/api/types/EntityVatIdResourceList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EntityVatIdResourceList { + data: Monite.EntityVatIdResponse[]; +} diff --git a/src/api/types/EntityVatIdResponse.ts b/src/api/types/EntityVatIdResponse.ts new file mode 100644 index 0000000..30edb45 --- /dev/null +++ b/src/api/types/EntityVatIdResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EntityVatIdResponse { + id: string; + country: Monite.AllowedCountries; + entity_id: string; + type?: Monite.VatIdTypeEnum; + value: string; +} diff --git a/src/api/types/ErrorSchema.ts b/src/api/types/ErrorSchema.ts new file mode 100644 index 0000000..559a44f --- /dev/null +++ b/src/api/types/ErrorSchema.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ErrorSchema { + message: string; +} diff --git a/src/api/types/ErrorSchemaResponse.ts b/src/api/types/ErrorSchemaResponse.ts new file mode 100644 index 0000000..c7e8035 --- /dev/null +++ b/src/api/types/ErrorSchemaResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ErrorSchemaResponse { + error: Monite.ErrorSchema; +} diff --git a/src/api/types/EstimatedMonthlyRevenue.ts b/src/api/types/EstimatedMonthlyRevenue.ts new file mode 100644 index 0000000..cd1d9f2 --- /dev/null +++ b/src/api/types/EstimatedMonthlyRevenue.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EstimatedMonthlyRevenue { + /** The amount of the monthly revenue, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250.. */ + amount?: number; + /** [Currency code](https://docs.monite.com/docs/currencies) of the revenue. */ + currency?: Monite.CurrencyEnum; +} diff --git a/src/api/types/EventCursorFields.ts b/src/api/types/EventCursorFields.ts new file mode 100644 index 0000000..f6b6183 --- /dev/null +++ b/src/api/types/EventCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EventCursorFields = "created_at" | "updated_at"; + +export const EventCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/EventPaginationResource.ts b/src/api/types/EventPaginationResource.ts new file mode 100644 index 0000000..5e29d07 --- /dev/null +++ b/src/api/types/EventPaginationResource.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EventPaginationResource { + /** A set of events returned per page */ + data: Monite.EventResource[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/EventResource.ts b/src/api/types/EventResource.ts new file mode 100644 index 0000000..2a3073f --- /dev/null +++ b/src/api/types/EventResource.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EventResource { + id: string; + /** The timestamp that was generated at the time of making the database transaction that has initially caused the event */ + created_at?: string; + action: string; + api_version?: string; + description: string; + entity_id: string; + object?: unknown; + object_type: Monite.WebhookObjectType; +} diff --git a/src/api/types/EventResourceForWebhookClient.ts b/src/api/types/EventResourceForWebhookClient.ts new file mode 100644 index 0000000..b9c1630 --- /dev/null +++ b/src/api/types/EventResourceForWebhookClient.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface EventResourceForWebhookClient { + id: string; + /** The timestamp that was generated at the time of making the database transaction that has initially caused the event */ + created_at?: string; + action: string; + api_version?: string; + description: string; + entity_id: string; + object?: unknown; + object_type: Monite.WebhookObjectType; + webhook_subscription_id: string; +} diff --git a/src/api/types/ExchangeRate.ts b/src/api/types/ExchangeRate.ts new file mode 100644 index 0000000..206bd53 --- /dev/null +++ b/src/api/types/ExchangeRate.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ExchangeRate { + base: Monite.CurrencyEnum; + rate: number; + to: Monite.CurrencyEnum; +} diff --git a/src/api/types/ExportFormat.ts b/src/api/types/ExportFormat.ts new file mode 100644 index 0000000..3833165 --- /dev/null +++ b/src/api/types/ExportFormat.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ExportFormat = "csv" | "pdf" | "csv_xero"; + +export const ExportFormat = { + Csv: "csv", + Pdf: "pdf", + CsvXero: "csv_xero", +} as const; diff --git a/src/api/types/ExportObjectSchema.ts b/src/api/types/ExportObjectSchema.ts new file mode 100644 index 0000000..6e744a7 --- /dev/null +++ b/src/api/types/ExportObjectSchema.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type ExportObjectSchema = Monite.ExportObjectSchema.Payable | Monite.ExportObjectSchema.Receivable; + +export declare namespace ExportObjectSchema { + interface Payable extends Monite.ExportPayableSchema { + name: "payable"; + } + + interface Receivable extends Monite.ExportReceivableSchema { + name: "receivable"; + } +} diff --git a/src/api/types/ExportPayableSchema.ts b/src/api/types/ExportPayableSchema.ts new file mode 100644 index 0000000..b3e3363 --- /dev/null +++ b/src/api/types/ExportPayableSchema.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ExportPayableSchema { + statuses: Monite.PayableStateEnum[]; +} diff --git a/src/api/types/ExportReceivableSchema.ts b/src/api/types/ExportReceivableSchema.ts new file mode 100644 index 0000000..0c67067 --- /dev/null +++ b/src/api/types/ExportReceivableSchema.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ExportReceivableSchema { + statuses: Monite.ReceivablesStatusEnum[]; +} diff --git a/src/api/types/ExportSettingCursorFields.ts b/src/api/types/ExportSettingCursorFields.ts new file mode 100644 index 0000000..df88ca5 --- /dev/null +++ b/src/api/types/ExportSettingCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ExportSettingCursorFields = "id" | "created_at"; + +export const ExportSettingCursorFields = { + Id: "id", + CreatedAt: "created_at", +} as const; diff --git a/src/api/types/ExtraDataResource.ts b/src/api/types/ExtraDataResource.ts new file mode 100644 index 0000000..7ba0f67 --- /dev/null +++ b/src/api/types/ExtraDataResource.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ExtraDataResource { + id: string; + created_at: string; + updated_at: string; + created_by?: string; + field_name: Monite.SupportedFieldNames; + field_value: string; + object_id: string; + object_type: "counterpart"; +} diff --git a/src/api/types/ExtraDataResourceList.ts b/src/api/types/ExtraDataResourceList.ts new file mode 100644 index 0000000..5316300 --- /dev/null +++ b/src/api/types/ExtraDataResourceList.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ExtraDataResourceList { + data: Monite.ExtraDataResource[]; + next_pagination_token?: string; + prev_pagination_token?: string; +} diff --git a/src/api/types/FileResponse.ts b/src/api/types/FileResponse.ts new file mode 100644 index 0000000..e9df806 --- /dev/null +++ b/src/api/types/FileResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface FileResponse { + id: string; + created_at: string; + updated_at: string; + file_type: string; + md5: string; + mimetype: string; + name: string; + region: string; + s3_bucket: string; + s3_file_path: string; + size: number; + url: string; +} diff --git a/src/api/types/FileSchema.ts b/src/api/types/FileSchema.ts new file mode 100644 index 0000000..3c51415 --- /dev/null +++ b/src/api/types/FileSchema.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a file (such as a PDF invoice) that was uploaded to Monite. + */ +export interface FileSchema { + /** A unique ID of this file. */ + id: string; + /** UTC date and time when this workflow was uploaded to Monite. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ + created_at: string; + /** The type of the business object associated with this file. */ + file_type: string; + /** The MD5 hash of the file. */ + md5: string; + /** The file's [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types). */ + mimetype: string; + /** The original file name (if available). */ + name: string; + /** If the file is a PDF document, this property contains individual pages extracted from the file. Otherwise, an empty array. */ + pages?: Monite.PageSchema[]; + /** Preview images generated for this file. There can be multiple images with different sizes. */ + previews?: Monite.PreviewSchema[]; + /** Geographical region of the data center where the file is stored. */ + region: string; + /** The file size in bytes. */ + size: number; + /** The URL to download the file. */ + url: string; +} diff --git a/src/api/types/FileSchema2.ts b/src/api/types/FileSchema2.ts new file mode 100644 index 0000000..61d73d2 --- /dev/null +++ b/src/api/types/FileSchema2.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a file (such as a PDF invoice) that was uploaded to Monite. + */ +export interface FileSchema2 { + /** A unique ID of this file. */ + id: string; + /** UTC date and time when this workflow was uploaded to Monite. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ + created_at: string; + /** The type of the business object associated with this file. */ + file_type: string; + /** The MD5 hash of the file. */ + md5: string; + /** The file's [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types). */ + mimetype: string; + /** The original file name (if available). */ + name: string; + /** If the file is a PDF document, this property contains individual pages extracted from the file. Otherwise, an empty array. */ + pages?: Monite.PageSchema2[]; + /** Preview images generated for this file. There can be multiple images with different sizes. */ + previews?: Monite.PreviewSchema2[]; + /** Geographical region of the data center where the file is stored. */ + region: string; + /** The file size in bytes. */ + size: number; + /** The URL to download the file. */ + url: string; +} diff --git a/src/api/types/FileSchema3.ts b/src/api/types/FileSchema3.ts new file mode 100644 index 0000000..50350ad --- /dev/null +++ b/src/api/types/FileSchema3.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a file (such as a PDF invoice) that was uploaded to Monite. + */ +export interface FileSchema3 { + /** A unique ID of this file. */ + id: string; + /** UTC date and time when this file was uploaded to Monite. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ + created_at: string; + /** The type of the business object associated with this file. */ + file_type: string; + /** The original file name (if available). */ + name: string; + /** Geographical region of the data center where the file is stored. */ + region: string; + /** The MD5 hash of the file. */ + md5: string; + /** The file's [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types). */ + mimetype: string; + /** The URL to download the file. */ + url: string; + /** The file size in bytes. */ + size: number; + /** Preview images generated for this file. There can be multiple images with different sizes. */ + previews?: Monite.PreviewSchema3[]; + /** If the file is a PDF document, this property contains individual pages extracted from the file. Otherwise, an empty array. */ + pages?: Monite.PageSchema3[]; +} diff --git a/src/api/types/FileSchema4.ts b/src/api/types/FileSchema4.ts new file mode 100644 index 0000000..1d0424e --- /dev/null +++ b/src/api/types/FileSchema4.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a file (such as a PDF invoice) that was uploaded to Monite. + */ +export interface FileSchema4 { + /** A unique ID of this file. */ + id: string; + /** UTC date and time when this workflow was uploaded to Monite. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ + created_at: string; + /** The type of the business object associated with this file. */ + file_type: string; + /** The MD5 hash of the file. */ + md5: string; + /** The file's [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types). */ + mimetype: string; + /** The original file name (if available). */ + name: string; + /** If the file is a PDF document, this property contains individual pages extracted from the file. Otherwise, an empty array. */ + pages?: Monite.PageSchema4[]; + /** Preview images generated for this file. There can be multiple images with different sizes. */ + previews?: Monite.PreviewSchema4[]; + /** Geographical region of the data center where the file is stored. */ + region: string; + /** The file size in bytes. */ + size: number; + /** The URL to download the file. */ + url: string; +} diff --git a/src/api/types/FilesResponse.ts b/src/api/types/FilesResponse.ts new file mode 100644 index 0000000..af04336 --- /dev/null +++ b/src/api/types/FilesResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface FilesResponse { + data: Monite.FileResponse[]; +} diff --git a/src/api/types/GetAllPaymentReminders.ts b/src/api/types/GetAllPaymentReminders.ts new file mode 100644 index 0000000..35bd0d1 --- /dev/null +++ b/src/api/types/GetAllPaymentReminders.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface GetAllPaymentReminders { + data: Monite.PaymentReminderResponse[]; +} diff --git a/src/api/types/GetAllRecurrences.ts b/src/api/types/GetAllRecurrences.ts new file mode 100644 index 0000000..6f8dae7 --- /dev/null +++ b/src/api/types/GetAllRecurrences.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface GetAllRecurrences { + data: Monite.Recurrence[]; +} diff --git a/src/api/types/GetOnboardingRequirementsResponse.ts b/src/api/types/GetOnboardingRequirementsResponse.ts new file mode 100644 index 0000000..f470060 --- /dev/null +++ b/src/api/types/GetOnboardingRequirementsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface GetOnboardingRequirementsResponse { + data: Monite.SingleOnboardingRequirementsResponse[]; +} diff --git a/src/api/types/GrantType.ts b/src/api/types/GrantType.ts new file mode 100644 index 0000000..9bb563b --- /dev/null +++ b/src/api/types/GrantType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type GrantType = "client_credentials" | "entity_user"; + +export const GrantType = { + ClientCredentials: "client_credentials", + EntityUser: "entity_user", +} as const; diff --git a/src/api/types/HttpValidationError.ts b/src/api/types/HttpValidationError.ts new file mode 100644 index 0000000..1d0e607 --- /dev/null +++ b/src/api/types/HttpValidationError.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface HttpValidationError { + detail?: Monite.ValidationError[]; +} diff --git a/src/api/types/IndividualResponseSchema.ts b/src/api/types/IndividualResponseSchema.ts new file mode 100644 index 0000000..db3b670 --- /dev/null +++ b/src/api/types/IndividualResponseSchema.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Contains data specific to entities of the `individual` type. + */ +export interface IndividualResponseSchema { + date_of_birth?: string; + /** A first name of an individual */ + first_name: string; + id_number?: string; + /** A last name of an individual */ + last_name: string; + ssn_last_4?: string; + /** A title of an individual */ + title?: string; +} diff --git a/src/api/types/IndividualSchema.ts b/src/api/types/IndividualSchema.ts new file mode 100644 index 0000000..0afa903 --- /dev/null +++ b/src/api/types/IndividualSchema.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A schema contains metadata for an individual + */ +export interface IndividualSchema { + date_of_birth?: string; + /** A first name of an individual */ + first_name: string; + id_number?: string; + /** A last name of an individual */ + last_name: string; + /** The last four digits of the individual's Social Security number */ + ssn_last_4?: string; + /** A title of an individual */ + title?: string; +} diff --git a/src/api/types/Invoice.ts b/src/api/types/Invoice.ts new file mode 100644 index 0000000..1b5130e --- /dev/null +++ b/src/api/types/Invoice.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface Invoice { + due_date?: string; + file?: Monite.InvoiceFile; + issue_date?: string; +} diff --git a/src/api/types/InvoiceFile.ts b/src/api/types/InvoiceFile.ts new file mode 100644 index 0000000..343582e --- /dev/null +++ b/src/api/types/InvoiceFile.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface InvoiceFile { + mimetype: string; + name: string; + url: string; +} diff --git a/src/api/types/InvoiceResponsePayload.ts b/src/api/types/InvoiceResponsePayload.ts new file mode 100644 index 0000000..8975283 --- /dev/null +++ b/src/api/types/InvoiceResponsePayload.ts @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface InvoiceResponsePayload { + id: string; + /** Time at which the receivable was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the receivable was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + /** How much is left to be paid in [minor units](https://docs.monite.com/docs/currencies#minor-units). Equal 0 if the Invoice is fully paid. */ + amount_due: number; + /** How much has been paid [minor units](https://docs.monite.com/docs/currencies#minor-units) */ + amount_paid: number; + /** How much is left to be paid in in [minor units](https://docs.monite.com/docs/currencies#minor-units), including payment_term discounts. */ + amount_to_pay?: number; + /** The unique ID of a previous document related to the receivable if applicable. */ + based_on?: string; + /** The unique document ID of a previous document related to the receivable if applicable. */ + based_on_document_id?: string; + /** Field with a comment for pay/partially/uncollectible info on this Invoice */ + comment?: string; + /** The commercial terms of the receivable (e.g. The products must be delivered in X days). */ + commercial_condition_description?: string; + /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ + counterpart_billing_address?: Monite.ReceivablesRepresentationOfCounterpartAddress; + /** Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. */ + counterpart_business_type?: string; + /** Additional information about counterpart contacts. */ + counterpart_contact?: Monite.ReceivableCounterpartContact; + /** Unique ID of the counterpart. */ + counterpart_id: string; + /** A legal name of a counterpart it is an organization or first and last name if it is an individual */ + counterpart_name?: string; + /** Address where goods were shipped / where services were provided. */ + counterpart_shipping_address?: Monite.ReceivablesRepresentationOfCounterpartAddress; + /** The VAT/TAX ID of the counterpart. */ + counterpart_tax_id?: string; + /** The type of the counterpart. */ + counterpart_type: Monite.ReceivableCounterpartType; + counterpart_vat_id?: Monite.ReceivableCounterpartVatIdResponse; + /** The currency used in the receivable. */ + currency: Monite.CurrencyEnum; + /** The amount of tax deducted in minor units */ + deduction_amount?: number; + /** A note with additional information about a tax deduction */ + deduction_memo?: string; + /** The discount for a receivable. */ + discount?: Monite.Discount; + /** Total price of the receivable with discounts before taxes [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + discounted_subtotal?: number; + /** The sequential code systematically assigned to invoices. */ + document_id?: string; + /** Optional field representing date until which invoice should be paid */ + due_date?: string; + entity: Monite.InvoiceResponsePayloadEntity; + entity_address: Monite.ReceivableEntityAddressSchema; + entity_bank_account?: Monite.ReceivablesRepresentationOfEntityBankAccount; + /** The entity user who created this document. */ + entity_user_id?: string; + entity_vat_id?: Monite.ReceivableEntityVatIdResponse; + file?: Monite.ReceivableFileSchema; + /** The language of the customer-facing PDF file (`file_url`). The value matches the counterpart's `language` at the time when this PDF file was generated. */ + file_language: Monite.LanguageCodeEnum; + /** The receivable's PDF URL in the counterpart's default language. */ + file_url?: string; + /** + * The date when the goods are shipped or the service is provided. + * + * If omitted, defaults to the invoice issue date, + * and the value is automatically set when the invoice status changes to `issued`. + */ + fulfillment_date?: string; + /** Optional field for the issue of the entry. */ + issue_date?: string; + line_items: Monite.ResponseItem[]; + /** A note with additional information for a receivable. */ + memo?: string; + /** The language of the entity's copy of the PDF file (`original_file_url`). The value matches the entity's `language` at the time when this PDF file was generated. */ + original_file_language: Monite.LanguageCodeEnum; + /** The receivable's PDF URL in the entity's default language. */ + original_file_url?: string; + overdue_reminder_id?: string; + /** Date and time when the invoice was paid. */ + paid_at?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** Link to the invoice's payment page. Either Monite's payment links or your custom payment links. */ + payment_page_url?: string; + payment_reminder_id?: string; + payment_terms?: Monite.PaymentTerms; + /** A project related to current receivable */ + project_id?: string; + /** Contain purchase order number. */ + purchase_order?: string; + /** Stores an unique ID of a recurrence if the receivable is in a recurring status */ + recurrence_id?: string; + /** Ids of documents that relate to invoice. I.e credit notes, proforma invoices, etc. */ + related_documents: Monite.RelatedDocuments; + /** The status of the receivable inside the receivable workflow. */ + status: Monite.ReceivablesStatusEnum; + /** The subtotal (excluding VAT), in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + subtotal?: number; + /** The list of tags for this receivable. */ + tags?: Monite.TagReadSchema[]; + /** Total price of the receivable in [minor units](https://docs.monite.com/docs/currencies#minor-units). Calculated as a subtotal + total_vat_amount. */ + total_amount?: number; + /** The total price of the receivable in [minor units](https://docs.monite.com/docs/currencies#minor-units), including VAT and excluding all issued credit notes. */ + total_amount_with_credit_notes: number; + /** The total VAT of all line items, in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + total_vat_amount: number; + /** List of total vat amount for each VAT, presented in receivable */ + total_vat_amounts?: Monite.TotalVatAmountItem[]; + /** Total price of the receivable with tax withheld in minor units */ + total_withholding_tax?: number; + /** Trade name of the entity */ + trade_name?: string; + /** Indicates whether the goods, materials, or services listed in the receivable are exempt from VAT or not. */ + vat_exempt?: boolean; + /** The reason for the VAT exemption, if applicable. */ + vat_exemption_rationale?: string; + /** Defines whether the prices of products in receivable will already include VAT or not. */ + vat_mode?: Monite.VatModeEnum; + /** The amount of tax withheld in percent minor units */ + withholding_tax_rate?: number; +} diff --git a/src/api/types/InvoiceResponsePayloadEntity.ts b/src/api/types/InvoiceResponsePayloadEntity.ts new file mode 100644 index 0000000..5cd90ad --- /dev/null +++ b/src/api/types/InvoiceResponsePayloadEntity.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type InvoiceResponsePayloadEntity = + | Monite.InvoiceResponsePayloadEntity.Organization + | Monite.InvoiceResponsePayloadEntity.Individual; + +export declare namespace InvoiceResponsePayloadEntity { + interface Organization extends Monite.ReceivableEntityOrganization { + type: "organization"; + } + + interface Individual extends Monite.ReceivableEntityIndividual { + type: "individual"; + } +} diff --git a/src/api/types/Item.ts b/src/api/types/Item.ts new file mode 100644 index 0000000..62ca8cc --- /dev/null +++ b/src/api/types/Item.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Contains information about a text block or line extracted from an uploaded document by OCR. + */ +export interface Item { + /** The text as recognized by OCR. */ + text: string; + /** OCR confidence score - the estimated accuracy percentage of character recognition of the extracted text, from 0 to 100%. */ + confidence: number; + processed_text?: unknown; +} diff --git a/src/api/types/IterationStatus.ts b/src/api/types/IterationStatus.ts new file mode 100644 index 0000000..b6ece86 --- /dev/null +++ b/src/api/types/IterationStatus.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type IterationStatus = "pending" | "completed" | "canceled" | "issue_failed" | "send_failed"; + +export const IterationStatus = { + Pending: "pending", + Completed: "completed", + Canceled: "canceled", + IssueFailed: "issue_failed", + SendFailed: "send_failed", +} as const; diff --git a/src/api/types/LabelNValue.ts b/src/api/types/LabelNValue.ts new file mode 100644 index 0000000..ef7f7e8 --- /dev/null +++ b/src/api/types/LabelNValue.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A label-value pair extracted from an uploaded document by OCR. + * For example, the label could be "Total" and the value could be a currency amount. + */ +export interface LabelNValue { + /** Text label. */ + label: Monite.Item; + /** The value (if any). */ + value: Monite.Item; +} diff --git a/src/api/types/LanguageCodeEnum.ts b/src/api/types/LanguageCodeEnum.ts new file mode 100644 index 0000000..9af11e4 --- /dev/null +++ b/src/api/types/LanguageCodeEnum.ts @@ -0,0 +1,368 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type LanguageCodeEnum = + | "ab" + | "aa" + | "af" + | "ak" + | "sq" + | "am" + | "ar" + | "an" + | "hy" + | "av" + | "ae" + | "ay" + | "az" + | "bm" + | "ba" + | "eu" + | "be" + | "bn" + | "bi" + | "bs" + | "br" + | "bg" + | "my" + | "ca" + | "ch" + | "ce" + | "ny" + | "zh" + | "cu" + | "cv" + | "kw" + | "co" + | "cr" + | "hr" + | "cs" + | "da" + | "dv" + | "nl" + | "dz" + | "en" + | "eo" + | "et" + | "ee" + | "fo" + | "fj" + | "fi" + | "fr" + | "fy" + | "ff" + | "gd" + | "gl" + | "lg" + | "ka" + | "de" + | "el" + | "kl" + | "gn" + | "gu" + | "ht" + | "ha" + | "he" + | "hz" + | "hi" + | "ho" + | "hu" + | "io" + | "ig" + | "id" + | "ia" + | "ie" + | "iu" + | "ik" + | "ga" + | "it" + | "ja" + | "jv" + | "kn" + | "kr" + | "ks" + | "kk" + | "km" + | "ki" + | "rw" + | "ky" + | "kv" + | "kg" + | "ko" + | "kj" + | "ku" + | "lo" + | "la" + | "lv" + | "li" + | "ln" + | "lt" + | "lu" + | "lb" + | "mk" + | "mg" + | "ms" + | "ml" + | "mt" + | "gv" + | "mi" + | "mr" + | "mh" + | "mn" + | "na" + | "nv" + | "nd" + | "nr" + | "ng" + | "ne" + | "no" + | "nb" + | "nn" + | "ii" + | "oc" + | "oj" + | "om" + | "os" + | "pi" + | "ps" + | "fa" + | "pl" + | "pt" + | "pa" + | "qu" + | "ro" + | "rm" + | "rn" + | "ru" + | "se" + | "sm" + | "sg" + | "sa" + | "sc" + | "sr" + | "sn" + | "sd" + | "si" + | "sk" + | "sl" + | "so" + | "st" + | "es" + | "su" + | "sw" + | "ss" + | "sv" + | "tl" + | "ty" + | "tg" + | "ta" + | "tt" + | "te" + | "th" + | "bo" + | "ti" + | "to" + | "ts" + | "tn" + | "tr" + | "tk" + | "tw" + | "ug" + | "uk" + | "ur" + | "uz" + | "ve" + | "vi" + | "vo" + | "wa" + | "cy" + | "wo" + | "xh" + | "yi" + | "yo" + | "za" + | "zu"; + +export const LanguageCodeEnum = { + Ab: "ab", + Aa: "aa", + Af: "af", + Ak: "ak", + Sq: "sq", + Am: "am", + Ar: "ar", + An: "an", + Hy: "hy", + Av: "av", + Ae: "ae", + Ay: "ay", + Az: "az", + Bm: "bm", + Ba: "ba", + Eu: "eu", + Be: "be", + Bn: "bn", + Bi: "bi", + Bs: "bs", + Br: "br", + Bg: "bg", + My: "my", + Ca: "ca", + Ch: "ch", + Ce: "ce", + Ny: "ny", + Zh: "zh", + Cu: "cu", + Cv: "cv", + Kw: "kw", + Co: "co", + Cr: "cr", + Hr: "hr", + Cs: "cs", + Da: "da", + Dv: "dv", + Nl: "nl", + Dz: "dz", + En: "en", + Eo: "eo", + Et: "et", + Ee: "ee", + Fo: "fo", + Fj: "fj", + Fi: "fi", + Fr: "fr", + Fy: "fy", + Ff: "ff", + Gd: "gd", + Gl: "gl", + Lg: "lg", + Ka: "ka", + De: "de", + El: "el", + Kl: "kl", + Gn: "gn", + Gu: "gu", + Ht: "ht", + Ha: "ha", + He: "he", + Hz: "hz", + Hi: "hi", + Ho: "ho", + Hu: "hu", + Io: "io", + Ig: "ig", + Id: "id", + Ia: "ia", + Ie: "ie", + Iu: "iu", + Ik: "ik", + Ga: "ga", + It: "it", + Ja: "ja", + Jv: "jv", + Kn: "kn", + Kr: "kr", + Ks: "ks", + Kk: "kk", + Km: "km", + Ki: "ki", + Rw: "rw", + Ky: "ky", + Kv: "kv", + Kg: "kg", + Ko: "ko", + Kj: "kj", + Ku: "ku", + Lo: "lo", + La: "la", + Lv: "lv", + Li: "li", + Ln: "ln", + Lt: "lt", + Lu: "lu", + Lb: "lb", + Mk: "mk", + Mg: "mg", + Ms: "ms", + Ml: "ml", + Mt: "mt", + Gv: "gv", + Mi: "mi", + Mr: "mr", + Mh: "mh", + Mn: "mn", + Na: "na", + Nv: "nv", + Nd: "nd", + Nr: "nr", + Ng: "ng", + Ne: "ne", + No: "no", + Nb: "nb", + Nn: "nn", + Ii: "ii", + Oc: "oc", + Oj: "oj", + Om: "om", + Os: "os", + Pi: "pi", + Ps: "ps", + Fa: "fa", + Pl: "pl", + Pt: "pt", + Pa: "pa", + Qu: "qu", + Ro: "ro", + Rm: "rm", + Rn: "rn", + Ru: "ru", + Se: "se", + Sm: "sm", + Sg: "sg", + Sa: "sa", + Sc: "sc", + Sr: "sr", + Sn: "sn", + Sd: "sd", + Si: "si", + Sk: "sk", + Sl: "sl", + So: "so", + St: "st", + Es: "es", + Su: "su", + Sw: "sw", + Ss: "ss", + Sv: "sv", + Tl: "tl", + Ty: "ty", + Tg: "tg", + Ta: "ta", + Tt: "tt", + Te: "te", + Th: "th", + Bo: "bo", + Ti: "ti", + To: "to", + Ts: "ts", + Tn: "tn", + Tr: "tr", + Tk: "tk", + Tw: "tw", + Ug: "ug", + Uk: "uk", + Ur: "ur", + Uz: "uz", + Ve: "ve", + Vi: "vi", + Vo: "vo", + Wa: "wa", + Cy: "cy", + Wo: "wo", + Xh: "xh", + Yi: "yi", + Yo: "yo", + Za: "za", + Zu: "zu", +} as const; diff --git a/src/api/types/LedgerAccountCursorFields.ts b/src/api/types/LedgerAccountCursorFields.ts new file mode 100644 index 0000000..de45682 --- /dev/null +++ b/src/api/types/LedgerAccountCursorFields.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type LedgerAccountCursorFields = "name"; diff --git a/src/api/types/LedgerAccountListResponse.ts b/src/api/types/LedgerAccountListResponse.ts new file mode 100644 index 0000000..ce31d69 --- /dev/null +++ b/src/api/types/LedgerAccountListResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of ledger accounts. + */ +export interface LedgerAccountListResponse { + data: Monite.LedgerAccountResponse[]; + next_pagination_token?: string; + prev_pagination_token?: string; +} diff --git a/src/api/types/LedgerAccountResponse.ts b/src/api/types/LedgerAccountResponse.ts new file mode 100644 index 0000000..9ea5819 --- /dev/null +++ b/src/api/types/LedgerAccountResponse.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a general ledger account retrieved from an accounting system. + */ +export interface LedgerAccountResponse { + /** A unique identifier of the ledger account. */ + id: string; + /** The currency of the ledger account, specified as a three-letter [currency code](https://docs.monite.com/docs/currencies) (ISO 4217). */ + currency?: Monite.CurrencyEnum; + /** The current balance in the account. */ + current_balance?: number; + /** User-defined description of the ledger account. */ + description?: string; + /** Indicates whether this ledger account represents a bank account. */ + is_bank_account: boolean; + /** A user-defined name of the ledger account. Examples: Accounts Receivable, Office Equipment, Advertising, Salaries. */ + name: string; + /** The account code in the accounting system. */ + nominal_code?: string; + /** The status of the ledger account. Possible values: Active, Archived, Pending, Unknown. */ + status: string; + /** The subtype or category of the ledger account. Possible values vary based on the accounting system used. Examples: Current, Fixed, Expense, Inventory, Equity. */ + subtype?: string; + /** The type of the ledger account. It determines whether the account is a credit account or a debit account and where it appears in financial reports within the accounting system. Possible values: Asset, Equity, Expense, Income, Liability, Unknown. */ + type: string; +} diff --git a/src/api/types/LineItem.ts b/src/api/types/LineItem.ts new file mode 100644 index 0000000..89abe6f --- /dev/null +++ b/src/api/types/LineItem.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LineItem { + /** The discount for a product. */ + discount?: Monite.Discount; + /** Object of product. Can be used instead of product_id, created in product's catalog */ + product?: Monite.LineItemProductCreate; + /** Unique identifier of the product. */ + product_id?: string; + /** The quantity of each of the goods, materials, or services listed in the receivable. */ + quantity: number; + /** Percent minor units. Example: 12.5% is 1250. This field is only required on invoices issued by entities in the US, Pakistan, and other unsupported countries. */ + tax_rate_value?: number; + /** Unique identifier of the vat rate object. This field is required for all entities in supported countries except the US and Pakistan. */ + vat_rate_id?: string; +} diff --git a/src/api/types/LineItemCursorFields.ts b/src/api/types/LineItemCursorFields.ts new file mode 100644 index 0000000..e841ebe --- /dev/null +++ b/src/api/types/LineItemCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type LineItemCursorFields = "created_at" | "updated_at"; + +export const LineItemCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/LineItemInternalRequest.ts b/src/api/types/LineItemInternalRequest.ts new file mode 100644 index 0000000..3cc7818 --- /dev/null +++ b/src/api/types/LineItemInternalRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface LineItemInternalRequest { + /** ID of the tax rate reference used for accounting integration. May be used to override auto-picked tax rate reference in accounting platform in case of any platform-specific constraints. */ + accounting_tax_rate_id?: string; + /** Description of the product. */ + description?: string; + /** ID of the account record used to store bookkeeping entries for balance-sheet and income-statement transactions. */ + ledger_account_id?: string; + /** Name of the product. */ + name?: string; + /** The quantity of each of the goods, materials, or services listed in the payable. */ + quantity?: number; + subtotal?: number; + /** VAT rate in percent [minor units](https://docs.monite.com/docs/currencies#minor-units). Example: 12.5% is 1250. */ + tax?: number; + total?: number; + /** The unit of the product */ + unit?: string; + /** The unit price of the product, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + unit_price?: number; +} diff --git a/src/api/types/LineItemPaginationResponse.ts b/src/api/types/LineItemPaginationResponse.ts new file mode 100644 index 0000000..62941c4 --- /dev/null +++ b/src/api/types/LineItemPaginationResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LineItemPaginationResponse { + data: Monite.LineItemResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/LineItemProduct.ts b/src/api/types/LineItemProduct.ts new file mode 100644 index 0000000..3bfb9b6 --- /dev/null +++ b/src/api/types/LineItemProduct.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LineItemProduct { + /** Unique ID of the product. */ + id: string; + /** Time at which the product was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the product was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + /** Description of the product. */ + description?: string; + entity_id: string; + entity_user_id?: string; + /** Indicates whether the product is inline */ + is_inline?: boolean; + ledger_account_id?: string; + measure_unit?: Monite.LineItemProductMeasureUnit; + /** The unique ID reference of the unit used to measure the quantity of this product (e.g. items, meters, kilograms). */ + measure_unit_id?: string; + /** Name of the product. */ + name: string; + price: Monite.Price; + price_after_vat: Monite.Price; + /** The smallest amount allowed for this product. */ + smallest_amount?: number; + /** Specifies whether this offering is a product or service. This may affect the applicable tax rates. */ + type?: Monite.ProductServiceTypeEnum; + vat_rate: Monite.LineItemProductVatRate; +} diff --git a/src/api/types/LineItemProductCreate.ts b/src/api/types/LineItemProductCreate.ts new file mode 100644 index 0000000..80ee218 --- /dev/null +++ b/src/api/types/LineItemProductCreate.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LineItemProductCreate { + /** Description of the product. */ + description?: string; + ledger_account_id?: string; + measure_unit?: Monite.UnitRequest; + /** Name of the product. */ + name: string; + price: Monite.Price; + /** The smallest amount allowed for this product. */ + smallest_amount?: number; + /** Specifies whether this offering is a product or service. This may affect the applicable tax rates. */ + type?: Monite.ProductServiceTypeEnum; +} diff --git a/src/api/types/LineItemProductMeasureUnit.ts b/src/api/types/LineItemProductMeasureUnit.ts new file mode 100644 index 0000000..a6c46b0 --- /dev/null +++ b/src/api/types/LineItemProductMeasureUnit.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface LineItemProductMeasureUnit { + id?: string; + created_at: string; + updated_at: string; + description?: string; + name: string; +} diff --git a/src/api/types/LineItemProductVatRate.ts b/src/api/types/LineItemProductVatRate.ts new file mode 100644 index 0000000..e7aab1a --- /dev/null +++ b/src/api/types/LineItemProductVatRate.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LineItemProductVatRate { + /** Unique identifier of the vat rate object. */ + id?: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country: Monite.AllowedCountries; + /** Percent minor units. Example: 12.5% is 1250. */ + value: number; +} diff --git a/src/api/types/LineItemRequest.ts b/src/api/types/LineItemRequest.ts new file mode 100644 index 0000000..9380431 --- /dev/null +++ b/src/api/types/LineItemRequest.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface LineItemRequest { + /** ID of the tax rate reference used for accounting integration. May be used to override auto-picked tax rate reference in accounting platform in case of any platform-specific constraints. */ + accounting_tax_rate_id?: string; + /** Description of the product. */ + description?: string; + /** ID of the account record used to store bookkeeping entries for balance-sheet and income-statement transactions. */ + ledger_account_id?: string; + /** Name of the product. */ + name?: string; + /** The quantity of each of the goods, materials, or services listed in the payable. */ + quantity?: number; + /** VAT rate in percent [minor units](https://docs.monite.com/docs/currencies#minor-units). Example: 12.5% is 1250. */ + tax?: number; + /** The unit of the product */ + unit?: string; + /** The unit price of the product, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + unit_price?: number; +} diff --git a/src/api/types/LineItemResponse.ts b/src/api/types/LineItemResponse.ts new file mode 100644 index 0000000..a588042 --- /dev/null +++ b/src/api/types/LineItemResponse.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface LineItemResponse { + id: string; + /** ID of the tax rate reference used for accounting integartion. May be used to override auto-picked tax rate reference in accounting platform in case of any platform-specific constraints. */ + accounting_tax_rate_id?: string; + /** Description of the product. */ + description?: string; + /** ID of the account record used to store bookkeeping entries for balance-sheet and income-statement transactions. */ + ledger_account_id?: string; + /** Name of the product. */ + name?: string; + payable_id: string; + /** The quantity of each of the goods, materials, or services listed in the payable. */ + quantity?: number; + /** The subtotal (excluding VAT), in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + subtotal?: number; + /** VAT rate in percent [minor units](https://docs.monite.com/docs/currencies#minor-units). Example: 12.5% is 1250. */ + tax?: number; + /** Tax amount in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + tax_amount?: number; + /** The actual price of the product. */ + total?: number; + /** The unit of the product */ + unit?: string; + /** The unit price of the product, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + unit_price?: number; + /** ID of the user who created the tag. */ + was_created_by_user_id?: string; +} diff --git a/src/api/types/LineItemUpdate.ts b/src/api/types/LineItemUpdate.ts new file mode 100644 index 0000000..d1eeaa9 --- /dev/null +++ b/src/api/types/LineItemUpdate.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LineItemUpdate { + /** The discount for a product. */ + discount?: Monite.Discount; + /** The actual price of the product in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + price?: number; + /** The quantity of each of the goods, materials, or services listed in the receivable. */ + quantity?: number; + /** Percent minor units. Example: 12.5% is 1250. This field is only required on invoices issued by entities in the US, Pakistan, and other unsupported countries. */ + tax_rate_value?: number; + /** Unique identifier of the vat rate object. This field is required for all entities in supported countries except the US and Pakistan. */ + vat_rate_id?: string; +} diff --git a/src/api/types/LineItemsReplaceResponse.ts b/src/api/types/LineItemsReplaceResponse.ts new file mode 100644 index 0000000..02abd24 --- /dev/null +++ b/src/api/types/LineItemsReplaceResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LineItemsReplaceResponse { + data: Monite.LineItemResponse[]; +} diff --git a/src/api/types/LineItemsResponse.ts b/src/api/types/LineItemsResponse.ts new file mode 100644 index 0000000..0dd2915 --- /dev/null +++ b/src/api/types/LineItemsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LineItemsResponse { + data: Monite.ResponseItem[]; +} diff --git a/src/api/types/LogMethodEnum.ts b/src/api/types/LogMethodEnum.ts new file mode 100644 index 0000000..fa33987 --- /dev/null +++ b/src/api/types/LogMethodEnum.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type LogMethodEnum = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; + +export const LogMethodEnum = { + Get: "GET", + Post: "POST", + Put: "PUT", + Patch: "PATCH", + Delete: "DELETE", +} as const; diff --git a/src/api/types/LogResponse.ts b/src/api/types/LogResponse.ts new file mode 100644 index 0000000..1f06e22 --- /dev/null +++ b/src/api/types/LogResponse.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LogResponse { + id: string; + body?: Monite.LogResponseBody; + content_type: string; + entity_id: string; + entity_user_id?: string; + headers?: Record; + method?: string; + params?: string; + parent_log_id?: string; + partner_id: string; + path?: string; + status_code?: number; + target_service: string; + timestamp: string; + type: string; +} diff --git a/src/api/types/LogResponseBody.ts b/src/api/types/LogResponseBody.ts new file mode 100644 index 0000000..8bf2b1d --- /dev/null +++ b/src/api/types/LogResponseBody.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type LogResponseBody = Record | unknown[]; diff --git a/src/api/types/LogTypeEnum.ts b/src/api/types/LogTypeEnum.ts new file mode 100644 index 0000000..5c89117 --- /dev/null +++ b/src/api/types/LogTypeEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type LogTypeEnum = "request" | "response"; + +export const LogTypeEnum = { + Request: "request", + Response: "response", +} as const; diff --git a/src/api/types/LogsResponse.ts b/src/api/types/LogsResponse.ts new file mode 100644 index 0000000..af599df --- /dev/null +++ b/src/api/types/LogsResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface LogsResponse { + data: Monite.LogResponse[]; + next_pagination_token?: string; + prev_pagination_token?: string; + total_logs: number; + total_pages: number; +} diff --git a/src/api/types/MailSentEventData.ts b/src/api/types/MailSentEventData.ts new file mode 100644 index 0000000..e2a5aa5 --- /dev/null +++ b/src/api/types/MailSentEventData.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface MailSentEventData { + mail_id: string; + mail_status: Monite.ReceivableMailStatusEnum; + recipients: Monite.ReceivableMailRecipients; +} diff --git a/src/api/types/MailSettingsPayload.ts b/src/api/types/MailSettingsPayload.ts new file mode 100644 index 0000000..d0b082b --- /dev/null +++ b/src/api/types/MailSettingsPayload.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface MailSettingsPayload { + attach_documents_as_pdf: boolean; + from_email_username?: string; + from_name?: string; +} diff --git a/src/api/types/MailSettingsResponse.ts b/src/api/types/MailSettingsResponse.ts new file mode 100644 index 0000000..da85ebb --- /dev/null +++ b/src/api/types/MailSettingsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface MailSettingsResponse { + attach_documents_as_pdf: boolean; + from_email_username?: string; + from_name?: string; +} diff --git a/src/api/types/MailboxDataResponse.ts b/src/api/types/MailboxDataResponse.ts new file mode 100644 index 0000000..8036e87 --- /dev/null +++ b/src/api/types/MailboxDataResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface MailboxDataResponse { + data?: Monite.MailboxResponse[]; +} diff --git a/src/api/types/MailboxObjectTypeEnum.ts b/src/api/types/MailboxObjectTypeEnum.ts new file mode 100644 index 0000000..a2e34d8 --- /dev/null +++ b/src/api/types/MailboxObjectTypeEnum.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type MailboxObjectTypeEnum = "payable"; diff --git a/src/api/types/MailboxResponse.ts b/src/api/types/MailboxResponse.ts new file mode 100644 index 0000000..8ec6055 --- /dev/null +++ b/src/api/types/MailboxResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface MailboxResponse { + /** Mailbox UUID */ + id: string; + mailbox_domain_id?: string; + mailbox_full_address: string; + mailbox_name: string; + related_object_type: string; + status: string; +} diff --git a/src/api/types/MergedSettingsResponse.ts b/src/api/types/MergedSettingsResponse.ts new file mode 100644 index 0000000..1042f2e --- /dev/null +++ b/src/api/types/MergedSettingsResponse.ts @@ -0,0 +1,47 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface MergedSettingsResponse { + /** Settings for the accounting module. */ + accounting?: Monite.AccountingSettingsResponse; + /** Automatically attempt to find a corresponding purchase order for all incoming payables. */ + allow_purchase_order_autolinking?: boolean; + /** Default API version for partner. */ + api_version?: Monite.ApiVersion; + /** Commercial conditions for receivables. */ + commercial_conditions?: string[]; + /** Custom currency exchange rates. */ + currency?: Monite.CurrencySettings; + /** A default role to provision upon new entity creation. */ + default_role?: Record; + document_ids?: Monite.DocumentIDsSettings; + /** Settings for the e-invoicing module. */ + einvoicing?: Monite.EInvoicingSettingsResponse; + /** If enabled, the paid invoice's PDF will be in a new layout set by the user */ + generate_paid_invoice_pdf?: boolean; + language?: Monite.LanguageCodeEnum; + /** Settings for email and mailboxes. */ + mail?: Monite.MailSettingsResponse; + /** Settings for the payables module. */ + payable?: Monite.PayableSettingsResponse; + /** Auto tagging settings for all incoming OCR payable documents. */ + payables_ocr_auto_tagging?: Monite.OcrAutoTaggingSettingsRequest[]; + /** Payment preferences for entity to automate calculating suggested payment date basing on payment terms and entity preferences */ + payment_priority?: Monite.PaymentPriorityEnum; + /** Settings for the payments module. */ + payments?: Monite.PaymentsSettingsResponse; + /** Sets the default behavior of whether a signature is required to accept quotes */ + quote_signature_required?: boolean; + /** Settings for the receivables module. */ + receivable?: Monite.ReceivableSettingsResponse; + receivable_edit_flow?: Monite.ReceivableEditFlow; + reminder?: Monite.RemindersSettings; + /** Measurement units. */ + units?: Monite.Unit[]; + /** Defines whether the prices of products in receivables will already include VAT or not. */ + vat_mode?: Monite.VatModeEnum; + website?: string; +} diff --git a/src/api/types/MessageResponse.ts b/src/api/types/MessageResponse.ts new file mode 100644 index 0000000..75b51cf --- /dev/null +++ b/src/api/types/MessageResponse.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface MessageResponse { + message: string; +} diff --git a/src/api/types/MissingFields.ts b/src/api/types/MissingFields.ts new file mode 100644 index 0000000..6b8f151 --- /dev/null +++ b/src/api/types/MissingFields.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface MissingFields { + /** Missing fields of counterpart. */ + counterpart?: string[]; + /** Missing fields of entity. */ + entity?: string[]; + /** Missing fields of line items. */ + products?: Monite.MissingLineItemFields[]; + /** Missing fields of receivable. */ + receivable?: string[]; + /** List of invalid vat rates. */ + vat_rates?: string[]; +} diff --git a/src/api/types/MissingLineItemFields.ts b/src/api/types/MissingLineItemFields.ts new file mode 100644 index 0000000..4992652 --- /dev/null +++ b/src/api/types/MissingLineItemFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface MissingLineItemFields { + /** Order number of line item. */ + line_item_number: number; + /** Missing fields of line item. */ + missing_fields: string[]; +} diff --git a/src/api/types/MoniteAllPaymentMethods.ts b/src/api/types/MoniteAllPaymentMethods.ts new file mode 100644 index 0000000..8e95c0b --- /dev/null +++ b/src/api/types/MoniteAllPaymentMethods.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type MoniteAllPaymentMethods = + | "SEPA Payments" + | "US ACH Payments" + | "BLIK" + | "Card payments" + | "Bacs Direct Debit" + | "Bancontact" + | "Electronic Payment Standard" + | "Giropay" + | "iDEAL" + | "Przelewy24" + | "SEPA Direct Debit" + | "SOFORT" + | "Apple Pay" + | "Google Pay"; + +export const MoniteAllPaymentMethods = { + SepaPayments: "SEPA Payments", + UsAchPayments: "US ACH Payments", + Blik: "BLIK", + CardPayments: "Card payments", + BacsDirectDebit: "Bacs Direct Debit", + Bancontact: "Bancontact", + ElectronicPaymentStandard: "Electronic Payment Standard", + Giropay: "Giropay", + IDeal: "iDEAL", + Przelewy24: "Przelewy24", + SepaDirectDebit: "SEPA Direct Debit", + Sofort: "SOFORT", + ApplePay: "Apple Pay", + GooglePay: "Google Pay", +} as const; diff --git a/src/api/types/MoniteAllPaymentMethodsTypes.ts b/src/api/types/MoniteAllPaymentMethodsTypes.ts new file mode 100644 index 0000000..33d719f --- /dev/null +++ b/src/api/types/MoniteAllPaymentMethodsTypes.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type MoniteAllPaymentMethodsTypes = + | "sepa_credit" + | "us_ach" + | "blik" + | "card" + | "bacs_direct_debit" + | "bancontact" + | "eps" + | "giropay" + | "ideal" + | "p24" + | "sepa_debit" + | "sofort" + | "applepay" + | "googlepay"; + +export const MoniteAllPaymentMethodsTypes = { + SepaCredit: "sepa_credit", + UsAch: "us_ach", + Blik: "blik", + Card: "card", + BacsDirectDebit: "bacs_direct_debit", + Bancontact: "bancontact", + Eps: "eps", + Giropay: "giropay", + Ideal: "ideal", + P24: "p24", + SepaDebit: "sepa_debit", + Sofort: "sofort", + Applepay: "applepay", + Googlepay: "googlepay", +} as const; diff --git a/src/api/types/ObjectMatchTypes.ts b/src/api/types/ObjectMatchTypes.ts new file mode 100644 index 0000000..fef0d8e --- /dev/null +++ b/src/api/types/ObjectMatchTypes.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ObjectMatchTypes = "product" | "customer" | "vendor" | "receivable" | "bill"; + +export const ObjectMatchTypes = { + Product: "product", + Customer: "customer", + Vendor: "vendor", + Receivable: "receivable", + Bill: "bill", +} as const; diff --git a/src/api/types/ObjectType.ts b/src/api/types/ObjectType.ts new file mode 100644 index 0000000..ac6f89d --- /dev/null +++ b/src/api/types/ObjectType.ts @@ -0,0 +1,110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ObjectType = + | "account" + | "approval" + | "approval_request" + | "approval_policy" + | "monitescript_process" + | "audit_trail" + | "comment" + | "counterpart" + | "counterpart_address" + | "counterpart_bank_account" + | "counterpart_contact_person" + | "counterpart_partner_metadata" + | "counterpart_tax_id" + | "counterpart_vat_id" + | "entity" + | "entity_bank_account" + | "entity_settings" + | "entity_token" + | "entity_user" + | "entity_user_token" + | "entity_vat_ids" + | "export" + | "onboarding" + | "partner" + | "partner_internal_config" + | "partner_settings" + | "partner_token" + | "payable" + | "project" + | "payable_line_item" + | "payables_purchase_order" + | "payment" + | "payment_intent" + | "payment_link" + | "payment_record" + | "payment_reminder" + | "person" + | "product" + | "receivable" + | "reconciliation" + | "recurrence" + | "role" + | "tag" + | "todo_task" + | "todo_task_mute" + | "transaction" + | "webhook" + | "workflow" + | "workflow_pipeline" + | "overdue_reminder" + | "einvoicing"; + +export const ObjectType = { + Account: "account", + Approval: "approval", + ApprovalRequest: "approval_request", + ApprovalPolicy: "approval_policy", + MonitescriptProcess: "monitescript_process", + AuditTrail: "audit_trail", + Comment: "comment", + Counterpart: "counterpart", + CounterpartAddress: "counterpart_address", + CounterpartBankAccount: "counterpart_bank_account", + CounterpartContactPerson: "counterpart_contact_person", + CounterpartPartnerMetadata: "counterpart_partner_metadata", + CounterpartTaxId: "counterpart_tax_id", + CounterpartVatId: "counterpart_vat_id", + Entity: "entity", + EntityBankAccount: "entity_bank_account", + EntitySettings: "entity_settings", + EntityToken: "entity_token", + EntityUser: "entity_user", + EntityUserToken: "entity_user_token", + EntityVatIds: "entity_vat_ids", + Export: "export", + Onboarding: "onboarding", + Partner: "partner", + PartnerInternalConfig: "partner_internal_config", + PartnerSettings: "partner_settings", + PartnerToken: "partner_token", + Payable: "payable", + Project: "project", + PayableLineItem: "payable_line_item", + PayablesPurchaseOrder: "payables_purchase_order", + Payment: "payment", + PaymentIntent: "payment_intent", + PaymentLink: "payment_link", + PaymentRecord: "payment_record", + PaymentReminder: "payment_reminder", + Person: "person", + Product: "product", + Receivable: "receivable", + Reconciliation: "reconciliation", + Recurrence: "recurrence", + Role: "role", + Tag: "tag", + TodoTask: "todo_task", + TodoTaskMute: "todo_task_mute", + Transaction: "transaction", + Webhook: "webhook", + Workflow: "workflow", + WorkflowPipeline: "workflow_pipeline", + OverdueReminder: "overdue_reminder", + Einvoicing: "einvoicing", +} as const; diff --git a/src/api/types/ObjectTypeAvailableComment.ts b/src/api/types/ObjectTypeAvailableComment.ts new file mode 100644 index 0000000..bdc9b69 --- /dev/null +++ b/src/api/types/ObjectTypeAvailableComment.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ObjectTypeAvailableComment = "payable"; diff --git a/src/api/types/ObjectTypeEnum.ts b/src/api/types/ObjectTypeEnum.ts new file mode 100644 index 0000000..d0d8c22 --- /dev/null +++ b/src/api/types/ObjectTypeEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ObjectTypeEnum = "receivable" | "payable"; + +export const ObjectTypeEnum = { + Receivable: "receivable", + Payable: "payable", +} as const; diff --git a/src/api/types/OcrAddress.ts b/src/api/types/OcrAddress.ts new file mode 100644 index 0000000..b81ec08 --- /dev/null +++ b/src/api/types/OcrAddress.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * In general it's compatible with CounterpartAddress model but + * + * - All fields are optional + * - There is an additional field original_country_name + */ +export interface OcrAddress { + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country?: string; + /** Country name as it is stated in the document. */ + original_country_name?: string; + /** City name. */ + city?: string; + /** ZIP or postal code. */ + postal_code?: string; + /** State, region, province, or county. */ + state?: string; + /** Street address. */ + line1?: string; + /** Additional address information (if any). */ + line2?: string; +} diff --git a/src/api/types/OcrAutoTaggingSettingsRequest.ts b/src/api/types/OcrAutoTaggingSettingsRequest.ts new file mode 100644 index 0000000..01ec9ae --- /dev/null +++ b/src/api/types/OcrAutoTaggingSettingsRequest.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OcrAutoTaggingSettingsRequest { + /** Tag identifier that will be assigned to the payable document if one of the words listed in keywords is found during OCR */ + tag_id: string; + /** A list of words that will be searched for assigning a tag in the recognized fields of the document after OCR processing. If at least one match is found, the tag will be assigned. Each keyword must be between 2 and 25 characters long */ + keywords: string[]; + /** A switch to temporarily disable a keyword without removing it from the list */ + enabled: boolean; +} diff --git a/src/api/types/OcrRecognitionResponse.ts b/src/api/types/OcrRecognitionResponse.ts new file mode 100644 index 0000000..19f316a --- /dev/null +++ b/src/api/types/OcrRecognitionResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Contains information about all text blocks extracted from an uploaded invoice by OCR. + * The text blocks are grouped into `line_items` (invoice line items) and `summary` (all other information). + * Legacy schema used for AWS textract recognition. + */ +export interface OcrRecognitionResponse { + /** Invoice text content other than the line items. Such as the invoice issue and due dates, vendor name and address, and other general information. */ + summary?: Monite.LabelNValue[]; + /** Text content of the invoice line items as recognized by OCR. */ + line_items?: Monite.LabelNValue[]; +} diff --git a/src/api/types/OcrResponseInvoiceReceiptData.ts b/src/api/types/OcrResponseInvoiceReceiptData.ts new file mode 100644 index 0000000..874eda1 --- /dev/null +++ b/src/api/types/OcrResponseInvoiceReceiptData.ts @@ -0,0 +1,56 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface OcrResponseInvoiceReceiptData { + /** Total in cents/eurocents. Outdated, actual conversion happens in payables. */ + total?: number; + /** Total, without minor units */ + total_raw?: number; + /** Subtotal cents/eurocents. Outdated, actual conversion happens in payables. */ + total_excl_vat?: number; + /** Subtotal, without minor units */ + total_excl_vat_raw?: number; + /** VAT amount in cents. Outdated, actual conversion happens in payables. */ + total_vat_amount?: number; + /** VAT amount, without minor units */ + total_vat_amount_raw?: number; + /** VAT Percent minor units. Example: 12.5% is 1250. Outdated, actual conversion happens in payables. */ + total_vat_rate?: number; + /** VAT Percent raw, without minor units. */ + total_vat_rate_raw?: number; + /** ISO 4217 currency code */ + currency?: string; + /** Purchase Order Number */ + purchase_order_number?: string; + /** Counterpart name */ + counterpart_name?: string; + /** Counterpart address */ + counterpart_address?: string; + /** Counterpart bank ID */ + counterpart_account_id?: string; + /** Invoice/receipt ID */ + document_id?: string; + /** Raw payment terms parsed but not calculated. */ + payment_terms_raw?: string[]; + /** Tax payer ID */ + tax_payer_id?: string; + /** Counterpart VAT ID */ + counterpart_vat_id?: string; + /** Document issuance date in ISO format */ + document_issued_at_date?: string; + /** Document due date in ISO format */ + document_due_date?: string; + /** Counterpart address as a json object compatible with counterparts service */ + counterpart_address_object?: Monite.OcrAddress; + /** The bank account number */ + counterpart_account_number?: string; + /** The bank routing number */ + counterpart_routing_number?: string; + /** List of line items from document. Outdated, actual conversion happens in payables. */ + line_items?: Monite.OcrResponseInvoiceReceiptLineItem[]; + /** List of line items from document raw, without minor units conversion. */ + line_items_raw?: Monite.OcrResponseInvoiceReceiptLineItemRaw[]; +} diff --git a/src/api/types/OcrResponseInvoiceReceiptLineItem.ts b/src/api/types/OcrResponseInvoiceReceiptLineItem.ts new file mode 100644 index 0000000..a8e45fa --- /dev/null +++ b/src/api/types/OcrResponseInvoiceReceiptLineItem.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OcrResponseInvoiceReceiptLineItem { + /** OCR Id of line item */ + line_item_ocr_id?: string; + /** Human-readable line item description */ + description?: string; + /** Quanity */ + quantity?: number; + /** Price in cents/eurocents */ + unit_price?: number; + /** Unit */ + unit?: string; + /** VAT Percent minor units. Example: 12.5% is 1250. */ + vat_percentage?: number; + /** VAT Amount minor units. */ + vat_amount?: number; + /** Total excl VAT */ + total_excl_vat?: number; + /** Total included VAT */ + total_incl_vat?: number; +} diff --git a/src/api/types/OcrResponseInvoiceReceiptLineItemRaw.ts b/src/api/types/OcrResponseInvoiceReceiptLineItemRaw.ts new file mode 100644 index 0000000..e0c173c --- /dev/null +++ b/src/api/types/OcrResponseInvoiceReceiptLineItemRaw.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OcrResponseInvoiceReceiptLineItemRaw { + /** OCR Id of line item */ + line_item_ocr_id?: string; + /** Human-readable line item description */ + description?: string; + /** Quanity */ + quantity?: number; + /** Price as parsed */ + unit_price?: number; + /** Unit */ + unit?: string; + /** VAT Percent as parsed. */ + vat_percentage?: number; + /** VAT Amount as parsed. */ + vat_amount?: number; + /** Total excluded VAT as parsed. */ + total_excl_vat?: number; + /** Total included VAT as parsed. */ + total_incl_vat?: number; +} diff --git a/src/api/types/OcrStatusEnum.ts b/src/api/types/OcrStatusEnum.ts new file mode 100644 index 0000000..7716b24 --- /dev/null +++ b/src/api/types/OcrStatusEnum.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type OcrStatusEnum = "processing" | "error" | "success"; + +export const OcrStatusEnum = { + Processing: "processing", + Error: "error", + Success: "success", +} as const; diff --git a/src/api/types/OnboardingLinkPublicResponse.ts b/src/api/types/OnboardingLinkPublicResponse.ts new file mode 100644 index 0000000..1019e76 --- /dev/null +++ b/src/api/types/OnboardingLinkPublicResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OnboardingLinkPublicResponse { + id: string; + entity_id: string; + expires_at: string; + refresh_url: string; + return_url: string; + url: string; +} diff --git a/src/api/types/OnboardingLinkResponse.ts b/src/api/types/OnboardingLinkResponse.ts new file mode 100644 index 0000000..974794b --- /dev/null +++ b/src/api/types/OnboardingLinkResponse.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface OnboardingLinkResponse { + id: string; + created_at: string; + expires_at: string; + recipient: Monite.Recipient; + refresh_url: string; + return_url: string; + url: string; +} diff --git a/src/api/types/OnboardingPaymentMethodsResponse.ts b/src/api/types/OnboardingPaymentMethodsResponse.ts new file mode 100644 index 0000000..63283dc --- /dev/null +++ b/src/api/types/OnboardingPaymentMethodsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface OnboardingPaymentMethodsResponse { + data: Monite.PaymentMethod[]; +} diff --git a/src/api/types/OnboardingRequirementsError.ts b/src/api/types/OnboardingRequirementsError.ts new file mode 100644 index 0000000..6f02f83 --- /dev/null +++ b/src/api/types/OnboardingRequirementsError.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OnboardingRequirementsError { + code: string; + reason: string; + requirement: string; +} diff --git a/src/api/types/OnboardingRequirementsResponse.ts b/src/api/types/OnboardingRequirementsResponse.ts new file mode 100644 index 0000000..7787991 --- /dev/null +++ b/src/api/types/OnboardingRequirementsResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface OnboardingRequirementsResponse { + disabled_reason?: Monite.AccountDisabledReason; + requirements: Monite.PaymentRequirements; + requirements_errors: Monite.RequirementsError[]; + verification_errors: Monite.VerificationError[]; + verification_status: Monite.VerificationStatusEnum; +} diff --git a/src/api/types/OnboardingVerificationError.ts b/src/api/types/OnboardingVerificationError.ts new file mode 100644 index 0000000..b208176 --- /dev/null +++ b/src/api/types/OnboardingVerificationError.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OnboardingVerificationError { + code: string; + details: string; +} diff --git a/src/api/types/OnboardingVerificationStatusEnum.ts b/src/api/types/OnboardingVerificationStatusEnum.ts new file mode 100644 index 0000000..ce147ad --- /dev/null +++ b/src/api/types/OnboardingVerificationStatusEnum.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type OnboardingVerificationStatusEnum = "enabled" | "disabled" | "pending"; + +export const OnboardingVerificationStatusEnum = { + Enabled: "enabled", + Disabled: "disabled", + Pending: "pending", +} as const; diff --git a/src/api/types/OptionalIndividualSchema.ts b/src/api/types/OptionalIndividualSchema.ts new file mode 100644 index 0000000..1144ddc --- /dev/null +++ b/src/api/types/OptionalIndividualSchema.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A schema for metadata for updating an individual + */ +export interface OptionalIndividualSchema { + date_of_birth?: string; + /** A first name of an individual */ + first_name?: string; + id_number?: string; + /** A last name of an individual */ + last_name?: string; + /** The last four digits of the individual's Social Security number */ + ssn_last_4?: string; + /** A title of an individual */ + title?: string; +} diff --git a/src/api/types/OptionalOrganizationSchema.ts b/src/api/types/OptionalOrganizationSchema.ts new file mode 100644 index 0000000..cb749cc --- /dev/null +++ b/src/api/types/OptionalOrganizationSchema.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema contains metadata for updating an organization + */ +export interface OptionalOrganizationSchema { + /** Business structure of the company */ + business_structure?: Monite.EntityBusinessStructure; + directors_provided?: boolean; + executives_provided?: boolean; + /** A code which identifies uniquely a party of a transaction worldwide */ + legal_entity_id?: string; + /** A legal name of an organization */ + legal_name?: string; + owners_provided?: boolean; + representative_provided?: boolean; +} diff --git a/src/api/types/OptionalPersonAddressRequest.ts b/src/api/types/OptionalPersonAddressRequest.ts new file mode 100644 index 0000000..fb0c76f --- /dev/null +++ b/src/api/types/OptionalPersonAddressRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface OptionalPersonAddressRequest { + /** City, district, suburb, town, or village */ + city?: string; + /** Two-letter country code (ISO 3166-1 alpha-2) */ + country?: Monite.AllowedCountries; + /** Address line 1 (e.g., street, PO Box, or company name) */ + line1?: string; + /** Address line 2 (e.g., apartment, suite, unit, or building) */ + line2?: string; + /** ZIP or postal code */ + postal_code?: string; + /** State, county, province, or region */ + state?: string; +} diff --git a/src/api/types/OptionalPersonRelationship.ts b/src/api/types/OptionalPersonRelationship.ts new file mode 100644 index 0000000..60cfc65 --- /dev/null +++ b/src/api/types/OptionalPersonRelationship.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OptionalPersonRelationship { + /** Whether the person is a director of the account's legal entity */ + director?: boolean; + /** Whether the person has significant responsibility to control, manage, or direct the organization */ + executive?: boolean; + /** Whether the person is an owner of the account's legal entity */ + owner?: boolean; + /** The percent owned by the person of the account's legal entity */ + percent_ownership?: number; + /** Whether the person is authorized as the primary representative of the account */ + representative?: boolean; + /** The person's title (e.g., CEO, Support Engineer) */ + title?: string; +} diff --git a/src/api/types/OrderEnum.ts b/src/api/types/OrderEnum.ts new file mode 100644 index 0000000..004d815 --- /dev/null +++ b/src/api/types/OrderEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type OrderEnum = "asc" | "desc"; + +export const OrderEnum = { + Asc: "asc", + Desc: "desc", +} as const; diff --git a/src/api/types/OrderEnum2.ts b/src/api/types/OrderEnum2.ts new file mode 100644 index 0000000..b707bb6 --- /dev/null +++ b/src/api/types/OrderEnum2.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type OrderEnum2 = "asc" | "desc"; + +export const OrderEnum2 = { + Asc: "asc", + Desc: "desc", +} as const; diff --git a/src/api/types/OrderEnum3.ts b/src/api/types/OrderEnum3.ts new file mode 100644 index 0000000..1264802 --- /dev/null +++ b/src/api/types/OrderEnum3.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type OrderEnum3 = "asc" | "desc"; + +export const OrderEnum3 = { + Asc: "asc", + Desc: "desc", +} as const; diff --git a/src/api/types/OrganizationResponseSchema.ts b/src/api/types/OrganizationResponseSchema.ts new file mode 100644 index 0000000..89e70a3 --- /dev/null +++ b/src/api/types/OrganizationResponseSchema.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Contains data specific to entities of the `organization` type. + */ +export interface OrganizationResponseSchema { + /** Business structure of the company */ + business_structure?: Monite.EntityBusinessStructure; + directors_provided?: boolean; + executives_provided?: boolean; + /** A code which identifies uniquely a party of a transaction worldwide */ + legal_entity_id?: string; + /** A legal name of an organization */ + legal_name: string; + owners_provided?: boolean; + representative_provided?: boolean; +} diff --git a/src/api/types/OrganizationSchema.ts b/src/api/types/OrganizationSchema.ts new file mode 100644 index 0000000..a822b65 --- /dev/null +++ b/src/api/types/OrganizationSchema.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema contains metadata for an organization + */ +export interface OrganizationSchema { + /** Business structure of the company */ + business_structure?: Monite.EntityBusinessStructure; + directors_provided?: boolean; + executives_provided?: boolean; + /** A code which identifies uniquely a party of a transaction worldwide */ + legal_entity_id?: string; + /** A legal name of an organization */ + legal_name: string; + owners_provided?: boolean; + representative_provided?: boolean; +} diff --git a/src/api/types/OverdueReminderResponse.ts b/src/api/types/OverdueReminderResponse.ts new file mode 100644 index 0000000..175268b --- /dev/null +++ b/src/api/types/OverdueReminderResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface OverdueReminderResponse { + id: string; + /** Time at which the OverdueReminder was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the OverdueReminder was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + name: string; + recipients?: Monite.Recipients; + /** Overdue reminder terms to send for payment */ + terms?: Monite.OverdueReminderTerm[]; +} diff --git a/src/api/types/OverdueReminderTerm.ts b/src/api/types/OverdueReminderTerm.ts new file mode 100644 index 0000000..45af422 --- /dev/null +++ b/src/api/types/OverdueReminderTerm.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OverdueReminderTerm { + body: string; + days_after: number; + subject: string; +} diff --git a/src/api/types/OwnershipDeclaration.ts b/src/api/types/OwnershipDeclaration.ts new file mode 100644 index 0000000..abc9663 --- /dev/null +++ b/src/api/types/OwnershipDeclaration.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OwnershipDeclaration { + /** The date and time (in the ISO 8601 format) when the beneficial owner attestation was made. */ + date?: string; + /** The IP address from which the beneficial owner attestation was made. If omitted or set to `null` in the request, the IP address is inferred from the request origin or the `X-Forwarded-For` request header. */ + ip?: string; +} diff --git a/src/api/types/PageSchema.ts b/src/api/types/PageSchema.ts new file mode 100644 index 0000000..863debb --- /dev/null +++ b/src/api/types/PageSchema.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * When a PDF document is uploaded to Monite, it extracts individual pages from the document + * and saves them as PNG images. This object contains the image and metadata of a single page. + */ +export interface PageSchema { + /** A unique ID of the image. */ + id: string; + /** The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the image. */ + mimetype: string; + /** The page number in the PDF document, from 0. */ + number: number; + /** Image file size, in bytes. */ + size: number; + /** The URL to download the image. */ + url: string; +} diff --git a/src/api/types/PageSchema2.ts b/src/api/types/PageSchema2.ts new file mode 100644 index 0000000..2eb3ac8 --- /dev/null +++ b/src/api/types/PageSchema2.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * When a PDF document is uploaded to Monite, it extracts individual pages from the document + * and saves them as PNG images. This object contains the image and metadata of a single page. + */ +export interface PageSchema2 { + /** A unique ID of the image. */ + id: string; + /** The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the image. */ + mimetype: string; + /** The page number in the PDF document, from 0. */ + number: number; + /** Image file size, in bytes. */ + size: number; + /** The URL to download the image. */ + url: string; +} diff --git a/src/api/types/PageSchema3.ts b/src/api/types/PageSchema3.ts new file mode 100644 index 0000000..9b1f33e --- /dev/null +++ b/src/api/types/PageSchema3.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * When a PDF document is uploaded to Monite, it extracts individual pages from the document + * and saves them as PNG images. This object contains the image and metadata of a single page. + */ +export interface PageSchema3 { + /** A unique ID of the image. */ + id: string; + /** The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the image. */ + mimetype: string; + /** Image file size, in bytes. */ + size: number; + /** The page number in the PDF document, from 0. */ + number: number; + /** The URL to download the image. */ + url: string; +} diff --git a/src/api/types/PageSchema4.ts b/src/api/types/PageSchema4.ts new file mode 100644 index 0000000..23efc8a --- /dev/null +++ b/src/api/types/PageSchema4.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * When a PDF document is uploaded to Monite, it extracts individual pages from the document + * and saves them as PNG images. This object contains the image and metadata of a single page. + */ +export interface PageSchema4 { + /** A unique ID of the image. */ + id: string; + /** The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the image. */ + mimetype: string; + /** The page number in the PDF document, from 0. */ + number: number; + /** Image file size, in bytes. */ + size: number; + /** The URL to download the image. */ + url: string; +} diff --git a/src/api/types/PartnerMetadata.ts b/src/api/types/PartnerMetadata.ts new file mode 100644 index 0000000..70d62bd --- /dev/null +++ b/src/api/types/PartnerMetadata.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PartnerMetadata { + /** Metadata for partner needs */ + metadata: Record; +} diff --git a/src/api/types/PartnerMetadataResponse.ts b/src/api/types/PartnerMetadataResponse.ts new file mode 100644 index 0000000..ee61731 --- /dev/null +++ b/src/api/types/PartnerMetadataResponse.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PartnerMetadataResponse { + /** Metadata for partner needs */ + metadata?: Record; +} diff --git a/src/api/types/PartnerProjectSettingsResponse.ts b/src/api/types/PartnerProjectSettingsResponse.ts new file mode 100644 index 0000000..caf425f --- /dev/null +++ b/src/api/types/PartnerProjectSettingsResponse.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PartnerProjectSettingsResponse { + /** Settings for the accounting module. */ + accounting?: Monite.AccountingSettingsResponse; + /** Default API version for partner. */ + api_version?: Monite.ApiVersion; + /** Commercial conditions for receivables. */ + commercial_conditions?: string[]; + /** Custom currency exchange rates. */ + currency?: Monite.CurrencySettings; + /** A default role to provision upon new entity creation. */ + default_role?: Record; + /** Settings for the e-invoicing module. */ + einvoicing?: Monite.EInvoicingSettingsResponse; + /** Settings for email and mailboxes. */ + mail?: Monite.MailSettingsResponse; + /** Settings for the payables module. */ + payable?: Monite.PayableSettingsResponse; + /** Settings for the payments module. */ + payments?: Monite.PaymentsSettingsResponse; + /** Settings for the receivables module. */ + receivable?: Monite.ReceivableSettingsResponse; + /** Measurement units. */ + units?: Monite.Unit[]; + website?: string; +} diff --git a/src/api/types/PayableActionEnum.ts b/src/api/types/PayableActionEnum.ts new file mode 100644 index 0000000..5cbed81 --- /dev/null +++ b/src/api/types/PayableActionEnum.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PayableActionEnum = + | "create" + | "read" + | "update" + | "delete" + | "pay" + | "approve" + | "cancel" + | "submit" + | "create_from_mail" + | "reopen"; + +export const PayableActionEnum = { + Create: "create", + Read: "read", + Update: "update", + Delete: "delete", + Pay: "pay", + Approve: "approve", + Cancel: "cancel", + Submit: "submit", + CreateFromMail: "create_from_mail", + Reopen: "reopen", +} as const; diff --git a/src/api/types/PayableActionSchema.ts b/src/api/types/PayableActionSchema.ts new file mode 100644 index 0000000..4b41b73 --- /dev/null +++ b/src/api/types/PayableActionSchema.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PayableActionSchema { + /** Action name */ + action_name?: Monite.PayableActionEnum; + /** Permission type */ + permission?: Monite.PermissionEnum; +} diff --git a/src/api/types/PayableAggregatedDataResponse.ts b/src/api/types/PayableAggregatedDataResponse.ts new file mode 100644 index 0000000..9644954 --- /dev/null +++ b/src/api/types/PayableAggregatedDataResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PayableAggregatedDataResponse { + /** The total count of payables across all statuses. */ + count: number; + /** A list of aggregated items, each representing a status with its associated sum of the amount field and count. */ + data: Monite.PayableAggregatedItem[]; + /** The total sum of the amount field for all payables across all statuses. */ + sum_total_amount: number; +} diff --git a/src/api/types/PayableAggregatedItem.ts b/src/api/types/PayableAggregatedItem.ts new file mode 100644 index 0000000..a7e2224 --- /dev/null +++ b/src/api/types/PayableAggregatedItem.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PayableAggregatedItem { + /** The total count of payables with this specific status. */ + count: number; + /** The status of the payable (e.g., paid, draft, etc.). */ + status: Monite.PayableStateEnum; + /** The total sum of the amount field for all payables with this specific status. */ + sum_total_amount: number; +} diff --git a/src/api/types/PayableCursorFields.ts b/src/api/types/PayableCursorFields.ts new file mode 100644 index 0000000..6071f8c --- /dev/null +++ b/src/api/types/PayableCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PayableCursorFields = "id" | "created_at"; + +export const PayableCursorFields = { + Id: "id", + CreatedAt: "created_at", +} as const; diff --git a/src/api/types/PayableEntityAddressSchema.ts b/src/api/types/PayableEntityAddressSchema.ts new file mode 100644 index 0000000..88af7f7 --- /dev/null +++ b/src/api/types/PayableEntityAddressSchema.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema represents address info of the entity + */ +export interface PayableEntityAddressSchema { + /** A city (a full name) where the entity is registered */ + city: string; + /** A country name (as ISO code) where the entity is registered */ + country?: Monite.AllowedCountries; + /** A street where the entity is registered */ + line1: string; + /** An alternative street used by the entity */ + line2?: string; + /** A postal code of the address where the entity is registered */ + postal_code: string; + /** A state in a country where the entity is registered */ + state?: string; +} diff --git a/src/api/types/PayableEntityIndividualResponse.ts b/src/api/types/PayableEntityIndividualResponse.ts new file mode 100644 index 0000000..181519b --- /dev/null +++ b/src/api/types/PayableEntityIndividualResponse.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A base for an entity response schema + */ +export interface PayableEntityIndividualResponse { + /** UUID entity ID */ + id: string; + /** UTC datetime */ + created_at: string; + /** UTC datetime */ + updated_at: string; + address: Monite.PayableEntityAddressSchema; + /** An official email address of the entity */ + email?: string; + /** A set of metadata describing an individual */ + individual: Monite.PayableIndividualSchema; + /** A logo image of the entity */ + logo?: Monite.FileSchema2; + /** A phone number of the entity */ + phone?: string; + /** record status, 'active' by default */ + status: Monite.StatusEnum; + /** The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. */ + tax_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/PayableEntityOrganizationResponse.ts b/src/api/types/PayableEntityOrganizationResponse.ts new file mode 100644 index 0000000..b85addc --- /dev/null +++ b/src/api/types/PayableEntityOrganizationResponse.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A base for an entity response schema + */ +export interface PayableEntityOrganizationResponse { + /** UUID entity ID */ + id: string; + /** UTC datetime */ + created_at: string; + /** UTC datetime */ + updated_at: string; + address: Monite.PayableEntityAddressSchema; + /** An official email address of the entity */ + email?: string; + /** A logo image of the entity */ + logo?: Monite.FileSchema2; + /** A set of metadata describing an organization */ + organization: Monite.PayableOrganizationSchema; + /** A phone number of the entity */ + phone?: string; + /** record status, 'active' by default */ + status: Monite.StatusEnum; + /** The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. */ + tax_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/PayableIndividualSchema.ts b/src/api/types/PayableIndividualSchema.ts new file mode 100644 index 0000000..71ad338 --- /dev/null +++ b/src/api/types/PayableIndividualSchema.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A schema contains metadata for an individual + */ +export interface PayableIndividualSchema { + date_of_birth?: string; + /** A first name of an individual */ + first_name: string; + id_number?: string; + /** A last name of an individual */ + last_name: string; + /** The last four digits of the individual's Social Security number */ + ssn_last_4?: string; + /** A title of an individual */ + title?: string; +} diff --git a/src/api/types/PayableOrganizationSchema.ts b/src/api/types/PayableOrganizationSchema.ts new file mode 100644 index 0000000..be3bbaf --- /dev/null +++ b/src/api/types/PayableOrganizationSchema.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema contains metadata for an organization + */ +export interface PayableOrganizationSchema { + /** Business structure of the company */ + business_structure?: Monite.EntityBusinessStructure; + directors_provided?: boolean; + executives_provided?: boolean; + /** A code which identifies uniquely a party of a transaction worldwide */ + legal_entity_id?: string; + /** A legal name of an organization */ + legal_name: string; + owners_provided?: boolean; + representative_provided?: boolean; +} diff --git a/src/api/types/PayableOriginEnum.ts b/src/api/types/PayableOriginEnum.ts new file mode 100644 index 0000000..8766ae2 --- /dev/null +++ b/src/api/types/PayableOriginEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PayableOriginEnum = "upload" | "email"; + +export const PayableOriginEnum = { + Upload: "upload", + Email: "email", +} as const; diff --git a/src/api/types/PayablePaginationResponse.ts b/src/api/types/PayablePaginationResponse.ts new file mode 100644 index 0000000..4d457cd --- /dev/null +++ b/src/api/types/PayablePaginationResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of payables. + */ +export interface PayablePaginationResponse { + data: Monite.PayableResponseSchema[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/PayablePaymentTermDiscount.ts b/src/api/types/PayablePaymentTermDiscount.ts new file mode 100644 index 0000000..a855bb5 --- /dev/null +++ b/src/api/types/PayablePaymentTermDiscount.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PayablePaymentTermDiscount { + /** The discount percentage in minor units. E.g., 200 means 2%, 1050 means 10.5%. */ + discount: number; + /** The amount of days after the invoice issue date. */ + number_of_days: number; +} diff --git a/src/api/types/PayablePaymentTermFinal.ts b/src/api/types/PayablePaymentTermFinal.ts new file mode 100644 index 0000000..be7a110 --- /dev/null +++ b/src/api/types/PayablePaymentTermFinal.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PayablePaymentTermFinal { + /** The amount of days after the invoice issue date. */ + number_of_days: number; +} diff --git a/src/api/types/PayablePaymentTermsCreatePayload.ts b/src/api/types/PayablePaymentTermsCreatePayload.ts new file mode 100644 index 0000000..3c9e357 --- /dev/null +++ b/src/api/types/PayablePaymentTermsCreatePayload.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PayablePaymentTermsCreatePayload { + description?: string; + name: string; + term_1?: Monite.PayablePaymentTermDiscount; + term_2?: Monite.PayablePaymentTermDiscount; + term_final: Monite.PayablePaymentTermFinal; +} diff --git a/src/api/types/PayableResponseSchema.ts b/src/api/types/PayableResponseSchema.ts new file mode 100644 index 0000000..78d50f6 --- /dev/null +++ b/src/api/types/PayableResponseSchema.ts @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents an Accounts Payable document received from a vendor or supplier. + */ +export interface PayableResponseSchema { + /** A unique ID assigned to this payable. */ + id: string; + /** UTC date and time when this payable was created. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ + created_at: string; + /** UTC date and time when this payable was last updated. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ + updated_at: string; + /** How much is left to be paid on the invoice (in minor units). */ + amount_due?: number; + /** How much was paid on the invoice (in minor units). */ + amount_paid?: number; + /** How much is left to be paid on the invoice (in minor units) with discounts from payment terms. */ + amount_to_pay?: number; + /** Id of existing approval policy that applies to this payable, if any. A policy is applied if the payable matches the policy trigger conditions. */ + approval_policy_id?: string; + /** Object representing de-normalized counterpart data. Filled at the moment of invoice submitting for approval or payment. */ + counterpart?: Monite.CounterpartRawData; + /** The ID of counterpart address object stored in counterparts service */ + counterpart_address_id?: string; + /** The ID of counterpart bank account object stored in counterparts service */ + counterpart_bank_account_id?: string; + /** The ID of the counterpart object that represents the vendor or supplier. */ + counterpart_id?: string; + /** Object representing counterpart data which was extracted by OCR. Used for informational purposes. */ + counterpart_raw_data?: Monite.CounterpartRawData; + /** The ID of counterpart VAT ID object stored in counterparts service */ + counterpart_vat_id_id?: string; + /** The ID of the role that the entity user who created this payable had at that time. If the payable was created using a partner access token, the value is `null`. */ + created_by_role_id?: string; + /** The [currency code](https://docs.monite.com/docs/currencies) of the currency used in the payable. */ + currency?: Monite.CurrencyEnum; + currency_exchange?: Monite.CurrencyExchangeSchema; + /** An arbitrary description of this payable. */ + description?: string; + /** A unique invoice number assigned by the invoice issuer for payment tracking purposes. This is different from `id` which is an internal ID created automatically by Monite. */ + document_id?: string; + /** The date by which the payable must be paid, in the YYYY-MM-DD format. If the payable specifies payment terms with early payment discounts, this is the final payment date. */ + due_date?: string; + /** The ID of the entity to which the payable was issued. */ + entity_id: string; + /** The original file from which this payable was created. */ + file?: Monite.FileSchema3; + /** File id to retrieve file info from file saver. */ + file_id?: string; + /** The date when the payable was issued, in the YYYY-MM-DD format. */ + issued_at?: string; + /** The ID of the entity user who marked this document as paid. */ + marked_as_paid_by_entity_user_id?: string; + /** An arbitrary comment that describes how and when this payable was paid. */ + marked_as_paid_with_comment?: string; + /** Id of OCR request to match asynchronous result of processing payable. */ + ocr_request_id?: string; + /** The status of the data recognition process using OCR. The 'processing' status means that the data recognition is in progress and the user needs to wait for the data enrichment. The 'error' status indicates that some error occurred on the OCR side and the user can fill in the data manually. The 'success' status means the data recognition has been successfully completed, after which the user can check the data if desired and enrich or correct it. */ + ocr_status?: Monite.OcrStatusEnum; + /** Data extracted from the uploaded payable by OCR. */ + other_extracted_data?: Monite.PayableResponseSchemaOtherExtractedData; + /** The date by which the payable was paid */ + paid_at?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** Specifies how this payable was created in Monite: `upload` - created via an API call, `email` - sent via email to the entity's mailbox. */ + payable_origin: Monite.PayableOriginEnum; + /** The number of days to pay with potential discount for options shorter than due_date */ + payment_terms?: Monite.PayablePaymentTermsCreatePayload; + /** Project ID of a payable. */ + project_id?: string; + /** The identifier of the purchase order to which this payable belongs. */ + purchase_order_id?: string; + /** The email address from which the invoice was sent to the entity. */ + sender?: string; + /** Specifies how the property values of this payable were provided: `ocr` - Monite OCR service extracted the values from the provided PDF or image file, `user_specified` - values were added or updated via an API call. */ + source_of_payable_data: Monite.SourceOfPayableDataEnum; + /** The [status](https://docs.monite.com/docs/payables-lifecycle) of the payable. */ + status: Monite.PayableStateEnum; + /** The subtotal amount to be paid, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + subtotal?: number; + /** The suggested date and corresponding discount in which payable could be paid. The date is in the YYYY-MM-DD format. The discount is calculated as X \* (10^-4) - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on the payment terms and may even be equal to the due date with discount 0. */ + suggested_payment_term?: Monite.SuggestedPaymentTerm; + /** A list of user-defined tags (labels) assigned to this payable. Tags can be used to trigger a specific approval policy for this payable. */ + tags?: Monite.TagReadSchema[]; + /** Registered tax percentage applied for a service price in minor units, e.g. 200 means 2%, 1050 means 10.5%. */ + tax?: number; + /** Tax amount in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + tax_amount?: number; + /** The total amount to be paid, in [minor units](https://docs.monite.com/docs/currencies#minor-units). For example, $12.50 is represented as 1250. */ + total_amount?: number; + was_created_by_user_id?: string; +} diff --git a/src/api/types/PayableResponseSchemaOtherExtractedData.ts b/src/api/types/PayableResponseSchemaOtherExtractedData.ts new file mode 100644 index 0000000..1d077f9 --- /dev/null +++ b/src/api/types/PayableResponseSchemaOtherExtractedData.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Data extracted from the uploaded payable by OCR. + */ +export type PayableResponseSchemaOtherExtractedData = + | Monite.OcrResponseInvoiceReceiptData + | Monite.OcrRecognitionResponse; diff --git a/src/api/types/PayableSchema.ts b/src/api/types/PayableSchema.ts new file mode 100644 index 0000000..c1a4a1e --- /dev/null +++ b/src/api/types/PayableSchema.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PayableSchema { + /** List of actions */ + actions?: Monite.PayableActionSchema[]; +} diff --git a/src/api/types/PayableSettingsPayload.ts b/src/api/types/PayableSettingsPayload.ts new file mode 100644 index 0000000..cceda7b --- /dev/null +++ b/src/api/types/PayableSettingsPayload.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PayableSettingsPayload { + allow_cancel_duplicates_automatically?: boolean; + allow_counterpart_autocreation?: boolean; + allow_counterpart_autolinking?: boolean; + approve_page_url: string; + /** A state each new payable will have upon creation */ + default_state?: string; + enable_line_items?: boolean; +} diff --git a/src/api/types/PayableSettingsResponse.ts b/src/api/types/PayableSettingsResponse.ts new file mode 100644 index 0000000..83e8106 --- /dev/null +++ b/src/api/types/PayableSettingsResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PayableSettingsResponse { + allow_cancel_duplicates_automatically?: boolean; + allow_counterpart_autocreation?: boolean; + allow_counterpart_autolinking?: boolean; + approve_page_url: string; + /** A state each new payable will have upon creation */ + default_state?: string; + enable_line_items?: boolean; +} diff --git a/src/api/types/PayableStateEnum.ts b/src/api/types/PayableStateEnum.ts new file mode 100644 index 0000000..43a0803 --- /dev/null +++ b/src/api/types/PayableStateEnum.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PayableStateEnum = + | "draft" + | "new" + | "approve_in_progress" + | "waiting_to_be_paid" + | "partially_paid" + | "paid" + | "canceled" + | "rejected"; + +export const PayableStateEnum = { + Draft: "draft", + New: "new", + ApproveInProgress: "approve_in_progress", + WaitingToBePaid: "waiting_to_be_paid", + PartiallyPaid: "partially_paid", + Paid: "paid", + Canceled: "canceled", + Rejected: "rejected", +} as const; diff --git a/src/api/types/PayableTemplatesVariable.ts b/src/api/types/PayableTemplatesVariable.ts new file mode 100644 index 0000000..2e07bd7 --- /dev/null +++ b/src/api/types/PayableTemplatesVariable.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PayableTemplatesVariable { + description: string; + name: string; +} diff --git a/src/api/types/PayableTemplatesVariablesObject.ts b/src/api/types/PayableTemplatesVariablesObject.ts new file mode 100644 index 0000000..d3b69fa --- /dev/null +++ b/src/api/types/PayableTemplatesVariablesObject.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PayableTemplatesVariablesObject { + object_subtype: Monite.PayablesVariableType; + object_type: Monite.ObjectType; + variables: Monite.PayableTemplatesVariable[]; +} diff --git a/src/api/types/PayableTemplatesVariablesObjectList.ts b/src/api/types/PayableTemplatesVariablesObjectList.ts new file mode 100644 index 0000000..677403c --- /dev/null +++ b/src/api/types/PayableTemplatesVariablesObjectList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PayableTemplatesVariablesObjectList { + data: Monite.PayableTemplatesVariablesObject[]; +} diff --git a/src/api/types/PayableValidationResponse.ts b/src/api/types/PayableValidationResponse.ts new file mode 100644 index 0000000..c83b2d7 --- /dev/null +++ b/src/api/types/PayableValidationResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PayableValidationResponse { + /** A unique ID assigned to this payable. */ + id: string; + validation_errors?: Record[]; +} diff --git a/src/api/types/PayableValidationsResource.ts b/src/api/types/PayableValidationsResource.ts new file mode 100644 index 0000000..f4cf235 --- /dev/null +++ b/src/api/types/PayableValidationsResource.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PayableValidationsResource { + required_fields: Monite.PayablesFieldsAllowedForValidate[]; +} diff --git a/src/api/types/PayablesFieldsAllowedForValidate.ts b/src/api/types/PayablesFieldsAllowedForValidate.ts new file mode 100644 index 0000000..e2d9967 --- /dev/null +++ b/src/api/types/PayablesFieldsAllowedForValidate.ts @@ -0,0 +1,66 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PayablesFieldsAllowedForValidate = + | "currency" + | "document_id" + | "due_date" + | "issued_at" + | "tax_amount" + | "total_amount" + | "subtotal" + | "description" + | "suggested_payment_term" + | "payment_terms" + | "tax" + | "sender" + | "file_id" + | "counterpart_id" + | "counterpart_bank_account_id" + | "counterpart_address_id" + | "counterpart_vat_id_id" + | "line_items" + | "line_items.quantity" + | "line_items.unit_price" + | "line_items.tax" + | "line_items.ledger_account_id" + | "line_items.accounting_tax_rate_id" + | "line_items.unit" + | "line_items.name" + | "line_items.description" + | "line_items.subtotal" + | "line_items.total" + | "line_items.tax_amount"; + +export const PayablesFieldsAllowedForValidate = { + Currency: "currency", + DocumentId: "document_id", + DueDate: "due_date", + IssuedAt: "issued_at", + TaxAmount: "tax_amount", + TotalAmount: "total_amount", + Subtotal: "subtotal", + Description: "description", + SuggestedPaymentTerm: "suggested_payment_term", + PaymentTerms: "payment_terms", + Tax: "tax", + Sender: "sender", + FileId: "file_id", + CounterpartId: "counterpart_id", + CounterpartBankAccountId: "counterpart_bank_account_id", + CounterpartAddressId: "counterpart_address_id", + CounterpartVatIdId: "counterpart_vat_id_id", + LineItems: "line_items", + LineItemsQuantity: "line_items.quantity", + LineItemsUnitPrice: "line_items.unit_price", + LineItemsTax: "line_items.tax", + LineItemsLedgerAccountId: "line_items.ledger_account_id", + LineItemsAccountingTaxRateId: "line_items.accounting_tax_rate_id", + LineItemsUnit: "line_items.unit", + LineItemsName: "line_items.name", + LineItemsDescription: "line_items.description", + LineItemsSubtotal: "line_items.subtotal", + LineItemsTotal: "line_items.total", + LineItemsTaxAmount: "line_items.tax_amount", +} as const; diff --git a/src/api/types/PayablesVariableType.ts b/src/api/types/PayablesVariableType.ts new file mode 100644 index 0000000..bc0ec87 --- /dev/null +++ b/src/api/types/PayablesVariableType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PayablesVariableType = "payables_purchase_order" | "payables_notify_approver"; + +export const PayablesVariableType = { + PayablesPurchaseOrder: "payables_purchase_order", + PayablesNotifyApprover: "payables_notify_approver", +} as const; diff --git a/src/api/types/PaymentAccountObject.ts b/src/api/types/PaymentAccountObject.ts new file mode 100644 index 0000000..15fbbfe --- /dev/null +++ b/src/api/types/PaymentAccountObject.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentAccountObject { + id: string; + type: Monite.PaymentAccountType; +} diff --git a/src/api/types/PaymentAccountType.ts b/src/api/types/PaymentAccountType.ts new file mode 100644 index 0000000..20c1d96 --- /dev/null +++ b/src/api/types/PaymentAccountType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentAccountType = "entity" | "counterpart"; + +export const PaymentAccountType = { + Entity: "entity", + Counterpart: "counterpart", +} as const; diff --git a/src/api/types/PaymentIntent.ts b/src/api/types/PaymentIntent.ts new file mode 100644 index 0000000..3f14e42 --- /dev/null +++ b/src/api/types/PaymentIntent.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentIntent { + id: string; + updated_at: string; + application_fee_amount?: number; + object?: Monite.PaymentObject; + provider?: string; + selected_payment_method?: string; + status: string; +} diff --git a/src/api/types/PaymentIntentCursorFields.ts b/src/api/types/PaymentIntentCursorFields.ts new file mode 100644 index 0000000..5b6dfe6 --- /dev/null +++ b/src/api/types/PaymentIntentCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentIntentCursorFields = "id" | "created_at"; + +export const PaymentIntentCursorFields = { + Id: "id", + CreatedAt: "created_at", +} as const; diff --git a/src/api/types/PaymentIntentHistory.ts b/src/api/types/PaymentIntentHistory.ts new file mode 100644 index 0000000..c9bc856 --- /dev/null +++ b/src/api/types/PaymentIntentHistory.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PaymentIntentHistory { + id: string; + created_at: string; + updated_at: string; + payment_intent_id: string; + status: string; +} diff --git a/src/api/types/PaymentIntentHistoryResponse.ts b/src/api/types/PaymentIntentHistoryResponse.ts new file mode 100644 index 0000000..850a989 --- /dev/null +++ b/src/api/types/PaymentIntentHistoryResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentIntentHistoryResponse { + /** Payment intent history */ + data: Monite.PaymentIntentHistory[]; +} diff --git a/src/api/types/PaymentIntentPayoutMethod.ts b/src/api/types/PaymentIntentPayoutMethod.ts new file mode 100644 index 0000000..c0213f4 --- /dev/null +++ b/src/api/types/PaymentIntentPayoutMethod.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentIntentPayoutMethod = "bank_account" | "paper_check"; + +export const PaymentIntentPayoutMethod = { + BankAccount: "bank_account", + PaperCheck: "paper_check", +} as const; diff --git a/src/api/types/PaymentIntentResponse.ts b/src/api/types/PaymentIntentResponse.ts new file mode 100644 index 0000000..418d032 --- /dev/null +++ b/src/api/types/PaymentIntentResponse.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentIntentResponse { + id: string; + updated_at: string; + amount: number; + application_fee_amount?: number; + batch_payment_id?: string; + currency: string; + invoice?: Monite.Invoice; + object?: Monite.PaymentObject; + payer?: Monite.AccountResponse; + payment_link_id?: string; + payment_methods: Monite.MoniteAllPaymentMethodsTypes[]; + payment_reference?: string; + provider?: string; + recipient: Monite.RecipientAccountResponse; + selected_payment_method?: Monite.MoniteAllPaymentMethodsTypes; + status: string; +} diff --git a/src/api/types/PaymentIntentsListResponse.ts b/src/api/types/PaymentIntentsListResponse.ts new file mode 100644 index 0000000..2c809cc --- /dev/null +++ b/src/api/types/PaymentIntentsListResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentIntentsListResponse { + data: Monite.PaymentIntentResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/PaymentIntentsRecipient.ts b/src/api/types/PaymentIntentsRecipient.ts new file mode 100644 index 0000000..0c2aa59 --- /dev/null +++ b/src/api/types/PaymentIntentsRecipient.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentIntentsRecipient { + id: string; + bank_account_id?: string; + payout_method?: Monite.PaymentIntentPayoutMethod; + type: "counterpart"; +} diff --git a/src/api/types/PaymentMethod.ts b/src/api/types/PaymentMethod.ts new file mode 100644 index 0000000..195550c --- /dev/null +++ b/src/api/types/PaymentMethod.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentMethod { + direction: Monite.PaymentMethodDirection; + name: Monite.MoniteAllPaymentMethods; + status: Monite.PaymentMethodStatus; + type: Monite.MoniteAllPaymentMethodsTypes; +} diff --git a/src/api/types/PaymentMethodDirection.ts b/src/api/types/PaymentMethodDirection.ts new file mode 100644 index 0000000..74d7865 --- /dev/null +++ b/src/api/types/PaymentMethodDirection.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentMethodDirection = "receive" | "send"; + +export const PaymentMethodDirection = { + Receive: "receive", + Send: "send", +} as const; diff --git a/src/api/types/PaymentMethodRequirements.ts b/src/api/types/PaymentMethodRequirements.ts new file mode 100644 index 0000000..980b596 --- /dev/null +++ b/src/api/types/PaymentMethodRequirements.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PaymentMethodRequirements { + current_deadline?: string; + currently_due: string[]; + eventually_due: string[]; + past_due: string[]; + pending_verification: string[]; +} diff --git a/src/api/types/PaymentMethodStatus.ts b/src/api/types/PaymentMethodStatus.ts new file mode 100644 index 0000000..25f5f18 --- /dev/null +++ b/src/api/types/PaymentMethodStatus.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentMethodStatus = "active" | "inactive"; + +export const PaymentMethodStatus = { + Active: "active", + Inactive: "inactive", +} as const; diff --git a/src/api/types/PaymentObject.ts b/src/api/types/PaymentObject.ts new file mode 100644 index 0000000..760960c --- /dev/null +++ b/src/api/types/PaymentObject.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentObject { + id: string; + type: Monite.PaymentObjectType; +} diff --git a/src/api/types/PaymentObjectPayable.ts b/src/api/types/PaymentObjectPayable.ts new file mode 100644 index 0000000..07f3e24 --- /dev/null +++ b/src/api/types/PaymentObjectPayable.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PaymentObjectPayable { + id: string; + type: "payable"; +} diff --git a/src/api/types/PaymentObjectType.ts b/src/api/types/PaymentObjectType.ts new file mode 100644 index 0000000..caa3e03 --- /dev/null +++ b/src/api/types/PaymentObjectType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentObjectType = "payable" | "receivable"; + +export const PaymentObjectType = { + Payable: "payable", + Receivable: "receivable", +} as const; diff --git a/src/api/types/PaymentPageThemePayload.ts b/src/api/types/PaymentPageThemePayload.ts new file mode 100644 index 0000000..132885a --- /dev/null +++ b/src/api/types/PaymentPageThemePayload.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentPageThemePayload { + background_color?: string; + border_radius?: string; + button?: Monite.ButtonThemePayload; + card?: Monite.CardThemePayload; + font_color?: string; + font_family?: string; + font_link_href?: string; + logo_src?: string; +} diff --git a/src/api/types/PaymentPageThemeResponse.ts b/src/api/types/PaymentPageThemeResponse.ts new file mode 100644 index 0000000..bc6ee8a --- /dev/null +++ b/src/api/types/PaymentPageThemeResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentPageThemeResponse { + background_color?: string; + border_radius?: string; + button?: Monite.ButtonThemeResponse; + card?: Monite.CardThemeResponse; + font_color?: string; + font_family?: string; + font_link_href?: string; + logo_src?: string; +} diff --git a/src/api/types/PaymentPriorityEnum.ts b/src/api/types/PaymentPriorityEnum.ts new file mode 100644 index 0000000..0be6876 --- /dev/null +++ b/src/api/types/PaymentPriorityEnum.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentPriorityEnum = "working_capital" | "balanced" | "bottom_line"; + +export const PaymentPriorityEnum = { + WorkingCapital: "working_capital", + Balanced: "balanced", + BottomLine: "bottom_line", +} as const; diff --git a/src/api/types/PaymentReceivedEventData.ts b/src/api/types/PaymentReceivedEventData.ts new file mode 100644 index 0000000..4b36953 --- /dev/null +++ b/src/api/types/PaymentReceivedEventData.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PaymentReceivedEventData { + amount_due: number; + amount_paid: number; + comment?: string; +} diff --git a/src/api/types/PaymentRecordCursorFields.ts b/src/api/types/PaymentRecordCursorFields.ts new file mode 100644 index 0000000..a09dada --- /dev/null +++ b/src/api/types/PaymentRecordCursorFields.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentRecordCursorFields = "paid_at" | "amount" | "overpaid_amount"; + +export const PaymentRecordCursorFields = { + PaidAt: "paid_at", + Amount: "amount", + OverpaidAmount: "overpaid_amount", +} as const; diff --git a/src/api/types/PaymentRecordObjectRequest.ts b/src/api/types/PaymentRecordObjectRequest.ts new file mode 100644 index 0000000..67ed4f0 --- /dev/null +++ b/src/api/types/PaymentRecordObjectRequest.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentRecordObjectRequest { + /** ID of the invoice */ + id: string; + type: Monite.ObjectTypeEnum; +} diff --git a/src/api/types/PaymentRecordObjectResponse.ts b/src/api/types/PaymentRecordObjectResponse.ts new file mode 100644 index 0000000..91b65f1 --- /dev/null +++ b/src/api/types/PaymentRecordObjectResponse.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentRecordObjectResponse { + /** ID of the invoice */ + id: string; + /** Status, in which object has been moved */ + new_status: string; + /** Status, in which object was before payment */ + old_status: string; + type: Monite.ObjectTypeEnum; +} diff --git a/src/api/types/PaymentRecordResponse.ts b/src/api/types/PaymentRecordResponse.ts new file mode 100644 index 0000000..2ff5144 --- /dev/null +++ b/src/api/types/PaymentRecordResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentRecordResponse { + id: string; + amount: number; + currency: Monite.CurrencyEnum; + entity_user_id?: string; + is_external: boolean; + object: Monite.PaymentRecordObjectResponse; + /** Filled in a case, if payment amount is more, than total_amount */ + overpaid_amount?: number; + paid_at: string; + payment_intent_id: string; +} diff --git a/src/api/types/PaymentRecordResponseList.ts b/src/api/types/PaymentRecordResponseList.ts new file mode 100644 index 0000000..67556ed --- /dev/null +++ b/src/api/types/PaymentRecordResponseList.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentRecordResponseList { + data: Monite.PaymentRecordResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/PaymentReminderResponse.ts b/src/api/types/PaymentReminderResponse.ts new file mode 100644 index 0000000..8a8b7e0 --- /dev/null +++ b/src/api/types/PaymentReminderResponse.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentReminderResponse { + id: string; + /** Time at which the PaymentReminder was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the PaymentReminder was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + entity_id: string; + name: string; + recipients?: Monite.Recipients; + status: Monite.StatusEnum; + /** Reminder to send for first payment term */ + term_1_reminder?: Monite.Reminder; + /** Reminder to send for second payment term */ + term_2_reminder?: Monite.Reminder; + /** Reminder to send for final payment term */ + term_final_reminder?: Monite.Reminder; +} diff --git a/src/api/types/PaymentRequirements.ts b/src/api/types/PaymentRequirements.ts new file mode 100644 index 0000000..50043d5 --- /dev/null +++ b/src/api/types/PaymentRequirements.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PaymentRequirements { + current_deadline?: string; + currently_due: string[]; + eventually_due: string[]; + pending_verification: string[]; +} diff --git a/src/api/types/PaymentTerm.ts b/src/api/types/PaymentTerm.ts new file mode 100644 index 0000000..d748266 --- /dev/null +++ b/src/api/types/PaymentTerm.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PaymentTerm { + /** The amount of days after the invoice issue date. */ + number_of_days: number; +} diff --git a/src/api/types/PaymentTermDiscount.ts b/src/api/types/PaymentTermDiscount.ts new file mode 100644 index 0000000..144ac72 --- /dev/null +++ b/src/api/types/PaymentTermDiscount.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PaymentTermDiscount { + /** The discount percentage in minor units. E.g., 200 means 2%. 1050 means 10.5%. */ + discount: number; + /** The amount of days after the invoice issue date. */ + number_of_days: number; +} diff --git a/src/api/types/PaymentTermDiscountWithDate.ts b/src/api/types/PaymentTermDiscountWithDate.ts new file mode 100644 index 0000000..993aa7a --- /dev/null +++ b/src/api/types/PaymentTermDiscountWithDate.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PaymentTermDiscountWithDate { + /** The discount percentage in minor units. E.g., 200 means 2%. 1050 means 10.5%. */ + discount: number; + end_date?: string; + /** The amount of days after the invoice issue date. */ + number_of_days: number; +} diff --git a/src/api/types/PaymentTerms.ts b/src/api/types/PaymentTerms.ts new file mode 100644 index 0000000..6c7169f --- /dev/null +++ b/src/api/types/PaymentTerms.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentTerms { + id: string; + name?: string; + /** The first tier of the payment term. Represents the terms of the first early discount. */ + term_1?: Monite.PaymentTermDiscountWithDate; + /** The second tier of the payment term. Defines the terms of the second early discount. */ + term_2?: Monite.PaymentTermDiscountWithDate; + /** The final tier of the payment term. Defines the invoice due date. */ + term_final: Monite.TermFinalWithDate; +} diff --git a/src/api/types/PaymentTermsListResponse.ts b/src/api/types/PaymentTermsListResponse.ts new file mode 100644 index 0000000..0ef2464 --- /dev/null +++ b/src/api/types/PaymentTermsListResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentTermsListResponse { + data?: Monite.PaymentTermsResponse[]; +} diff --git a/src/api/types/PaymentTermsResponse.ts b/src/api/types/PaymentTermsResponse.ts new file mode 100644 index 0000000..581d33d --- /dev/null +++ b/src/api/types/PaymentTermsResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentTermsResponse { + id: string; + description?: string; + name: string; + /** The first tier of the payment term. Represents the terms of the first early discount. */ + term_1?: Monite.PaymentTermDiscount; + /** The second tier of the payment term. Defines the terms of the second early discount. */ + term_2?: Monite.PaymentTermDiscount; + /** The final tier of the payment term. Defines the invoice due date. */ + term_final: Monite.PaymentTerm; +} diff --git a/src/api/types/PaymentsBatchPaymentResponse.ts b/src/api/types/PaymentsBatchPaymentResponse.ts new file mode 100644 index 0000000..54e7f34 --- /dev/null +++ b/src/api/types/PaymentsBatchPaymentResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentsBatchPaymentResponse { + id: string; + created_at: string; + error?: Record; + payer_bank_account_id: string; + payment_intents: Monite.SinglePaymentIntentResponse[]; + payment_method: "us_ach"; + status: Monite.PaymentsBatchPaymentStatus; + total_amount?: number; +} diff --git a/src/api/types/PaymentsBatchPaymentStatus.ts b/src/api/types/PaymentsBatchPaymentStatus.ts new file mode 100644 index 0000000..e708b03 --- /dev/null +++ b/src/api/types/PaymentsBatchPaymentStatus.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PaymentsBatchPaymentStatus = "created" | "processing" | "partially_successful" | "succeeded" | "failed"; + +export const PaymentsBatchPaymentStatus = { + Created: "created", + Processing: "processing", + PartiallySuccessful: "partially_successful", + Succeeded: "succeeded", + Failed: "failed", +} as const; diff --git a/src/api/types/PaymentsSettingsPayload.ts b/src/api/types/PaymentsSettingsPayload.ts new file mode 100644 index 0000000..5fa215f --- /dev/null +++ b/src/api/types/PaymentsSettingsPayload.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentsSettingsPayload { + payment_page_domain?: string; + payment_page_theme?: Monite.PaymentPageThemePayload; + /** The support email address */ + support_email?: string; +} diff --git a/src/api/types/PaymentsSettingsResponse.ts b/src/api/types/PaymentsSettingsResponse.ts new file mode 100644 index 0000000..9973e37 --- /dev/null +++ b/src/api/types/PaymentsSettingsResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PaymentsSettingsResponse { + payment_page_domain?: string; + payment_page_theme?: Monite.PaymentPageThemeResponse; + /** The support email address */ + support_email?: string; +} diff --git a/src/api/types/PermissionEnum.ts b/src/api/types/PermissionEnum.ts new file mode 100644 index 0000000..9bc96f1 --- /dev/null +++ b/src/api/types/PermissionEnum.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PermissionEnum = "allowed" | "allowed_for_own" | "not_allowed"; + +export const PermissionEnum = { + Allowed: "allowed", + AllowedForOwn: "allowed_for_own", + NotAllowed: "not_allowed", +} as const; diff --git a/src/api/types/PersonAddressRequest.ts b/src/api/types/PersonAddressRequest.ts new file mode 100644 index 0000000..8b87a09 --- /dev/null +++ b/src/api/types/PersonAddressRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PersonAddressRequest { + /** City, district, suburb, town, or village */ + city: string; + /** Two-letter country code (ISO 3166-1 alpha-2) */ + country: Monite.AllowedCountries; + /** Address line 1 (e.g., street, PO Box, or company name) */ + line1: string; + /** Address line 2 (e.g., apartment, suite, unit, or building) */ + line2?: string; + /** ZIP or postal code */ + postal_code: string; + /** State, county, province, or region */ + state?: string; +} diff --git a/src/api/types/PersonAddressResponse.ts b/src/api/types/PersonAddressResponse.ts new file mode 100644 index 0000000..098c7a5 --- /dev/null +++ b/src/api/types/PersonAddressResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PersonAddressResponse { + /** City, district, suburb, town, or village */ + city: string; + /** Two-letter country code (ISO 3166-1 alpha-2) */ + country: string; + /** Address line 1 (e.g., street, PO Box, or company name) */ + line1: string; + /** Address line 2 (e.g., apartment, suite, unit, or building) */ + line2?: string; + /** ZIP or postal code */ + postal_code: string; + /** State, county, province, or region */ + state?: string; +} diff --git a/src/api/types/PersonOnboardingDocuments.ts b/src/api/types/PersonOnboardingDocuments.ts new file mode 100644 index 0000000..1bca816 --- /dev/null +++ b/src/api/types/PersonOnboardingDocuments.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PersonOnboardingDocuments { + verification_document_front?: string; + verification_document_back?: string; + additional_verification_document_front?: string; + additional_verification_document_back?: string; +} diff --git a/src/api/types/PersonRelationshipRequest.ts b/src/api/types/PersonRelationshipRequest.ts new file mode 100644 index 0000000..77f4ec5 --- /dev/null +++ b/src/api/types/PersonRelationshipRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PersonRelationshipRequest { + /** Whether the person is a director of the account's legal entity */ + director?: boolean; + /** Whether the person has significant responsibility to control, manage, or direct the organization */ + executive?: boolean; + /** Whether the person is an owner of the account's legal entity */ + owner?: boolean; + /** The percent owned by the person of the account's legal entity */ + percent_ownership?: number; + /** Whether the person is authorized as the primary representative of the account */ + representative?: boolean; + /** The person's title (e.g., CEO, Support Engineer) */ + title?: string; +} diff --git a/src/api/types/PersonRelationshipResponse.ts b/src/api/types/PersonRelationshipResponse.ts new file mode 100644 index 0000000..75f3ff0 --- /dev/null +++ b/src/api/types/PersonRelationshipResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PersonRelationshipResponse { + /** Whether the person is a director of the account's legal entity */ + director?: boolean; + /** Whether the person has significant responsibility to control, manage, or direct the organization */ + executive?: boolean; + /** Whether the person is an owner of the account's legal entity */ + owner?: boolean; + /** The percent owned by the person of the account's legal entity */ + percent_ownership?: number; + /** Whether the person is authorized as the primary representative of the account */ + representative?: boolean; + /** The person's title (e.g., CEO, Support Engineer) */ + title?: string; +} diff --git a/src/api/types/PersonResponse.ts b/src/api/types/PersonResponse.ts new file mode 100644 index 0000000..9533a4c --- /dev/null +++ b/src/api/types/PersonResponse.ts @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PersonResponse { + /** The person's unique identifier */ + id: string; + /** Time at which the person was created */ + created_at: string; + /** Time at which the person was updated */ + updated_at: string; + /** The person's address */ + address?: Monite.PersonAddressResponse; + /** Required for persons of US entities. The country of the person's citizenship, as a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple citizenship, specify any. */ + citizenship?: Monite.AllowedCountries; + /** ID of the entity user who created this person, or null if the person was created using a partner access token. */ + created_by_entity_user_id?: string; + /** The person's date of birth */ + date_of_birth?: string; + /** The person's email address */ + email: string; + /** Entity ID */ + entity_id: string; + /** The person's first name */ + first_name: string; + /** The person's ID number, as appropriate for their country */ + id_number?: string; + /** The person's last name */ + last_name: string; + /** The person's phone number */ + phone?: string; + /** Describes the person's relationship to the entity */ + relationship: Monite.PersonRelationshipResponse; + /** The last four digits of the person's Social Security number */ + ssn_last_4?: string; +} diff --git a/src/api/types/PersonsResponse.ts b/src/api/types/PersonsResponse.ts new file mode 100644 index 0000000..949dfac --- /dev/null +++ b/src/api/types/PersonsResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PersonsResponse { + /** array of objects of type person */ + data: Monite.PersonResponse[]; +} diff --git a/src/api/types/Platform.ts b/src/api/types/Platform.ts new file mode 100644 index 0000000..32d9130 --- /dev/null +++ b/src/api/types/Platform.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type Platform = "xero" | "quickbooks_online" | "quickbooks_online_sandbox"; + +export const Platform = { + Xero: "xero", + QuickbooksOnline: "quickbooks_online", + QuickbooksOnlineSandbox: "quickbooks_online_sandbox", +} as const; diff --git a/src/api/types/PreviewSchema.ts b/src/api/types/PreviewSchema.ts new file mode 100644 index 0000000..04ef368 --- /dev/null +++ b/src/api/types/PreviewSchema.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A preview image generated for a file. + */ +export interface PreviewSchema { + /** The image height in pixels. */ + height: number; + /** The image URL. */ + url: string; + /** The image width in pixels. */ + width: number; +} diff --git a/src/api/types/PreviewSchema2.ts b/src/api/types/PreviewSchema2.ts new file mode 100644 index 0000000..b03999f --- /dev/null +++ b/src/api/types/PreviewSchema2.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A preview image generated for a file. + */ +export interface PreviewSchema2 { + /** The image height in pixels. */ + height: number; + /** The image URL. */ + url: string; + /** The image width in pixels. */ + width: number; +} diff --git a/src/api/types/PreviewSchema3.ts b/src/api/types/PreviewSchema3.ts new file mode 100644 index 0000000..33900e8 --- /dev/null +++ b/src/api/types/PreviewSchema3.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A preview image generated for a file. + */ +export interface PreviewSchema3 { + /** The image URL. */ + url: string; + /** The image width in pixels. */ + width: number; + /** The image height in pixels. */ + height: number; +} diff --git a/src/api/types/PreviewSchema4.ts b/src/api/types/PreviewSchema4.ts new file mode 100644 index 0000000..8f1091e --- /dev/null +++ b/src/api/types/PreviewSchema4.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A preview image generated for a file. + */ +export interface PreviewSchema4 { + /** The image height in pixels. */ + height: number; + /** The image URL. */ + url: string; + /** The image width in pixels. */ + width: number; +} diff --git a/src/api/types/PreviewTemplateResponse.ts b/src/api/types/PreviewTemplateResponse.ts new file mode 100644 index 0000000..71894e6 --- /dev/null +++ b/src/api/types/PreviewTemplateResponse.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PreviewTemplateResponse { + body_preview: string; + subject_preview: string; +} diff --git a/src/api/types/Price.ts b/src/api/types/Price.ts new file mode 100644 index 0000000..fb775f6 --- /dev/null +++ b/src/api/types/Price.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface Price { + /** The currency in which the price of the product is set. */ + currency: Monite.CurrencyEnum; + /** The actual price of the product. */ + value: number; +} diff --git a/src/api/types/ProcessResource.ts b/src/api/types/ProcessResource.ts new file mode 100644 index 0000000..11ac211 --- /dev/null +++ b/src/api/types/ProcessResource.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ProcessResource { + id: string; + /** Tthe current status of the approval policy process. */ + status: Monite.ProcessStatusEnum; + /** The input for the script. */ + input: Record; + /** The error for the process. */ + error?: Record; + /** The script snapshot taken when script started. */ + script_snapshot?: Monite.ProcessResourceScriptSnapshot; + /** The metadata for the process. */ + metadata: Record; + created_at: string; + updated_at?: string; + created_by?: string; + updated_by?: string; +} diff --git a/src/api/types/ProcessResourceScriptSnapshot.ts b/src/api/types/ProcessResourceScriptSnapshot.ts new file mode 100644 index 0000000..918e267 --- /dev/null +++ b/src/api/types/ProcessResourceScriptSnapshot.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The script snapshot taken when script started. + */ +export type ProcessResourceScriptSnapshot = boolean | number | string | unknown[] | Record; diff --git a/src/api/types/ProcessStatusEnum.ts b/src/api/types/ProcessStatusEnum.ts new file mode 100644 index 0000000..9c93c8d --- /dev/null +++ b/src/api/types/ProcessStatusEnum.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ProcessStatusEnum = "succeeded" | "waiting" | "failed" | "running" | "canceled" | "timed_out"; + +export const ProcessStatusEnum = { + Succeeded: "succeeded", + Waiting: "waiting", + Failed: "failed", + Running: "running", + Canceled: "canceled", + TimedOut: "timed_out", +} as const; diff --git a/src/api/types/ProductCursorFields.ts b/src/api/types/ProductCursorFields.ts new file mode 100644 index 0000000..0250ae4 --- /dev/null +++ b/src/api/types/ProductCursorFields.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ProductCursorFields = "name"; diff --git a/src/api/types/ProductServicePaginationResponse.ts b/src/api/types/ProductServicePaginationResponse.ts new file mode 100644 index 0000000..1f9227a --- /dev/null +++ b/src/api/types/ProductServicePaginationResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of products and services + */ +export interface ProductServicePaginationResponse { + data: Monite.ProductServiceResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/ProductServiceResponse.ts b/src/api/types/ProductServiceResponse.ts new file mode 100644 index 0000000..406c56b --- /dev/null +++ b/src/api/types/ProductServiceResponse.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ProductServiceResponse { + /** Unique ID of the product. */ + id: string; + /** Time at which the product was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the product was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + /** Description of the product. */ + description?: string; + entity_id: string; + entity_user_id?: string; + ledger_account_id?: string; + /** The unique ID reference of the unit used to measure the quantity of this product (e.g. items, meters, kilograms). */ + measure_unit_id?: string; + /** Name of the product. */ + name: string; + price?: Monite.Price; + /** The smallest amount allowed for this product. */ + smallest_amount?: number; + /** Specifies whether this offering is a product or service. This may affect the applicable tax rates. */ + type?: Monite.ProductServiceTypeEnum; +} diff --git a/src/api/types/ProductServiceTypeEnum.ts b/src/api/types/ProductServiceTypeEnum.ts new file mode 100644 index 0000000..4b3619a --- /dev/null +++ b/src/api/types/ProductServiceTypeEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ProductServiceTypeEnum = "product" | "service"; + +export const ProductServiceTypeEnum = { + Product: "product", + Service: "service", +} as const; diff --git a/src/api/types/ProjectCursorFields.ts b/src/api/types/ProjectCursorFields.ts new file mode 100644 index 0000000..19d604c --- /dev/null +++ b/src/api/types/ProjectCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ProjectCursorFields = "id" | "created_at"; + +export const ProjectCursorFields = { + Id: "id", + CreatedAt: "created_at", +} as const; diff --git a/src/api/types/ProjectPaginationResponse.ts b/src/api/types/ProjectPaginationResponse.ts new file mode 100644 index 0000000..585e25f --- /dev/null +++ b/src/api/types/ProjectPaginationResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of projects. + */ +export interface ProjectPaginationResponse { + data: Monite.ProjectResource[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/ProjectResource.ts b/src/api/types/ProjectResource.ts new file mode 100644 index 0000000..ff77374 --- /dev/null +++ b/src/api/types/ProjectResource.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ProjectResource { + /** A unique ID assigned to this project. */ + id: string; + /** Project created at */ + created_at: string; + /** Last time project was updated at */ + updated_at: string; + /** Project code */ + code?: string; + /** Project color */ + color?: string; + /** Project created by entity user */ + created_by_entity_user_id?: string; + /** Description of project */ + description?: string; + /** Project end date */ + end_date?: string; + /** The ID of the entity to which the project was issued. */ + entity_id: string; + /** The project name. */ + name: string; + /** Parent project ID */ + parent_id?: string; + /** Project metadata */ + partner_metadata?: Record; + /** Project start date */ + start_date?: string; + /** A list of user-defined tags (labels) assigned to this project. */ + tags?: Monite.TagReadSchema[]; +} diff --git a/src/api/types/PublicPaymentLinkResponse.ts b/src/api/types/PublicPaymentLinkResponse.ts new file mode 100644 index 0000000..3f1b0b6 --- /dev/null +++ b/src/api/types/PublicPaymentLinkResponse.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PublicPaymentLinkResponse { + id: string; + amount: number; + currency: Monite.CurrencyEnum; + expires_at: string; + invoice?: Monite.Invoice; + payer?: Monite.AccountResponse; + payment_intent?: Monite.PaymentIntent; + payment_intent_id: string; + payment_methods: string[]; + payment_page_url: string; + payment_reference?: string; + recipient: Monite.RecipientAccountResponse; + return_url?: string; + status: string; +} diff --git a/src/api/types/PurchaseOrderCounterpartAddressSchema.ts b/src/api/types/PurchaseOrderCounterpartAddressSchema.ts new file mode 100644 index 0000000..61c88ba --- /dev/null +++ b/src/api/types/PurchaseOrderCounterpartAddressSchema.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Address information. + */ +export interface PurchaseOrderCounterpartAddressSchema { + /** City name. */ + city: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country: Monite.AllowedCountries; + /** Street address. */ + line1: string; + /** Additional address information (if any). */ + line2?: string; + /** ZIP or postal code. */ + postal_code: string; + /** State, region, province, or county. */ + state?: string; +} diff --git a/src/api/types/PurchaseOrderCounterpartIndividualResponse.ts b/src/api/types/PurchaseOrderCounterpartIndividualResponse.ts new file mode 100644 index 0000000..b3ab0bc --- /dev/null +++ b/src/api/types/PurchaseOrderCounterpartIndividualResponse.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Represents counterparts that are individuals (natural persons). + */ +export interface PurchaseOrderCounterpartIndividualResponse { + /** The person's email address. */ + email?: string; + /** The person's first name. */ + first_name: string; + /** Indicates if the counterpart is a customer. */ + is_customer: boolean; + /** Indicates if the counterpart is a vendor. */ + is_vendor: boolean; + /** The person's last name. */ + last_name: string; + /** The person's phone number. */ + phone?: string; + /** The person's title or honorific. Examples: Mr., Ms., Dr., Prof. */ + title?: string; +} diff --git a/src/api/types/PurchaseOrderCounterpartIndividualRootResponse.ts b/src/api/types/PurchaseOrderCounterpartIndividualRootResponse.ts new file mode 100644 index 0000000..c9fec20 --- /dev/null +++ b/src/api/types/PurchaseOrderCounterpartIndividualRootResponse.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are individuals (natural persons). + */ +export interface PurchaseOrderCounterpartIndividualRootResponse { + /** Unique ID of the counterpart. */ + id: string; + /** Date and time when the counterpart was created. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + created_at: string; + /** Date and time when the counterpart was last updated. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + updated_at: string; + /** `true` if the counterpart was created automatically by Monite when processing incoming invoices with OCR. `false` if the counterpart was created by the API client. */ + created_automatically?: boolean; + /** ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. */ + default_billing_address_id?: string; + /** ID of the shipping address. */ + default_shipping_address_id?: string; + /** Entity user ID of counterpart creator. */ + created_by_entity_user_id?: string; + individual: Monite.PurchaseOrderCounterpartIndividualResponse; + /** The language used to generate pdf documents for this counterpart. */ + language?: Monite.LanguageCodeEnum; + reminders_enabled?: boolean; + /** The counterpart's taxpayer identification number or tax ID. This field is required for counterparts that are non-VAT registered. */ + tax_id?: string; + /** The counterpart type: `organization` (juridical person) or `individual` (natural person). */ + type: Monite.CounterpartType; +} diff --git a/src/api/types/PurchaseOrderCounterpartOrganizationResponse.ts b/src/api/types/PurchaseOrderCounterpartOrganizationResponse.ts new file mode 100644 index 0000000..3fe8aff --- /dev/null +++ b/src/api/types/PurchaseOrderCounterpartOrganizationResponse.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Represents counterparts that are organizations (juridical persons). + */ +export interface PurchaseOrderCounterpartOrganizationResponse { + /** The email address of the organization */ + email?: string; + /** Indicates if the counterpart is a customer. */ + is_customer: boolean; + /** Indicates if the counterpart is a vendor. */ + is_vendor: boolean; + /** The legal name of the organization. */ + legal_name: string; + /** The phone number of the organization */ + phone?: string; +} diff --git a/src/api/types/PurchaseOrderCounterpartOrganizationRootResponse.ts b/src/api/types/PurchaseOrderCounterpartOrganizationRootResponse.ts new file mode 100644 index 0000000..8cfda19 --- /dev/null +++ b/src/api/types/PurchaseOrderCounterpartOrganizationRootResponse.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents counterparts that are organizations (juridical persons). + */ +export interface PurchaseOrderCounterpartOrganizationRootResponse { + /** Unique ID of the counterpart. */ + id: string; + /** Date and time when the counterpart was created. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + created_at: string; + /** Date and time when the counterpart was last updated. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + updated_at: string; + /** `true` if the counterpart was created automatically by Monite when processing incoming invoices with OCR. `false` if the counterpart was created by the API client. */ + created_automatically?: boolean; + /** ID of the counterpart's billing address. If the counterpart is US-based and needs to accept ACH payments, this address must have all fields filled in. If `default_billing_address_id` is not defined, the default address is instead used as the billing address for ACH payments. */ + default_billing_address_id?: string; + /** ID of the shipping address. */ + default_shipping_address_id?: string; + /** Entity user ID of counterpart creator. */ + created_by_entity_user_id?: string; + /** The language used to generate pdf documents for this counterpart. */ + language?: Monite.LanguageCodeEnum; + organization: Monite.PurchaseOrderCounterpartOrganizationResponse; + reminders_enabled?: boolean; + /** The counterpart's taxpayer identification number or tax ID. This field is required for counterparts that are non-VAT registered. */ + tax_id?: string; + /** The counterpart type: `organization` (juridical person) or `individual` (natural person). */ + type: Monite.CounterpartType; +} diff --git a/src/api/types/PurchaseOrderCounterpartSchema.ts b/src/api/types/PurchaseOrderCounterpartSchema.ts new file mode 100644 index 0000000..ac44007 --- /dev/null +++ b/src/api/types/PurchaseOrderCounterpartSchema.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A Counterpart object contains information about an organization (juridical person) or + * individual (natural person) that provides goods and services to or buys them from an + * [SME](https://docs.monite.com/docs/glossary#sme). + */ +export type PurchaseOrderCounterpartSchema = + | Monite.PurchaseOrderCounterpartIndividualRootResponse + | Monite.PurchaseOrderCounterpartOrganizationRootResponse; diff --git a/src/api/types/PurchaseOrderCursorFields.ts b/src/api/types/PurchaseOrderCursorFields.ts new file mode 100644 index 0000000..c4b7847 --- /dev/null +++ b/src/api/types/PurchaseOrderCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PurchaseOrderCursorFields = "created_at" | "updated_at"; + +export const PurchaseOrderCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/PurchaseOrderEmailPreviewResponse.ts b/src/api/types/PurchaseOrderEmailPreviewResponse.ts new file mode 100644 index 0000000..a8b8738 --- /dev/null +++ b/src/api/types/PurchaseOrderEmailPreviewResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A schema for returning a response for email preview + */ +export interface PurchaseOrderEmailPreviewResponse { + body_preview: string; + subject_preview: string; +} diff --git a/src/api/types/PurchaseOrderEmailSentResponse.ts b/src/api/types/PurchaseOrderEmailSentResponse.ts new file mode 100644 index 0000000..fe016f4 --- /dev/null +++ b/src/api/types/PurchaseOrderEmailSentResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A schema for returning a response an email with a link to purchase order document has been sent + */ +export interface PurchaseOrderEmailSentResponse { + mail_id: string; +} diff --git a/src/api/types/PurchaseOrderItem.ts b/src/api/types/PurchaseOrderItem.ts new file mode 100644 index 0000000..ac70f22 --- /dev/null +++ b/src/api/types/PurchaseOrderItem.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface PurchaseOrderItem { + /** The currency in which the price of the product is set. */ + currency: Monite.CurrencyEnum; + /** The name of the product to purchase */ + name: string; + /** The subtotal cost (excluding VAT), in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + price: number; + /** Number (quantity) of products */ + quantity: number; + /** Units (hours, meters, unit) */ + unit: string; + /** Percent minor units. Example: 12.5% is 1250 */ + vat_rate: number; +} diff --git a/src/api/types/PurchaseOrderPaginationResponse.ts b/src/api/types/PurchaseOrderPaginationResponse.ts new file mode 100644 index 0000000..3e0aa94 --- /dev/null +++ b/src/api/types/PurchaseOrderPaginationResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of purchase orders. + */ +export interface PurchaseOrderPaginationResponse { + data: Monite.PurchaseOrderResponseSchema[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/PurchaseOrderResponseSchema.ts b/src/api/types/PurchaseOrderResponseSchema.ts new file mode 100644 index 0000000..139811b --- /dev/null +++ b/src/api/types/PurchaseOrderResponseSchema.ts @@ -0,0 +1,47 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents response for an Accounts Purchase Order document created by entity. + */ +export interface PurchaseOrderResponseSchema { + /** A unique ID assigned to this purchase order. */ + id: string; + /** Time at which the receivable was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the receivable was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + /** Counterpart information about an organization (juridical person) or individual (natural person) that provides goods and services to or buys them from an */ + counterpart: Monite.PurchaseOrderCounterpartSchema; + /** Counterpart address data saved on creation or update of the purchase order. */ + counterpart_address?: Monite.PurchaseOrderCounterpartAddressSchema; + /** The ID of counterpart address object stored in counterparts service. If not provided, counterpart's default address is used. */ + counterpart_address_id?: string; + /** Counterpart unique ID. */ + counterpart_id: string; + /** ID of the creator of the purchase order */ + created_by_user_id?: string; + /** The currency in which the price of the product is set. (all items need to have the same currency) */ + currency: Monite.CurrencyEnum; + document_id: string; + /** Data of the entity (address, name, contact) */ + entity: Monite.PurchaseOrderResponseSchemaEntity; + /** The ID of the entity which issued the purchase order. */ + entity_id: string; + entity_vat_id?: Monite.PurchaseOrderVatId; + file_id?: string; + file_url?: string; + /** When status changed from 'draft' to 'send', so after sending purchase order */ + issued_at?: string; + /** List of item to purchase */ + items: Monite.PurchaseOrderItem[]; + /** Msg which will be send to counterpart for who the purchase order is issued. */ + message: string; + /** Purchase order can be in 'draft' state before sending it to counterpart. After that state is 'issued' */ + status: string; + /** Number of days for which purchase order is valid */ + valid_for_days: number; +} diff --git a/src/api/types/PurchaseOrderResponseSchemaEntity.ts b/src/api/types/PurchaseOrderResponseSchemaEntity.ts new file mode 100644 index 0000000..a5f8565 --- /dev/null +++ b/src/api/types/PurchaseOrderResponseSchemaEntity.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Data of the entity (address, name, contact) + */ +export type PurchaseOrderResponseSchemaEntity = + | Monite.PayableEntityIndividualResponse + | Monite.PayableEntityOrganizationResponse; diff --git a/src/api/types/PurchaseOrderStatusEnum.ts b/src/api/types/PurchaseOrderStatusEnum.ts new file mode 100644 index 0000000..e6bc053 --- /dev/null +++ b/src/api/types/PurchaseOrderStatusEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PurchaseOrderStatusEnum = "draft" | "issued"; + +export const PurchaseOrderStatusEnum = { + Draft: "draft", + Issued: "issued", +} as const; diff --git a/src/api/types/PurchaseOrderVatId.ts b/src/api/types/PurchaseOrderVatId.ts new file mode 100644 index 0000000..c2e0e82 --- /dev/null +++ b/src/api/types/PurchaseOrderVatId.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PurchaseOrderVatId { + id: string; + country: string; + entity_id: string; + type: string; + value: string; +} diff --git a/src/api/types/QuoteResponsePayload.ts b/src/api/types/QuoteResponsePayload.ts new file mode 100644 index 0000000..bf40548 --- /dev/null +++ b/src/api/types/QuoteResponsePayload.ts @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface QuoteResponsePayload { + id: string; + /** Time at which the receivable was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the receivable was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + /** The unique ID of a previous document related to the receivable if applicable. */ + based_on?: string; + /** The unique document ID of a previous document related to the receivable if applicable. */ + based_on_document_id?: string; + /** Field with a comment on why the client declined this Quote */ + comment?: string; + /** The commercial terms of the receivable (e.g. The products must be delivered in X days). */ + commercial_condition_description?: string; + /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ + counterpart_billing_address?: Monite.ReceivablesRepresentationOfCounterpartAddress; + /** Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. */ + counterpart_business_type?: string; + /** Additional information about counterpart contacts. */ + counterpart_contact?: Monite.ReceivableCounterpartContact; + /** Unique ID of the counterpart. */ + counterpart_id: string; + /** A legal name of a counterpart it is an organization or first and last name if it is an individual */ + counterpart_name?: string; + /** Address where goods were shipped / where services were provided. */ + counterpart_shipping_address?: Monite.ReceivablesRepresentationOfCounterpartAddress; + /** The VAT/TAX ID of the counterpart. */ + counterpart_tax_id?: string; + /** The type of the counterpart. */ + counterpart_type: Monite.ReceivableCounterpartType; + counterpart_vat_id?: Monite.ReceivableCounterpartVatIdResponse; + /** The currency used in the receivable. */ + currency: Monite.CurrencyEnum; + /** The amount of tax deducted in minor units */ + deduction_amount?: number; + /** A note with additional information about a tax deduction */ + deduction_memo?: string; + /** The discount for a receivable. */ + discount?: Monite.Discount; + /** Total price of the receivable with discounts before taxes [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + discounted_subtotal?: number; + /** The sequential code systematically assigned to invoices. */ + document_id?: string; + /** Optional field representing date until which invoice should be paid */ + due_date?: string; + entity: Monite.QuoteResponsePayloadEntity; + entity_address: Monite.ReceivableEntityAddressSchema; + entity_bank_account?: Monite.ReceivablesRepresentationOfEntityBankAccount; + /** The entity user who created this document. */ + entity_user_id?: string; + entity_vat_id?: Monite.ReceivableEntityVatIdResponse; + /** The date (in ISO 8601 format) until which the quote is valid. */ + expiry_date?: string; + file?: Monite.ReceivableFileSchema; + /** The language of the customer-facing PDF file (`file_url`). The value matches the counterpart's `language` at the time when this PDF file was generated. */ + file_language: Monite.LanguageCodeEnum; + /** The receivable's PDF URL in the counterpart's default language. */ + file_url?: string; + /** Optional field for the issue of the entry. */ + issue_date?: string; + line_items: Monite.ResponseItem[]; + /** A note with additional information for a receivable. */ + memo?: string; + /** The language of the entity's copy of the PDF file (`original_file_url`). The value matches the entity's `language` at the time when this PDF file was generated. */ + original_file_language: Monite.LanguageCodeEnum; + /** The receivable's PDF URL in the entity's default language. */ + original_file_url?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** A project related to current receivable */ + project_id?: string; + /** Link for custom quote accept page */ + quote_accept_page_url?: string; + /** Whether acceptance a quote requires a signature. */ + signature_required?: boolean; + /** The status of the Quote inside the receivable workflow. */ + status: Monite.QuoteStateEnum; + /** The subtotal (excluding VAT), in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + subtotal?: number; + /** The list of tags for this receivable. */ + tags?: Monite.TagReadSchema[]; + /** Total price of the receivable in [minor units](https://docs.monite.com/docs/currencies#minor-units). Calculated as a subtotal + total_vat_amount. */ + total_amount?: number; + /** The total VAT of all line items, in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + total_vat_amount: number; + /** List of total vat amount for each VAT, presented in receivable */ + total_vat_amounts?: Monite.TotalVatAmountItem[]; + /** Total price of the receivable with tax withheld in minor units */ + total_withholding_tax?: number; + /** Trade name of the entity */ + trade_name?: string; + /** Indicates whether the goods, materials, or services listed in the receivable are exempt from VAT or not. */ + vat_exempt?: boolean; + /** The reason for the VAT exemption, if applicable. */ + vat_exemption_rationale?: string; + /** Defines whether the prices of products in receivable will already include VAT or not. */ + vat_mode?: Monite.VatModeEnum; + /** The amount of tax withheld in percent minor units */ + withholding_tax_rate?: number; +} diff --git a/src/api/types/QuoteResponsePayloadEntity.ts b/src/api/types/QuoteResponsePayloadEntity.ts new file mode 100644 index 0000000..373341d --- /dev/null +++ b/src/api/types/QuoteResponsePayloadEntity.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type QuoteResponsePayloadEntity = + | Monite.QuoteResponsePayloadEntity.Organization + | Monite.QuoteResponsePayloadEntity.Individual; + +export declare namespace QuoteResponsePayloadEntity { + interface Organization extends Monite.ReceivableEntityOrganization { + type: "organization"; + } + + interface Individual extends Monite.ReceivableEntityIndividual { + type: "individual"; + } +} diff --git a/src/api/types/QuoteStateEnum.ts b/src/api/types/QuoteStateEnum.ts new file mode 100644 index 0000000..68cf645 --- /dev/null +++ b/src/api/types/QuoteStateEnum.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type QuoteStateEnum = "draft" | "issued" | "accepted" | "expired" | "declined" | "deleted"; + +export const QuoteStateEnum = { + Draft: "draft", + Issued: "issued", + Accepted: "accepted", + Expired: "expired", + Declined: "declined", + Deleted: "deleted", +} as const; diff --git a/src/api/types/ReceivableCounterpartContact.ts b/src/api/types/ReceivableCounterpartContact.ts new file mode 100644 index 0000000..6c6b941 --- /dev/null +++ b/src/api/types/ReceivableCounterpartContact.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableCounterpartContact { + /** The contact address of the counterpart */ + address: Monite.ReceivablesRepresentationOfCounterpartAddress; + /** The contact email of the counterpart. */ + email?: string; + /** The first name of the counterpart contact. */ + first_name: string; + /** The last name of the counterpart contact. */ + last_name: string; + /** The contact phone number of the counterpart. */ + phone?: string; + /** The counterpart contact title (e.g. Dr., Mr., Mrs., Ms., etc). */ + title?: string; +} diff --git a/src/api/types/ReceivableCounterpartType.ts b/src/api/types/ReceivableCounterpartType.ts new file mode 100644 index 0000000..50d8ec4 --- /dev/null +++ b/src/api/types/ReceivableCounterpartType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableCounterpartType = "individual" | "organization"; + +export const ReceivableCounterpartType = { + Individual: "individual", + Organization: "organization", +} as const; diff --git a/src/api/types/ReceivableCounterpartVatIdResponse.ts b/src/api/types/ReceivableCounterpartVatIdResponse.ts new file mode 100644 index 0000000..cbc7960 --- /dev/null +++ b/src/api/types/ReceivableCounterpartVatIdResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableCounterpartVatIdResponse { + id: string; + counterpart_id: string; + country?: Monite.AllowedCountries; + type?: Monite.VatIdTypeEnum; + value: string; +} diff --git a/src/api/types/ReceivableCreateBasedOnPayload.ts b/src/api/types/ReceivableCreateBasedOnPayload.ts new file mode 100644 index 0000000..651ea82 --- /dev/null +++ b/src/api/types/ReceivableCreateBasedOnPayload.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableCreateBasedOnPayload { + /** The unique ID of a previous document related to the receivable if applicable. */ + based_on: string; + /** A list of IDs of user-defined tags (labels) assigned to this receivable. */ + tag_ids?: string[]; + /** The type of a created receivable. Currently supported transitions:quote -> invoice; invoice -> credit_note */ + type: Monite.BasedOnTransitionType; +} diff --git a/src/api/types/ReceivableCursorFields.ts b/src/api/types/ReceivableCursorFields.ts new file mode 100644 index 0000000..79bd656 --- /dev/null +++ b/src/api/types/ReceivableCursorFields.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableCursorFields = + | "counterpart_name" + | "counterpart_id" + | "amount" + | "status" + | "due_date" + | "issue_date" + | "document_id" + | "created_at" + | "project_id"; + +export const ReceivableCursorFields = { + CounterpartName: "counterpart_name", + CounterpartId: "counterpart_id", + Amount: "amount", + Status: "status", + DueDate: "due_date", + IssueDate: "issue_date", + DocumentId: "document_id", + CreatedAt: "created_at", + ProjectId: "project_id", +} as const; diff --git a/src/api/types/ReceivableEditFlow.ts b/src/api/types/ReceivableEditFlow.ts new file mode 100644 index 0000000..92ada43 --- /dev/null +++ b/src/api/types/ReceivableEditFlow.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableEditFlow = "compliant" | "partially_compliant" | "non_compliant"; + +export const ReceivableEditFlow = { + Compliant: "compliant", + PartiallyCompliant: "partially_compliant", + NonCompliant: "non_compliant", +} as const; diff --git a/src/api/types/ReceivableEntityAddressSchema.ts b/src/api/types/ReceivableEntityAddressSchema.ts new file mode 100644 index 0000000..605555a --- /dev/null +++ b/src/api/types/ReceivableEntityAddressSchema.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema represents address info of the entity + */ +export interface ReceivableEntityAddressSchema { + /** A city (a full name) where the entity is registered */ + city: string; + /** A country name (as ISO code) where the entity is registered */ + country?: Monite.AllowedCountries; + /** A street where the entity is registered */ + line1: string; + /** An alternative street used by the entity */ + line2?: string; + /** A postal code of the address where the entity is registered */ + postal_code: string; + /** A state in a country where the entity is registered */ + state?: string; +} diff --git a/src/api/types/ReceivableEntityBase.ts b/src/api/types/ReceivableEntityBase.ts new file mode 100644 index 0000000..bd41b23 --- /dev/null +++ b/src/api/types/ReceivableEntityBase.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A base schemas for an entity + */ +export interface ReceivableEntityBase { + /** An email of the entity */ + email?: string; + /** A link to the entity logo */ + logo?: string; + /** A phone number of the entity */ + phone?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/ReceivableEntityIndividual.ts b/src/api/types/ReceivableEntityIndividual.ts new file mode 100644 index 0000000..3118d75 --- /dev/null +++ b/src/api/types/ReceivableEntityIndividual.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A Response schema for an entity of individual type + */ +export interface ReceivableEntityIndividual { + /** An email of the entity */ + email?: string; + /** The first name of the entity issuing the receivable */ + first_name: string; + /** The last name of the entity issuing the receivable */ + last_name: string; + /** A link to the entity logo */ + logo?: string; + /** A phone number of the entity */ + phone?: string; + /** The Tax ID of the entity issuing the receivable */ + tax_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/ReceivableEntityIndividualRequest.ts b/src/api/types/ReceivableEntityIndividualRequest.ts new file mode 100644 index 0000000..e1c35f7 --- /dev/null +++ b/src/api/types/ReceivableEntityIndividualRequest.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A Request schema for an entity of individual type + */ +export interface ReceivableEntityIndividualRequest { + /** An email of the entity */ + email?: string; + /** The first name of the entity issuing the receivable */ + first_name: string; + /** The last name of the entity issuing the receivable */ + last_name: string; + /** A link to the entity logo */ + logo?: string; + /** A phone number of the entity */ + phone?: string; + /** The Tax ID of the entity issuing the receivable */ + tax_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/ReceivableEntityOrganization.ts b/src/api/types/ReceivableEntityOrganization.ts new file mode 100644 index 0000000..c905612 --- /dev/null +++ b/src/api/types/ReceivableEntityOrganization.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A Response schema for an entity of organization type + */ +export interface ReceivableEntityOrganization { + /** An email of the entity */ + email?: string; + /** A link to the entity logo */ + logo?: string; + /** The name of the entity issuing the receivable, when it is an organization. */ + name: string; + /** A phone number of the entity */ + phone?: string; + /** The Tax ID of the entity issuing the receivable */ + tax_id?: string; + /** The VAT ID of the entity issuing the receivable, when it is an organization. */ + vat_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/ReceivableEntityOrganizationRequest.ts b/src/api/types/ReceivableEntityOrganizationRequest.ts new file mode 100644 index 0000000..685f340 --- /dev/null +++ b/src/api/types/ReceivableEntityOrganizationRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A Request schema for an entity of organization type + */ +export interface ReceivableEntityOrganizationRequest { + /** An email of the entity */ + email?: string; + /** A link to the entity logo */ + logo?: string; + /** The name of the entity issuing the receivable, when it is an organization. */ + name: string; + /** A phone number of the entity */ + phone?: string; + /** The Tax ID of the entity issuing the receivable */ + tax_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/ReceivableEntityVatIdResponse.ts b/src/api/types/ReceivableEntityVatIdResponse.ts new file mode 100644 index 0000000..207b4cc --- /dev/null +++ b/src/api/types/ReceivableEntityVatIdResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableEntityVatIdResponse { + id: string; + country: Monite.AllowedCountries; + entity_id: string; + type?: Monite.VatIdTypeEnum; + value: string; +} diff --git a/src/api/types/ReceivableFacadeCreateInvoicePayload.ts b/src/api/types/ReceivableFacadeCreateInvoicePayload.ts new file mode 100644 index 0000000..6e941e6 --- /dev/null +++ b/src/api/types/ReceivableFacadeCreateInvoicePayload.ts @@ -0,0 +1,65 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableFacadeCreateInvoicePayload { + commercial_condition_description?: string; + /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ + counterpart_billing_address_id: string; + /** Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. */ + counterpart_business_type?: string; + counterpart_id: string; + /** Address where goods were shipped / where services were provided. */ + counterpart_shipping_address_id?: string; + /** Counterpart VAT ID id */ + counterpart_vat_id_id?: string; + currency: Monite.CurrencyEnum; + /** The amount of tax deducted in minor units */ + deduction_amount?: number; + /** A note with additional information about a tax deduction */ + deduction_memo?: string; + /** The discount for a receivable. */ + discount?: Monite.Discount; + entity?: Monite.ReceivableEntityBase; + /** Entity bank account ID */ + entity_bank_account_id?: string; + /** Entity VAT ID id */ + entity_vat_id_id?: string; + /** + * The date when the goods are shipped or the service is provided. + * + * If omitted, defaults to the invoice issue date, + * and the value is automatically set when the invoice status changes to `issued`. + */ + fulfillment_date?: string; + line_items: Monite.LineItem[]; + /** A note with additional information for a receivable */ + memo?: string; + overdue_reminder_id?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** Link to the invoice's payment page. Either Monite's payment links or your custom payment links. */ + payment_page_url?: string; + payment_reminder_id?: string; + payment_terms_id?: string; + /** A project related to current receivable */ + project_id?: string; + /** Contain purchase order number. */ + purchase_order?: string; + /** A list of IDs of user-defined tags (labels) assigned to this receivable. */ + tag_ids?: string[]; + /** Trade name of the entity */ + trade_name?: string; + /** The type of the document uploaded. */ + type: "invoice"; + /** Indicates whether the goods, materials, or services listed in the receivable are exempt from VAT or not. */ + vat_exempt?: boolean; + /** The reason for the VAT exemption, if applicable. */ + vat_exemption_rationale?: string; + /** Defines whether the prices of products in receivable will already include VAT or not. */ + vat_mode?: Monite.VatModeEnum; + /** The amount of tax withheld in percent minor units */ + withholding_tax_rate?: number; +} diff --git a/src/api/types/ReceivableFacadeCreatePayload.ts b/src/api/types/ReceivableFacadeCreatePayload.ts new file mode 100644 index 0000000..149c191 --- /dev/null +++ b/src/api/types/ReceivableFacadeCreatePayload.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type ReceivableFacadeCreatePayload = + | Monite.ReceivableFacadeCreateQuotePayload + | Monite.ReceivableFacadeCreateInvoicePayload + | Monite.ReceivableCreateBasedOnPayload; diff --git a/src/api/types/ReceivableFacadeCreateQuotePayload.ts b/src/api/types/ReceivableFacadeCreateQuotePayload.ts new file mode 100644 index 0000000..2e734be --- /dev/null +++ b/src/api/types/ReceivableFacadeCreateQuotePayload.ts @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableFacadeCreateQuotePayload { + commercial_condition_description?: string; + /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ + counterpart_billing_address_id: string; + /** Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. */ + counterpart_business_type?: string; + counterpart_id: string; + /** Address where goods were shipped / where services were provided. */ + counterpart_shipping_address_id?: string; + /** Counterpart VAT ID id */ + counterpart_vat_id_id?: string; + currency: Monite.CurrencyEnum; + /** The amount of tax deducted in minor units */ + deduction_amount?: number; + /** A note with additional information about a tax deduction */ + deduction_memo?: string; + /** The discount for a receivable. */ + discount?: Monite.Discount; + entity?: Monite.ReceivableEntityBase; + /** Entity bank account ID */ + entity_bank_account_id?: string; + /** Entity VAT ID id */ + entity_vat_id_id?: string; + /** The date (in ISO 8601 format) until which the quote is valid. */ + expiry_date?: string; + line_items: Monite.LineItem[]; + /** A note with additional information for a receivable */ + memo?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** A project related to current receivable */ + project_id?: string; + /** Link for custom quote accept page */ + quote_accept_page_url?: string; + /** Whether acceptance a quote requires a signature. */ + signature_required?: boolean; + /** A list of IDs of user-defined tags (labels) assigned to this receivable. */ + tag_ids?: string[]; + /** Trade name of the entity */ + trade_name?: string; + /** The type of the document uploaded. */ + type: "quote"; + /** Indicates whether the goods, materials, or services listed in the receivable are exempt from VAT or not. */ + vat_exempt?: boolean; + /** The reason for the VAT exemption, if applicable. */ + vat_exemption_rationale?: string; + /** Defines whether the prices of products in receivable will already include VAT or not. */ + vat_mode?: Monite.VatModeEnum; + /** The amount of tax withheld in percent minor units */ + withholding_tax_rate?: number; +} diff --git a/src/api/types/ReceivableFileSchema.ts b/src/api/types/ReceivableFileSchema.ts new file mode 100644 index 0000000..e5cf0c4 --- /dev/null +++ b/src/api/types/ReceivableFileSchema.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a file (such as a PDF invoice) that was uploaded to Monite. + */ +export interface ReceivableFileSchema { + /** A unique ID of this file. */ + id: string; + /** UTC date and time when this workflow was uploaded to Monite. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ + created_at: string; + /** The type of the business object associated with this file. */ + file_type: string; + /** The MD5 hash of the file. */ + md5: string; + /** The file's [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types). */ + mimetype: string; + /** The original file name (if available). */ + name: string; + /** If the file is a PDF document, this property contains individual pages extracted from the file. Otherwise, an empty array. */ + pages?: Monite.ReceivablePageSchema[]; + /** Preview images generated for this file. There can be multiple images with different sizes. */ + previews?: Monite.ReceivablePreviewSchema[]; + /** Geographical region of the data center where the file is stored. */ + region: string; + /** The file size in bytes. */ + size: number; + /** The URL to download the file. */ + url: string; +} diff --git a/src/api/types/ReceivableFileUrl.ts b/src/api/types/ReceivableFileUrl.ts new file mode 100644 index 0000000..eb81b1d --- /dev/null +++ b/src/api/types/ReceivableFileUrl.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ReceivableFileUrl { + /** The receivable's PDF URL in the counterpart's default language. */ + file_url?: string; + /** The receivable's PDF URL in the entity's default language. */ + original_file_url?: string; +} diff --git a/src/api/types/ReceivableHistoryCursorFields.ts b/src/api/types/ReceivableHistoryCursorFields.ts new file mode 100644 index 0000000..44eaf2f --- /dev/null +++ b/src/api/types/ReceivableHistoryCursorFields.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableHistoryCursorFields = "timestamp"; diff --git a/src/api/types/ReceivableHistoryEventTypeEnum.ts b/src/api/types/ReceivableHistoryEventTypeEnum.ts new file mode 100644 index 0000000..fd2bc1e --- /dev/null +++ b/src/api/types/ReceivableHistoryEventTypeEnum.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableHistoryEventTypeEnum = + | "status_changed" + | "receivable_updated" + | "based_on_receivable_created" + | "payment_received" + | "mail_sent"; + +export const ReceivableHistoryEventTypeEnum = { + StatusChanged: "status_changed", + ReceivableUpdated: "receivable_updated", + BasedOnReceivableCreated: "based_on_receivable_created", + PaymentReceived: "payment_received", + MailSent: "mail_sent", +} as const; diff --git a/src/api/types/ReceivableHistoryPaginationResponse.ts b/src/api/types/ReceivableHistoryPaginationResponse.ts new file mode 100644 index 0000000..6c2513f --- /dev/null +++ b/src/api/types/ReceivableHistoryPaginationResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableHistoryPaginationResponse { + data: Monite.ReceivableHistoryResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/ReceivableHistoryResponse.ts b/src/api/types/ReceivableHistoryResponse.ts new file mode 100644 index 0000000..08b3a0d --- /dev/null +++ b/src/api/types/ReceivableHistoryResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableHistoryResponse { + /** ID of the history record. */ + id: string; + /** Link, that will lead to the PDF that shows the state of the document after this change. If this change doesn’t change PDF - this field will be empty. */ + current_pdf_url?: string; + entity_user_id?: string; + /** Payload of the event. */ + event_data: Monite.ReceivableHistoryResponseEventData; + /** The type of event. */ + event_type: Monite.ReceivableHistoryEventTypeEnum; + /** ID of receivable that was changed. */ + receivable_id: string; + /** Timestamp when the event has happened. */ + timestamp: string; +} diff --git a/src/api/types/ReceivableHistoryResponseEventData.ts b/src/api/types/ReceivableHistoryResponseEventData.ts new file mode 100644 index 0000000..5f36098 --- /dev/null +++ b/src/api/types/ReceivableHistoryResponseEventData.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Payload of the event. + */ +export type ReceivableHistoryResponseEventData = + | Monite.StatusChangedEventData + | Monite.ReceivableUpdatedEventData + | Monite.BasedOnReceivableCreatedEventData + | Monite.PaymentReceivedEventData + | Monite.MailSentEventData; diff --git a/src/api/types/ReceivableMailCursorFields.ts b/src/api/types/ReceivableMailCursorFields.ts new file mode 100644 index 0000000..40e5a34 --- /dev/null +++ b/src/api/types/ReceivableMailCursorFields.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableMailCursorFields = "status" | "created_at" | "updated_at"; + +export const ReceivableMailCursorFields = { + Status: "status", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/ReceivableMailPaginationResponse.ts b/src/api/types/ReceivableMailPaginationResponse.ts new file mode 100644 index 0000000..6306576 --- /dev/null +++ b/src/api/types/ReceivableMailPaginationResponse.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableMailPaginationResponse { + data: Monite.ReceivableMailResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/ReceivableMailRecipientState.ts b/src/api/types/ReceivableMailRecipientState.ts new file mode 100644 index 0000000..02cebd4 --- /dev/null +++ b/src/api/types/ReceivableMailRecipientState.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ReceivableMailRecipientState { + /** An email address of the recipient. */ + email: string; + /** An error message in case the mailing was unsuccessful. */ + error?: string; + /** Whether mail was sent successfully. */ + is_success: boolean; +} diff --git a/src/api/types/ReceivableMailRecipients.ts b/src/api/types/ReceivableMailRecipients.ts new file mode 100644 index 0000000..96d1f0b --- /dev/null +++ b/src/api/types/ReceivableMailRecipients.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableMailRecipients { + bcc?: Monite.ReceivableMailRecipientState[]; + cc?: Monite.ReceivableMailRecipientState[]; + to?: Monite.ReceivableMailRecipientState[]; +} diff --git a/src/api/types/ReceivableMailResponse.ts b/src/api/types/ReceivableMailResponse.ts new file mode 100644 index 0000000..971f2ad --- /dev/null +++ b/src/api/types/ReceivableMailResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableMailResponse { + id: string; + /** The time the mail task was created */ + created_at: string; + /** The time the mail task was updated */ + updated_at: string; + recipients?: Monite.ReceivableMailRecipients; + /** The status of the mail sent by receivable */ + status: Monite.ReceivableMailStatusEnum; +} diff --git a/src/api/types/ReceivableMailStatusEnum.ts b/src/api/types/ReceivableMailStatusEnum.ts new file mode 100644 index 0000000..ffb7f08 --- /dev/null +++ b/src/api/types/ReceivableMailStatusEnum.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableMailStatusEnum = "pending" | "processing" | "sent" | "partially_sent" | "failed"; + +export const ReceivableMailStatusEnum = { + Pending: "pending", + Processing: "processing", + Sent: "sent", + PartiallySent: "partially_sent", + Failed: "failed", +} as const; diff --git a/src/api/types/ReceivablePageSchema.ts b/src/api/types/ReceivablePageSchema.ts new file mode 100644 index 0000000..efa3f6c --- /dev/null +++ b/src/api/types/ReceivablePageSchema.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * When a PDF document is uploaded to Monite, it extracts individual pages from the document + * and saves them as PNG images. This object contains the image and metadata of a single page. + */ +export interface ReceivablePageSchema { + /** A unique ID of the image. */ + id: string; + /** The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the image. */ + mimetype: string; + /** The page number in the PDF document, from 0. */ + number: number; + /** Image file size, in bytes. */ + size: number; + /** The URL to download the image. */ + url: string; +} diff --git a/src/api/types/ReceivablePaginationResponse.ts b/src/api/types/ReceivablePaginationResponse.ts new file mode 100644 index 0000000..1bba829 --- /dev/null +++ b/src/api/types/ReceivablePaginationResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of receivables + */ +export interface ReceivablePaginationResponse { + data: Monite.ReceivableResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/ReceivablePreviewResponse.ts b/src/api/types/ReceivablePreviewResponse.ts new file mode 100644 index 0000000..23f92d4 --- /dev/null +++ b/src/api/types/ReceivablePreviewResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A schema for receiving a request for previewing an email with a receivable document + */ +export interface ReceivablePreviewResponse { + body_preview: string; + subject_preview: string; +} diff --git a/src/api/types/ReceivablePreviewSchema.ts b/src/api/types/ReceivablePreviewSchema.ts new file mode 100644 index 0000000..5d2e7d6 --- /dev/null +++ b/src/api/types/ReceivablePreviewSchema.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A preview image generated for a file. + */ +export interface ReceivablePreviewSchema { + /** The image height in pixels. */ + height: number; + /** The image URL. */ + url: string; + /** The image width in pixels. */ + width: number; +} diff --git a/src/api/types/ReceivableResponse.ts b/src/api/types/ReceivableResponse.ts new file mode 100644 index 0000000..c6c710c --- /dev/null +++ b/src/api/types/ReceivableResponse.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type ReceivableResponse = + | Monite.ReceivableResponse.Quote + | Monite.ReceivableResponse.Invoice + | Monite.ReceivableResponse.CreditNote; + +export declare namespace ReceivableResponse { + interface Quote extends Monite.QuoteResponsePayload { + type: "quote"; + } + + interface Invoice extends Monite.InvoiceResponsePayload { + type: "invoice"; + } + + interface CreditNote extends Monite.CreditNoteResponsePayload { + type: "credit_note"; + } +} diff --git a/src/api/types/ReceivableSendResponse.ts b/src/api/types/ReceivableSendResponse.ts new file mode 100644 index 0000000..2ec6596 --- /dev/null +++ b/src/api/types/ReceivableSendResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A schema for returning a response an email with a link to receivable document has been sent + */ +export interface ReceivableSendResponse { + mail_id: string; +} diff --git a/src/api/types/ReceivableSettingsPayload.ts b/src/api/types/ReceivableSettingsPayload.ts new file mode 100644 index 0000000..1f3046c --- /dev/null +++ b/src/api/types/ReceivableSettingsPayload.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ReceivableSettingsPayload { + create_without_personal_info: boolean; + deduction_title?: string; +} diff --git a/src/api/types/ReceivableSettingsResponse.ts b/src/api/types/ReceivableSettingsResponse.ts new file mode 100644 index 0000000..4ce0a9f --- /dev/null +++ b/src/api/types/ReceivableSettingsResponse.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ReceivableSettingsResponse { + create_without_personal_info: boolean; + deduction_title?: string; +} diff --git a/src/api/types/ReceivableTemplatesVariable.ts b/src/api/types/ReceivableTemplatesVariable.ts new file mode 100644 index 0000000..f912a9a --- /dev/null +++ b/src/api/types/ReceivableTemplatesVariable.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ReceivableTemplatesVariable { + description: string; + name: string; +} diff --git a/src/api/types/ReceivableTemplatesVariablesObject.ts b/src/api/types/ReceivableTemplatesVariablesObject.ts new file mode 100644 index 0000000..9d7a5d3 --- /dev/null +++ b/src/api/types/ReceivableTemplatesVariablesObject.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableTemplatesVariablesObject { + object_subtype: Monite.VariablesType; + object_type: string; + variables: Monite.ReceivableTemplatesVariable[]; +} diff --git a/src/api/types/ReceivableTemplatesVariablesObjectList.ts b/src/api/types/ReceivableTemplatesVariablesObjectList.ts new file mode 100644 index 0000000..420c6b4 --- /dev/null +++ b/src/api/types/ReceivableTemplatesVariablesObjectList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivableTemplatesVariablesObjectList { + data: Monite.ReceivableTemplatesVariablesObject[]; +} diff --git a/src/api/types/ReceivableType.ts b/src/api/types/ReceivableType.ts new file mode 100644 index 0000000..e5ae4d9 --- /dev/null +++ b/src/api/types/ReceivableType.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableType = "quote" | "invoice" | "credit_note"; + +export const ReceivableType = { + Quote: "quote", + Invoice: "invoice", + CreditNote: "credit_note", +} as const; diff --git a/src/api/types/ReceivableUpdatePayload.ts b/src/api/types/ReceivableUpdatePayload.ts new file mode 100644 index 0000000..4e6e53c --- /dev/null +++ b/src/api/types/ReceivableUpdatePayload.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type ReceivableUpdatePayload = + | Monite.UpdateQuotePayload + | Monite.UpdateInvoicePayload + | Monite.UpdateCreditNotePayload + | Monite.UpdateIssuedInvoicePayload; diff --git a/src/api/types/ReceivableUpdatedEventData.ts b/src/api/types/ReceivableUpdatedEventData.ts new file mode 100644 index 0000000..3f79440 --- /dev/null +++ b/src/api/types/ReceivableUpdatedEventData.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ReceivableUpdatedEventData {} diff --git a/src/api/types/ReceivablesPreviewTypeEnum.ts b/src/api/types/ReceivablesPreviewTypeEnum.ts new file mode 100644 index 0000000..07d4a47 --- /dev/null +++ b/src/api/types/ReceivablesPreviewTypeEnum.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivablesPreviewTypeEnum = "receivable" | "discount_reminder" | "final_reminder"; + +export const ReceivablesPreviewTypeEnum = { + Receivable: "receivable", + DiscountReminder: "discount_reminder", + FinalReminder: "final_reminder", +} as const; diff --git a/src/api/types/ReceivablesRemindersWarningMessage.ts b/src/api/types/ReceivablesRemindersWarningMessage.ts new file mode 100644 index 0000000..9132099 --- /dev/null +++ b/src/api/types/ReceivablesRemindersWarningMessage.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ReceivablesRemindersWarningMessage { + /** Warning message for payment reminder */ + payment_reminders?: string; +} diff --git a/src/api/types/ReceivablesRepresentationOfCounterpartAddress.ts b/src/api/types/ReceivablesRepresentationOfCounterpartAddress.ts new file mode 100644 index 0000000..bcbd5f4 --- /dev/null +++ b/src/api/types/ReceivablesRepresentationOfCounterpartAddress.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ReceivablesRepresentationOfCounterpartAddress { + /** Unique ID of the address in the system */ + id?: string; + /** City name. */ + city: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country: Monite.AllowedCountries; + /** Street address. */ + line1: string; + /** Additional address information (if any). */ + line2?: string; + /** ZIP or postal code. */ + postal_code: string; + /** State, region, province, or county. */ + state?: string; +} diff --git a/src/api/types/ReceivablesRepresentationOfEntityBankAccount.ts b/src/api/types/ReceivablesRepresentationOfEntityBankAccount.ts new file mode 100644 index 0000000..446f895 --- /dev/null +++ b/src/api/types/ReceivablesRepresentationOfEntityBankAccount.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ReceivablesRepresentationOfEntityBankAccount { + /** Unique ID of the entity bank account. */ + id?: string; + /** Account holder's name */ + account_holder_name?: string; + /** Account number (required if IBAN is not provided) */ + account_number?: string; + /** The name of the entity's bank account. */ + bank_name?: string; + /** The BIC of the entity's bank account. */ + bic?: string; + /** The IBAN of the entity's bank account. */ + iban?: string; + /** Routing number (US) */ + routing_number?: string; + /** Sort code (GB) */ + sort_code?: string; +} diff --git a/src/api/types/ReceivablesSendResponse.ts b/src/api/types/ReceivablesSendResponse.ts new file mode 100644 index 0000000..5e86ce5 --- /dev/null +++ b/src/api/types/ReceivablesSendResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A schema for returning a response with list of ids by which user check sending status + */ +export interface ReceivablesSendResponse { + mail_ids: string[]; +} diff --git a/src/api/types/ReceivablesStatusEnum.ts b/src/api/types/ReceivablesStatusEnum.ts new file mode 100644 index 0000000..914afa3 --- /dev/null +++ b/src/api/types/ReceivablesStatusEnum.ts @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * This Enum the results of combining two types of statuses from + * QuoteStateEnum, CreditNoteStateEnum and InvoiceStateEnum. You shouldn't use + * it in your scenarios if only for edge cases in workers, but ideally need to + * remove this shared Enum. + */ +export type ReceivablesStatusEnum = + | "draft" + | "issued" + | "accepted" + | "expired" + | "declined" + | "recurring" + | "partially_paid" + | "paid" + | "overdue" + | "uncollectible" + | "canceled" + | "deleted"; + +export const ReceivablesStatusEnum = { + Draft: "draft", + Issued: "issued", + Accepted: "accepted", + Expired: "expired", + Declined: "declined", + Recurring: "recurring", + PartiallyPaid: "partially_paid", + Paid: "paid", + Overdue: "overdue", + Uncollectible: "uncollectible", + Canceled: "canceled", + Deleted: "deleted", +} as const; diff --git a/src/api/types/ReceivablesVerifyResponse.ts b/src/api/types/ReceivablesVerifyResponse.ts new file mode 100644 index 0000000..f4de88d --- /dev/null +++ b/src/api/types/ReceivablesVerifyResponse.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema for returning a response with validation results + */ +export interface ReceivablesVerifyResponse { + /** Missing fields of receivable */ + errors?: Monite.MissingFields; + /** Warning message for payment reminder */ + warnings?: Monite.ReceivablesRemindersWarningMessage; +} diff --git a/src/api/types/Recipient.ts b/src/api/types/Recipient.ts new file mode 100644 index 0000000..7439b70 --- /dev/null +++ b/src/api/types/Recipient.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface Recipient { + id: string; + type: Monite.RecipientType; +} diff --git a/src/api/types/RecipientAccountResponse.ts b/src/api/types/RecipientAccountResponse.ts new file mode 100644 index 0000000..a2af9a9 --- /dev/null +++ b/src/api/types/RecipientAccountResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface RecipientAccountResponse { + id: string; + bank_accounts?: Monite.BankAccount[]; + name?: string; + type: Monite.PaymentAccountType; +} diff --git a/src/api/types/RecipientType.ts b/src/api/types/RecipientType.ts new file mode 100644 index 0000000..d916f6c --- /dev/null +++ b/src/api/types/RecipientType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type RecipientType = "entity" | "counterpart"; + +export const RecipientType = { + Entity: "entity", + Counterpart: "counterpart", +} as const; diff --git a/src/api/types/Recipients.ts b/src/api/types/Recipients.ts new file mode 100644 index 0000000..f0e6225 --- /dev/null +++ b/src/api/types/Recipients.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface Recipients { + bcc?: string[]; + cc?: string[]; + to?: string[]; +} diff --git a/src/api/types/Recurrence.ts b/src/api/types/Recurrence.ts new file mode 100644 index 0000000..4900f62 --- /dev/null +++ b/src/api/types/Recurrence.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface Recurrence { + id: string; + /** Time at which the receivable was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the receivable was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + current_iteration: number; + day_of_month: Monite.DayOfMonth; + end_month: number; + end_year: number; + invoice_id: string; + iterations: Monite.RecurrenceIteration[]; + start_month: number; + start_year: number; + status: Monite.RecurrenceStatus; +} diff --git a/src/api/types/RecurrenceIteration.ts b/src/api/types/RecurrenceIteration.ts new file mode 100644 index 0000000..f5f7eb9 --- /dev/null +++ b/src/api/types/RecurrenceIteration.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface RecurrenceIteration { + issue_at: string; + issued_invoice_id?: string; + iteration?: number; + status: Monite.IterationStatus; +} diff --git a/src/api/types/RecurrenceStatus.ts b/src/api/types/RecurrenceStatus.ts new file mode 100644 index 0000000..bed512d --- /dev/null +++ b/src/api/types/RecurrenceStatus.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type RecurrenceStatus = "active" | "canceled" | "completed"; + +export const RecurrenceStatus = { + Active: "active", + Canceled: "canceled", + Completed: "completed", +} as const; diff --git a/src/api/types/RelatedDocuments.ts b/src/api/types/RelatedDocuments.ts new file mode 100644 index 0000000..ef41169 --- /dev/null +++ b/src/api/types/RelatedDocuments.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface RelatedDocuments { + credit_note_ids?: string[]; + proforma_invoice_id?: string; +} diff --git a/src/api/types/Reminder.ts b/src/api/types/Reminder.ts new file mode 100644 index 0000000..2c7ba47 --- /dev/null +++ b/src/api/types/Reminder.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface Reminder { + body: string; + days_before: number; + subject: string; +} diff --git a/src/api/types/ReminderTypeEnum.ts b/src/api/types/ReminderTypeEnum.ts new file mode 100644 index 0000000..a997428 --- /dev/null +++ b/src/api/types/ReminderTypeEnum.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReminderTypeEnum = "term_1" | "term_2" | "term_final" | "overdue"; + +export const ReminderTypeEnum = { + Term1: "term_1", + Term2: "term_2", + TermFinal: "term_final", + Overdue: "overdue", +} as const; diff --git a/src/api/types/RemindersSettings.ts b/src/api/types/RemindersSettings.ts new file mode 100644 index 0000000..642cd90 --- /dev/null +++ b/src/api/types/RemindersSettings.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface RemindersSettings { + enabled?: boolean; +} diff --git a/src/api/types/RequirementsError.ts b/src/api/types/RequirementsError.ts new file mode 100644 index 0000000..e05afb3 --- /dev/null +++ b/src/api/types/RequirementsError.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface RequirementsError { + code: string; + reason: string; + requirement: string; +} diff --git a/src/api/types/ResponseItem.ts b/src/api/types/ResponseItem.ts new file mode 100644 index 0000000..f5b751e --- /dev/null +++ b/src/api/types/ResponseItem.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ResponseItem { + /** The discount for a product. */ + discount?: Monite.Discount; + product: Monite.LineItemProduct; + /** The quantity of each of the goods, materials, or services listed in the receivable. */ + quantity: number; + /** Total of line_item before VAT in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + total_before_vat?: number; +} diff --git a/src/api/types/RoleCursorFields.ts b/src/api/types/RoleCursorFields.ts new file mode 100644 index 0000000..16bd1fe --- /dev/null +++ b/src/api/types/RoleCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type RoleCursorFields = "updated_at" | "created_at"; + +export const RoleCursorFields = { + UpdatedAt: "updated_at", + CreatedAt: "created_at", +} as const; diff --git a/src/api/types/RolePaginationResponse.ts b/src/api/types/RolePaginationResponse.ts new file mode 100644 index 0000000..f73ecb7 --- /dev/null +++ b/src/api/types/RolePaginationResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface RolePaginationResponse { + /** array of records */ + data: Monite.RoleResponse[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/RoleResponse.ts b/src/api/types/RoleResponse.ts new file mode 100644 index 0000000..af67521 --- /dev/null +++ b/src/api/types/RoleResponse.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface RoleResponse { + /** UUID role ID */ + id: string; + /** UTC datetime */ + created_at: string; + /** UTC datetime */ + updated_at: string; + /** Role name */ + name: string; + /** Access permissions */ + permissions: Monite.BizObjectsSchema; + /** record status, 'active' by default */ + status: Monite.StatusEnum; +} diff --git a/src/api/types/RootSchema.ts b/src/api/types/RootSchema.ts new file mode 100644 index 0000000..09b9234 --- /dev/null +++ b/src/api/types/RootSchema.ts @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type RootSchema = + | Monite.RootSchema.Person + | Monite.RootSchema.Onboarding + | Monite.RootSchema.Comment + | Monite.RootSchema.Counterpart + | Monite.RootSchema.EntityUser + | Monite.RootSchema.Entity + | Monite.RootSchema.EntityVatIds + | Monite.RootSchema.CounterpartVatId + | Monite.RootSchema.EntityBankAccount + | Monite.RootSchema.Export + | Monite.RootSchema.PayablesPurchaseOrder + | Monite.RootSchema.PaymentReminder + | Monite.RootSchema.OverdueReminder + | Monite.RootSchema.Product + | Monite.RootSchema.Project + | Monite.RootSchema.Receivable + | Monite.RootSchema.Reconciliation + | Monite.RootSchema.Role + | Monite.RootSchema.Tag + | Monite.RootSchema.TodoTask + | Monite.RootSchema.TodoTaskMute + | Monite.RootSchema.Transaction + | Monite.RootSchema.Workflow + | Monite.RootSchema.ApprovalRequest + | Monite.RootSchema.ApprovalPolicy + | Monite.RootSchema.PaymentRecord + | Monite.RootSchema.Payable; + +export declare namespace RootSchema { + interface Person extends Monite.CommonSchema { + object_type: "person"; + } + + interface Onboarding extends Monite.CommonSchema { + object_type: "onboarding"; + } + + interface Comment extends Monite.CommonSchema { + object_type: "comment"; + } + + interface Counterpart extends Monite.CommonSchema { + object_type: "counterpart"; + } + + interface EntityUser extends Monite.CommonSchema { + object_type: "entity_user"; + } + + interface Entity extends Monite.CommonSchema { + object_type: "entity"; + } + + interface EntityVatIds extends Monite.CommonSchema { + object_type: "entity_vat_ids"; + } + + interface CounterpartVatId extends Monite.CommonSchema { + object_type: "counterpart_vat_id"; + } + + interface EntityBankAccount extends Monite.CommonSchema { + object_type: "entity_bank_account"; + } + + interface Export extends Monite.CommonSchema { + object_type: "export"; + } + + interface PayablesPurchaseOrder extends Monite.CommonSchema { + object_type: "payables_purchase_order"; + } + + interface PaymentReminder extends Monite.CommonSchema { + object_type: "payment_reminder"; + } + + interface OverdueReminder extends Monite.CommonSchema { + object_type: "overdue_reminder"; + } + + interface Product extends Monite.CommonSchema { + object_type: "product"; + } + + interface Project extends Monite.CommonSchema { + object_type: "project"; + } + + interface Receivable extends Monite.CommonSchema { + object_type: "receivable"; + } + + interface Reconciliation extends Monite.CommonSchema { + object_type: "reconciliation"; + } + + interface Role extends Monite.CommonSchema { + object_type: "role"; + } + + interface Tag extends Monite.CommonSchema { + object_type: "tag"; + } + + interface TodoTask extends Monite.CommonSchema { + object_type: "todo_task"; + } + + interface TodoTaskMute extends Monite.CommonSchema { + object_type: "todo_task_mute"; + } + + interface Transaction extends Monite.CommonSchema { + object_type: "transaction"; + } + + interface Workflow extends Monite.CommonSchema { + object_type: "workflow"; + } + + interface ApprovalRequest extends Monite.CommonSchema { + object_type: "approval_request"; + } + + interface ApprovalPolicy extends Monite.CommonSchema { + object_type: "approval_policy"; + } + + interface PaymentRecord extends Monite.CommonSchema { + object_type: "payment_record"; + } + + interface Payable extends Monite.PayableSchema { + object_type: "payable"; + } +} diff --git a/src/api/types/ServiceProvidersEnum.ts b/src/api/types/ServiceProvidersEnum.ts new file mode 100644 index 0000000..43fa014 --- /dev/null +++ b/src/api/types/ServiceProvidersEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ServiceProvidersEnum = "codat" | "railz"; + +export const ServiceProvidersEnum = { + Codat: "codat", + Railz: "railz", +} as const; diff --git a/src/api/types/Signature.ts b/src/api/types/Signature.ts new file mode 100644 index 0000000..d0b4370 --- /dev/null +++ b/src/api/types/Signature.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface Signature { + /** The email of a person who signed a quote */ + email: string; + /** The full name of a person who signed a quote */ + full_name: string; + /** Base64 encoded PNG image of a signature */ + signature_image: string; +} diff --git a/src/api/types/SingleOnboardingRequirementsResponse.ts b/src/api/types/SingleOnboardingRequirementsResponse.ts new file mode 100644 index 0000000..7b46e4e --- /dev/null +++ b/src/api/types/SingleOnboardingRequirementsResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface SingleOnboardingRequirementsResponse { + disabled_reason?: string; + payment_method: string; + requirements: Monite.PaymentMethodRequirements; + requirements_errors: Monite.OnboardingRequirementsError[]; + verification_errors: Monite.OnboardingVerificationError[]; + verification_status: Monite.OnboardingVerificationStatusEnum; +} diff --git a/src/api/types/SinglePaymentIntent.ts b/src/api/types/SinglePaymentIntent.ts new file mode 100644 index 0000000..8a8a0ff --- /dev/null +++ b/src/api/types/SinglePaymentIntent.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface SinglePaymentIntent { + object: Monite.PaymentObjectPayable; + /** Must be provided if payable's document id is missing. */ + payment_reference?: string; + recipient: Monite.PaymentIntentsRecipient; +} diff --git a/src/api/types/SinglePaymentIntentResponse.ts b/src/api/types/SinglePaymentIntentResponse.ts new file mode 100644 index 0000000..28975a3 --- /dev/null +++ b/src/api/types/SinglePaymentIntentResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface SinglePaymentIntentResponse { + id: string; + created_at: string; + amount: number; + currency: Monite.CurrencyEnum; + error?: Record; + object: Monite.PaymentObjectPayable; + payment_reference: string; + recipient: Monite.PaymentIntentsRecipient; + status: string; +} diff --git a/src/api/types/SourceOfPayableDataEnum.ts b/src/api/types/SourceOfPayableDataEnum.ts new file mode 100644 index 0000000..69be636 --- /dev/null +++ b/src/api/types/SourceOfPayableDataEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SourceOfPayableDataEnum = "ocr" | "user_specified"; + +export const SourceOfPayableDataEnum = { + Ocr: "ocr", + UserSpecified: "user_specified", +} as const; diff --git a/src/api/types/StatusChangedEventData.ts b/src/api/types/StatusChangedEventData.ts new file mode 100644 index 0000000..6b22958 --- /dev/null +++ b/src/api/types/StatusChangedEventData.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface StatusChangedEventData { + new_status: Monite.ReceivablesStatusEnum; + old_status: Monite.ReceivablesStatusEnum; +} diff --git a/src/api/types/StatusEnum.ts b/src/api/types/StatusEnum.ts new file mode 100644 index 0000000..673f71c --- /dev/null +++ b/src/api/types/StatusEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type StatusEnum = "active" | "deleted"; + +export const StatusEnum = { + Active: "active", + Deleted: "deleted", +} as const; diff --git a/src/api/types/SuccessResult.ts b/src/api/types/SuccessResult.ts new file mode 100644 index 0000000..07496e8 --- /dev/null +++ b/src/api/types/SuccessResult.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SuccessResult { + success?: boolean; +} diff --git a/src/api/types/SuggestedPaymentTerm.ts b/src/api/types/SuggestedPaymentTerm.ts new file mode 100644 index 0000000..6ea34ef --- /dev/null +++ b/src/api/types/SuggestedPaymentTerm.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Suggested payment date and corresponding discount + */ +export interface SuggestedPaymentTerm { + date: string; + discount?: number; +} diff --git a/src/api/types/SupportedFieldNames.ts b/src/api/types/SupportedFieldNames.ts new file mode 100644 index 0000000..66624a1 --- /dev/null +++ b/src/api/types/SupportedFieldNames.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SupportedFieldNames = "default_account_code" | "default_tax_rate_code"; + +export const SupportedFieldNames = { + DefaultAccountCode: "default_account_code", + DefaultTaxRateCode: "default_tax_rate_code", +} as const; diff --git a/src/api/types/SupportedFormatSchema.ts b/src/api/types/SupportedFormatSchema.ts new file mode 100644 index 0000000..f52172f --- /dev/null +++ b/src/api/types/SupportedFormatSchema.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface SupportedFormatSchema { + available_types: Record; + object_type: Monite.SupportedFormatSchemaObjectType; +} diff --git a/src/api/types/SupportedFormatSchemaObjectType.ts b/src/api/types/SupportedFormatSchemaObjectType.ts new file mode 100644 index 0000000..53a6382 --- /dev/null +++ b/src/api/types/SupportedFormatSchemaObjectType.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SupportedFormatSchemaObjectType = "payable" | "receivable"; + +export const SupportedFormatSchemaObjectType = { + Payable: "payable", + Receivable: "receivable", +} as const; diff --git a/src/api/types/SyncRecordCursorFields.ts b/src/api/types/SyncRecordCursorFields.ts new file mode 100644 index 0000000..95a9f49 --- /dev/null +++ b/src/api/types/SyncRecordCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SyncRecordCursorFields = "created_at" | "updated_at"; + +export const SyncRecordCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/SyncRecordResource.ts b/src/api/types/SyncRecordResource.ts new file mode 100644 index 0000000..119baf2 --- /dev/null +++ b/src/api/types/SyncRecordResource.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface SyncRecordResource { + id: string; + created_at: string; + updated_at: string; + errors?: Record; + last_pulled_at: string; + object_id?: string; + object_type: Monite.ObjectMatchTypes; + object_updated_at?: string; + platform?: Monite.Platform; + platform_object_id?: string; + platform_updated_at?: string; + provider?: Monite.ServiceProvidersEnum; + provider_object_id?: string; + provider_updated_at?: string; + sync_status: Monite.SyncStatus; +} diff --git a/src/api/types/SyncRecordResourceList.ts b/src/api/types/SyncRecordResourceList.ts new file mode 100644 index 0000000..2323d54 --- /dev/null +++ b/src/api/types/SyncRecordResourceList.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface SyncRecordResourceList { + data: Monite.SyncRecordResource[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/SyncStatus.ts b/src/api/types/SyncStatus.ts new file mode 100644 index 0000000..839a07a --- /dev/null +++ b/src/api/types/SyncStatus.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SyncStatus = "pending" | "error" | "done"; + +export const SyncStatus = { + Pending: "pending", + Error: "error", + Done: "done", +} as const; diff --git a/src/api/types/SystemTemplateDataSchema.ts b/src/api/types/SystemTemplateDataSchema.ts new file mode 100644 index 0000000..e9e71be --- /dev/null +++ b/src/api/types/SystemTemplateDataSchema.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface SystemTemplateDataSchema { + /** Array of templates */ + available_templates: Monite.TemplateDataSchema[]; + /** Name of the template */ + template_name: string; +} diff --git a/src/api/types/SystemTemplates.ts b/src/api/types/SystemTemplates.ts new file mode 100644 index 0000000..68d1e54 --- /dev/null +++ b/src/api/types/SystemTemplates.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface SystemTemplates { + /** All pre-defined email templates */ + data: Monite.SystemTemplateDataSchema[]; +} diff --git a/src/api/types/TagCategory.ts b/src/api/types/TagCategory.ts new file mode 100644 index 0000000..c25ca8f --- /dev/null +++ b/src/api/types/TagCategory.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type TagCategory = + | "document_type" + | "department" + | "project" + | "cost_center" + | "vendor_type" + | "payment_method" + | "approval_status"; + +export const TagCategory = { + DocumentType: "document_type", + Department: "department", + Project: "project", + CostCenter: "cost_center", + VendorType: "vendor_type", + PaymentMethod: "payment_method", + ApprovalStatus: "approval_status", +} as const; diff --git a/src/api/types/TagCursorFields.ts b/src/api/types/TagCursorFields.ts new file mode 100644 index 0000000..7d044d9 --- /dev/null +++ b/src/api/types/TagCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type TagCursorFields = "created_at" | "updated_at"; + +export const TagCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/TagReadSchema.ts b/src/api/types/TagReadSchema.ts new file mode 100644 index 0000000..d312fe2 --- /dev/null +++ b/src/api/types/TagReadSchema.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Represents a user-defined tag that can be assigned to resources to filter them. + */ +export interface TagReadSchema { + /** A unique ID of this tag. */ + id: string; + /** Date and time when the tag was created. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + created_at: string; + /** Date and time when the tag was last updated. Timestamps follow the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ + updated_at: string; + /** The tag category. */ + category?: Monite.TagCategory; + /** ID of the user who created the tag. */ + created_by_entity_user_id?: string; + /** The tag description. */ + description?: string; + /** The tag name. */ + name: string; +} diff --git a/src/api/types/TagsPaginationResponse.ts b/src/api/types/TagsPaginationResponse.ts new file mode 100644 index 0000000..5c69adb --- /dev/null +++ b/src/api/types/TagsPaginationResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A paginated list of tags. + */ +export interface TagsPaginationResponse { + data: Monite.TagReadSchema[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/TaxComponentResponse.ts b/src/api/types/TaxComponentResponse.ts new file mode 100644 index 0000000..58e770e --- /dev/null +++ b/src/api/types/TaxComponentResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface TaxComponentResponse { + /** A flag to indicate with the tax is calculated using the principle of compounding. */ + is_compound?: boolean; + name?: string; + /** Component tax rate in percent [minor units](https://docs.monite.com/docs/currencies#minor-units). Example: 12.5% is 1250. */ + rate?: number; +} diff --git a/src/api/types/TaxRateAccountCursorFields.ts b/src/api/types/TaxRateAccountCursorFields.ts new file mode 100644 index 0000000..9273fc6 --- /dev/null +++ b/src/api/types/TaxRateAccountCursorFields.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type TaxRateAccountCursorFields = "name"; diff --git a/src/api/types/TemplateDataSchema.ts b/src/api/types/TemplateDataSchema.ts new file mode 100644 index 0000000..11e33b5 --- /dev/null +++ b/src/api/types/TemplateDataSchema.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface TemplateDataSchema { + /** Jinja2 compatible email body template */ + body_template: string; + /** Lowercase ISO code of language */ + language: string; + /** Jinja2 compatible email subject template */ + subject_template: string; +} diff --git a/src/api/types/TemplateListResponse.ts b/src/api/types/TemplateListResponse.ts new file mode 100644 index 0000000..26793ba --- /dev/null +++ b/src/api/types/TemplateListResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface TemplateListResponse { + data?: Monite.TemplateReceivableResponse[]; +} diff --git a/src/api/types/TemplateReceivableResponse.ts b/src/api/types/TemplateReceivableResponse.ts new file mode 100644 index 0000000..c017333 --- /dev/null +++ b/src/api/types/TemplateReceivableResponse.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface TemplateReceivableResponse { + id: string; + created_at?: string; + updated_at?: string; + blocks?: string[]; + document_type: Monite.DocumentTypeEnum; + is_default: boolean; + language: string; + name: string; + preview?: Monite.FileSchema; + template: string; + template_type?: Monite.TemplateTypeEnum; +} diff --git a/src/api/types/TemplateTypeEnum.ts b/src/api/types/TemplateTypeEnum.ts new file mode 100644 index 0000000..858dde1 --- /dev/null +++ b/src/api/types/TemplateTypeEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type TemplateTypeEnum = "block" | "source_object"; + +export const TemplateTypeEnum = { + Block: "block", + SourceObject: "source_object", +} as const; diff --git a/src/api/types/TermFinalWithDate.ts b/src/api/types/TermFinalWithDate.ts new file mode 100644 index 0000000..1cf6acc --- /dev/null +++ b/src/api/types/TermFinalWithDate.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface TermFinalWithDate { + end_date?: string; + /** The amount of days after the invoice issue date. */ + number_of_days: number; +} diff --git a/src/api/types/TermsOfServiceAcceptance.ts b/src/api/types/TermsOfServiceAcceptance.ts new file mode 100644 index 0000000..05eec6b --- /dev/null +++ b/src/api/types/TermsOfServiceAcceptance.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface TermsOfServiceAcceptance { + /** The date and time (in the ISO 8601 format) when the entity representative accepted the service agreement. */ + date?: string; + /** The IP address from which the entity representative accepted the service agreement. If omitted or set to `null` in the request, the IP address is inferred from the request origin or the `X-Forwarded-For` request header. */ + ip?: string; +} diff --git a/src/api/types/TextTemplateResponse.ts b/src/api/types/TextTemplateResponse.ts new file mode 100644 index 0000000..fd1be0c --- /dev/null +++ b/src/api/types/TextTemplateResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface TextTemplateResponse { + id: string; + created_at: string; + updated_at: string; + document_type: Monite.DocumentTypeEnum; + is_default: boolean; + name: string; + template: string; + type: Monite.TextTemplateType; +} diff --git a/src/api/types/TextTemplateResponseList.ts b/src/api/types/TextTemplateResponseList.ts new file mode 100644 index 0000000..0670eeb --- /dev/null +++ b/src/api/types/TextTemplateResponseList.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface TextTemplateResponseList { + data: Monite.TextTemplateResponse[]; + next_pagination_token?: string; + prev_pagination_token?: string; +} diff --git a/src/api/types/TextTemplateType.ts b/src/api/types/TextTemplateType.ts new file mode 100644 index 0000000..0a1ba66 --- /dev/null +++ b/src/api/types/TextTemplateType.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type TextTemplateType = "email_header" | "email_body" | "memo"; + +export const TextTemplateType = { + EmailHeader: "email_header", + EmailBody: "email_body", + Memo: "memo", +} as const; diff --git a/src/api/types/TotalVatAmountItem.ts b/src/api/types/TotalVatAmountItem.ts new file mode 100644 index 0000000..afcccdf --- /dev/null +++ b/src/api/types/TotalVatAmountItem.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface TotalVatAmountItem { + id?: string; + /** The total VAT of all line items, in [minor units](https://docs.monite.com/docs/currencies#minor-units). */ + amount: number; + /** Percent minor units. Example: 12.5% is 1250. */ + value: number; +} diff --git a/src/api/types/Unit.ts b/src/api/types/Unit.ts new file mode 100644 index 0000000..aa9e92c --- /dev/null +++ b/src/api/types/Unit.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface Unit { + designation: string; + name: string; +} diff --git a/src/api/types/UnitListResponse.ts b/src/api/types/UnitListResponse.ts new file mode 100644 index 0000000..c5be817 --- /dev/null +++ b/src/api/types/UnitListResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface UnitListResponse { + data: Monite.UnitResponse[]; +} diff --git a/src/api/types/UnitRequest.ts b/src/api/types/UnitRequest.ts new file mode 100644 index 0000000..5ba99b4 --- /dev/null +++ b/src/api/types/UnitRequest.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface UnitRequest { + description?: string; + name: string; +} diff --git a/src/api/types/UnitResponse.ts b/src/api/types/UnitResponse.ts new file mode 100644 index 0000000..f63b003 --- /dev/null +++ b/src/api/types/UnitResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface UnitResponse { + id: string; + created_at: string; + updated_at: string; + description?: string; + name: string; +} diff --git a/src/api/types/UpdateCreditNote.ts b/src/api/types/UpdateCreditNote.ts new file mode 100644 index 0000000..a4a3087 --- /dev/null +++ b/src/api/types/UpdateCreditNote.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface UpdateCreditNote { + /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ + counterpart_billing_address_id?: string; + /** Additional information about counterpart contacts. */ + counterpart_contact?: Monite.ReceivableCounterpartContact; + /** Address where goods were shipped / where services were provided. */ + counterpart_shipping_address_id?: string; + entity?: Monite.ReceivableEntityBase; + line_items?: Monite.UpdateLineItemForCreditNote; + /** A note with additional information for a receivable */ + memo?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** A project related to current receivable */ + project_id?: string; + /** A list of IDs of user-defined tags (labels) assigned to this receivable. */ + tag_ids?: string[]; +} diff --git a/src/api/types/UpdateCreditNotePayload.ts b/src/api/types/UpdateCreditNotePayload.ts new file mode 100644 index 0000000..a5c2666 --- /dev/null +++ b/src/api/types/UpdateCreditNotePayload.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface UpdateCreditNotePayload { + credit_note: Monite.UpdateCreditNote; +} diff --git a/src/api/types/UpdateEntityAddressSchema.ts b/src/api/types/UpdateEntityAddressSchema.ts new file mode 100644 index 0000000..724368b --- /dev/null +++ b/src/api/types/UpdateEntityAddressSchema.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface UpdateEntityAddressSchema { + /** A city (a full name) where the entity is registered */ + city?: string; + /** A street where the entity is registered */ + line1?: string; + /** An alternative street used by the entity */ + line2?: string; + /** A postal code of the address where the entity is registered */ + postal_code?: string; + /** A state in a country where the entity is registered */ + state?: string; +} diff --git a/src/api/types/UpdateEntityRequest.ts b/src/api/types/UpdateEntityRequest.ts new file mode 100644 index 0000000..b956408 --- /dev/null +++ b/src/api/types/UpdateEntityRequest.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * A schema for a request to update an entity + */ +export interface UpdateEntityRequest { + /** An address description of the entity */ + address?: Monite.UpdateEntityAddressSchema; + /** An official email address of the entity */ + email?: string; + /** A set of meta data describing the individual */ + individual?: Monite.OptionalIndividualSchema; + /** A set of meta data describing the organization */ + organization?: Monite.OptionalOrganizationSchema; + /** A phone number of the entity */ + phone?: string; + /** The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered. */ + tax_id?: string; + /** A website of the entity */ + website?: string; +} diff --git a/src/api/types/UpdateInvoice.ts b/src/api/types/UpdateInvoice.ts new file mode 100644 index 0000000..b2b8148 --- /dev/null +++ b/src/api/types/UpdateInvoice.ts @@ -0,0 +1,63 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Raise if None was explicitly passed to given fields + */ +export interface UpdateInvoice { + /** Unique ID of the counterpart contact. */ + contact_id?: string; + /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ + counterpart_billing_address_id?: string; + /** Unique ID of the counterpart. */ + counterpart_id?: string; + /** Address where goods were shipped / where services were provided. */ + counterpart_shipping_address_id?: string; + /** Counterpart VAT ID id */ + counterpart_vat_id_id?: string; + currency?: Monite.CurrencyEnum; + /** The amount of tax deducted in minor units */ + deduction_amount?: number; + /** A note with additional information about a tax deduction */ + deduction_memo?: string; + /** The discount for a receivable. */ + discount?: Monite.Discount; + entity?: Monite.ReceivableEntityBase; + /** Entity bank account ID */ + entity_bank_account_id?: string; + /** Entity VAT ID id */ + entity_vat_id_id?: string; + /** + * The date when the goods are shipped or the service is provided. + * + * If omitted, defaults to the invoice issue date, + * and the value is automatically set when the invoice status changes to `issued`. + */ + fulfillment_date?: string; + line_items?: Monite.LineItemUpdate[]; + /** A note with additional information for a receivable */ + memo?: string; + overdue_reminder_id?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** Link to your invoice's custom payment rails or external payment link. */ + payment_page_url?: string; + payment_reminder_id?: string; + /** Unique ID of the payment terms. */ + payment_terms_id?: string; + /** A project related to current receivable */ + project_id?: string; + /** A list of IDs of user-defined tags (labels) assigned to this receivable. */ + tag_ids?: string[]; + /** Trade name of the entity */ + trade_name?: string; + /** Indicates whether the goods, materials, or services listed in the receivable are exempt from VAT or not. */ + vat_exempt?: boolean; + /** The reason for the VAT exemption, if applicable. */ + vat_exemption_rationale?: string; + /** The amount of tax withheld in percent minor units */ + withholding_tax_rate?: number; +} diff --git a/src/api/types/UpdateInvoicePayload.ts b/src/api/types/UpdateInvoicePayload.ts new file mode 100644 index 0000000..8e0431a --- /dev/null +++ b/src/api/types/UpdateInvoicePayload.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface UpdateInvoicePayload { + invoice: Monite.UpdateInvoice; +} diff --git a/src/api/types/UpdateIssuedInvoice.ts b/src/api/types/UpdateIssuedInvoice.ts new file mode 100644 index 0000000..35e58c4 --- /dev/null +++ b/src/api/types/UpdateIssuedInvoice.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Raise if None was explicitly passed to given fields + */ +export interface UpdateIssuedInvoice { + /** Unique ID of the counterpart contact. */ + contact_id?: string; + /** Id of a new or updated counterpart */ + counterpart_id?: string; + /** Counterpart VAT ID id */ + counterpart_vat_id_id?: string; + entity?: Monite.UpdateIssuedInvoiceEntity; + entity_address?: Monite.ReceivableEntityAddressSchema; + /** Entity VAT ID id */ + entity_vat_id_id?: string; + /** + * The date when the goods are shipped or the service is provided. + * + * If omitted, defaults to the invoice issue date, + * and the value is automatically set when the invoice status changes to `issued`. + */ + fulfillment_date?: string; + /** A note with additional information for a receivable */ + memo?: string; + overdue_reminder_id?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + payment_reminder_id?: string; + payment_terms_id?: string; + /** A project related to current receivable */ + project_id?: string; + /** A list of IDs of user-defined tags (labels) assigned to this receivable. */ + tag_ids?: string[]; +} diff --git a/src/api/types/UpdateIssuedInvoiceEntity.ts b/src/api/types/UpdateIssuedInvoiceEntity.ts new file mode 100644 index 0000000..c62f004 --- /dev/null +++ b/src/api/types/UpdateIssuedInvoiceEntity.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export type UpdateIssuedInvoiceEntity = + | Monite.UpdateIssuedInvoiceEntity.Organization + | Monite.UpdateIssuedInvoiceEntity.Individual; + +export declare namespace UpdateIssuedInvoiceEntity { + interface Organization extends Monite.ReceivableEntityOrganizationRequest { + type: "organization"; + } + + interface Individual extends Monite.ReceivableEntityIndividualRequest { + type: "individual"; + } +} diff --git a/src/api/types/UpdateIssuedInvoicePayload.ts b/src/api/types/UpdateIssuedInvoicePayload.ts new file mode 100644 index 0000000..74d4533 --- /dev/null +++ b/src/api/types/UpdateIssuedInvoicePayload.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface UpdateIssuedInvoicePayload { + issued_invoice: Monite.UpdateIssuedInvoice; +} diff --git a/src/api/types/UpdateLineItemForCreditNote.ts b/src/api/types/UpdateLineItemForCreditNote.ts new file mode 100644 index 0000000..242ace7 --- /dev/null +++ b/src/api/types/UpdateLineItemForCreditNote.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Line item with given product id can be changed only once + */ +export type UpdateLineItemForCreditNote = Record; diff --git a/src/api/types/UpdateProductForCreditNote.ts b/src/api/types/UpdateProductForCreditNote.ts new file mode 100644 index 0000000..25841b8 --- /dev/null +++ b/src/api/types/UpdateProductForCreditNote.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface UpdateProductForCreditNote { + /** The old price of the line item. Used to choose for which line item new price should be applied */ + old_price?: number; + /** The price diff of the line item, i.e. applied discount */ + price_diff?: number; + /** The quantity of each of the goods, materials, or services listed in the receivable. */ + quantity: number; +} diff --git a/src/api/types/UpdateQuote.ts b/src/api/types/UpdateQuote.ts new file mode 100644 index 0000000..9e2ddd2 --- /dev/null +++ b/src/api/types/UpdateQuote.ts @@ -0,0 +1,58 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +/** + * Raise if None was explicitly passed to given fields + */ +export interface UpdateQuote { + /** Unique ID of the counterpart contact. */ + contact_id?: string; + /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ + counterpart_billing_address_id?: string; + /** Unique ID of the counterpart. */ + counterpart_id?: string; + /** Address where goods were shipped / where services were provided. */ + counterpart_shipping_address_id?: string; + /** Counterpart VAT ID id */ + counterpart_vat_id_id?: string; + currency?: Monite.CurrencyEnum; + /** The amount of tax deducted in minor units */ + deduction_amount?: number; + /** A note with additional information about a tax deduction */ + deduction_memo?: string; + /** The discount for a receivable. */ + discount?: Monite.Discount; + entity?: Monite.ReceivableEntityBase; + /** Entity bank account ID */ + entity_bank_account_id?: string; + /** Entity VAT ID id */ + entity_vat_id_id?: string; + /** The date (in ISO 8601 format) until which the quote is valid. */ + expiry_date?: string; + line_items?: Monite.LineItemUpdate[]; + /** A note with additional information for a receivable */ + memo?: string; + /** Metadata for partner needs */ + partner_metadata?: Record; + /** Unique ID of the payment terms. */ + payment_terms_id?: string; + /** A project related to current receivable */ + project_id?: string; + /** Link for custom quote accept page */ + quote_accept_page_url?: string; + /** Whether acceptance a quote requires a signature. */ + signature_required?: boolean; + /** A list of IDs of user-defined tags (labels) assigned to this receivable. */ + tag_ids?: string[]; + /** Trade name of the entity */ + trade_name?: string; + /** Indicates whether the goods, materials, or services listed in the receivable are exempt from VAT or not. */ + vat_exempt?: boolean; + /** The reason for the VAT exemption, if applicable. */ + vat_exemption_rationale?: string; + /** The amount of tax withheld in percent minor units */ + withholding_tax_rate?: number; +} diff --git a/src/api/types/UpdateQuotePayload.ts b/src/api/types/UpdateQuotePayload.ts new file mode 100644 index 0000000..ebf5ccd --- /dev/null +++ b/src/api/types/UpdateQuotePayload.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface UpdateQuotePayload { + quote: Monite.UpdateQuote; +} diff --git a/src/api/types/ValidationError.ts b/src/api/types/ValidationError.ts new file mode 100644 index 0000000..9e72e4d --- /dev/null +++ b/src/api/types/ValidationError.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface ValidationError { + loc: Monite.ValidationErrorLocItem[]; + msg: string; + type: string; +} diff --git a/src/api/types/ValidationErrorLocItem.ts b/src/api/types/ValidationErrorLocItem.ts new file mode 100644 index 0000000..c97f7db --- /dev/null +++ b/src/api/types/ValidationErrorLocItem.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ValidationErrorLocItem = string | number; diff --git a/src/api/types/Variable.ts b/src/api/types/Variable.ts new file mode 100644 index 0000000..b5d7bfc --- /dev/null +++ b/src/api/types/Variable.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface Variable { + description: string; + name: string; +} diff --git a/src/api/types/VariablesObject.ts b/src/api/types/VariablesObject.ts new file mode 100644 index 0000000..16f2205 --- /dev/null +++ b/src/api/types/VariablesObject.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface VariablesObject { + object_subtype: Monite.DocumentTypeEnum; + object_type: string; + variables: Monite.Variable[]; +} diff --git a/src/api/types/VariablesObjectList.ts b/src/api/types/VariablesObjectList.ts new file mode 100644 index 0000000..bac4133 --- /dev/null +++ b/src/api/types/VariablesObjectList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface VariablesObjectList { + data: Monite.VariablesObject[]; +} diff --git a/src/api/types/VariablesType.ts b/src/api/types/VariablesType.ts new file mode 100644 index 0000000..2644e8d --- /dev/null +++ b/src/api/types/VariablesType.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type VariablesType = + | "quote" + | "invoice" + | "credit_note" + | "discount_reminder" + | "final_reminder" + | "overdue_reminder"; + +export const VariablesType = { + Quote: "quote", + Invoice: "invoice", + CreditNote: "credit_note", + DiscountReminder: "discount_reminder", + FinalReminder: "final_reminder", + OverdueReminder: "overdue_reminder", +} as const; diff --git a/src/api/types/VatIdTypeEnum.ts b/src/api/types/VatIdTypeEnum.ts new file mode 100644 index 0000000..034aceb --- /dev/null +++ b/src/api/types/VatIdTypeEnum.ts @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type VatIdTypeEnum = + | "ae_trn" + | "au_abn" + | "au_arn" + | "bg_uic" + | "br_cnpj" + | "br_cpf" + | "ca_bn" + | "ca_gst_hst" + | "ca_pst_bc" + | "ca_pst_mb" + | "ca_pst_sk" + | "ca_qst" + | "ch_vat" + | "cl_tin" + | "es_cif" + | "eu_oss_vat" + | "eu_vat" + | "gb_vat" + | "ge_vat" + | "hk_br" + | "hu_tin" + | "id_npwp" + | "il_vat" + | "in_gst" + | "is_vat" + | "jp_cn" + | "jp_rn" + | "kr_brn" + | "li_uid" + | "mx_rfc" + | "my_frp" + | "my_itn" + | "my_sst" + | "no_vat" + | "nz_gst" + | "ru_inn" + | "ru_kpp" + | "sa_vat" + | "sg_gst" + | "sg_uen" + | "si_tin" + | "th_vat" + | "tw_vat" + | "ua_vat" + | "us_ein" + | "za_vat" + | "unknown"; + +export const VatIdTypeEnum = { + AeTrn: "ae_trn", + AuAbn: "au_abn", + AuArn: "au_arn", + BgUic: "bg_uic", + BrCnpj: "br_cnpj", + BrCpf: "br_cpf", + CaBn: "ca_bn", + CaGstHst: "ca_gst_hst", + CaPstBc: "ca_pst_bc", + CaPstMb: "ca_pst_mb", + CaPstSk: "ca_pst_sk", + CaQst: "ca_qst", + ChVat: "ch_vat", + ClTin: "cl_tin", + EsCif: "es_cif", + EuOssVat: "eu_oss_vat", + EuVat: "eu_vat", + GbVat: "gb_vat", + GeVat: "ge_vat", + HkBr: "hk_br", + HuTin: "hu_tin", + IdNpwp: "id_npwp", + IlVat: "il_vat", + InGst: "in_gst", + IsVat: "is_vat", + JpCn: "jp_cn", + JpRn: "jp_rn", + KrBrn: "kr_brn", + LiUid: "li_uid", + MxRfc: "mx_rfc", + MyFrp: "my_frp", + MyItn: "my_itn", + MySst: "my_sst", + NoVat: "no_vat", + NzGst: "nz_gst", + RuInn: "ru_inn", + RuKpp: "ru_kpp", + SaVat: "sa_vat", + SgGst: "sg_gst", + SgUen: "sg_uen", + SiTin: "si_tin", + ThVat: "th_vat", + TwVat: "tw_vat", + UaVat: "ua_vat", + UsEin: "us_ein", + ZaVat: "za_vat", + Unknown: "unknown", +} as const; diff --git a/src/api/types/VatModeEnum.ts b/src/api/types/VatModeEnum.ts new file mode 100644 index 0000000..73c91b9 --- /dev/null +++ b/src/api/types/VatModeEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type VatModeEnum = "exclusive" | "inclusive"; + +export const VatModeEnum = { + Exclusive: "exclusive", + Inclusive: "inclusive", +} as const; diff --git a/src/api/types/VatRateCreator.ts b/src/api/types/VatRateCreator.ts new file mode 100644 index 0000000..5a9fed3 --- /dev/null +++ b/src/api/types/VatRateCreator.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type VatRateCreator = "monite" | "accounting"; + +export const VatRateCreator = { + Monite: "monite", + Accounting: "accounting", +} as const; diff --git a/src/api/types/VatRateListResponse.ts b/src/api/types/VatRateListResponse.ts new file mode 100644 index 0000000..f9d0e14 --- /dev/null +++ b/src/api/types/VatRateListResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface VatRateListResponse { + data: Monite.VatRateResponse[]; +} diff --git a/src/api/types/VatRateResponse.ts b/src/api/types/VatRateResponse.ts new file mode 100644 index 0000000..920c656 --- /dev/null +++ b/src/api/types/VatRateResponse.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface VatRateResponse { + /** Unique identifier of the vat rate object. */ + id: string; + /** Date/time when this rate was recorded in the table. */ + created_at: string; + /** Date/time when this rate was updated in the table. */ + updated_at: string; + /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ + country: Monite.AllowedCountries; + /** By whom this rate was recorded: monite employee | accounting system. */ + created_by?: Monite.VatRateCreator; + /** Status for this vat rate: active | inactive. */ + status?: Monite.VatRateStatusEnum; + /** Date starting from when this rate can be used. */ + valid_from?: string; + /** Date when this rate was depreciated, after this date rate cannot be used. */ + valid_until?: string; + /** Percent minor units. Example: 12.5% is 1250. */ + value: number; +} diff --git a/src/api/types/VatRateStatusEnum.ts b/src/api/types/VatRateStatusEnum.ts new file mode 100644 index 0000000..279a26c --- /dev/null +++ b/src/api/types/VatRateStatusEnum.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type VatRateStatusEnum = "active" | "inactive"; + +export const VatRateStatusEnum = { + Active: "active", + Inactive: "inactive", +} as const; diff --git a/src/api/types/VerificationAirwallexPlaidRequest.ts b/src/api/types/VerificationAirwallexPlaidRequest.ts new file mode 100644 index 0000000..b2c0c53 --- /dev/null +++ b/src/api/types/VerificationAirwallexPlaidRequest.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface VerificationAirwallexPlaidRequest { + /** The name of your application to be displayed in Plaid Modal */ + client_name: string; + /** The name of the Link customization configured on the Plaid Dashboard. If not specified, the default customization will be applied */ + link_customization_name?: string; + /** URL to handle the OAuth verification flow */ + redirect_url: string; +} diff --git a/src/api/types/VerificationAirwallexPlaidResponse.ts b/src/api/types/VerificationAirwallexPlaidResponse.ts new file mode 100644 index 0000000..b2053b9 --- /dev/null +++ b/src/api/types/VerificationAirwallexPlaidResponse.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface VerificationAirwallexPlaidResponse { + /** Client name from the request */ + client_name: string; + expires_at: string; + /** Customization name from the request */ + link_customization_name?: string; + /** Link token that should be used to init Plaid SDK */ + link_token: string; + /** URL from the request */ + redirect_url: string; +} diff --git a/src/api/types/VerificationError.ts b/src/api/types/VerificationError.ts new file mode 100644 index 0000000..6d1faff --- /dev/null +++ b/src/api/types/VerificationError.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface VerificationError { + code: string; + details: string; +} diff --git a/src/api/types/VerificationRequest.ts b/src/api/types/VerificationRequest.ts new file mode 100644 index 0000000..7281029 --- /dev/null +++ b/src/api/types/VerificationRequest.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface VerificationRequest { + airwallex_plaid: Monite.VerificationAirwallexPlaidRequest; + type: Monite.BankAccountVerificationType; +} diff --git a/src/api/types/VerificationResponse.ts b/src/api/types/VerificationResponse.ts new file mode 100644 index 0000000..4f7f7e3 --- /dev/null +++ b/src/api/types/VerificationResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface VerificationResponse { + airwallex_plaid: Monite.VerificationAirwallexPlaidResponse; + type: Monite.BankAccountVerificationType; +} diff --git a/src/api/types/VerificationStatusEnum.ts b/src/api/types/VerificationStatusEnum.ts new file mode 100644 index 0000000..e26dab9 --- /dev/null +++ b/src/api/types/VerificationStatusEnum.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type VerificationStatusEnum = "enabled" | "disabled" | "pending"; + +export const VerificationStatusEnum = { + Enabled: "enabled", + Disabled: "disabled", + Pending: "pending", +} as const; diff --git a/src/api/types/VerifyResponse.ts b/src/api/types/VerifyResponse.ts new file mode 100644 index 0000000..02f0e13 --- /dev/null +++ b/src/api/types/VerifyResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface VerifyResponse { + /** Entry UUID */ + id: string; + domain: string; + status: string; +} diff --git a/src/api/types/WebhookDeliveryCursorFields.ts b/src/api/types/WebhookDeliveryCursorFields.ts new file mode 100644 index 0000000..269f2ec --- /dev/null +++ b/src/api/types/WebhookDeliveryCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type WebhookDeliveryCursorFields = "created_at" | "updated_at"; + +export const WebhookDeliveryCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/WebhookDeliveryPaginationResource.ts b/src/api/types/WebhookDeliveryPaginationResource.ts new file mode 100644 index 0000000..4f3133b --- /dev/null +++ b/src/api/types/WebhookDeliveryPaginationResource.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface WebhookDeliveryPaginationResource { + /** A set of webhooks returned per page */ + data: Monite.WebhookDeliveryResource[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/WebhookDeliveryResource.ts b/src/api/types/WebhookDeliveryResource.ts new file mode 100644 index 0000000..8e981e3 --- /dev/null +++ b/src/api/types/WebhookDeliveryResource.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface WebhookDeliveryResource { + id: string; + event_id: string; + requests_made_count: number; + response?: string; + response_status_code?: number; + url: string; + was_successful?: boolean; +} diff --git a/src/api/types/WebhookObjectType.ts b/src/api/types/WebhookObjectType.ts new file mode 100644 index 0000000..b3b9566 --- /dev/null +++ b/src/api/types/WebhookObjectType.ts @@ -0,0 +1,80 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type WebhookObjectType = + | "account" + | "approval" + | "approval_request" + | "approval_policy" + | "batch_payment" + | "comment" + | "counterpart" + | "counterpart_address" + | "counterpart_bank_account" + | "counterpart_contact_person" + | "counterpart_partner_metadata" + | "counterpart_tax_id" + | "entity" + | "entity_bank_account" + | "entity_settings" + | "entity_user" + | "export" + | "partner_settings" + | "payable" + | "payables_purchase_order" + | "payable.line_item" + | "payment" + | "payment_intent" + | "payment_link" + | "product" + | "receivable" + | "recurrence" + | "role" + | "tag" + | "todo_task" + | "workflow" + | "workflow_pipeline" + | "overdue_reminder" + | "payment_reminder" + | "accounting_connection" + | "project"; + +export const WebhookObjectType = { + Account: "account", + Approval: "approval", + ApprovalRequest: "approval_request", + ApprovalPolicy: "approval_policy", + BatchPayment: "batch_payment", + Comment: "comment", + Counterpart: "counterpart", + CounterpartAddress: "counterpart_address", + CounterpartBankAccount: "counterpart_bank_account", + CounterpartContactPerson: "counterpart_contact_person", + CounterpartPartnerMetadata: "counterpart_partner_metadata", + CounterpartTaxId: "counterpart_tax_id", + Entity: "entity", + EntityBankAccount: "entity_bank_account", + EntitySettings: "entity_settings", + EntityUser: "entity_user", + Export: "export", + PartnerSettings: "partner_settings", + Payable: "payable", + PayablesPurchaseOrder: "payables_purchase_order", + PayableLineItem: "payable.line_item", + Payment: "payment", + PaymentIntent: "payment_intent", + PaymentLink: "payment_link", + Product: "product", + Receivable: "receivable", + Recurrence: "recurrence", + Role: "role", + Tag: "tag", + TodoTask: "todo_task", + Workflow: "workflow", + WorkflowPipeline: "workflow_pipeline", + OverdueReminder: "overdue_reminder", + PaymentReminder: "payment_reminder", + AccountingConnection: "accounting_connection", + Project: "project", +} as const; diff --git a/src/api/types/WebhookSubscriptionCursorFields.ts b/src/api/types/WebhookSubscriptionCursorFields.ts new file mode 100644 index 0000000..090612f --- /dev/null +++ b/src/api/types/WebhookSubscriptionCursorFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type WebhookSubscriptionCursorFields = "created_at" | "updated_at"; + +export const WebhookSubscriptionCursorFields = { + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} as const; diff --git a/src/api/types/WebhookSubscriptionPaginationResource.ts b/src/api/types/WebhookSubscriptionPaginationResource.ts new file mode 100644 index 0000000..c129d98 --- /dev/null +++ b/src/api/types/WebhookSubscriptionPaginationResource.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface WebhookSubscriptionPaginationResource { + /** A set of webhook settings of different types returned per page */ + data: Monite.WebhookSubscriptionResource[]; + /** A token that can be sent in the `pagination_token` query parameter to get the next page of results, or `null` if there is no next page (i.e. you've reached the last page). */ + next_pagination_token?: string; + /** A token that can be sent in the `pagination_token` query parameter to get the previous page of results, or `null` if there is no previous page (i.e. you've reached the first page). */ + prev_pagination_token?: string; +} diff --git a/src/api/types/WebhookSubscriptionResource.ts b/src/api/types/WebhookSubscriptionResource.ts new file mode 100644 index 0000000..06e1d2d --- /dev/null +++ b/src/api/types/WebhookSubscriptionResource.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface WebhookSubscriptionResource { + id: string; + event_types: string[]; + object_type: Monite.WebhookObjectType; + status: Monite.WebhookSubscriptionStatus; + url: string; +} diff --git a/src/api/types/WebhookSubscriptionResourceWithSecret.ts b/src/api/types/WebhookSubscriptionResourceWithSecret.ts new file mode 100644 index 0000000..c720c69 --- /dev/null +++ b/src/api/types/WebhookSubscriptionResourceWithSecret.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index"; + +export interface WebhookSubscriptionResourceWithSecret { + id: string; + event_types: string[]; + object_type: Monite.WebhookObjectType; + secret: string; + status: Monite.WebhookSubscriptionStatus; + url: string; +} diff --git a/src/api/types/WebhookSubscriptionStatus.ts b/src/api/types/WebhookSubscriptionStatus.ts new file mode 100644 index 0000000..449dc12 --- /dev/null +++ b/src/api/types/WebhookSubscriptionStatus.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type WebhookSubscriptionStatus = "enabled" | "disabled"; + +export const WebhookSubscriptionStatus = { + Enabled: "enabled", + Disabled: "disabled", +} as const; diff --git a/src/api/types/index.ts b/src/api/types/index.ts new file mode 100644 index 0000000..2d96b49 --- /dev/null +++ b/src/api/types/index.ts @@ -0,0 +1,523 @@ +export * from "./ApiVersion"; +export * from "./AccessTokenResponse"; +export * from "./AccountDisabledReason"; +export * from "./AccountResponse"; +export * from "./AccountingConnectionList"; +export * from "./AccountingConnectionResponse"; +export * from "./AccountingCustomerRefObject"; +export * from "./AccountingLineItem"; +export * from "./AccountingMessageResponse"; +export * from "./AccountingPayableDueDate"; +export * from "./AccountingPayable"; +export * from "./AccountingPayableList"; +export * from "./AccountingPurchaseOrderRef"; +export * from "./AccountingReceivableDueDate"; +export * from "./AccountingReceivable"; +export * from "./AccountingReceivableList"; +export * from "./AccountingRefObject"; +export * from "./AccountingSettingsPayload"; +export * from "./AccountingSettingsResponse"; +export * from "./AccountingTaxRateListResponse"; +export * from "./AccountingTaxRateResponse"; +export * from "./AccountingVendorRefObject"; +export * from "./ActionEnum"; +export * from "./ActionSchema"; +export * from "./AirwallexMandate"; +export * from "./AirwallexMandateType"; +export * from "./AirwallexMandateVersion"; +export * from "./AirwallexPlaidAccount"; +export * from "./AirwallexPlaidBankAccountVerificationStatus"; +export * from "./AirwallexPlaidInstitution"; +export * from "./AirwallexPlaidVerification"; +export * from "./AllDocumentExportResponseSchema"; +export * from "./AllOverdueRemindersResponse"; +export * from "./AllowedCountries"; +export * from "./AllowedFileTypes"; +export * from "./ApprovalPolicyCursorFields"; +export * from "./ApprovalPolicyResourceScriptItem"; +export * from "./ApprovalPolicyResourceTrigger"; +export * from "./ApprovalPolicyResourceStatus"; +export * from "./ApprovalPolicyResource"; +export * from "./ApprovalPolicyResourceList"; +export * from "./ApprovalPolicyStatus"; +export * from "./ApprovalProcessResourceList"; +export * from "./ApprovalProcessStepResource"; +export * from "./ApprovalProcessStepResourceList"; +export * from "./ApprovalProcessStepStatus"; +export * from "./ApprovalRequestCreateByRoleRequest"; +export * from "./ApprovalRequestCreateByUserRequest"; +export * from "./ApprovalRequestCreateRequest"; +export * from "./ApprovalRequestCursorFields"; +export * from "./ApprovalRequestResourceList"; +export * from "./ApprovalRequestResourceWithMetadata"; +export * from "./ApprovalRequestStatus"; +export * from "./BankAccount"; +export * from "./BankAccountVerificationType"; +export * from "./BankAccountVerifications"; +export * from "./BasedOnReceivableCreatedEventData"; +export * from "./BasedOnTransitionType"; +export * from "./BizObjectsSchema"; +export * from "./BusinessProfile"; +export * from "./ButtonThemePayload"; +export * from "./ButtonThemeResponse"; +export * from "./CardThemePayload"; +export * from "./CardThemeResponse"; +export * from "./CommentCursorFields"; +export * from "./CommentResource"; +export * from "./CommentResourceList"; +export * from "./CommonSchema"; +export * from "./CompleteRefreshVerificationResponse"; +export * from "./CompleteVerificationAirwallexPlaidRequest"; +export * from "./CompleteVerificationResponse"; +export * from "./ConnectionStatus"; +export * from "./CounterpartAddress"; +export * from "./CounterpartAddressResourceList"; +export * from "./CounterpartAddressResponseWithCounterpartId"; +export * from "./CounterpartBankAccountResourceList"; +export * from "./CounterpartBankAccountResponse"; +export * from "./CounterpartContactResponse"; +export * from "./CounterpartContactsResourceList"; +export * from "./CounterpartCreatePayload"; +export * from "./CounterpartCursorFields"; +export * from "./CounterpartIndividualCreatePayload"; +export * from "./CounterpartIndividualResponse"; +export * from "./CounterpartIndividualRootCreatePayload"; +export * from "./CounterpartIndividualRootResponse"; +export * from "./CounterpartIndividualRootUpdatePayload"; +export * from "./CounterpartIndividualUpdatePayload"; +export * from "./CounterpartOrganizationCreatePayload"; +export * from "./CounterpartOrganizationResponse"; +export * from "./CounterpartOrganizationRootCreatePayload"; +export * from "./CounterpartOrganizationRootResponse"; +export * from "./CounterpartOrganizationRootUpdatePayload"; +export * from "./CounterpartOrganizationUpdatePayload"; +export * from "./CounterpartPaginationResponse"; +export * from "./CounterpartRawAddress"; +export * from "./CounterpartRawAddressUpdateRequest"; +export * from "./CounterpartRawBankAccount"; +export * from "./CounterpartRawBankAccountUpdateRequest"; +export * from "./CounterpartRawData"; +export * from "./CounterpartRawDataUpdateRequest"; +export * from "./CounterpartRawVatId"; +export * from "./CounterpartRawVatIdUpdateRequest"; +export * from "./CounterpartResponse"; +export * from "./CounterpartTagCategory"; +export * from "./CounterpartTagSchema"; +export * from "./CounterpartType"; +export * from "./CounterpartUpdatePayload"; +export * from "./CounterpartVatIdResourceList"; +export * from "./CounterpartVatIdResponse"; +export * from "./CreateExportTaskResponseSchema"; +export * from "./CreateOnboardingLinkRequest"; +export * from "./CreditNoteResponsePayloadEntity"; +export * from "./CreditNoteResponsePayload"; +export * from "./CreditNoteStateEnum"; +export * from "./CurrencyEnum"; +export * from "./CurrencyExchangeSchema"; +export * from "./CurrencySettings"; +export * from "./CustomTemplateDataSchema"; +export * from "./CustomTemplatesCursorFields"; +export * from "./CustomTemplatesPaginationResponse"; +export * from "./DnsRecord"; +export * from "./DnsRecordPurpose"; +export * from "./DnsRecordType"; +export * from "./DnsRecords"; +export * from "./DataExportCursorFields"; +export * from "./DayOfMonth"; +export * from "./Discount"; +export * from "./DiscountType"; +export * from "./DocumentExportResponseSchema"; +export * from "./DocumentIdSeparators"; +export * from "./DocumentIDsSettings"; +export * from "./DocumentIDsSettingsNextNumber"; +export * from "./DocumentIDsSettingsRequest"; +export * from "./DocumentObjectTypeRequestEnum"; +export * from "./DocumentTypeEnum"; +export * from "./DocumentTypePrefix"; +export * from "./DomainListResponse"; +export * from "./DomainResponseDnsRecords"; +export * from "./DomainResponse"; +export * from "./EInvoicingProviderEnum"; +export * from "./EInvoicingSettingsPayload"; +export * from "./EInvoicingSettingsResponse"; +export * from "./EntityAddressResponseSchema"; +export * from "./EntityAddressSchema"; +export * from "./EntityBankAccountPaginationResponse"; +export * from "./EntityBankAccountResponse"; +export * from "./EntityBusinessStructure"; +export * from "./EntityCursorFields"; +export * from "./EntityIndividualResponse"; +export * from "./EntityOnboardingDataResponse"; +export * from "./EntityOnboardingDocuments"; +export * from "./EntityOrganizationResponse"; +export * from "./EntityPaginationResponse"; +export * from "./EntityResponse"; +export * from "./EntityTypeEnum"; +export * from "./EntityUserCursorFields"; +export * from "./EntityUserPaginationResponse"; +export * from "./EntityUserResponse"; +export * from "./EntityVatIdResourceList"; +export * from "./EntityVatIdResponse"; +export * from "./ErrorSchema"; +export * from "./ErrorSchemaResponse"; +export * from "./EstimatedMonthlyRevenue"; +export * from "./EventCursorFields"; +export * from "./EventPaginationResource"; +export * from "./EventResource"; +export * from "./EventResourceForWebhookClient"; +export * from "./ExchangeRate"; +export * from "./ExportFormat"; +export * from "./ExportObjectSchema"; +export * from "./ExportPayableSchema"; +export * from "./ExportReceivableSchema"; +export * from "./ExportSettingCursorFields"; +export * from "./ExtraDataResource"; +export * from "./ExtraDataResourceList"; +export * from "./FileResponse"; +export * from "./FileSchema"; +export * from "./FileSchema2"; +export * from "./FileSchema3"; +export * from "./FileSchema4"; +export * from "./FilesResponse"; +export * from "./GetAllPaymentReminders"; +export * from "./GetAllRecurrences"; +export * from "./GetOnboardingRequirementsResponse"; +export * from "./GrantType"; +export * from "./HttpValidationError"; +export * from "./IndividualResponseSchema"; +export * from "./IndividualSchema"; +export * from "./Invoice"; +export * from "./InvoiceFile"; +export * from "./InvoiceResponsePayloadEntity"; +export * from "./InvoiceResponsePayload"; +export * from "./Item"; +export * from "./IterationStatus"; +export * from "./LabelNValue"; +export * from "./LanguageCodeEnum"; +export * from "./LedgerAccountCursorFields"; +export * from "./LedgerAccountListResponse"; +export * from "./LedgerAccountResponse"; +export * from "./LineItem"; +export * from "./LineItemCursorFields"; +export * from "./LineItemInternalRequest"; +export * from "./LineItemPaginationResponse"; +export * from "./LineItemProduct"; +export * from "./LineItemProductCreate"; +export * from "./LineItemProductMeasureUnit"; +export * from "./LineItemProductVatRate"; +export * from "./LineItemRequest"; +export * from "./LineItemResponse"; +export * from "./LineItemUpdate"; +export * from "./LineItemsReplaceResponse"; +export * from "./LineItemsResponse"; +export * from "./LogMethodEnum"; +export * from "./LogResponseBody"; +export * from "./LogResponse"; +export * from "./LogTypeEnum"; +export * from "./LogsResponse"; +export * from "./MailSentEventData"; +export * from "./MailSettingsPayload"; +export * from "./MailSettingsResponse"; +export * from "./MailboxDataResponse"; +export * from "./MailboxObjectTypeEnum"; +export * from "./MailboxResponse"; +export * from "./MergedSettingsResponse"; +export * from "./MessageResponse"; +export * from "./MissingFields"; +export * from "./MissingLineItemFields"; +export * from "./MoniteAllPaymentMethods"; +export * from "./MoniteAllPaymentMethodsTypes"; +export * from "./OcrAddress"; +export * from "./OcrResponseInvoiceReceiptData"; +export * from "./OcrResponseInvoiceReceiptLineItem"; +export * from "./OcrResponseInvoiceReceiptLineItemRaw"; +export * from "./ObjectMatchTypes"; +export * from "./ObjectType"; +export * from "./ObjectTypeAvailableComment"; +export * from "./ObjectTypeEnum"; +export * from "./OcrAutoTaggingSettingsRequest"; +export * from "./OcrRecognitionResponse"; +export * from "./OcrStatusEnum"; +export * from "./OnboardingLinkPublicResponse"; +export * from "./OnboardingLinkResponse"; +export * from "./OnboardingPaymentMethodsResponse"; +export * from "./OnboardingRequirementsError"; +export * from "./OnboardingRequirementsResponse"; +export * from "./OnboardingVerificationError"; +export * from "./OnboardingVerificationStatusEnum"; +export * from "./OptionalIndividualSchema"; +export * from "./OptionalOrganizationSchema"; +export * from "./OptionalPersonAddressRequest"; +export * from "./OptionalPersonRelationship"; +export * from "./OrderEnum"; +export * from "./OrderEnum2"; +export * from "./OrderEnum3"; +export * from "./OrganizationResponseSchema"; +export * from "./OrganizationSchema"; +export * from "./OverdueReminderResponse"; +export * from "./OverdueReminderTerm"; +export * from "./OwnershipDeclaration"; +export * from "./PageSchema"; +export * from "./PageSchema2"; +export * from "./PageSchema3"; +export * from "./PageSchema4"; +export * from "./PartnerMetadata"; +export * from "./PartnerMetadataResponse"; +export * from "./PartnerProjectSettingsResponse"; +export * from "./PayableActionEnum"; +export * from "./PayableActionSchema"; +export * from "./PayableAggregatedDataResponse"; +export * from "./PayableAggregatedItem"; +export * from "./PayableCursorFields"; +export * from "./PayableEntityAddressSchema"; +export * from "./PayableEntityIndividualResponse"; +export * from "./PayableEntityOrganizationResponse"; +export * from "./PayableIndividualSchema"; +export * from "./PayableOrganizationSchema"; +export * from "./PayableOriginEnum"; +export * from "./PayablePaginationResponse"; +export * from "./PayablePaymentTermDiscount"; +export * from "./PayablePaymentTermFinal"; +export * from "./PayablePaymentTermsCreatePayload"; +export * from "./PayableResponseSchemaOtherExtractedData"; +export * from "./PayableResponseSchema"; +export * from "./PayableSchema"; +export * from "./PayableSettingsPayload"; +export * from "./PayableSettingsResponse"; +export * from "./PayableStateEnum"; +export * from "./PayableTemplatesVariable"; +export * from "./PayableTemplatesVariablesObject"; +export * from "./PayableTemplatesVariablesObjectList"; +export * from "./PayableValidationResponse"; +export * from "./PayableValidationsResource"; +export * from "./PayablesFieldsAllowedForValidate"; +export * from "./PayablesVariableType"; +export * from "./PaymentAccountObject"; +export * from "./PaymentAccountType"; +export * from "./PaymentIntent"; +export * from "./PaymentIntentCursorFields"; +export * from "./PaymentIntentHistory"; +export * from "./PaymentIntentHistoryResponse"; +export * from "./PaymentIntentPayoutMethod"; +export * from "./PaymentIntentResponse"; +export * from "./PaymentIntentsListResponse"; +export * from "./PaymentIntentsRecipient"; +export * from "./PaymentMethod"; +export * from "./PaymentMethodDirection"; +export * from "./PaymentMethodRequirements"; +export * from "./PaymentMethodStatus"; +export * from "./PaymentObject"; +export * from "./PaymentObjectPayable"; +export * from "./PaymentObjectType"; +export * from "./PaymentPageThemePayload"; +export * from "./PaymentPageThemeResponse"; +export * from "./PaymentPriorityEnum"; +export * from "./PaymentReceivedEventData"; +export * from "./PaymentRecordCursorFields"; +export * from "./PaymentRecordObjectRequest"; +export * from "./PaymentRecordObjectResponse"; +export * from "./PaymentRecordResponse"; +export * from "./PaymentRecordResponseList"; +export * from "./PaymentReminderResponse"; +export * from "./PaymentRequirements"; +export * from "./PaymentTerm"; +export * from "./PaymentTermDiscount"; +export * from "./PaymentTermDiscountWithDate"; +export * from "./PaymentTerms"; +export * from "./PaymentTermsListResponse"; +export * from "./PaymentTermsResponse"; +export * from "./PaymentsBatchPaymentResponse"; +export * from "./PaymentsBatchPaymentStatus"; +export * from "./PaymentsSettingsPayload"; +export * from "./PaymentsSettingsResponse"; +export * from "./PermissionEnum"; +export * from "./PersonAddressRequest"; +export * from "./PersonAddressResponse"; +export * from "./PersonOnboardingDocuments"; +export * from "./PersonRelationshipRequest"; +export * from "./PersonRelationshipResponse"; +export * from "./PersonResponse"; +export * from "./PersonsResponse"; +export * from "./Platform"; +export * from "./PreviewSchema"; +export * from "./PreviewSchema2"; +export * from "./PreviewSchema3"; +export * from "./PreviewSchema4"; +export * from "./PreviewTemplateResponse"; +export * from "./Price"; +export * from "./ProcessResourceScriptSnapshot"; +export * from "./ProcessResource"; +export * from "./ProcessStatusEnum"; +export * from "./ProductCursorFields"; +export * from "./ProductServicePaginationResponse"; +export * from "./ProductServiceResponse"; +export * from "./ProductServiceTypeEnum"; +export * from "./ProjectCursorFields"; +export * from "./ProjectPaginationResponse"; +export * from "./ProjectResource"; +export * from "./PublicPaymentLinkResponse"; +export * from "./PurchaseOrderCounterpartAddressSchema"; +export * from "./PurchaseOrderCounterpartIndividualResponse"; +export * from "./PurchaseOrderCounterpartIndividualRootResponse"; +export * from "./PurchaseOrderCounterpartOrganizationResponse"; +export * from "./PurchaseOrderCounterpartOrganizationRootResponse"; +export * from "./PurchaseOrderCounterpartSchema"; +export * from "./PurchaseOrderCursorFields"; +export * from "./PurchaseOrderEmailPreviewResponse"; +export * from "./PurchaseOrderEmailSentResponse"; +export * from "./PurchaseOrderItem"; +export * from "./PurchaseOrderPaginationResponse"; +export * from "./PurchaseOrderResponseSchemaEntity"; +export * from "./PurchaseOrderResponseSchema"; +export * from "./PurchaseOrderStatusEnum"; +export * from "./PurchaseOrderVatId"; +export * from "./QuoteResponsePayloadEntity"; +export * from "./QuoteResponsePayload"; +export * from "./QuoteStateEnum"; +export * from "./ReceivableCounterpartContact"; +export * from "./ReceivableCounterpartType"; +export * from "./ReceivableCounterpartVatIdResponse"; +export * from "./ReceivableCreateBasedOnPayload"; +export * from "./ReceivableCursorFields"; +export * from "./ReceivableEditFlow"; +export * from "./ReceivableEntityAddressSchema"; +export * from "./ReceivableEntityBase"; +export * from "./ReceivableEntityIndividual"; +export * from "./ReceivableEntityIndividualRequest"; +export * from "./ReceivableEntityOrganization"; +export * from "./ReceivableEntityOrganizationRequest"; +export * from "./ReceivableEntityVatIdResponse"; +export * from "./ReceivableFacadeCreateInvoicePayload"; +export * from "./ReceivableFacadeCreatePayload"; +export * from "./ReceivableFacadeCreateQuotePayload"; +export * from "./ReceivableFileSchema"; +export * from "./ReceivableFileUrl"; +export * from "./ReceivableHistoryCursorFields"; +export * from "./ReceivableHistoryEventTypeEnum"; +export * from "./ReceivableHistoryPaginationResponse"; +export * from "./ReceivableHistoryResponseEventData"; +export * from "./ReceivableHistoryResponse"; +export * from "./ReceivableMailCursorFields"; +export * from "./ReceivableMailPaginationResponse"; +export * from "./ReceivableMailRecipientState"; +export * from "./ReceivableMailRecipients"; +export * from "./ReceivableMailResponse"; +export * from "./ReceivableMailStatusEnum"; +export * from "./ReceivablePageSchema"; +export * from "./ReceivablePaginationResponse"; +export * from "./ReceivablePreviewResponse"; +export * from "./ReceivablePreviewSchema"; +export * from "./ReceivableResponse"; +export * from "./ReceivableSendResponse"; +export * from "./ReceivableSettingsPayload"; +export * from "./ReceivableSettingsResponse"; +export * from "./ReceivableTemplatesVariable"; +export * from "./ReceivableTemplatesVariablesObject"; +export * from "./ReceivableTemplatesVariablesObjectList"; +export * from "./ReceivableType"; +export * from "./ReceivableUpdatePayload"; +export * from "./ReceivableUpdatedEventData"; +export * from "./ReceivablesPreviewTypeEnum"; +export * from "./ReceivablesRemindersWarningMessage"; +export * from "./ReceivablesRepresentationOfCounterpartAddress"; +export * from "./ReceivablesRepresentationOfEntityBankAccount"; +export * from "./ReceivablesSendResponse"; +export * from "./ReceivablesStatusEnum"; +export * from "./ReceivablesVerifyResponse"; +export * from "./Recipient"; +export * from "./RecipientAccountResponse"; +export * from "./RecipientType"; +export * from "./Recipients"; +export * from "./Recurrence"; +export * from "./RecurrenceIteration"; +export * from "./RecurrenceStatus"; +export * from "./RelatedDocuments"; +export * from "./Reminder"; +export * from "./ReminderTypeEnum"; +export * from "./RemindersSettings"; +export * from "./RequirementsError"; +export * from "./ResponseItem"; +export * from "./RoleCursorFields"; +export * from "./RolePaginationResponse"; +export * from "./RoleResponse"; +export * from "./RootSchema"; +export * from "./ServiceProvidersEnum"; +export * from "./Signature"; +export * from "./SingleOnboardingRequirementsResponse"; +export * from "./SinglePaymentIntent"; +export * from "./SinglePaymentIntentResponse"; +export * from "./SourceOfPayableDataEnum"; +export * from "./StatusChangedEventData"; +export * from "./StatusEnum"; +export * from "./SuccessResult"; +export * from "./SuggestedPaymentTerm"; +export * from "./SupportedFieldNames"; +export * from "./SupportedFormatSchemaObjectType"; +export * from "./SupportedFormatSchema"; +export * from "./SyncRecordCursorFields"; +export * from "./SyncRecordResource"; +export * from "./SyncRecordResourceList"; +export * from "./SyncStatus"; +export * from "./SystemTemplateDataSchema"; +export * from "./SystemTemplates"; +export * from "./TagCategory"; +export * from "./TagCursorFields"; +export * from "./TagReadSchema"; +export * from "./TagsPaginationResponse"; +export * from "./TaxComponentResponse"; +export * from "./TaxRateAccountCursorFields"; +export * from "./TemplateDataSchema"; +export * from "./TemplateListResponse"; +export * from "./TemplateReceivableResponse"; +export * from "./TemplateTypeEnum"; +export * from "./TermFinalWithDate"; +export * from "./TermsOfServiceAcceptance"; +export * from "./TextTemplateResponse"; +export * from "./TextTemplateResponseList"; +export * from "./TextTemplateType"; +export * from "./TotalVatAmountItem"; +export * from "./Unit"; +export * from "./UnitListResponse"; +export * from "./UnitRequest"; +export * from "./UnitResponse"; +export * from "./UpdateCreditNote"; +export * from "./UpdateCreditNotePayload"; +export * from "./UpdateEntityAddressSchema"; +export * from "./UpdateEntityRequest"; +export * from "./UpdateInvoice"; +export * from "./UpdateInvoicePayload"; +export * from "./UpdateIssuedInvoiceEntity"; +export * from "./UpdateIssuedInvoice"; +export * from "./UpdateIssuedInvoicePayload"; +export * from "./UpdateLineItemForCreditNote"; +export * from "./UpdateProductForCreditNote"; +export * from "./UpdateQuote"; +export * from "./UpdateQuotePayload"; +export * from "./ValidationErrorLocItem"; +export * from "./ValidationError"; +export * from "./Variable"; +export * from "./VariablesObject"; +export * from "./VariablesObjectList"; +export * from "./VariablesType"; +export * from "./VatIdTypeEnum"; +export * from "./VatModeEnum"; +export * from "./VatRateCreator"; +export * from "./VatRateListResponse"; +export * from "./VatRateResponse"; +export * from "./VatRateStatusEnum"; +export * from "./VerificationAirwallexPlaidRequest"; +export * from "./VerificationAirwallexPlaidResponse"; +export * from "./VerificationError"; +export * from "./VerificationRequest"; +export * from "./VerificationResponse"; +export * from "./VerificationStatusEnum"; +export * from "./VerifyResponse"; +export * from "./WebhookDeliveryCursorFields"; +export * from "./WebhookDeliveryPaginationResource"; +export * from "./WebhookDeliveryResource"; +export * from "./WebhookObjectType"; +export * from "./WebhookSubscriptionCursorFields"; +export * from "./WebhookSubscriptionPaginationResource"; +export * from "./WebhookSubscriptionResource"; +export * from "./WebhookSubscriptionResourceWithSecret"; +export * from "./WebhookSubscriptionStatus"; diff --git a/src/core/auth/BasicAuth.ts b/src/core/auth/BasicAuth.ts new file mode 100644 index 0000000..146df21 --- /dev/null +++ b/src/core/auth/BasicAuth.ts @@ -0,0 +1,31 @@ +import { Base64 } from "js-base64"; + +export interface BasicAuth { + username: string; + password: string; +} + +const BASIC_AUTH_HEADER_PREFIX = /^Basic /i; + +export const BasicAuth = { + toAuthorizationHeader: (basicAuth: BasicAuth | undefined): string | undefined => { + if (basicAuth == null) { + return undefined; + } + const token = Base64.encode(`${basicAuth.username}:${basicAuth.password}`); + return `Basic ${token}`; + }, + fromAuthorizationHeader: (header: string): BasicAuth => { + const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, ""); + const decoded = Base64.decode(credentials); + const [username, password] = decoded.split(":", 2); + + if (username == null || password == null) { + throw new Error("Invalid basic auth"); + } + return { + username, + password, + }; + }, +}; diff --git a/src/core/auth/BearerToken.ts b/src/core/auth/BearerToken.ts new file mode 100644 index 0000000..fe987fc --- /dev/null +++ b/src/core/auth/BearerToken.ts @@ -0,0 +1,15 @@ +export type BearerToken = string; + +const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i; + +export const BearerToken = { + toAuthorizationHeader: (token: BearerToken | undefined): string | undefined => { + if (token == null) { + return undefined; + } + return `Bearer ${token}`; + }, + fromAuthorizationHeader: (header: string): BearerToken => { + return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim() as BearerToken; + }, +}; diff --git a/src/core/auth/index.ts b/src/core/auth/index.ts new file mode 100644 index 0000000..ee293b3 --- /dev/null +++ b/src/core/auth/index.ts @@ -0,0 +1,2 @@ +export { BasicAuth } from "./BasicAuth"; +export { BearerToken } from "./BearerToken"; diff --git a/src/core/fetcher/APIResponse.ts b/src/core/fetcher/APIResponse.ts new file mode 100644 index 0000000..3664d09 --- /dev/null +++ b/src/core/fetcher/APIResponse.ts @@ -0,0 +1,12 @@ +export type APIResponse = SuccessfulResponse | FailedResponse; + +export interface SuccessfulResponse { + ok: true; + body: T; + headers?: Record; +} + +export interface FailedResponse { + ok: false; + error: T; +} diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts new file mode 100644 index 0000000..d67bc04 --- /dev/null +++ b/src/core/fetcher/Fetcher.ts @@ -0,0 +1,143 @@ +import { APIResponse } from "./APIResponse"; +import { createRequestUrl } from "./createRequestUrl"; +import { getFetchFn } from "./getFetchFn"; +import { getRequestBody } from "./getRequestBody"; +import { getResponseBody } from "./getResponseBody"; +import { makeRequest } from "./makeRequest"; +import { requestWithRetries } from "./requestWithRetries"; + +export type FetchFunction = (args: Fetcher.Args) => Promise>; + +export declare namespace Fetcher { + export interface Args { + url: string; + method: string; + contentType?: string; + headers?: Record; + queryParameters?: Record; + body?: unknown; + timeoutMs?: number; + maxRetries?: number; + withCredentials?: boolean; + abortSignal?: AbortSignal; + requestType?: "json" | "file" | "bytes"; + responseType?: "json" | "blob" | "sse" | "streaming" | "text"; + duplex?: "half"; + } + + export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; + + export interface FailedStatusCodeError { + reason: "status-code"; + statusCode: number; + body: unknown; + } + + export interface NonJsonError { + reason: "non-json"; + statusCode: number; + rawBody: string; + } + + export interface TimeoutError { + reason: "timeout"; + } + + export interface UnknownError { + reason: "unknown"; + errorMessage: string; + } +} + +export async function fetcherImpl(args: Fetcher.Args): Promise> { + const headers: Record = {}; + if (args.body !== undefined && args.contentType != null) { + headers["Content-Type"] = args.contentType; + } + + if (args.headers != null) { + for (const [key, value] of Object.entries(args.headers)) { + if (value != null) { + headers[key] = value; + } + } + } + + const url = createRequestUrl(args.url, args.queryParameters); + let requestBody: BodyInit | undefined = await getRequestBody({ + body: args.body, + type: args.requestType === "json" ? "json" : "other", + }); + const fetchFn = await getFetchFn(); + + try { + const response = await requestWithRetries( + async () => + makeRequest( + fetchFn, + url, + args.method, + headers, + requestBody, + args.timeoutMs, + args.abortSignal, + args.withCredentials, + args.duplex + ), + args.maxRetries + ); + let responseBody = await getResponseBody(response, args.responseType); + + if (response.status >= 200 && response.status < 400) { + return { + ok: true, + body: responseBody as R, + headers: response.headers, + }; + } else { + return { + ok: false, + error: { + reason: "status-code", + statusCode: response.status, + body: responseBody, + }, + }; + } + } catch (error) { + if (args.abortSignal != null && args.abortSignal.aborted) { + return { + ok: false, + error: { + reason: "unknown", + errorMessage: "The user aborted a request", + }, + }; + } else if (error instanceof Error && error.name === "AbortError") { + return { + ok: false, + error: { + reason: "timeout", + }, + }; + } else if (error instanceof Error) { + return { + ok: false, + error: { + reason: "unknown", + errorMessage: error.message, + }, + }; + } + + return { + ok: false, + error: { + reason: "unknown", + errorMessage: JSON.stringify(error), + }, + }; + } +} + +export const fetcher: FetchFunction = fetcherImpl; diff --git a/src/core/fetcher/Supplier.ts b/src/core/fetcher/Supplier.ts new file mode 100644 index 0000000..867c931 --- /dev/null +++ b/src/core/fetcher/Supplier.ts @@ -0,0 +1,11 @@ +export type Supplier = T | Promise | (() => T | Promise); + +export const Supplier = { + get: async (supplier: Supplier): Promise => { + if (typeof supplier === "function") { + return (supplier as () => T)(); + } else { + return supplier; + } + }, +}; diff --git a/src/core/fetcher/createRequestUrl.ts b/src/core/fetcher/createRequestUrl.ts new file mode 100644 index 0000000..9288a99 --- /dev/null +++ b/src/core/fetcher/createRequestUrl.ts @@ -0,0 +1,10 @@ +import qs from "qs"; + +export function createRequestUrl( + baseUrl: string, + queryParameters?: Record +): string { + return Object.keys(queryParameters ?? {}).length > 0 + ? `${baseUrl}?${qs.stringify(queryParameters, { arrayFormat: "repeat" })}` + : baseUrl; +} diff --git a/src/core/fetcher/getFetchFn.ts b/src/core/fetcher/getFetchFn.ts new file mode 100644 index 0000000..9fd9bfc --- /dev/null +++ b/src/core/fetcher/getFetchFn.ts @@ -0,0 +1,25 @@ +import { RUNTIME } from "../runtime"; + +/** + * Returns a fetch function based on the runtime + */ +export async function getFetchFn(): Promise { + // In Node.js 18+ environments, use native fetch + if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) { + return fetch; + } + + // In Node.js 18 or lower environments, the SDK always uses`node-fetch`. + if (RUNTIME.type === "node") { + return (await import("node-fetch")).default as any; + } + + // Otherwise the SDK uses global fetch if available, + // and falls back to node-fetch. + if (typeof fetch == "function") { + return fetch; + } + + // Defaults to node `node-fetch` if global fetch isn't available + return (await import("node-fetch")).default as any; +} diff --git a/src/core/fetcher/getHeader.ts b/src/core/fetcher/getHeader.ts new file mode 100644 index 0000000..50f922b --- /dev/null +++ b/src/core/fetcher/getHeader.ts @@ -0,0 +1,8 @@ +export function getHeader(headers: Record, header: string): string | undefined { + for (const [headerKey, headerValue] of Object.entries(headers)) { + if (headerKey.toLowerCase() === header.toLowerCase()) { + return headerValue; + } + } + return undefined; +} diff --git a/src/core/fetcher/getRequestBody.ts b/src/core/fetcher/getRequestBody.ts new file mode 100644 index 0000000..1138414 --- /dev/null +++ b/src/core/fetcher/getRequestBody.ts @@ -0,0 +1,14 @@ +export declare namespace GetRequestBody { + interface Args { + body: unknown; + type: "json" | "file" | "bytes" | "other"; + } +} + +export async function getRequestBody({ body, type }: GetRequestBody.Args): Promise { + if (type.includes("json")) { + return JSON.stringify(body); + } else { + return body as BodyInit; + } +} diff --git a/src/core/fetcher/getResponseBody.ts b/src/core/fetcher/getResponseBody.ts new file mode 100644 index 0000000..a7a9c50 --- /dev/null +++ b/src/core/fetcher/getResponseBody.ts @@ -0,0 +1,32 @@ +import { chooseStreamWrapper } from "./stream-wrappers/chooseStreamWrapper"; + +export async function getResponseBody(response: Response, responseType?: string): Promise { + if (response.body != null && responseType === "blob") { + return await response.blob(); + } else if (response.body != null && responseType === "sse") { + return response.body; + } else if (response.body != null && responseType === "streaming") { + return chooseStreamWrapper(response.body); + } else if (response.body != null && responseType === "text") { + return await response.text(); + } else { + const text = await response.text(); + if (text.length > 0) { + try { + let responseBody = JSON.parse(text); + return responseBody; + } catch (err) { + return { + ok: false, + error: { + reason: "non-json", + statusCode: response.status, + rawBody: text, + }, + }; + } + } else { + return undefined; + } + } +} diff --git a/src/core/fetcher/index.ts b/src/core/fetcher/index.ts new file mode 100644 index 0000000..2d658ca --- /dev/null +++ b/src/core/fetcher/index.ts @@ -0,0 +1,5 @@ +export type { APIResponse } from "./APIResponse"; +export { fetcher } from "./Fetcher"; +export type { Fetcher, FetchFunction } from "./Fetcher"; +export { getHeader } from "./getHeader"; +export { Supplier } from "./Supplier"; diff --git a/src/core/fetcher/makeRequest.ts b/src/core/fetcher/makeRequest.ts new file mode 100644 index 0000000..8fb4bac --- /dev/null +++ b/src/core/fetcher/makeRequest.ts @@ -0,0 +1,44 @@ +import { anySignal, getTimeoutSignal } from "./signals"; + +export const makeRequest = async ( + fetchFn: (url: string, init: RequestInit) => Promise, + url: string, + method: string, + headers: Record, + requestBody: BodyInit | undefined, + timeoutMs?: number, + abortSignal?: AbortSignal, + withCredentials?: boolean, + duplex?: "half" +): Promise => { + const signals: AbortSignal[] = []; + + // Add timeout signal + let timeoutAbortId: NodeJS.Timeout | undefined = undefined; + if (timeoutMs != null) { + const { signal, abortId } = getTimeoutSignal(timeoutMs); + timeoutAbortId = abortId; + signals.push(signal); + } + + // Add arbitrary signal + if (abortSignal != null) { + signals.push(abortSignal); + } + let newSignals = anySignal(signals); + const response = await fetchFn(url, { + method: method, + headers, + body: requestBody, + signal: newSignals, + credentials: withCredentials ? "include" : undefined, + // @ts-ignore + duplex, + }); + + if (timeoutAbortId != null) { + clearTimeout(timeoutAbortId); + } + + return response; +}; diff --git a/src/core/fetcher/requestWithRetries.ts b/src/core/fetcher/requestWithRetries.ts new file mode 100644 index 0000000..ff5dc3b --- /dev/null +++ b/src/core/fetcher/requestWithRetries.ts @@ -0,0 +1,21 @@ +const INITIAL_RETRY_DELAY = 1; +const MAX_RETRY_DELAY = 60; +const DEFAULT_MAX_RETRIES = 2; + +export async function requestWithRetries( + requestFn: () => Promise, + maxRetries: number = DEFAULT_MAX_RETRIES +): Promise { + let response: Response = await requestFn(); + + for (let i = 0; i < maxRetries; ++i) { + if ([408, 409, 429].includes(response.status) || response.status >= 500) { + const delay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY); + await new Promise((resolve) => setTimeout(resolve, delay)); + response = await requestFn(); + } else { + break; + } + } + return response!; +} diff --git a/src/core/fetcher/signals.ts b/src/core/fetcher/signals.ts new file mode 100644 index 0000000..6c124ff --- /dev/null +++ b/src/core/fetcher/signals.ts @@ -0,0 +1,38 @@ +const TIMEOUT = "timeout"; + +export function getTimeoutSignal(timeoutMs: number): { signal: AbortSignal; abortId: NodeJS.Timeout } { + const controller = new AbortController(); + const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs); + return { signal: controller.signal, abortId }; +} + +/** + * Returns an abort signal that is getting aborted when + * at least one of the specified abort signals is aborted. + * + * Requires at least node.js 18. + */ +export function anySignal(...args: AbortSignal[] | [AbortSignal[]]): AbortSignal { + // Allowing signals to be passed either as array + // of signals or as multiple arguments. + const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args); + + const controller = new AbortController(); + + for (const signal of signals) { + if (signal.aborted) { + // Exiting early if one of the signals + // is already aborted. + controller.abort((signal as any)?.reason); + break; + } + + // Listening for signals and removing the listeners + // when at least one symbol is aborted. + signal.addEventListener("abort", () => controller.abort((signal as any)?.reason), { + signal: controller.signal, + }); + } + + return controller.signal; +} diff --git a/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts b/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts new file mode 100644 index 0000000..4d7b7d5 --- /dev/null +++ b/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts @@ -0,0 +1,256 @@ +import type { Writable } from "readable-stream"; +import { EventCallback, StreamWrapper } from "./chooseStreamWrapper"; + +export class Node18UniversalStreamWrapper + implements + StreamWrapper | Writable | WritableStream, ReadFormat> +{ + private readableStream: ReadableStream; + private reader: ReadableStreamDefaultReader; + private events: Record; + private paused: boolean; + private resumeCallback: ((value?: unknown) => void) | null; + private encoding: string | null; + + constructor(readableStream: ReadableStream) { + this.readableStream = readableStream; + this.reader = this.readableStream.getReader(); + this.events = { + data: [], + end: [], + error: [], + readable: [], + close: [], + pause: [], + resume: [], + }; + this.paused = false; + this.resumeCallback = null; + this.encoding = null; + } + + public on(event: string, callback: EventCallback): void { + this.events[event]?.push(callback); + } + + public off(event: string, callback: EventCallback): void { + this.events[event] = this.events[event]?.filter((cb) => cb !== callback); + } + + public pipe( + dest: Node18UniversalStreamWrapper | Writable | WritableStream + ): Node18UniversalStreamWrapper | Writable | WritableStream { + this.on("data", async (chunk) => { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._write(chunk); + } else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.write(chunk).then(() => writer.releaseLock()); + } else { + dest.write(chunk); + } + }); + + this.on("end", async () => { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._end(); + } else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.close(); + } else { + dest.end(); + } + }); + + this.on("error", async (error) => { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._error(error); + } else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.abort(error); + } else { + dest.destroy(error); + } + }); + + this._startReading(); + + return dest; + } + + public pipeTo( + dest: Node18UniversalStreamWrapper | Writable | WritableStream + ): Node18UniversalStreamWrapper | Writable | WritableStream { + return this.pipe(dest); + } + + public unpipe(dest: Node18UniversalStreamWrapper | Writable | WritableStream): void { + this.off("data", async (chunk) => { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._write(chunk); + } else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.write(chunk).then(() => writer.releaseLock()); + } else { + dest.write(chunk); + } + }); + + this.off("end", async () => { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._end(); + } else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.close(); + } else { + dest.end(); + } + }); + + this.off("error", async (error) => { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._error(error); + } else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.abort(error); + } else { + dest.destroy(error); + } + }); + } + + public destroy(error?: Error): void { + this.reader + .cancel(error) + .then(() => { + this._emit("close"); + }) + .catch((err) => { + this._emit("error", err); + }); + } + + public pause(): void { + this.paused = true; + this._emit("pause"); + } + + public resume(): void { + if (this.paused) { + this.paused = false; + this._emit("resume"); + if (this.resumeCallback) { + this.resumeCallback(); + this.resumeCallback = null; + } + } + } + + public get isPaused(): boolean { + return this.paused; + } + + public async read(): Promise { + if (this.paused) { + await new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = await this.reader.read(); + + if (done) { + return undefined; + } + return value; + } + + public setEncoding(encoding: string): void { + this.encoding = encoding; + } + + public async text(): Promise { + const chunks: ReadFormat[] = []; + + while (true) { + const { done, value } = await this.reader.read(); + if (done) { + break; + } + if (value) { + chunks.push(value); + } + } + + const decoder = new TextDecoder(this.encoding || "utf-8"); + return decoder.decode(await new Blob(chunks).arrayBuffer()); + } + + public async json(): Promise { + const text = await this.text(); + return JSON.parse(text); + } + + private _write(chunk: ReadFormat): void { + this._emit("data", chunk); + } + + private _end(): void { + this._emit("end"); + } + + private _error(error: any): void { + this._emit("error", error); + } + + private _emit(event: string, data?: any): void { + if (this.events[event]) { + for (const callback of this.events[event] || []) { + callback(data); + } + } + } + + private async _startReading(): Promise { + try { + this._emit("readable"); + while (true) { + if (this.paused) { + await new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = await this.reader.read(); + if (done) { + this._emit("end"); + this._emit("close"); + break; + } + if (value) { + this._emit("data", value); + } + } + } catch (error) { + this._emit("error", error); + } + } + + [Symbol.asyncIterator](): AsyncIterableIterator { + return { + next: async () => { + if (this.paused) { + await new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = await this.reader.read(); + if (done) { + return { done: true, value: undefined }; + } + return { done: false, value }; + }, + [Symbol.asyncIterator]() { + return this; + }, + }; + } +} diff --git a/src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts b/src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts new file mode 100644 index 0000000..ba5f727 --- /dev/null +++ b/src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts @@ -0,0 +1,106 @@ +import type { Readable, Writable } from "readable-stream"; +import { EventCallback, StreamWrapper } from "./chooseStreamWrapper"; + +export class NodePre18StreamWrapper implements StreamWrapper { + private readableStream: Readable; + private encoding: string | undefined; + + constructor(readableStream: Readable) { + this.readableStream = readableStream; + } + + public on(event: string, callback: EventCallback): void { + this.readableStream.on(event, callback); + } + + public off(event: string, callback: EventCallback): void { + this.readableStream.off(event, callback); + } + + public pipe(dest: Writable): Writable { + this.readableStream.pipe(dest); + return dest; + } + + public pipeTo(dest: Writable): Writable { + return this.pipe(dest); + } + + public unpipe(dest?: Writable): void { + if (dest) { + this.readableStream.unpipe(dest); + } else { + this.readableStream.unpipe(); + } + } + + public destroy(error?: Error): void { + this.readableStream.destroy(error); + } + + public pause(): void { + this.readableStream.pause(); + } + + public resume(): void { + this.readableStream.resume(); + } + + public get isPaused(): boolean { + return this.readableStream.isPaused(); + } + + public async read(): Promise { + return new Promise((resolve, reject) => { + const chunk = this.readableStream.read(); + if (chunk) { + resolve(chunk); + } else { + this.readableStream.once("readable", () => { + const chunk = this.readableStream.read(); + resolve(chunk); + }); + this.readableStream.once("error", reject); + } + }); + } + + public setEncoding(encoding?: string): void { + this.readableStream.setEncoding(encoding as BufferEncoding); + this.encoding = encoding; + } + + public async text(): Promise { + const chunks: Uint8Array[] = []; + const encoder = new TextEncoder(); + this.readableStream.setEncoding((this.encoding || "utf-8") as BufferEncoding); + + for await (const chunk of this.readableStream) { + chunks.push(encoder.encode(chunk)); + } + + const decoder = new TextDecoder(this.encoding || "utf-8"); + return decoder.decode(Buffer.concat(chunks)); + } + + public async json(): Promise { + const text = await this.text(); + return JSON.parse(text); + } + + public [Symbol.asyncIterator](): AsyncIterableIterator { + const readableStream = this.readableStream; + const iterator = readableStream[Symbol.asyncIterator](); + + // Create and return an async iterator that yields buffers + return { + async next(): Promise> { + const { value, done } = await iterator.next(); + return { value: value as Buffer, done }; + }, + [Symbol.asyncIterator]() { + return this; + }, + }; + } +} diff --git a/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts b/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts new file mode 100644 index 0000000..263af00 --- /dev/null +++ b/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts @@ -0,0 +1,243 @@ +import { StreamWrapper } from "./chooseStreamWrapper"; + +type EventCallback = (data?: any) => void; + +export class UndiciStreamWrapper + implements StreamWrapper | WritableStream, ReadFormat> +{ + private readableStream: ReadableStream; + private reader: ReadableStreamDefaultReader; + private events: Record; + private paused: boolean; + private resumeCallback: ((value?: unknown) => void) | null; + private encoding: string | null; + + constructor(readableStream: ReadableStream) { + this.readableStream = readableStream; + this.reader = this.readableStream.getReader(); + this.events = { + data: [], + end: [], + error: [], + readable: [], + close: [], + pause: [], + resume: [], + }; + this.paused = false; + this.resumeCallback = null; + this.encoding = null; + } + + public on(event: string, callback: EventCallback): void { + this.events[event]?.push(callback); + } + + public off(event: string, callback: EventCallback): void { + this.events[event] = this.events[event]?.filter((cb) => cb !== callback); + } + + public pipe( + dest: UndiciStreamWrapper | WritableStream + ): UndiciStreamWrapper | WritableStream { + this.on("data", (chunk) => { + if (dest instanceof UndiciStreamWrapper) { + dest._write(chunk); + } else { + const writer = dest.getWriter(); + writer.write(chunk).then(() => writer.releaseLock()); + } + }); + + this.on("end", () => { + if (dest instanceof UndiciStreamWrapper) { + dest._end(); + } else { + const writer = dest.getWriter(); + writer.close(); + } + }); + + this.on("error", (error) => { + if (dest instanceof UndiciStreamWrapper) { + dest._error(error); + } else { + const writer = dest.getWriter(); + writer.abort(error); + } + }); + + this._startReading(); + + return dest; + } + + public pipeTo( + dest: UndiciStreamWrapper | WritableStream + ): UndiciStreamWrapper | WritableStream { + return this.pipe(dest); + } + + public unpipe(dest: UndiciStreamWrapper | WritableStream): void { + this.off("data", (chunk) => { + if (dest instanceof UndiciStreamWrapper) { + dest._write(chunk); + } else { + const writer = dest.getWriter(); + writer.write(chunk).then(() => writer.releaseLock()); + } + }); + + this.off("end", () => { + if (dest instanceof UndiciStreamWrapper) { + dest._end(); + } else { + const writer = dest.getWriter(); + writer.close(); + } + }); + + this.off("error", (error) => { + if (dest instanceof UndiciStreamWrapper) { + dest._error(error); + } else { + const writer = dest.getWriter(); + writer.abort(error); + } + }); + } + + public destroy(error?: Error): void { + this.reader + .cancel(error) + .then(() => { + this._emit("close"); + }) + .catch((err) => { + this._emit("error", err); + }); + } + + public pause(): void { + this.paused = true; + this._emit("pause"); + } + + public resume(): void { + if (this.paused) { + this.paused = false; + this._emit("resume"); + if (this.resumeCallback) { + this.resumeCallback(); + this.resumeCallback = null; + } + } + } + + public get isPaused(): boolean { + return this.paused; + } + + public async read(): Promise { + if (this.paused) { + await new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = await this.reader.read(); + if (done) { + return undefined; + } + return value; + } + + public setEncoding(encoding: string): void { + this.encoding = encoding; + } + + public async text(): Promise { + const chunks: BlobPart[] = []; + + while (true) { + const { done, value } = await this.reader.read(); + if (done) { + break; + } + if (value) { + chunks.push(value); + } + } + + const decoder = new TextDecoder(this.encoding || "utf-8"); + return decoder.decode(await new Blob(chunks).arrayBuffer()); + } + + public async json(): Promise { + const text = await this.text(); + return JSON.parse(text); + } + + private _write(chunk: ReadFormat): void { + this._emit("data", chunk); + } + + private _end(): void { + this._emit("end"); + } + + private _error(error: any): void { + this._emit("error", error); + } + + private _emit(event: string, data?: any): void { + if (this.events[event]) { + for (const callback of this.events[event] || []) { + callback(data); + } + } + } + + private async _startReading(): Promise { + try { + this._emit("readable"); + while (true) { + if (this.paused) { + await new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = await this.reader.read(); + if (done) { + this._emit("end"); + this._emit("close"); + break; + } + if (value) { + this._emit("data", value); + } + } + } catch (error) { + this._emit("error", error); + } + } + + [Symbol.asyncIterator](): AsyncIterableIterator { + return { + next: async () => { + if (this.paused) { + await new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = await this.reader.read(); + if (done) { + return { done: true, value: undefined }; + } + return { done: false, value }; + }, + [Symbol.asyncIterator]() { + return this; + }, + }; + } +} diff --git a/src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts b/src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts new file mode 100644 index 0000000..2abd6b2 --- /dev/null +++ b/src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts @@ -0,0 +1,33 @@ +import type { Readable } from "readable-stream"; +import { RUNTIME } from "../../runtime"; + +export type EventCallback = (data?: any) => void; + +export interface StreamWrapper { + setEncoding(encoding?: string): void; + on(event: string, callback: EventCallback): void; + off(event: string, callback: EventCallback): void; + pipe(dest: WritableStream): WritableStream; + pipeTo(dest: WritableStream): WritableStream; + unpipe(dest?: WritableStream): void; + destroy(error?: Error): void; + pause(): void; + resume(): void; + get isPaused(): boolean; + read(): Promise; + text(): Promise; + json(): Promise; + [Symbol.asyncIterator](): AsyncIterableIterator; +} + +export async function chooseStreamWrapper(responseBody: any): Promise>> { + if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) { + return new (await import("./Node18UniversalStreamWrapper")).Node18UniversalStreamWrapper( + responseBody as ReadableStream + ); + } else if (RUNTIME.type !== "node" && typeof fetch === "function") { + return new (await import("./UndiciStreamWrapper")).UndiciStreamWrapper(responseBody as ReadableStream); + } else { + return new (await import("./NodePre18StreamWrapper")).NodePre18StreamWrapper(responseBody as Readable); + } +} diff --git a/src/core/form-data-utils/FormDataWrapper.ts b/src/core/form-data-utils/FormDataWrapper.ts new file mode 100644 index 0000000..67b5ebd --- /dev/null +++ b/src/core/form-data-utils/FormDataWrapper.ts @@ -0,0 +1,177 @@ +import { RUNTIME } from "../runtime"; + +export type MaybePromise = Promise | T; + +interface FormDataRequest { + body: Body; + headers: Record; + duplex?: "half"; +} + +function isNamedValue(value: unknown): value is { name: string } { + return typeof value === "object" && value != null && "name" in value; +} + +export interface CrossPlatformFormData { + setup(): Promise; + + append(key: string, value: unknown): void; + + appendFile(key: string, value: unknown, fileName?: string): Promise; + + getRequest(): MaybePromise>; +} + +export async function newFormData(): Promise { + let formdata: CrossPlatformFormData; + if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) { + formdata = new Node18FormData(); + } else if (RUNTIME.type === "node") { + formdata = new Node16FormData(); + } else { + formdata = new WebFormData(); + } + await formdata.setup(); + return formdata; +} + +export type Node18FormDataFd = + | { + append(name: string, value: unknown, fileName?: string): void; + } + | undefined; + +/** + * Form Data Implementation for Node.js 18+ + */ +export class Node18FormData implements CrossPlatformFormData { + private fd: Node18FormDataFd; + + public async setup() { + this.fd = new (await import("formdata-node")).FormData(); + } + + public append(key: string, value: any): void { + this.fd?.append(key, value); + } + + public async appendFile(key: string, value: unknown, fileName?: string): Promise { + if (fileName == null && isNamedValue(value)) { + fileName = value.name; + } + + if (value instanceof Blob) { + this.fd?.append(key, value, fileName); + } else { + this.fd?.append(key, { + type: undefined, + name: fileName, + [Symbol.toStringTag]: "File", + stream() { + return value; + }, + }); + } + } + + public async getRequest(): Promise> { + const encoder = new (await import("form-data-encoder")).FormDataEncoder(this.fd as any); + return { + body: (await import("readable-stream")).Readable.from(encoder), + headers: encoder.headers, + duplex: "half", + }; + } +} + +export type Node16FormDataFd = + | { + append( + name: string, + value: unknown, + options?: + | string + | { + header?: string | Headers; + knownLength?: number; + filename?: string; + filepath?: string; + contentType?: string; + } + ): void; + + getHeaders(): Record; + } + | undefined; + +/** + * Form Data Implementation for Node.js 16-18 + */ +export class Node16FormData implements CrossPlatformFormData { + private fd: Node16FormDataFd; + + public async setup(): Promise { + this.fd = new (await import("form-data")).default(); + } + + public append(key: string, value: any): void { + this.fd?.append(key, value); + } + + public async appendFile(key: string, value: unknown, fileName?: string): Promise { + if (fileName == null && isNamedValue(value)) { + fileName = value.name; + } + + let bufferedValue; + if (value instanceof Blob) { + bufferedValue = Buffer.from(await (value as any).arrayBuffer()); + } else { + bufferedValue = value; + } + + if (fileName == null) { + this.fd?.append(key, bufferedValue); + } else { + this.fd?.append(key, bufferedValue, { filename: fileName }); + } + } + + public getRequest(): FormDataRequest { + return { + body: this.fd, + headers: this.fd ? this.fd.getHeaders() : {}, + }; + } +} + +export type WebFormDataFd = { append(name: string, value: string | Blob, fileName?: string): void } | undefined; + +/** + * Form Data Implementation for Web + */ +export class WebFormData implements CrossPlatformFormData { + protected fd: WebFormDataFd; + + public async setup(): Promise { + this.fd = new FormData(); + } + + public append(key: string, value: any): void { + this.fd?.append(key, value); + } + + public async appendFile(key: string, value: any, fileName?: string): Promise { + if (fileName == null && isNamedValue(value)) { + fileName = value.name; + } + this.fd?.append(key, new Blob([value]), fileName); + } + + public getRequest(): FormDataRequest { + return { + body: this.fd, + headers: {}, + }; + } +} diff --git a/src/core/form-data-utils/index.ts b/src/core/form-data-utils/index.ts new file mode 100644 index 0000000..f210ac4 --- /dev/null +++ b/src/core/form-data-utils/index.ts @@ -0,0 +1 @@ +export * from "./FormDataWrapper"; diff --git a/src/core/index.ts b/src/core/index.ts new file mode 100644 index 0000000..b7edbb6 --- /dev/null +++ b/src/core/index.ts @@ -0,0 +1,4 @@ +export * from "./fetcher"; +export * from "./auth"; +export * from "./runtime"; +export * from "./form-data-utils"; diff --git a/src/core/runtime/index.ts b/src/core/runtime/index.ts new file mode 100644 index 0000000..5c76dbb --- /dev/null +++ b/src/core/runtime/index.ts @@ -0,0 +1 @@ +export { RUNTIME } from "./runtime"; diff --git a/src/core/runtime/runtime.ts b/src/core/runtime/runtime.ts new file mode 100644 index 0000000..4d0687e --- /dev/null +++ b/src/core/runtime/runtime.ts @@ -0,0 +1,126 @@ +interface DenoGlobal { + version: { + deno: string; + }; +} + +interface BunGlobal { + version: string; +} + +declare const Deno: DenoGlobal; +declare const Bun: BunGlobal; + +/** + * A constant that indicates whether the environment the code is running is a Web Browser. + */ +const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined"; + +/** + * A constant that indicates whether the environment the code is running is a Web Worker. + */ +const isWebWorker = + typeof self === "object" && + // @ts-ignore + typeof self?.importScripts === "function" && + (self.constructor?.name === "DedicatedWorkerGlobalScope" || + self.constructor?.name === "ServiceWorkerGlobalScope" || + self.constructor?.name === "SharedWorkerGlobalScope"); + +/** + * A constant that indicates whether the environment the code is running is Deno. + */ +const isDeno = + typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined"; + +/** + * A constant that indicates whether the environment the code is running is Bun.sh. + */ +const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined"; + +/** + * A constant that indicates whether the environment the code is running is Node.JS. + */ +const isNode = + typeof process !== "undefined" && + Boolean(process.version) && + Boolean(process.versions?.node) && + // Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions + !isDeno && + !isBun; + +/** + * A constant that indicates whether the environment the code is running is in React-Native. + * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js + */ +const isReactNative = typeof navigator !== "undefined" && navigator?.product === "ReactNative"; + +/** + * A constant that indicates whether the environment the code is running is Cloudflare. + * https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent + */ +const isCloudflare = typeof globalThis !== "undefined" && globalThis?.navigator?.userAgent === "Cloudflare-Workers"; + +/** + * A constant that indicates which environment and version the SDK is running in. + */ +export const RUNTIME: Runtime = evaluateRuntime(); + +export interface Runtime { + type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd"; + version?: string; + parsedVersion?: number; +} + +function evaluateRuntime(): Runtime { + if (isBrowser) { + return { + type: "browser", + version: window.navigator.userAgent, + }; + } + + if (isCloudflare) { + return { + type: "workerd", + }; + } + + if (isWebWorker) { + return { + type: "web-worker", + }; + } + + if (isDeno) { + return { + type: "deno", + version: Deno.version.deno, + }; + } + + if (isBun) { + return { + type: "bun", + version: Bun.version, + }; + } + + if (isNode) { + return { + type: "node", + version: process.versions.node, + parsedVersion: Number(process.versions.node.split(".")[0]), + }; + } + + if (isReactNative) { + return { + type: "react-native", + }; + } + + return { + type: "unknown", + }; +} diff --git a/src/environments.ts b/src/environments.ts new file mode 100644 index 0000000..f6b64e9 --- /dev/null +++ b/src/environments.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export const MoniteEnvironment = { + Sandbox: "https://api.sandbox.monite.com/v1", + EuProduction: "https://api.monite.com/v1", + NaProduction: "https://us.api.monite.com/v1", +} as const; + +export type MoniteEnvironment = + | typeof MoniteEnvironment.Sandbox + | typeof MoniteEnvironment.EuProduction + | typeof MoniteEnvironment.NaProduction; diff --git a/src/errors/MoniteError.ts b/src/errors/MoniteError.ts new file mode 100644 index 0000000..eaf7c93 --- /dev/null +++ b/src/errors/MoniteError.ts @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export class MoniteError extends Error { + readonly statusCode?: number; + readonly body?: unknown; + + constructor({ message, statusCode, body }: { message?: string; statusCode?: number; body?: unknown }) { + super(buildMessage({ message, statusCode, body })); + Object.setPrototypeOf(this, MoniteError.prototype); + if (statusCode != null) { + this.statusCode = statusCode; + } + + if (body !== undefined) { + this.body = body; + } + } +} + +function buildMessage({ + message, + statusCode, + body, +}: { + message: string | undefined; + statusCode: number | undefined; + body: unknown | undefined; +}): string { + let lines: string[] = []; + if (message != null) { + lines.push(message); + } + + if (statusCode != null) { + lines.push(`Status code: ${statusCode.toString()}`); + } + + if (body != null) { + lines.push(`Body: ${JSON.stringify(body, undefined, 2)}`); + } + + return lines.join("\n"); +} diff --git a/src/errors/MoniteTimeoutError.ts b/src/errors/MoniteTimeoutError.ts new file mode 100644 index 0000000..92e1de8 --- /dev/null +++ b/src/errors/MoniteTimeoutError.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export class MoniteTimeoutError extends Error { + constructor() { + super("Timeout"); + Object.setPrototypeOf(this, MoniteTimeoutError.prototype); + } +} diff --git a/src/errors/index.ts b/src/errors/index.ts new file mode 100644 index 0000000..8f63c9a --- /dev/null +++ b/src/errors/index.ts @@ -0,0 +1,2 @@ +export { MoniteError } from "./MoniteError"; +export { MoniteTimeoutError } from "./MoniteTimeoutError"; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..fa21f0c --- /dev/null +++ b/src/index.ts @@ -0,0 +1,4 @@ +export * as Monite from "./api"; +export { MoniteClient } from "./Client"; +export { MoniteEnvironment } from "./environments"; +export { MoniteError, MoniteTimeoutError } from "./errors"; diff --git a/src/version.ts b/src/version.ts new file mode 100644 index 0000000..231ca39 --- /dev/null +++ b/src/version.ts @@ -0,0 +1 @@ +export const SDK_VERSION = "0.1.0"; diff --git a/tests/custom.test.ts b/tests/custom.test.ts new file mode 100644 index 0000000..7f5e031 --- /dev/null +++ b/tests/custom.test.ts @@ -0,0 +1,13 @@ +/** + * This is a custom test file, if you wish to add more tests + * to your SDK. + * Be sure to mark this file in `.fernignore`. + * + * If you include example requests/responses in your fern definition, + * you will have tests automatically generated for you. + */ +describe("test", () => { + it("default", () => { + expect(true).toBe(true); + }); +}); diff --git a/tests/unit/auth/BasicAuth.test.ts b/tests/unit/auth/BasicAuth.test.ts new file mode 100644 index 0000000..fc35704 --- /dev/null +++ b/tests/unit/auth/BasicAuth.test.ts @@ -0,0 +1,22 @@ +import { BasicAuth } from "../../../src/core/auth/BasicAuth"; + +describe("BasicAuth", () => { + describe("toAuthorizationHeader", () => { + it("correctly converts to header", () => { + expect( + BasicAuth.toAuthorizationHeader({ + username: "username", + password: "password", + }) + ).toBe("Basic dXNlcm5hbWU6cGFzc3dvcmQ="); + }); + }); + describe("fromAuthorizationHeader", () => { + it("correctly parses header", () => { + expect(BasicAuth.fromAuthorizationHeader("Basic dXNlcm5hbWU6cGFzc3dvcmQ=")).toEqual({ + username: "username", + password: "password", + }); + }); + }); +}); diff --git a/tests/unit/auth/BearerToken.test.ts b/tests/unit/auth/BearerToken.test.ts new file mode 100644 index 0000000..7757b87 --- /dev/null +++ b/tests/unit/auth/BearerToken.test.ts @@ -0,0 +1,14 @@ +import { BearerToken } from "../../../src/core/auth/BearerToken"; + +describe("BearerToken", () => { + describe("toAuthorizationHeader", () => { + it("correctly converts to header", () => { + expect(BearerToken.toAuthorizationHeader("my-token")).toBe("Bearer my-token"); + }); + }); + describe("fromAuthorizationHeader", () => { + it("correctly parses header", () => { + expect(BearerToken.fromAuthorizationHeader("Bearer my-token")).toBe("my-token"); + }); + }); +}); diff --git a/tests/unit/fetcher/Fetcher.test.ts b/tests/unit/fetcher/Fetcher.test.ts new file mode 100644 index 0000000..0e14a8c --- /dev/null +++ b/tests/unit/fetcher/Fetcher.test.ts @@ -0,0 +1,25 @@ +import fetchMock from "fetch-mock-jest"; +import { Fetcher, fetcherImpl } from "../../../src/core/fetcher/Fetcher"; + +describe("Test fetcherImpl", () => { + it("should handle successful request", async () => { + const mockArgs: Fetcher.Args = { + url: "https://httpbin.org/post", + method: "POST", + headers: { "X-Test": "x-test-header" }, + body: { data: "test" }, + contentType: "application/json", + requestType: "json", + }; + + fetchMock.mock("https://httpbin.org/post", 200, { + response: JSON.stringify({ data: "test" }), + }); + + const result = await fetcherImpl(mockArgs); + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.body).toEqual({ data: "test" }); + } + }); +}); diff --git a/tests/unit/fetcher/createRequestUrl.test.ts b/tests/unit/fetcher/createRequestUrl.test.ts new file mode 100644 index 0000000..f2cd24b --- /dev/null +++ b/tests/unit/fetcher/createRequestUrl.test.ts @@ -0,0 +1,51 @@ +import { createRequestUrl } from "../../../src/core/fetcher/createRequestUrl"; + +describe("Test createRequestUrl", () => { + it("should return the base URL when no query parameters are provided", () => { + const baseUrl = "https://api.example.com"; + expect(createRequestUrl(baseUrl)).toBe(baseUrl); + }); + + it("should append simple query parameters", () => { + const baseUrl = "https://api.example.com"; + const queryParams = { key: "value", another: "param" }; + expect(createRequestUrl(baseUrl, queryParams)).toBe("https://api.example.com?key=value&another=param"); + }); + + it("should handle array query parameters", () => { + const baseUrl = "https://api.example.com"; + const queryParams = { items: ["a", "b", "c"] }; + expect(createRequestUrl(baseUrl, queryParams)).toBe("https://api.example.com?items=a&items=b&items=c"); + }); + + it("should handle object query parameters", () => { + const baseUrl = "https://api.example.com"; + const queryParams = { filter: { name: "John", age: 30 } }; + expect(createRequestUrl(baseUrl, queryParams)).toBe( + "https://api.example.com?filter%5Bname%5D=John&filter%5Bage%5D=30" + ); + }); + + it("should handle mixed types of query parameters", () => { + const baseUrl = "https://api.example.com"; + const queryParams = { + simple: "value", + array: ["x", "y"], + object: { key: "value" }, + }; + expect(createRequestUrl(baseUrl, queryParams)).toBe( + "https://api.example.com?simple=value&array=x&array=y&object%5Bkey%5D=value" + ); + }); + + it("should handle empty query parameters object", () => { + const baseUrl = "https://api.example.com"; + expect(createRequestUrl(baseUrl, {})).toBe(baseUrl); + }); + + it("should encode special characters in query parameters", () => { + const baseUrl = "https://api.example.com"; + const queryParams = { special: "a&b=c d" }; + expect(createRequestUrl(baseUrl, queryParams)).toBe("https://api.example.com?special=a%26b%3Dc%20d"); + }); +}); diff --git a/tests/unit/fetcher/getFetchFn.test.ts b/tests/unit/fetcher/getFetchFn.test.ts new file mode 100644 index 0000000..9b315ad --- /dev/null +++ b/tests/unit/fetcher/getFetchFn.test.ts @@ -0,0 +1,22 @@ +import { RUNTIME } from "../../../src/core/runtime"; +import { getFetchFn } from "../../../src/core/fetcher/getFetchFn"; + +describe("Test for getFetchFn", () => { + it("should get node-fetch function", async () => { + if (RUNTIME.type == "node") { + if (RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) { + expect(await getFetchFn()).toBe(fetch); + } else { + expect(await getFetchFn()).toEqual((await import("node-fetch")).default as any); + } + } + }); + + it("should get fetch function", async () => { + if (RUNTIME.type == "browser") { + const fetchFn = await getFetchFn(); + expect(typeof fetchFn).toBe("function"); + expect(fetchFn.name).toBe("fetch"); + } + }); +}); diff --git a/tests/unit/fetcher/getRequestBody.test.ts b/tests/unit/fetcher/getRequestBody.test.ts new file mode 100644 index 0000000..1b1462c --- /dev/null +++ b/tests/unit/fetcher/getRequestBody.test.ts @@ -0,0 +1,81 @@ +import { RUNTIME } from "../../../src/core/runtime"; +import { getRequestBody } from "../../../src/core/fetcher/getRequestBody"; + +if (RUNTIME.type === "browser") { + require("jest-fetch-mock").enableMocks(); +} + +describe("Test getRequestBody", () => { + it("should return FormData as is in Node environment", async () => { + if (RUNTIME.type === "node") { + const formData = new (await import("formdata-node")).FormData(); + formData.append("key", "value"); + const result = await getRequestBody({ + body: formData, + type: "file", + }); + expect(result).toBe(formData); + } + }); + + it("should stringify body if not FormData in Node environment", async () => { + if (RUNTIME.type === "node") { + const body = { key: "value" }; + const result = await getRequestBody({ + body, + type: "json", + }); + expect(result).toBe('{"key":"value"}'); + } + }); + + it("should return FormData in browser environment", async () => { + if (RUNTIME.type === "browser") { + const formData = new (await import("form-data")).default(); + formData.append("key", "value"); + const result = await getRequestBody({ + body: formData, + type: "file", + }); + expect(result).toBe(formData); + } + }); + + it("should stringify body if not FormData in browser environment", async () => { + if (RUNTIME.type === "browser") { + const body = { key: "value" }; + const result = await getRequestBody({ + body, + type: "json", + }); + expect(result).toBe('{"key":"value"}'); + } + }); + + it("should return the Uint8Array", async () => { + const input = new Uint8Array([1, 2, 3]); + const result = await getRequestBody({ + body: input, + type: "bytes", + }); + expect(result).toBe(input); + }); + + it("should return the input for content-type 'application/x-www-form-urlencoded'", async () => { + const input = "key=value&another=param"; + const result = await getRequestBody({ + body: input, + type: "other", + }); + expect(result).toBe(input); + }); + + it("should JSON stringify objects", async () => { + const input = { key: "value" }; + const result = await getRequestBody({ + body: input, + type: "json", + }); + expect(result).toBe('{"key":"value"}'); + }); +}); diff --git a/tests/unit/fetcher/getResponseBody.test.ts b/tests/unit/fetcher/getResponseBody.test.ts new file mode 100644 index 0000000..3510779 --- /dev/null +++ b/tests/unit/fetcher/getResponseBody.test.ts @@ -0,0 +1,68 @@ +import { RUNTIME } from "../../../src/core/runtime"; +import { getResponseBody } from "../../../src/core/fetcher/getResponseBody"; +import { chooseStreamWrapper } from "../../../src/core/fetcher/stream-wrappers/chooseStreamWrapper"; + +if (RUNTIME.type === "browser") { + require("jest-fetch-mock").enableMocks(); +} + +describe("Test getResponseBody", () => { + it("should handle blob response type", async () => { + const mockBlob = new Blob(["test"], { type: "text/plain" }); + const mockResponse = new Response(mockBlob); + const result = await getResponseBody(mockResponse, "blob"); + // @ts-expect-error + expect(result.constructor.name).toBe("Blob"); + }); + + it("should handle sse response type", async () => { + if (RUNTIME.type === "node") { + const mockStream = new ReadableStream(); + const mockResponse = new Response(mockStream); + const result = await getResponseBody(mockResponse, "sse"); + expect(result).toBe(mockStream); + } + }); + + it("should handle streaming response type", async () => { + if (RUNTIME.type === "node") { + const mockStream = new ReadableStream(); + const mockResponse = new Response(mockStream); + const result = await getResponseBody(mockResponse, "streaming"); + // need to reinstantiate string as a result of locked state in Readable Stream after registration with Response + expect(JSON.stringify(result)).toBe(JSON.stringify(await chooseStreamWrapper(new ReadableStream()))); + } + }); + + it("should handle text response type", async () => { + const mockResponse = new Response("test text"); + const result = await getResponseBody(mockResponse, "text"); + expect(result).toBe("test text"); + }); + + it("should handle JSON response", async () => { + const mockJson = { key: "value" }; + const mockResponse = new Response(JSON.stringify(mockJson)); + const result = await getResponseBody(mockResponse); + expect(result).toEqual(mockJson); + }); + + it("should handle empty response", async () => { + const mockResponse = new Response(""); + const result = await getResponseBody(mockResponse); + expect(result).toBeUndefined(); + }); + + it("should handle non-JSON response", async () => { + const mockResponse = new Response("invalid json"); + const result = await getResponseBody(mockResponse); + expect(result).toEqual({ + ok: false, + error: { + reason: "non-json", + statusCode: 200, + rawBody: "invalid json", + }, + }); + }); +}); diff --git a/tests/unit/fetcher/makeRequest.test.ts b/tests/unit/fetcher/makeRequest.test.ts new file mode 100644 index 0000000..5969d51 --- /dev/null +++ b/tests/unit/fetcher/makeRequest.test.ts @@ -0,0 +1,58 @@ +import { RUNTIME } from "../../../src/core/runtime"; +import { makeRequest } from "../../../src/core/fetcher/makeRequest"; + +if (RUNTIME.type === "browser") { + require("jest-fetch-mock").enableMocks(); +} + +describe("Test makeRequest", () => { + const mockPostUrl = "https://httpbin.org/post"; + const mockGetUrl = "https://httpbin.org/get"; + const mockHeaders = { "Content-Type": "application/json" }; + const mockBody = JSON.stringify({ key: "value" }); + + let mockFetch: jest.Mock; + + beforeEach(() => { + mockFetch = jest.fn(); + mockFetch.mockResolvedValue(new Response(JSON.stringify({ test: "successful" }), { status: 200 })); + }); + + it("should handle POST request correctly", async () => { + const response = await makeRequest(mockFetch, mockPostUrl, "POST", mockHeaders, mockBody); + const responseBody = await response.json(); + expect(responseBody).toEqual({ test: "successful" }); + expect(mockFetch).toHaveBeenCalledTimes(1); + const [calledUrl, calledOptions] = mockFetch.mock.calls[0]; + expect(calledUrl).toBe(mockPostUrl); + expect(calledOptions).toEqual( + expect.objectContaining({ + method: "POST", + headers: mockHeaders, + body: mockBody, + credentials: undefined, + }) + ); + expect(calledOptions.signal).toBeDefined(); + expect(calledOptions.signal).toBeInstanceOf(AbortSignal); + }); + + it("should handle GET request correctly", async () => { + const response = await makeRequest(mockFetch, mockGetUrl, "GET", mockHeaders, undefined); + const responseBody = await response.json(); + expect(responseBody).toEqual({ test: "successful" }); + expect(mockFetch).toHaveBeenCalledTimes(1); + const [calledUrl, calledOptions] = mockFetch.mock.calls[0]; + expect(calledUrl).toBe(mockGetUrl); + expect(calledOptions).toEqual( + expect.objectContaining({ + method: "GET", + headers: mockHeaders, + body: undefined, + credentials: undefined, + }) + ); + expect(calledOptions.signal).toBeDefined(); + expect(calledOptions.signal).toBeInstanceOf(AbortSignal); + }); +}); diff --git a/tests/unit/fetcher/requestWithRetries.test.ts b/tests/unit/fetcher/requestWithRetries.test.ts new file mode 100644 index 0000000..b53e043 --- /dev/null +++ b/tests/unit/fetcher/requestWithRetries.test.ts @@ -0,0 +1,85 @@ +import { RUNTIME } from "../../../src/core/runtime"; +import { requestWithRetries } from "../../../src/core/fetcher/requestWithRetries"; + +if (RUNTIME.type === "browser") { + require("jest-fetch-mock").enableMocks(); +} + +describe("Test exponential backoff", () => { + let mockFetch: jest.Mock; + let originalSetTimeout: typeof setTimeout; + + beforeEach(() => { + mockFetch = jest.fn(); + originalSetTimeout = global.setTimeout; + jest.useFakeTimers(); + }); + + afterEach(() => { + jest.useRealTimers(); + global.setTimeout = originalSetTimeout; + }); + + it("should retry on 408, 409, 429, 500+", async () => { + mockFetch + .mockResolvedValueOnce(new Response("", { status: 408 })) + .mockResolvedValueOnce(new Response("", { status: 409 })) + .mockResolvedValueOnce(new Response("", { status: 429 })) + .mockResolvedValueOnce(new Response("", { status: 500 })) + .mockResolvedValueOnce(new Response("", { status: 502 })) + .mockResolvedValueOnce(new Response("", { status: 200 })) + .mockResolvedValueOnce(new Response("", { status: 408 })); + + const responsePromise = requestWithRetries(() => mockFetch(), 10); + + await jest.advanceTimersByTimeAsync(10000); + const response = await responsePromise; + + expect(mockFetch).toHaveBeenCalledTimes(6); + expect(response.status).toBe(200); + }); + + it("should retry max 3 times", async () => { + mockFetch + .mockResolvedValueOnce(new Response("", { status: 408 })) + .mockResolvedValueOnce(new Response("", { status: 409 })) + .mockResolvedValueOnce(new Response("", { status: 429 })) + .mockResolvedValueOnce(new Response("", { status: 429 })); + + const responsePromise = requestWithRetries(() => mockFetch(), 3); + + await jest.advanceTimersByTimeAsync(10000); + const response = await responsePromise; + + expect(mockFetch).toHaveBeenCalledTimes(4); + expect(response.status).toBe(429); + }); + it("should not retry on 200", async () => { + mockFetch + .mockResolvedValueOnce(new Response("", { status: 200 })) + .mockResolvedValueOnce(new Response("", { status: 409 })); + + const responsePromise = requestWithRetries(() => mockFetch(), 3); + + await jest.advanceTimersByTimeAsync(10000); + const response = await responsePromise; + + expect(mockFetch).toHaveBeenCalledTimes(1); + expect(response.status).toBe(200); + }); + + it("should retry with exponential backoff timing", async () => { + mockFetch.mockResolvedValue(new Response("", { status: 500 })); + const maxRetries = 7; + const responsePromise = requestWithRetries(() => mockFetch(), maxRetries); + expect(mockFetch).toHaveBeenCalledTimes(1); + + const delays = [1, 2, 4, 8, 16, 32, 64]; + for (let i = 0; i < delays.length; i++) { + await jest.advanceTimersByTimeAsync(delays[i] as number); + expect(mockFetch).toHaveBeenCalledTimes(Math.min(i + 2, maxRetries + 1)); + } + const response = await responsePromise; + expect(response.status).toBe(500); + }); +}); diff --git a/tests/unit/fetcher/signals.test.ts b/tests/unit/fetcher/signals.test.ts new file mode 100644 index 0000000..9cabfa0 --- /dev/null +++ b/tests/unit/fetcher/signals.test.ts @@ -0,0 +1,69 @@ +import { anySignal, getTimeoutSignal } from "../../../src/core/fetcher/signals"; + +describe("Test getTimeoutSignal", () => { + beforeEach(() => { + jest.useFakeTimers(); + }); + + afterEach(() => { + jest.useRealTimers(); + }); + + it("should return an object with signal and abortId", () => { + const { signal, abortId } = getTimeoutSignal(1000); + + expect(signal).toBeDefined(); + expect(abortId).toBeDefined(); + expect(signal).toBeInstanceOf(AbortSignal); + expect(signal.aborted).toBe(false); + }); + + it("should create a signal that aborts after the specified timeout", () => { + const timeoutMs = 5000; + const { signal } = getTimeoutSignal(timeoutMs); + + expect(signal.aborted).toBe(false); + + jest.advanceTimersByTime(timeoutMs - 1); + expect(signal.aborted).toBe(false); + + jest.advanceTimersByTime(1); + expect(signal.aborted).toBe(true); + }); +}); + +describe("Test anySignal", () => { + it("should return an AbortSignal", () => { + const signal = anySignal(new AbortController().signal); + expect(signal).toBeInstanceOf(AbortSignal); + }); + + it("should abort when any of the input signals is aborted", () => { + const controller1 = new AbortController(); + const controller2 = new AbortController(); + const signal = anySignal(controller1.signal, controller2.signal); + + expect(signal.aborted).toBe(false); + controller1.abort(); + expect(signal.aborted).toBe(true); + }); + + it("should handle an array of signals", () => { + const controller1 = new AbortController(); + const controller2 = new AbortController(); + const signal = anySignal([controller1.signal, controller2.signal]); + + expect(signal.aborted).toBe(false); + controller2.abort(); + expect(signal.aborted).toBe(true); + }); + + it("should abort immediately if one of the input signals is already aborted", () => { + const controller1 = new AbortController(); + const controller2 = new AbortController(); + controller1.abort(); + + const signal = anySignal(controller1.signal, controller2.signal); + expect(signal.aborted).toBe(true); + }); +}); diff --git a/tests/unit/fetcher/stream-wrappers/Node18UniversalStreamWrapper.test.ts b/tests/unit/fetcher/stream-wrappers/Node18UniversalStreamWrapper.test.ts new file mode 100644 index 0000000..1dc9be0 --- /dev/null +++ b/tests/unit/fetcher/stream-wrappers/Node18UniversalStreamWrapper.test.ts @@ -0,0 +1,178 @@ +import { Node18UniversalStreamWrapper } from "../../../../src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper"; + +describe("Node18UniversalStreamWrapper", () => { + it("should set encoding to utf-8", async () => { + const rawStream = new ReadableStream(); + const stream = new Node18UniversalStreamWrapper(rawStream); + const setEncodingSpy = jest.spyOn(stream, "setEncoding"); + + stream.setEncoding("utf-8"); + + expect(setEncodingSpy).toHaveBeenCalledWith("utf-8"); + }); + + it("should register an event listener for readable", async () => { + const rawStream = new ReadableStream(); + const stream = new Node18UniversalStreamWrapper(rawStream); + const onSpy = jest.spyOn(stream, "on"); + + stream.on("readable", () => {}); + + expect(onSpy).toHaveBeenCalledWith("readable", expect.any(Function)); + }); + + it("should remove an event listener for data", async () => { + const rawStream = new ReadableStream(); + const stream = new Node18UniversalStreamWrapper(rawStream); + const offSpy = jest.spyOn(stream, "off"); + + const fn = () => {}; + stream.on("data", fn); + stream.off("data", fn); + + expect(offSpy).toHaveBeenCalledWith("data", expect.any(Function)); + }); + + it("should write to dest when calling pipe to writable stream", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + const stream = new Node18UniversalStreamWrapper(rawStream); + const dest = new WritableStream({ + write(chunk) { + expect(chunk).toEqual(new TextEncoder().encode("test")); + }, + }); + + stream.pipe(dest); + }); + + it("should write to dest when calling pipe to node writable stream", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + const stream = new Node18UniversalStreamWrapper(rawStream); + const dest = new (await import("readable-stream")).Writable({ + write(chunk, encoding, callback) { + expect(chunk.toString()).toEqual("test"); + callback(); + }, + }); + + stream.pipe(dest); + }); + + it("should write nothing when calling pipe and unpipe", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + const stream = new Node18UniversalStreamWrapper(rawStream); + const buffer: Uint8Array[] = []; + const dest = new WritableStream({ + write(chunk) { + buffer.push(chunk); + }, + }); + + stream.pipe(dest); + stream.unpipe(dest); + expect(buffer).toEqual([]); + }); + + it("should destroy the stream", async () => { + const rawStream = new ReadableStream(); + const stream = new Node18UniversalStreamWrapper(rawStream); + const destroySpy = jest.spyOn(stream, "destroy"); + + stream.destroy(); + + expect(destroySpy).toHaveBeenCalled(); + }); + + it("should pause and resume the stream", async () => { + const rawStream = new ReadableStream(); + const stream = new Node18UniversalStreamWrapper(rawStream); + const pauseSpy = jest.spyOn(stream, "pause"); + const resumeSpy = jest.spyOn(stream, "resume"); + + expect(stream.isPaused).toBe(false); + stream.pause(); + expect(stream.isPaused).toBe(true); + stream.resume(); + + expect(pauseSpy).toHaveBeenCalled(); + expect(resumeSpy).toHaveBeenCalled(); + }); + + it("should read the stream", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + const stream = new Node18UniversalStreamWrapper(rawStream); + + expect(await stream.read()).toEqual(new TextEncoder().encode("test")); + expect(await stream.read()).toEqual(new TextEncoder().encode("test")); + }); + + it("should read the stream as text", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + const stream = new Node18UniversalStreamWrapper(rawStream); + + const data = await stream.text(); + + expect(data).toEqual("testtest"); + }); + + it("should read the stream as json", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode(JSON.stringify({ test: "test" }))); + controller.close(); + }, + }); + const stream = new Node18UniversalStreamWrapper(rawStream); + + const data = await stream.json(); + + expect(data).toEqual({ test: "test" }); + }); + + it("should allow use with async iteratable stream", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + let data = ""; + const stream = new Node18UniversalStreamWrapper(rawStream); + for await (const chunk of stream) { + data += new TextDecoder().decode(chunk); + } + + expect(data).toEqual("testtest"); + }); +}); diff --git a/tests/unit/fetcher/stream-wrappers/NodePre18StreamWrapper.test.ts b/tests/unit/fetcher/stream-wrappers/NodePre18StreamWrapper.test.ts new file mode 100644 index 0000000..0c99d3b --- /dev/null +++ b/tests/unit/fetcher/stream-wrappers/NodePre18StreamWrapper.test.ts @@ -0,0 +1,124 @@ +import { NodePre18StreamWrapper } from "../../../../src/core/fetcher/stream-wrappers/NodePre18StreamWrapper"; + +describe("NodePre18StreamWrapper", () => { + it("should set encoding to utf-8", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + const setEncodingSpy = jest.spyOn(stream, "setEncoding"); + + stream.setEncoding("utf-8"); + + expect(setEncodingSpy).toHaveBeenCalledWith("utf-8"); + }); + + it("should register an event listener for readable", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + const onSpy = jest.spyOn(stream, "on"); + + stream.on("readable", () => {}); + + expect(onSpy).toHaveBeenCalledWith("readable", expect.any(Function)); + }); + + it("should remove an event listener for data", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + const offSpy = jest.spyOn(stream, "off"); + + const fn = () => {}; + stream.on("data", fn); + stream.off("data", fn); + + expect(offSpy).toHaveBeenCalledWith("data", expect.any(Function)); + }); + + it("should write to dest when calling pipe to node writable stream", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + const dest = new (await import("readable-stream")).Writable({ + write(chunk, encoding, callback) { + expect(chunk.toString()).toEqual("test"); + callback(); + }, + }); + + stream.pipe(dest); + }); + + it("should write nothing when calling pipe and unpipe", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + const buffer: Uint8Array[] = []; + const dest = new (await import("readable-stream")).Writable({ + write(chunk, encoding, callback) { + buffer.push(chunk); + callback(); + }, + }); + stream.pipe(dest); + stream.unpipe(); + + expect(buffer).toEqual([]); + }); + + it("should destroy the stream", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + const destroySpy = jest.spyOn(stream, "destroy"); + + stream.destroy(); + + expect(destroySpy).toHaveBeenCalledWith(); + }); + + it("should pause the stream and resume", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + const pauseSpy = jest.spyOn(stream, "pause"); + + stream.pause(); + expect(stream.isPaused).toBe(true); + stream.resume(); + expect(stream.isPaused).toBe(false); + + expect(pauseSpy).toHaveBeenCalledWith(); + }); + + it("should read the stream", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + + expect(await stream.read()).toEqual("test"); + expect(await stream.read()).toEqual("test"); + }); + + it("should read the stream as text", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + const stream = new NodePre18StreamWrapper(rawStream); + + const data = await stream.text(); + + expect(data).toEqual("testtest"); + }); + + it("should read the stream as json", async () => { + const rawStream = (await import("readable-stream")).Readable.from([JSON.stringify({ test: "test" })]); + const stream = new NodePre18StreamWrapper(rawStream); + + const data = await stream.json(); + + expect(data).toEqual({ test: "test" }); + }); + + it("should allow use with async iteratable stream", async () => { + const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]); + let data = ""; + const stream = new NodePre18StreamWrapper(rawStream); + for await (const chunk of stream) { + data += chunk; + } + + expect(data).toEqual("testtest"); + }); +}); diff --git a/tests/unit/fetcher/stream-wrappers/UndiciStreamWrapper.test.ts b/tests/unit/fetcher/stream-wrappers/UndiciStreamWrapper.test.ts new file mode 100644 index 0000000..1d171ce --- /dev/null +++ b/tests/unit/fetcher/stream-wrappers/UndiciStreamWrapper.test.ts @@ -0,0 +1,153 @@ +import { UndiciStreamWrapper } from "../../../../src/core/fetcher/stream-wrappers/UndiciStreamWrapper"; + +describe("UndiciStreamWrapper", () => { + it("should set encoding to utf-8", async () => { + const rawStream = new ReadableStream(); + const stream = new UndiciStreamWrapper(rawStream); + const setEncodingSpy = jest.spyOn(stream, "setEncoding"); + + stream.setEncoding("utf-8"); + + expect(setEncodingSpy).toHaveBeenCalledWith("utf-8"); + }); + + it("should register an event listener for readable", async () => { + const rawStream = new ReadableStream(); + const stream = new UndiciStreamWrapper(rawStream); + const onSpy = jest.spyOn(stream, "on"); + + stream.on("readable", () => {}); + + expect(onSpy).toHaveBeenCalledWith("readable", expect.any(Function)); + }); + + it("should remove an event listener for data", async () => { + const rawStream = new ReadableStream(); + const stream = new UndiciStreamWrapper(rawStream); + const offSpy = jest.spyOn(stream, "off"); + + const fn = () => {}; + stream.on("data", fn); + stream.off("data", fn); + + expect(offSpy).toHaveBeenCalledWith("data", expect.any(Function)); + }); + + it("should write to dest when calling pipe to writable stream", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + const stream = new UndiciStreamWrapper(rawStream); + const dest = new WritableStream({ + write(chunk) { + expect(chunk).toEqual(new TextEncoder().encode("test")); + }, + }); + + stream.pipe(dest); + }); + + it("should write nothing when calling pipe and unpipe", async () => { + const rawStream = new ReadableStream(); + const stream = new UndiciStreamWrapper(rawStream); + const buffer: Uint8Array[] = []; + const dest = new WritableStream({ + write(chunk) { + buffer.push(chunk); + }, + }); + stream.pipe(dest); + stream.unpipe(dest); + + expect(buffer).toEqual([]); + }); + + it("should destroy the stream", async () => { + const rawStream = new ReadableStream(); + const stream = new UndiciStreamWrapper(rawStream); + const destroySpy = jest.spyOn(stream, "destroy"); + + stream.destroy(); + + expect(destroySpy).toHaveBeenCalled(); + }); + + it("should pause and resume the stream", async () => { + const rawStream = new ReadableStream(); + const stream = new UndiciStreamWrapper(rawStream); + const pauseSpy = jest.spyOn(stream, "pause"); + const resumeSpy = jest.spyOn(stream, "resume"); + + expect(stream.isPaused).toBe(false); + stream.pause(); + expect(stream.isPaused).toBe(true); + stream.resume(); + + expect(pauseSpy).toHaveBeenCalled(); + expect(resumeSpy).toHaveBeenCalled(); + }); + + it("should read the stream", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + const stream = new UndiciStreamWrapper(rawStream); + + expect(await stream.read()).toEqual(new TextEncoder().encode("test")); + expect(await stream.read()).toEqual(new TextEncoder().encode("test")); + }); + + it("should read the stream as text", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + const stream = new UndiciStreamWrapper(rawStream); + + const data = await stream.text(); + + expect(data).toEqual("testtest"); + }); + + it("should read the stream as json", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode(JSON.stringify({ test: "test" }))); + controller.close(); + }, + }); + const stream = new UndiciStreamWrapper(rawStream); + + const data = await stream.json(); + + expect(data).toEqual({ test: "test" }); + }); + + it("should allow use with async iteratable stream", async () => { + const rawStream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode("test")); + controller.enqueue(new TextEncoder().encode("test")); + controller.close(); + }, + }); + let data = ""; + const stream = new UndiciStreamWrapper(rawStream); + for await (const chunk of stream) { + data += new TextDecoder().decode(chunk); + } + + expect(data).toEqual("testtest"); + }); +}); diff --git a/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts b/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts new file mode 100644 index 0000000..17cf37a --- /dev/null +++ b/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts @@ -0,0 +1,43 @@ +import { RUNTIME } from "../../../../src/core/runtime"; +import { chooseStreamWrapper } from "../../../../src/core/fetcher/stream-wrappers/chooseStreamWrapper"; +import { Node18UniversalStreamWrapper } from "../../../../src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper"; +import { NodePre18StreamWrapper } from "../../../../src/core/fetcher/stream-wrappers/NodePre18StreamWrapper"; +import { UndiciStreamWrapper } from "../../../../src/core/fetcher/stream-wrappers/UndiciStreamWrapper"; + +describe("chooseStreamWrapper", () => { + beforeEach(() => { + RUNTIME.type = "unknown"; + RUNTIME.parsedVersion = 0; + }); + + it('should return a Node18UniversalStreamWrapper when RUNTIME.type is "node" and RUNTIME.parsedVersion is not null and RUNTIME.parsedVersion is greater than or equal to 18', async () => { + const expected = new Node18UniversalStreamWrapper(new ReadableStream()); + RUNTIME.type = "node"; + RUNTIME.parsedVersion = 18; + + const result = await chooseStreamWrapper(new ReadableStream()); + + expect(JSON.stringify(result)).toBe(JSON.stringify(expected)); + }); + + it('should return a NodePre18StreamWrapper when RUNTIME.type is "node" and RUNTIME.parsedVersion is not null and RUNTIME.parsedVersion is less than 18', async () => { + const stream = await import("readable-stream"); + const expected = new NodePre18StreamWrapper(new stream.Readable()); + + RUNTIME.type = "node"; + RUNTIME.parsedVersion = 16; + + const result = await chooseStreamWrapper(new stream.Readable()); + + expect(JSON.stringify(result)).toEqual(JSON.stringify(expected)); + }); + + it('should return a Undici when RUNTIME.type is not "node"', async () => { + const expected = new UndiciStreamWrapper(new ReadableStream()); + RUNTIME.type = "browser"; + + const result = await chooseStreamWrapper(new ReadableStream()); + + expect(JSON.stringify(result)).toEqual(JSON.stringify(expected)); + }); +}); diff --git a/tests/unit/fetcher/stream-wrappers/webpack.test.ts b/tests/unit/fetcher/stream-wrappers/webpack.test.ts new file mode 100644 index 0000000..557db6d --- /dev/null +++ b/tests/unit/fetcher/stream-wrappers/webpack.test.ts @@ -0,0 +1,38 @@ +import webpack from "webpack"; + +describe("test env compatibility", () => { + test("webpack", () => { + return new Promise((resolve, reject) => { + webpack( + { + mode: "production", + entry: "./src/index.ts", + module: { + rules: [ + { + test: /\.tsx?$/, + use: "ts-loader", + exclude: /node_modules/, + }, + ], + }, + resolve: { + extensions: [".tsx", ".ts", ".js"], + }, + }, + (err, stats) => { + try { + expect(err).toBe(null); + if (stats?.hasErrors()) { + console.log(stats?.toString()); + } + expect(stats?.hasErrors()).toBe(false); + resolve(); + } catch (error) { + reject(error); + } + } + ); + }); + }, 60_000); +}); diff --git a/tests/unit/form-data-utils/formDataWrapper.test.ts b/tests/unit/form-data-utils/formDataWrapper.test.ts new file mode 100644 index 0000000..9af30c9 --- /dev/null +++ b/tests/unit/form-data-utils/formDataWrapper.test.ts @@ -0,0 +1,127 @@ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +import { Node18FormData, WebFormData } from "../../../src/core/form-data-utils/FormDataWrapper"; + +describe("CrossPlatformFormData", () => { + describe("Node18FormData", () => { + let formData: any; + + beforeEach(async () => { + formData = new Node18FormData(); + await formData.setup(); + }); + + it("should append a Readable stream with a specified filename", async () => { + const value = (await import("readable-stream")).Readable.from(["file content"]); + const filename = "testfile.txt"; + + await formData.appendFile("file", value, filename); + + const request = await formData.getRequest(); + const decoder = new TextDecoder("utf-8"); + let data = ""; + for await (const chunk of request.body) { + data += decoder.decode(chunk); + } + expect(data).toContain(filename); + }); + + it("should append a Blob with a specified filename", async () => { + const value = new Blob(["file content"], { type: "text/plain" }); + const filename = "testfile.txt"; + + await formData.appendFile("file", value, filename); + + const request = await formData.getRequest(); + const decoder = new TextDecoder("utf-8"); + let data = ""; + for await (const chunk of request.body) { + data += decoder.decode(chunk); + } + expect(data).toContain(filename); + }); + + it("should append a File with a specified filename", async () => { + const filename = "testfile.txt"; + // @ts-expect-error + const value = new (await import("buffer")).File(["file content"], filename); + + await formData.appendFile("file", value); + + const request = await formData.getRequest(); + const decoder = new TextDecoder("utf-8"); + let data = ""; + for await (const chunk of request.body) { + data += decoder.decode(chunk); + } + expect(data).toContain("testfile.txt"); + }); + + it("should append a File with an explicit filename", async () => { + const filename = "testfile.txt"; + // @ts-expect-error + const value = new (await import("buffer")).File(["file content"], filename); + + await formData.appendFile("file", value, "test.txt"); + + const request = await formData.getRequest(); + const decoder = new TextDecoder("utf-8"); + let data = ""; + for await (const chunk of request.body) { + data += decoder.decode(chunk); + } + expect(data).toContain("test.txt"); + }); + }); + + describe("WebFormData", () => { + let formData: any; + + beforeEach(async () => { + formData = new WebFormData(); + await formData.setup(); + }); + + it("should append a Readable stream with a specified filename", async () => { + const value = (await import("readable-stream")).Readable.from(["file content"]); + const filename = "testfile.txt"; + + await formData.appendFile("file", value, filename); + + const request = formData.getRequest(); + expect(request.body.get("file").name).toBe(filename); + }); + + it("should append a Blob with a specified filename", async () => { + const value = new Blob(["file content"], { type: "text/plain" }); + const filename = "testfile.txt"; + + await formData.appendFile("file", value, filename); + + const request = formData.getRequest(); + + expect(request.body.get("file").name).toBe(filename); + }); + + it("should append a File with a specified filename", async () => { + const filename = "testfile.txt"; + // @ts-expect-error + const value = new (await import("buffer")).File(["file content"], filename); + + await formData.appendFile("file", value); + + const request = formData.getRequest(); + expect(request.body.get("file").name).toBe(filename); + }); + + it("should append a File with an explicit filename", async () => { + const filename = "testfile.txt"; + // @ts-expect-error + const value = new (await import("buffer")).File(["file content"], filename); + + await formData.appendFile("file", value, "test.txt"); + + const request = formData.getRequest(); + expect(request.body.get("file").name).toBe("test.txt"); + }); + }); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..538c94f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "extendedDiagnostics": true, + "strict": true, + "target": "ES6", + "module": "CommonJS", + "moduleResolution": "node", + "esModuleInterop": true, + "skipLibCheck": true, + "declaration": true, + "outDir": "dist", + "rootDir": "src", + "baseUrl": "src" + }, + "include": ["src"], + "exclude": [] +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..d218139 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,3181 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@ampproject/remapping@^2.2.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.3.0.tgz#ed441b6fa600072520ce18b43d2c8cc8caecc7f4" + integrity sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw== + dependencies: + "@jridgewell/gen-mapping" "^0.3.5" + "@jridgewell/trace-mapping" "^0.3.24" + +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.25.9", "@babel/code-frame@^7.26.0": + version "7.26.2" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.26.2.tgz#4b5fab97d33338eff916235055f0ebc21e573a85" + integrity sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ== + dependencies: + "@babel/helper-validator-identifier" "^7.25.9" + js-tokens "^4.0.0" + picocolors "^1.0.0" + +"@babel/compat-data@^7.25.9": + version "7.26.2" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.26.2.tgz#278b6b13664557de95b8f35b90d96785850bb56e" + integrity sha512-Z0WgzSEa+aUcdiJuCIqgujCshpMWgUpgOxXotrYPSA53hA3qopNaqcJpyr0hVb1FeWdnqFA35/fUtXgBK8srQg== + +"@babel/core@^7.0.0", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.23.9": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.26.0.tgz#d78b6023cc8f3114ccf049eb219613f74a747b40" + integrity sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg== + dependencies: + "@ampproject/remapping" "^2.2.0" + "@babel/code-frame" "^7.26.0" + "@babel/generator" "^7.26.0" + "@babel/helper-compilation-targets" "^7.25.9" + "@babel/helper-module-transforms" "^7.26.0" + "@babel/helpers" "^7.26.0" + "@babel/parser" "^7.26.0" + "@babel/template" "^7.25.9" + "@babel/traverse" "^7.25.9" + "@babel/types" "^7.26.0" + convert-source-map "^2.0.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.3" + semver "^6.3.1" + +"@babel/generator@^7.25.9", "@babel/generator@^7.26.0", "@babel/generator@^7.7.2": + version "7.26.2" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.26.2.tgz#87b75813bec87916210e5e01939a4c823d6bb74f" + integrity sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw== + dependencies: + "@babel/parser" "^7.26.2" + "@babel/types" "^7.26.0" + "@jridgewell/gen-mapping" "^0.3.5" + "@jridgewell/trace-mapping" "^0.3.25" + jsesc "^3.0.2" + +"@babel/helper-compilation-targets@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz#55af025ce365be3cdc0c1c1e56c6af617ce88875" + integrity sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ== + dependencies: + "@babel/compat-data" "^7.25.9" + "@babel/helper-validator-option" "^7.25.9" + browserslist "^4.24.0" + lru-cache "^5.1.1" + semver "^6.3.1" + +"@babel/helper-module-imports@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz#e7f8d20602ebdbf9ebbea0a0751fb0f2a4141715" + integrity sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw== + dependencies: + "@babel/traverse" "^7.25.9" + "@babel/types" "^7.25.9" + +"@babel/helper-module-transforms@^7.26.0": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz#8ce54ec9d592695e58d84cd884b7b5c6a2fdeeae" + integrity sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw== + dependencies: + "@babel/helper-module-imports" "^7.25.9" + "@babel/helper-validator-identifier" "^7.25.9" + "@babel/traverse" "^7.25.9" + +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.25.9", "@babel/helper-plugin-utils@^7.8.0": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz#9cbdd63a9443a2c92a725cca7ebca12cc8dd9f46" + integrity sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw== + +"@babel/helper-string-parser@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz#1aabb72ee72ed35789b4bbcad3ca2862ce614e8c" + integrity sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA== + +"@babel/helper-validator-identifier@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz#24b64e2c3ec7cd3b3c547729b8d16871f22cbdc7" + integrity sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ== + +"@babel/helper-validator-option@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz#86e45bd8a49ab7e03f276577f96179653d41da72" + integrity sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw== + +"@babel/helpers@^7.26.0": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.26.0.tgz#30e621f1eba5aa45fe6f4868d2e9154d884119a4" + integrity sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw== + dependencies: + "@babel/template" "^7.25.9" + "@babel/types" "^7.26.0" + +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.25.9", "@babel/parser@^7.26.0", "@babel/parser@^7.26.2": + version "7.26.2" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.26.2.tgz#fd7b6f487cfea09889557ef5d4eeb9ff9a5abd11" + integrity sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ== + dependencies: + "@babel/types" "^7.26.0" + +"@babel/plugin-syntax-async-generators@^7.8.4": + version "7.8.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" + integrity sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-bigint@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz#4c9a6f669f5d0cdf1b90a1671e9a146be5300cea" + integrity sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-class-properties@^7.12.13": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10" + integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA== + dependencies: + "@babel/helper-plugin-utils" "^7.12.13" + +"@babel/plugin-syntax-class-static-block@^7.14.5": + version "7.14.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz#195df89b146b4b78b3bf897fd7a257c84659d406" + integrity sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw== + dependencies: + "@babel/helper-plugin-utils" "^7.14.5" + +"@babel/plugin-syntax-import-attributes@^7.24.7": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.26.0.tgz#3b1412847699eea739b4f2602c74ce36f6b0b0f7" + integrity sha512-e2dttdsJ1ZTpi3B9UYGLw41hifAubg19AtCu/2I/F1QNVclOBr1dYpTdmdyZ84Xiz43BS/tCUkMAZNLv12Pi+A== + dependencies: + "@babel/helper-plugin-utils" "^7.25.9" + +"@babel/plugin-syntax-import-meta@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz#ee601348c370fa334d2207be158777496521fd51" + integrity sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g== + dependencies: + "@babel/helper-plugin-utils" "^7.10.4" + +"@babel/plugin-syntax-json-strings@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" + integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-jsx@^7.7.2": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz#a34313a178ea56f1951599b929c1ceacee719290" + integrity sha512-ld6oezHQMZsZfp6pWtbjaNDF2tiiCYYDqQszHt5VV437lewP9aSi2Of99CK0D0XB21k7FLgnLcmQKyKzynfeAA== + dependencies: + "@babel/helper-plugin-utils" "^7.25.9" + +"@babel/plugin-syntax-logical-assignment-operators@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" + integrity sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== + dependencies: + "@babel/helper-plugin-utils" "^7.10.4" + +"@babel/plugin-syntax-nullish-coalescing-operator@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz#167ed70368886081f74b5c36c65a88c03b66d1a9" + integrity sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-numeric-separator@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97" + integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== + dependencies: + "@babel/helper-plugin-utils" "^7.10.4" + +"@babel/plugin-syntax-object-rest-spread@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" + integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-optional-catch-binding@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1" + integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-optional-chaining@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz#4f69c2ab95167e0180cd5336613f8c5788f7d48a" + integrity sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-private-property-in-object@^7.14.5": + version "7.14.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz#0dc6671ec0ea22b6e94a1114f857970cd39de1ad" + integrity sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg== + dependencies: + "@babel/helper-plugin-utils" "^7.14.5" + +"@babel/plugin-syntax-top-level-await@^7.14.5": + version "7.14.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz#c1cfdadc35a646240001f06138247b741c34d94c" + integrity sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw== + dependencies: + "@babel/helper-plugin-utils" "^7.14.5" + +"@babel/plugin-syntax-typescript@^7.7.2": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz#67dda2b74da43727cf21d46cf9afef23f4365399" + integrity sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ== + dependencies: + "@babel/helper-plugin-utils" "^7.25.9" + +"@babel/runtime@^7.0.0": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1" + integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw== + dependencies: + regenerator-runtime "^0.14.0" + +"@babel/template@^7.25.9", "@babel/template@^7.3.3": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.25.9.tgz#ecb62d81a8a6f5dc5fe8abfc3901fc52ddf15016" + integrity sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg== + dependencies: + "@babel/code-frame" "^7.25.9" + "@babel/parser" "^7.25.9" + "@babel/types" "^7.25.9" + +"@babel/traverse@^7.25.9": + version "7.25.9" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.9.tgz#a50f8fe49e7f69f53de5bea7e413cd35c5e13c84" + integrity sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw== + dependencies: + "@babel/code-frame" "^7.25.9" + "@babel/generator" "^7.25.9" + "@babel/parser" "^7.25.9" + "@babel/template" "^7.25.9" + "@babel/types" "^7.25.9" + debug "^4.3.1" + globals "^11.1.0" + +"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.25.9", "@babel/types@^7.26.0", "@babel/types@^7.3.3": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.26.0.tgz#deabd08d6b753bc8e0f198f8709fb575e31774ff" + integrity sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA== + dependencies: + "@babel/helper-string-parser" "^7.25.9" + "@babel/helper-validator-identifier" "^7.25.9" + +"@bcoe/v8-coverage@^0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" + integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== + +"@istanbuljs/load-nyc-config@^1.0.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" + integrity sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ== + dependencies: + camelcase "^5.3.1" + find-up "^4.1.0" + get-package-type "^0.1.0" + js-yaml "^3.13.1" + resolve-from "^5.0.0" + +"@istanbuljs/schema@^0.1.2", "@istanbuljs/schema@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" + integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== + +"@jest/console@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/console/-/console-29.7.0.tgz#cd4822dbdb84529265c5a2bdb529a3c9cc950ffc" + integrity sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg== + dependencies: + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + slash "^3.0.0" + +"@jest/core@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/core/-/core-29.7.0.tgz#b6cccc239f30ff36609658c5a5e2291757ce448f" + integrity sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg== + dependencies: + "@jest/console" "^29.7.0" + "@jest/reporters" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + ansi-escapes "^4.2.1" + chalk "^4.0.0" + ci-info "^3.2.0" + exit "^0.1.2" + graceful-fs "^4.2.9" + jest-changed-files "^29.7.0" + jest-config "^29.7.0" + jest-haste-map "^29.7.0" + jest-message-util "^29.7.0" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-resolve-dependencies "^29.7.0" + jest-runner "^29.7.0" + jest-runtime "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" + jest-watcher "^29.7.0" + micromatch "^4.0.4" + pretty-format "^29.7.0" + slash "^3.0.0" + strip-ansi "^6.0.0" + +"@jest/environment@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.7.0.tgz#24d61f54ff1f786f3cd4073b4b94416383baf2a7" + integrity sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw== + dependencies: + "@jest/fake-timers" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + jest-mock "^29.7.0" + +"@jest/expect-utils@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-29.7.0.tgz#023efe5d26a8a70f21677d0a1afc0f0a44e3a1c6" + integrity sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA== + dependencies: + jest-get-type "^29.6.3" + +"@jest/expect@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/expect/-/expect-29.7.0.tgz#76a3edb0cb753b70dfbfe23283510d3d45432bf2" + integrity sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ== + dependencies: + expect "^29.7.0" + jest-snapshot "^29.7.0" + +"@jest/fake-timers@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.7.0.tgz#fd91bf1fffb16d7d0d24a426ab1a47a49881a565" + integrity sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ== + dependencies: + "@jest/types" "^29.6.3" + "@sinonjs/fake-timers" "^10.0.2" + "@types/node" "*" + jest-message-util "^29.7.0" + jest-mock "^29.7.0" + jest-util "^29.7.0" + +"@jest/globals@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-29.7.0.tgz#8d9290f9ec47ff772607fa864ca1d5a2efae1d4d" + integrity sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/expect" "^29.7.0" + "@jest/types" "^29.6.3" + jest-mock "^29.7.0" + +"@jest/reporters@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-29.7.0.tgz#04b262ecb3b8faa83b0b3d321623972393e8f4c7" + integrity sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg== + dependencies: + "@bcoe/v8-coverage" "^0.2.3" + "@jest/console" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@jridgewell/trace-mapping" "^0.3.18" + "@types/node" "*" + chalk "^4.0.0" + collect-v8-coverage "^1.0.0" + exit "^0.1.2" + glob "^7.1.3" + graceful-fs "^4.2.9" + istanbul-lib-coverage "^3.0.0" + istanbul-lib-instrument "^6.0.0" + istanbul-lib-report "^3.0.0" + istanbul-lib-source-maps "^4.0.0" + istanbul-reports "^3.1.3" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + jest-worker "^29.7.0" + slash "^3.0.0" + string-length "^4.0.1" + strip-ansi "^6.0.0" + v8-to-istanbul "^9.0.1" + +"@jest/schemas@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03" + integrity sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA== + dependencies: + "@sinclair/typebox" "^0.27.8" + +"@jest/source-map@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-29.6.3.tgz#d90ba772095cf37a34a5eb9413f1b562a08554c4" + integrity sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw== + dependencies: + "@jridgewell/trace-mapping" "^0.3.18" + callsites "^3.0.0" + graceful-fs "^4.2.9" + +"@jest/test-result@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-29.7.0.tgz#8db9a80aa1a097bb2262572686734baed9b1657c" + integrity sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA== + dependencies: + "@jest/console" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/istanbul-lib-coverage" "^2.0.0" + collect-v8-coverage "^1.0.0" + +"@jest/test-sequencer@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz#6cef977ce1d39834a3aea887a1726628a6f072ce" + integrity sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw== + dependencies: + "@jest/test-result" "^29.7.0" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + slash "^3.0.0" + +"@jest/transform@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-29.7.0.tgz#df2dd9c346c7d7768b8a06639994640c642e284c" + integrity sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw== + dependencies: + "@babel/core" "^7.11.6" + "@jest/types" "^29.6.3" + "@jridgewell/trace-mapping" "^0.3.18" + babel-plugin-istanbul "^6.1.1" + chalk "^4.0.0" + convert-source-map "^2.0.0" + fast-json-stable-stringify "^2.1.0" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + jest-regex-util "^29.6.3" + jest-util "^29.7.0" + micromatch "^4.0.4" + pirates "^4.0.4" + slash "^3.0.0" + write-file-atomic "^4.0.2" + +"@jest/types@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.3.tgz#1131f8cf634e7e84c5e77bab12f052af585fba59" + integrity sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw== + dependencies: + "@jest/schemas" "^29.6.3" + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^17.0.8" + chalk "^4.0.0" + +"@jridgewell/gen-mapping@^0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz#dcce6aff74bdf6dad1a95802b69b04a2fcb1fb36" + integrity sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg== + dependencies: + "@jridgewell/set-array" "^1.2.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.24" + +"@jridgewell/resolve-uri@^3.1.0": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" + integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== + +"@jridgewell/set-array@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.2.1.tgz#558fb6472ed16a4c850b889530e6b36438c49280" + integrity sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A== + +"@jridgewell/source-map@^0.3.3": + version "0.3.6" + resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.6.tgz#9d71ca886e32502eb9362c9a74a46787c36df81a" + integrity sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ== + dependencies: + "@jridgewell/gen-mapping" "^0.3.5" + "@jridgewell/trace-mapping" "^0.3.25" + +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== + +"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.18", "@jridgewell/trace-mapping@^0.3.20", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25": + version "0.3.25" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0" + integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ== + dependencies: + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" + +"@sinclair/typebox@^0.27.8": + version "0.27.8" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" + integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== + +"@sinonjs/commons@^3.0.0": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.1.tgz#1029357e44ca901a615585f6d27738dbc89084cd" + integrity sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ== + dependencies: + type-detect "4.0.8" + +"@sinonjs/fake-timers@^10.0.2": + version "10.3.0" + resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz#55fdff1ecab9f354019129daf4df0dd4d923ea66" + integrity sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA== + dependencies: + "@sinonjs/commons" "^3.0.0" + +"@tootallnate/once@2": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" + integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== + +"@types/babel__core@^7.1.14": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" + integrity sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA== + dependencies: + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" + "@types/babel__generator" "*" + "@types/babel__template" "*" + "@types/babel__traverse" "*" + +"@types/babel__generator@*": + version "7.6.8" + resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.8.tgz#f836c61f48b1346e7d2b0d93c6dacc5b9535d3ab" + integrity sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw== + dependencies: + "@babel/types" "^7.0.0" + +"@types/babel__template@*": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.4.4.tgz#5672513701c1b2199bc6dad636a9d7491586766f" + integrity sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A== + dependencies: + "@babel/parser" "^7.1.0" + "@babel/types" "^7.0.0" + +"@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": + version "7.20.6" + resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.20.6.tgz#8dc9f0ae0f202c08d8d4dab648912c8d6038e3f7" + integrity sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg== + dependencies: + "@babel/types" "^7.20.7" + +"@types/eslint-scope@^3.7.7": + version "3.7.7" + resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" + integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== + dependencies: + "@types/eslint" "*" + "@types/estree" "*" + +"@types/eslint@*": + version "9.6.1" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-9.6.1.tgz#d5795ad732ce81715f27f75da913004a56751584" + integrity sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*", "@types/estree@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" + integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== + +"@types/graceful-fs@^4.1.3": + version "4.1.9" + resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" + integrity sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ== + dependencies: + "@types/node" "*" + +"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": + version "2.0.6" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" + integrity sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w== + +"@types/istanbul-lib-report@*": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz#53047614ae72e19fc0401d872de3ae2b4ce350bf" + integrity sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA== + dependencies: + "@types/istanbul-lib-coverage" "*" + +"@types/istanbul-reports@^3.0.0": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz#0f03e3d2f670fbdac586e34b433783070cc16f54" + integrity sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ== + dependencies: + "@types/istanbul-lib-report" "*" + +"@types/jest@29.5.5": + version "29.5.5" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.5.tgz#727204e06228fe24373df9bae76b90f3e8236a2a" + integrity sha512-ebylz2hnsWR9mYvmBFbXJXr+33UPc4+ZdxyDXh5w0FlPBTfCVN3wPL+kuOiQt3xvrK419v7XWeAs+AeOksafXg== + dependencies: + expect "^29.0.0" + pretty-format "^29.0.0" + +"@types/jsdom@^20.0.0": + version "20.0.1" + resolved "https://registry.yarnpkg.com/@types/jsdom/-/jsdom-20.0.1.tgz#07c14bc19bd2f918c1929541cdaacae894744808" + integrity sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ== + dependencies: + "@types/node" "*" + "@types/tough-cookie" "*" + parse5 "^7.0.0" + +"@types/json-schema@*", "@types/json-schema@^7.0.8": + version "7.0.15" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== + +"@types/node-fetch@2.6.9": + version "2.6.9" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.9.tgz#15f529d247f1ede1824f7e7acdaa192d5f28071e" + integrity sha512-bQVlnMLFJ2d35DkPNjEPmd9ueO/rh5EiaZt2bhqiSarPjZIuIV6bPQVqcrEyvNo+AfTrRGVazle1tl597w3gfA== + dependencies: + "@types/node" "*" + form-data "^4.0.0" + +"@types/node@*": + version "22.9.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.9.0.tgz#b7f16e5c3384788542c72dc3d561a7ceae2c0365" + integrity sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ== + dependencies: + undici-types "~6.19.8" + +"@types/node@17.0.33": + version "17.0.33" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.33.tgz#3c1879b276dc63e73030bb91165e62a4509cd506" + integrity sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ== + +"@types/qs@6.9.8": + version "6.9.8" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.8.tgz#f2a7de3c107b89b441e071d5472e6b726b4adf45" + integrity sha512-u95svzDlTysU5xecFNTgfFG5RUWu1A9P0VzgpcIiGZA9iraHOdSzcxMxQ55DyeRaGCSxQi7LxXDI4rzq/MYfdg== + +"@types/readable-stream@^4.0.15": + version "4.0.18" + resolved "https://registry.yarnpkg.com/@types/readable-stream/-/readable-stream-4.0.18.tgz#5d8d15d26c776500ce573cae580787d149823bfc" + integrity sha512-21jK/1j+Wg+7jVw1xnSwy/2Q1VgVjWuFssbYGTREPUBeZ+rqVFl2udq0IkxzPC0ZhOzVceUbyIACFZKLqKEBlA== + dependencies: + "@types/node" "*" + safe-buffer "~5.1.1" + +"@types/stack-utils@^2.0.0": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" + integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== + +"@types/tough-cookie@*": + version "4.0.5" + resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.5.tgz#cb6e2a691b70cb177c6e3ae9c1d2e8b2ea8cd304" + integrity sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA== + +"@types/url-join@4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@types/url-join/-/url-join-4.0.1.tgz#4989c97f969464647a8586c7252d97b449cdc045" + integrity sha512-wDXw9LEEUHyV+7UWy7U315nrJGJ7p1BzaCxDpEoLr789Dk1WDVMMlf3iBfbG2F8NdWnYyFbtTxUn2ZNbm1Q4LQ== + +"@types/yargs-parser@*": + version "21.0.3" + resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" + integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ== + +"@types/yargs@^17.0.8": + version "17.0.33" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.33.tgz#8c32303da83eec050a84b3c7ae7b9f922d13e32d" + integrity sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA== + dependencies: + "@types/yargs-parser" "*" + +"@webassemblyjs/ast@1.12.1", "@webassemblyjs/ast@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.12.1.tgz#bb16a0e8b1914f979f45864c23819cc3e3f0d4bb" + integrity sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg== + dependencies: + "@webassemblyjs/helper-numbers" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + +"@webassemblyjs/floating-point-hex-parser@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz#dacbcb95aff135c8260f77fa3b4c5fea600a6431" + integrity sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw== + +"@webassemblyjs/helper-api-error@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz#6132f68c4acd59dcd141c44b18cbebbd9f2fa768" + integrity sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q== + +"@webassemblyjs/helper-buffer@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.12.1.tgz#6df20d272ea5439bf20ab3492b7fb70e9bfcb3f6" + integrity sha512-nzJwQw99DNDKr9BVCOZcLuJJUlqkJh+kVzVl6Fmq/tI5ZtEyWT1KZMyOXltXLZJmDtvLCDgwsyrkohEtopTXCw== + +"@webassemblyjs/helper-numbers@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz#cbce5e7e0c1bd32cf4905ae444ef64cea919f1b5" + integrity sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g== + dependencies: + "@webassemblyjs/floating-point-hex-parser" "1.11.6" + "@webassemblyjs/helper-api-error" "1.11.6" + "@xtuc/long" "4.2.2" + +"@webassemblyjs/helper-wasm-bytecode@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz#bb2ebdb3b83aa26d9baad4c46d4315283acd51e9" + integrity sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA== + +"@webassemblyjs/helper-wasm-section@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.12.1.tgz#3da623233ae1a60409b509a52ade9bc22a37f7bf" + integrity sha512-Jif4vfB6FJlUlSbgEMHUyk1j234GTNG9dBJ4XJdOySoj518Xj0oGsNi59cUQF4RRMS9ouBUxDDdyBVfPTypa5g== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/wasm-gen" "1.12.1" + +"@webassemblyjs/ieee754@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz#bb665c91d0b14fffceb0e38298c329af043c6e3a" + integrity sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg== + dependencies: + "@xtuc/ieee754" "^1.2.0" + +"@webassemblyjs/leb128@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.6.tgz#70e60e5e82f9ac81118bc25381a0b283893240d7" + integrity sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ== + dependencies: + "@xtuc/long" "4.2.2" + +"@webassemblyjs/utf8@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.6.tgz#90f8bc34c561595fe156603be7253cdbcd0fab5a" + integrity sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA== + +"@webassemblyjs/wasm-edit@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.12.1.tgz#9f9f3ff52a14c980939be0ef9d5df9ebc678ae3b" + integrity sha512-1DuwbVvADvS5mGnXbE+c9NfA8QRcZ6iKquqjjmR10k6o+zzsRVesil54DKexiowcFCPdr/Q0qaMgB01+SQ1u6g== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/helper-wasm-section" "1.12.1" + "@webassemblyjs/wasm-gen" "1.12.1" + "@webassemblyjs/wasm-opt" "1.12.1" + "@webassemblyjs/wasm-parser" "1.12.1" + "@webassemblyjs/wast-printer" "1.12.1" + +"@webassemblyjs/wasm-gen@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.12.1.tgz#a6520601da1b5700448273666a71ad0a45d78547" + integrity sha512-TDq4Ojh9fcohAw6OIMXqiIcTq5KUXTGRkVxbSo1hQnSy6lAM5GSdfwWeSxpAo0YzgsgF182E/U0mDNhuA0tW7w== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/ieee754" "1.11.6" + "@webassemblyjs/leb128" "1.11.6" + "@webassemblyjs/utf8" "1.11.6" + +"@webassemblyjs/wasm-opt@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.12.1.tgz#9e6e81475dfcfb62dab574ac2dda38226c232bc5" + integrity sha512-Jg99j/2gG2iaz3hijw857AVYekZe2SAskcqlWIZXjji5WStnOpVoat3gQfT/Q5tb2djnCjBtMocY/Su1GfxPBg== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/wasm-gen" "1.12.1" + "@webassemblyjs/wasm-parser" "1.12.1" + +"@webassemblyjs/wasm-parser@1.12.1", "@webassemblyjs/wasm-parser@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.12.1.tgz#c47acb90e6f083391e3fa61d113650eea1e95937" + integrity sha512-xikIi7c2FHXysxXe3COrVUPSheuBtpcfhbpFj4gmu7KRLYOzANztwUU0IbsqvMqzuNK2+glRGWCEqZo1WCLyAQ== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-api-error" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/ieee754" "1.11.6" + "@webassemblyjs/leb128" "1.11.6" + "@webassemblyjs/utf8" "1.11.6" + +"@webassemblyjs/wast-printer@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.12.1.tgz#bcecf661d7d1abdaf989d8341a4833e33e2b31ac" + integrity sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@xtuc/long" "4.2.2" + +"@xtuc/ieee754@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" + integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== + +"@xtuc/long@4.2.2": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" + integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== + +abab@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291" + integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA== + +abort-controller@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== + dependencies: + event-target-shim "^5.0.0" + +acorn-globals@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-7.0.1.tgz#0dbf05c44fa7c94332914c02066d5beff62c40c3" + integrity sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q== + dependencies: + acorn "^8.1.0" + acorn-walk "^8.0.2" + +acorn-walk@^8.0.2: + version "8.3.4" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.4.tgz#794dd169c3977edf4ba4ea47583587c5866236b7" + integrity sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g== + dependencies: + acorn "^8.11.0" + +acorn@^8.1.0, acorn@^8.11.0, acorn@^8.14.0, acorn@^8.8.1, acorn@^8.8.2: + version "8.14.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0" + integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA== + +agent-base@6: + version "6.0.2" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" + integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== + dependencies: + debug "4" + +ajv-keywords@^3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" + integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== + +ajv@^6.12.5: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-escapes@^4.2.1: + version "4.3.2" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" + integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== + dependencies: + type-fest "^0.21.3" + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +ansi-styles@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" + integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== + +anymatch@^3.0.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + +babel-jest@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" + integrity sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg== + dependencies: + "@jest/transform" "^29.7.0" + "@types/babel__core" "^7.1.14" + babel-plugin-istanbul "^6.1.1" + babel-preset-jest "^29.6.3" + chalk "^4.0.0" + graceful-fs "^4.2.9" + slash "^3.0.0" + +babel-plugin-istanbul@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz#fa88ec59232fd9b4e36dbbc540a8ec9a9b47da73" + integrity sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@istanbuljs/load-nyc-config" "^1.0.0" + "@istanbuljs/schema" "^0.1.2" + istanbul-lib-instrument "^5.0.4" + test-exclude "^6.0.0" + +babel-plugin-jest-hoist@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz#aadbe943464182a8922c3c927c3067ff40d24626" + integrity sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg== + dependencies: + "@babel/template" "^7.3.3" + "@babel/types" "^7.3.3" + "@types/babel__core" "^7.1.14" + "@types/babel__traverse" "^7.0.6" + +babel-preset-current-node-syntax@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz#9a929eafece419612ef4ae4f60b1862ebad8ef30" + integrity sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw== + dependencies: + "@babel/plugin-syntax-async-generators" "^7.8.4" + "@babel/plugin-syntax-bigint" "^7.8.3" + "@babel/plugin-syntax-class-properties" "^7.12.13" + "@babel/plugin-syntax-class-static-block" "^7.14.5" + "@babel/plugin-syntax-import-attributes" "^7.24.7" + "@babel/plugin-syntax-import-meta" "^7.10.4" + "@babel/plugin-syntax-json-strings" "^7.8.3" + "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" + "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" + "@babel/plugin-syntax-numeric-separator" "^7.10.4" + "@babel/plugin-syntax-object-rest-spread" "^7.8.3" + "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" + "@babel/plugin-syntax-optional-chaining" "^7.8.3" + "@babel/plugin-syntax-private-property-in-object" "^7.14.5" + "@babel/plugin-syntax-top-level-await" "^7.14.5" + +babel-preset-jest@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz#fa05fa510e7d493896d7b0dd2033601c840f171c" + integrity sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA== + dependencies: + babel-plugin-jest-hoist "^29.6.3" + babel-preset-current-node-syntax "^1.0.0" + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== + dependencies: + fill-range "^7.1.1" + +browserslist@^4.24.0: + version "4.24.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.2.tgz#f5845bc91069dbd55ee89faf9822e1d885d16580" + integrity sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg== + dependencies: + caniuse-lite "^1.0.30001669" + electron-to-chromium "^1.5.41" + node-releases "^2.0.18" + update-browserslist-db "^1.1.1" + +bs-logger@0.x: + version "0.2.6" + resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" + integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog== + dependencies: + fast-json-stable-stringify "2.x" + +bser@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" + integrity sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ== + dependencies: + node-int64 "^0.4.0" + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + +call-bind@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" + integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + set-function-length "^1.2.1" + +callsites@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" + integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== + +camelcase@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +camelcase@^6.2.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +caniuse-lite@^1.0.30001669: + version "1.0.30001677" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001677.tgz#27c2e2c637e007cfa864a16f7dfe7cde66b38b5f" + integrity sha512-fmfjsOlJUpMWu+mAAtZZZHz7UEwsUxIIvu1TJfO1HqFQvB/B+ii0xr9B5HpbZY/mC4XZ8SvjHJqtAY6pDPQEog== + +chalk@^4.0.0, chalk@^4.1.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +char-regex@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" + integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== + +chrome-trace-event@^1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz#05bffd7ff928465093314708c93bdfa9bd1f0f5b" + integrity sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ== + +ci-info@^3.2.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" + integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== + +cjs-module-lexer@^1.0.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.4.1.tgz#707413784dbb3a72aa11c2f2b042a0bef4004170" + integrity sha512-cuSVIHi9/9E/+821Qjdvngor+xpnlwnuwIyZOaLmHBVdXL+gP+I6QQB9VkO7RI77YIcTV+S1W9AreJ5eN63JBA== + +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== + +collect-v8-coverage@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9" + integrity sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q== + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +commander@^2.20.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +convert-source-map@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" + integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== + +core-js@^3.0.0: + version "3.39.0" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.39.0.tgz#57f7647f4d2d030c32a72ea23a0555b2eaa30f83" + integrity sha512-raM0ew0/jJUqkJ0E6e8UDtl+y/7ktFivgWvqw8dNSQeNWoSDLvQ1H/RN3aPXB9tBd4/FhyR4RDPGhsNIMsAn7g== + +create-jest@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320" + integrity sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q== + dependencies: + "@jest/types" "^29.6.3" + chalk "^4.0.0" + exit "^0.1.2" + graceful-fs "^4.2.9" + jest-config "^29.7.0" + jest-util "^29.7.0" + prompts "^2.0.1" + +cross-spawn@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +cssom@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.5.0.tgz#d254fa92cd8b6fbd83811b9fbaed34663cc17c36" + integrity sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw== + +cssom@~0.3.6: + version "0.3.8" + resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a" + integrity sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg== + +cssstyle@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-2.3.0.tgz#ff665a0ddbdc31864b09647f34163443d90b0852" + integrity sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A== + dependencies: + cssom "~0.3.6" + +data-urls@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-3.0.2.tgz#9cf24a477ae22bcef5cd5f6f0bfbc1d2d3be9143" + integrity sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ== + dependencies: + abab "^2.0.6" + whatwg-mimetype "^3.0.0" + whatwg-url "^11.0.0" + +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + dependencies: + ms "^2.1.3" + +decimal.js@^10.4.2: + version "10.4.3" + resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.4.3.tgz#1044092884d245d1b7f65725fa4ad4c6f781cc23" + integrity sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA== + +dedent@^1.0.0: + version "1.5.3" + resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.5.3.tgz#99aee19eb9bae55a67327717b6e848d0bf777e5a" + integrity sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ== + +deepmerge@^4.2.2: + version "4.3.1" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" + integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== + +define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + +detect-newline@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" + integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== + +diff-sequences@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.6.3.tgz#4deaf894d11407c51efc8418012f9e70b84ea921" + integrity sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q== + +domexception@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/domexception/-/domexception-4.0.0.tgz#4ad1be56ccadc86fc76d033353999a8037d03673" + integrity sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw== + dependencies: + webidl-conversions "^7.0.0" + +electron-to-chromium@^1.5.41: + version "1.5.51" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.51.tgz#bb99216fed4892d131a8585a8593b00739310163" + integrity sha512-kKeWV57KSS8jH4alKt/jKnvHPmJgBxXzGUSbMd4eQF+iOsVPl7bz2KUmu6eo80eMP8wVioTfTyTzdMgM15WXNg== + +emittery@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad" + integrity sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +enhanced-resolve@^5.0.0, enhanced-resolve@^5.17.1: + version "5.17.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz#67bfbbcc2f81d511be77d686a90267ef7f898a15" + integrity sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + +entities@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" + integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== + +error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +es-define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" + integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== + dependencies: + get-intrinsic "^1.2.4" + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + +es-module-lexer@^1.2.1: + version "1.5.4" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.5.4.tgz#a8efec3a3da991e60efa6b633a7cad6ab8d26b78" + integrity sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw== + +escalade@^3.1.1, escalade@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" + integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== + +escape-string-regexp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" + integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== + +escodegen@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17" + integrity sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w== + dependencies: + esprima "^4.0.1" + estraverse "^5.2.0" + esutils "^2.0.2" + optionalDependencies: + source-map "~0.6.1" + +eslint-scope@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== + dependencies: + esrecurse "^4.3.0" + estraverse "^4.1.1" + +esprima@^4.0.0, esprima@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^4.1.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + +estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + +event-target-shim@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" + integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== + +events@^3.2.0, events@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + +execa@^5.0.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" + integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" + strip-final-newline "^2.0.0" + +exit@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" + integrity sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ== + +expect@^29.0.0, expect@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/expect/-/expect-29.7.0.tgz#578874590dcb3214514084c08115d8aee61e11bc" + integrity sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw== + dependencies: + "@jest/expect-utils" "^29.7.0" + jest-get-type "^29.6.3" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + +fast-deep-equal@^3.1.1: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fb-watchman@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" + integrity sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA== + dependencies: + bser "2.1.1" + +fetch-mock-jest@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/fetch-mock-jest/-/fetch-mock-jest-1.5.1.tgz#0e13df990d286d9239e284f12b279ed509bf53cd" + integrity sha512-+utwzP8C+Pax1GSka3nFXILWMY3Er2L+s090FOgqVNrNCPp0fDqgXnAHAJf12PLHi0z4PhcTaZNTz8e7K3fjqQ== + dependencies: + fetch-mock "^9.11.0" + +fetch-mock@^9.11.0: + version "9.11.0" + resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-9.11.0.tgz#371c6fb7d45584d2ae4a18ee6824e7ad4b637a3f" + integrity sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q== + dependencies: + "@babel/core" "^7.0.0" + "@babel/runtime" "^7.0.0" + core-js "^3.0.0" + debug "^4.1.1" + glob-to-regexp "^0.4.0" + is-subset "^0.1.1" + lodash.isequal "^4.5.0" + path-to-regexp "^2.2.1" + querystring "^0.2.0" + whatwg-url "^6.5.0" + +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== + dependencies: + to-regex-range "^5.0.1" + +find-up@^4.0.0, find-up@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + dependencies: + locate-path "^5.0.0" + path-exists "^4.0.0" + +form-data-encoder@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-4.0.2.tgz#dd286fd5f9049e8ded1d44ce427f5e29185c7c12" + integrity sha512-KQVhvhK8ZkWzxKxOr56CPulAhH3dobtuQ4+hNQ+HekH/Wp5gSOafqRAeTphQUJAIk0GBvHZgJ2ZGRWd5kphMuw== + +form-data@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.1.tgz#ba1076daaaa5bfd7e99c1a6cb02aa0a5cff90d48" + integrity sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + +formdata-node@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/formdata-node/-/formdata-node-6.0.3.tgz#48f8e2206ae2befded82af621ef015f08168dc6d" + integrity sha512-8e1++BCiTzUno9v5IZ2J6bv4RU+3UKDmqWUQD0MIMVCd9AdhWkO1gw57oo1mNEX1dMq2EGI+FbWz4B92pscSQg== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@^2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +gensync@^1.0.0-beta.2: + version "1.0.0-beta.2" + resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" + integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-intrinsic@^1.1.3, get-intrinsic@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" + integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + +get-package-type@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" + integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== + +get-stream@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" + integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== + +glob-to-regexp@^0.4.0, glob-to-regexp@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" + integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== + +glob@^7.1.3, glob@^7.1.4: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^11.1.0: + version "11.12.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" + integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + +graceful-fs@^4.1.2, graceful-fs@^4.2.11, graceful-fs@^4.2.4, graceful-fs@^4.2.9: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-proto@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.3.tgz#b31ddfe9b0e6e9914536a6ab286426d0214f77fd" + integrity sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q== + +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +hasown@^2.0.0, hasown@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" + integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== + dependencies: + function-bind "^1.1.2" + +html-encoding-sniffer@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz#2cb1a8cf0db52414776e5b2a7a04d5dd98158de9" + integrity sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA== + dependencies: + whatwg-encoding "^2.0.0" + +html-escaper@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" + integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== + +http-proxy-agent@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz#5129800203520d434f142bc78ff3c170800f2b43" + integrity sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w== + dependencies: + "@tootallnate/once" "2" + agent-base "6" + debug "4" + +https-proxy-agent@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" + integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== + dependencies: + agent-base "6" + debug "4" + +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== + +iconv-lite@0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + +ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +import-local@^3.0.2: + version "3.2.0" + resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.2.0.tgz#c3d5c745798c02a6f8b897726aba5100186ee260" + integrity sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA== + dependencies: + pkg-dir "^4.2.0" + resolve-cwd "^3.0.0" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== + +is-core-module@^2.13.0: + version "2.15.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.15.1.tgz#a7363a25bee942fefab0de13bf6aa372c82dcc37" + integrity sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ== + dependencies: + hasown "^2.0.2" + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-generator-fn@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" + integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-potential-custom-element-name@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" + integrity sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ== + +is-stream@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" + integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== + +is-subset@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6" + integrity sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756" + integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg== + +istanbul-lib-instrument@^5.0.4: + version "5.2.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz#d10c8885c2125574e1c231cacadf955675e1ce3d" + integrity sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg== + dependencies: + "@babel/core" "^7.12.3" + "@babel/parser" "^7.14.7" + "@istanbuljs/schema" "^0.1.2" + istanbul-lib-coverage "^3.2.0" + semver "^6.3.0" + +istanbul-lib-instrument@^6.0.0: + version "6.0.3" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz#fa15401df6c15874bcb2105f773325d78c666765" + integrity sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q== + dependencies: + "@babel/core" "^7.23.9" + "@babel/parser" "^7.23.9" + "@istanbuljs/schema" "^0.1.3" + istanbul-lib-coverage "^3.2.0" + semver "^7.5.4" + +istanbul-lib-report@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d" + integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw== + dependencies: + istanbul-lib-coverage "^3.0.0" + make-dir "^4.0.0" + supports-color "^7.1.0" + +istanbul-lib-source-maps@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz#895f3a709fcfba34c6de5a42939022f3e4358551" + integrity sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw== + dependencies: + debug "^4.1.1" + istanbul-lib-coverage "^3.0.0" + source-map "^0.6.1" + +istanbul-reports@^3.1.3: + version "3.1.7" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.7.tgz#daed12b9e1dca518e15c056e1e537e741280fa0b" + integrity sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g== + dependencies: + html-escaper "^2.0.0" + istanbul-lib-report "^3.0.0" + +jest-changed-files@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.7.0.tgz#1c06d07e77c78e1585d020424dedc10d6e17ac3a" + integrity sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w== + dependencies: + execa "^5.0.0" + jest-util "^29.7.0" + p-limit "^3.1.0" + +jest-circus@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-circus/-/jest-circus-29.7.0.tgz#b6817a45fcc835d8b16d5962d0c026473ee3668a" + integrity sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/expect" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + co "^4.6.0" + dedent "^1.0.0" + is-generator-fn "^2.0.0" + jest-each "^29.7.0" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-runtime "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" + p-limit "^3.1.0" + pretty-format "^29.7.0" + pure-rand "^6.0.0" + slash "^3.0.0" + stack-utils "^2.0.3" + +jest-cli@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-29.7.0.tgz#5592c940798e0cae677eec169264f2d839a37995" + integrity sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg== + dependencies: + "@jest/core" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" + chalk "^4.0.0" + create-jest "^29.7.0" + exit "^0.1.2" + import-local "^3.0.2" + jest-config "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" + yargs "^17.3.1" + +jest-config@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-29.7.0.tgz#bcbda8806dbcc01b1e316a46bb74085a84b0245f" + integrity sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ== + dependencies: + "@babel/core" "^7.11.6" + "@jest/test-sequencer" "^29.7.0" + "@jest/types" "^29.6.3" + babel-jest "^29.7.0" + chalk "^4.0.0" + ci-info "^3.2.0" + deepmerge "^4.2.2" + glob "^7.1.3" + graceful-fs "^4.2.9" + jest-circus "^29.7.0" + jest-environment-node "^29.7.0" + jest-get-type "^29.6.3" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-runner "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" + micromatch "^4.0.4" + parse-json "^5.2.0" + pretty-format "^29.7.0" + slash "^3.0.0" + strip-json-comments "^3.1.1" + +jest-diff@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.7.0.tgz#017934a66ebb7ecf6f205e84699be10afd70458a" + integrity sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw== + dependencies: + chalk "^4.0.0" + diff-sequences "^29.6.3" + jest-get-type "^29.6.3" + pretty-format "^29.7.0" + +jest-docblock@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-29.7.0.tgz#8fddb6adc3cdc955c93e2a87f61cfd350d5d119a" + integrity sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g== + dependencies: + detect-newline "^3.0.0" + +jest-each@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-29.7.0.tgz#162a9b3f2328bdd991beaabffbb74745e56577d1" + integrity sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ== + dependencies: + "@jest/types" "^29.6.3" + chalk "^4.0.0" + jest-get-type "^29.6.3" + jest-util "^29.7.0" + pretty-format "^29.7.0" + +jest-environment-jsdom@29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-29.7.0.tgz#d206fa3551933c3fd519e5dfdb58a0f5139a837f" + integrity sha512-k9iQbsf9OyOfdzWH8HDmrRT0gSIcX+FLNW7IQq94tFX0gynPwqDTW0Ho6iMVNjGz/nb+l/vW3dWM2bbLLpkbXA== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/fake-timers" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/jsdom" "^20.0.0" + "@types/node" "*" + jest-mock "^29.7.0" + jest-util "^29.7.0" + jsdom "^20.0.0" + +jest-environment-node@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-29.7.0.tgz#0b93e111dda8ec120bc8300e6d1fb9576e164376" + integrity sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/fake-timers" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + jest-mock "^29.7.0" + jest-util "^29.7.0" + +jest-get-type@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.6.3.tgz#36f499fdcea197c1045a127319c0481723908fd1" + integrity sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw== + +jest-haste-map@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-29.7.0.tgz#3c2396524482f5a0506376e6c858c3bbcc17b104" + integrity sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA== + dependencies: + "@jest/types" "^29.6.3" + "@types/graceful-fs" "^4.1.3" + "@types/node" "*" + anymatch "^3.0.3" + fb-watchman "^2.0.0" + graceful-fs "^4.2.9" + jest-regex-util "^29.6.3" + jest-util "^29.7.0" + jest-worker "^29.7.0" + micromatch "^4.0.4" + walker "^1.0.8" + optionalDependencies: + fsevents "^2.3.2" + +jest-leak-detector@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz#5b7ec0dadfdfec0ca383dc9aa016d36b5ea4c728" + integrity sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw== + dependencies: + jest-get-type "^29.6.3" + pretty-format "^29.7.0" + +jest-matcher-utils@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz#ae8fec79ff249fd592ce80e3ee474e83a6c44f12" + integrity sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g== + dependencies: + chalk "^4.0.0" + jest-diff "^29.7.0" + jest-get-type "^29.6.3" + pretty-format "^29.7.0" + +jest-message-util@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-29.7.0.tgz#8bc392e204e95dfe7564abbe72a404e28e51f7f3" + integrity sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w== + dependencies: + "@babel/code-frame" "^7.12.13" + "@jest/types" "^29.6.3" + "@types/stack-utils" "^2.0.0" + chalk "^4.0.0" + graceful-fs "^4.2.9" + micromatch "^4.0.4" + pretty-format "^29.7.0" + slash "^3.0.0" + stack-utils "^2.0.3" + +jest-mock@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.7.0.tgz#4e836cf60e99c6fcfabe9f99d017f3fdd50a6347" + integrity sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw== + dependencies: + "@jest/types" "^29.6.3" + "@types/node" "*" + jest-util "^29.7.0" + +jest-pnp-resolver@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" + integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== + +jest-regex-util@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-29.6.3.tgz#4a556d9c776af68e1c5f48194f4d0327d24e8a52" + integrity sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg== + +jest-resolve-dependencies@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz#1b04f2c095f37fc776ff40803dc92921b1e88428" + integrity sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA== + dependencies: + jest-regex-util "^29.6.3" + jest-snapshot "^29.7.0" + +jest-resolve@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-29.7.0.tgz#64d6a8992dd26f635ab0c01e5eef4399c6bcbc30" + integrity sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA== + dependencies: + chalk "^4.0.0" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + jest-pnp-resolver "^1.2.2" + jest-util "^29.7.0" + jest-validate "^29.7.0" + resolve "^1.20.0" + resolve.exports "^2.0.0" + slash "^3.0.0" + +jest-runner@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-29.7.0.tgz#809af072d408a53dcfd2e849a4c976d3132f718e" + integrity sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ== + dependencies: + "@jest/console" "^29.7.0" + "@jest/environment" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + emittery "^0.13.1" + graceful-fs "^4.2.9" + jest-docblock "^29.7.0" + jest-environment-node "^29.7.0" + jest-haste-map "^29.7.0" + jest-leak-detector "^29.7.0" + jest-message-util "^29.7.0" + jest-resolve "^29.7.0" + jest-runtime "^29.7.0" + jest-util "^29.7.0" + jest-watcher "^29.7.0" + jest-worker "^29.7.0" + p-limit "^3.1.0" + source-map-support "0.5.13" + +jest-runtime@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-29.7.0.tgz#efecb3141cf7d3767a3a0cc8f7c9990587d3d817" + integrity sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/fake-timers" "^29.7.0" + "@jest/globals" "^29.7.0" + "@jest/source-map" "^29.6.3" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + cjs-module-lexer "^1.0.0" + collect-v8-coverage "^1.0.0" + glob "^7.1.3" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + jest-message-util "^29.7.0" + jest-mock "^29.7.0" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" + slash "^3.0.0" + strip-bom "^4.0.0" + +jest-snapshot@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-29.7.0.tgz#c2c574c3f51865da1bb329036778a69bf88a6be5" + integrity sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw== + dependencies: + "@babel/core" "^7.11.6" + "@babel/generator" "^7.7.2" + "@babel/plugin-syntax-jsx" "^7.7.2" + "@babel/plugin-syntax-typescript" "^7.7.2" + "@babel/types" "^7.3.3" + "@jest/expect-utils" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + babel-preset-current-node-syntax "^1.0.0" + chalk "^4.0.0" + expect "^29.7.0" + graceful-fs "^4.2.9" + jest-diff "^29.7.0" + jest-get-type "^29.6.3" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + natural-compare "^1.4.0" + pretty-format "^29.7.0" + semver "^7.5.3" + +jest-util@^29.0.0, jest-util@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.7.0.tgz#23c2b62bfb22be82b44de98055802ff3710fc0bc" + integrity sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA== + dependencies: + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + ci-info "^3.2.0" + graceful-fs "^4.2.9" + picomatch "^2.2.3" + +jest-validate@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-29.7.0.tgz#7bf705511c64da591d46b15fce41400d52147d9c" + integrity sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw== + dependencies: + "@jest/types" "^29.6.3" + camelcase "^6.2.0" + chalk "^4.0.0" + jest-get-type "^29.6.3" + leven "^3.1.0" + pretty-format "^29.7.0" + +jest-watcher@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-29.7.0.tgz#7810d30d619c3a62093223ce6bb359ca1b28a2f2" + integrity sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g== + dependencies: + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + ansi-escapes "^4.2.1" + chalk "^4.0.0" + emittery "^0.13.1" + jest-util "^29.7.0" + string-length "^4.0.1" + +jest-worker@^27.4.5: + version "27.5.1" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" + integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== + dependencies: + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^8.0.0" + +jest-worker@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-29.7.0.tgz#acad073acbbaeb7262bd5389e1bcf43e10058d4a" + integrity sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw== + dependencies: + "@types/node" "*" + jest-util "^29.7.0" + merge-stream "^2.0.0" + supports-color "^8.0.0" + +jest@29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest/-/jest-29.7.0.tgz#994676fc24177f088f1c5e3737f5697204ff2613" + integrity sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw== + dependencies: + "@jest/core" "^29.7.0" + "@jest/types" "^29.6.3" + import-local "^3.0.2" + jest-cli "^29.7.0" + +js-base64@3.7.2: + version "3.7.2" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.2.tgz#816d11d81a8aff241603d19ce5761e13e41d7745" + integrity sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ== + +js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-yaml@^3.13.1: + version "3.14.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +jsdom@^20.0.0: + version "20.0.3" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-20.0.3.tgz#886a41ba1d4726f67a8858028c99489fed6ad4db" + integrity sha512-SYhBvTh89tTfCD/CRdSOm13mOBa42iTaTyfyEWBdKcGdPxPtLFBXuHR8XHb33YNYaP+lLbmSvBTsnoesCNJEsQ== + dependencies: + abab "^2.0.6" + acorn "^8.8.1" + acorn-globals "^7.0.0" + cssom "^0.5.0" + cssstyle "^2.3.0" + data-urls "^3.0.2" + decimal.js "^10.4.2" + domexception "^4.0.0" + escodegen "^2.0.0" + form-data "^4.0.0" + html-encoding-sniffer "^3.0.0" + http-proxy-agent "^5.0.0" + https-proxy-agent "^5.0.1" + is-potential-custom-element-name "^1.0.1" + nwsapi "^2.2.2" + parse5 "^7.1.1" + saxes "^6.0.0" + symbol-tree "^3.2.4" + tough-cookie "^4.1.2" + w3c-xmlserializer "^4.0.0" + webidl-conversions "^7.0.0" + whatwg-encoding "^2.0.0" + whatwg-mimetype "^3.0.0" + whatwg-url "^11.0.0" + ws "^8.11.0" + xml-name-validator "^4.0.0" + +jsesc@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.0.2.tgz#bb8b09a6597ba426425f2e4a07245c3d00b9343e" + integrity sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g== + +json-parse-even-better-errors@^2.3.0, json-parse-even-better-errors@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" + integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json5@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== + +kleur@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" + integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== + +leven@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" + integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== + +lines-and-columns@^1.1.6: + version "1.2.4" + resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" + integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== + +loader-runner@^4.2.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" + integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg== + +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" + +lodash.isequal@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" + integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ== + +lodash.memoize@4.x: + version "4.1.2" + resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" + integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag== + +lodash.sortby@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" + integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA== + +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" + +make-dir@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" + integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== + dependencies: + semver "^7.5.3" + +make-error@1.x: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +makeerror@1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.12.tgz#3e5dd2079a82e812e983cc6610c4a2cb0eaa801a" + integrity sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg== + dependencies: + tmpl "1.0.5" + +merge-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" + integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== + +micromatch@^4.0.0, micromatch@^4.0.4: + version "4.0.8" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" + integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== + dependencies: + braces "^3.0.3" + picomatch "^2.3.1" + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12, mime-types@^2.1.27: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +minimatch@^3.0.4, minimatch@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +ms@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== + +neo-async@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" + integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== + +node-fetch@2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + +node-int64@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" + integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== + +node-releases@^2.0.18: + version "2.0.18" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.18.tgz#f010e8d35e2fe8d6b2944f03f70213ecedc4ca3f" + integrity sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g== + +normalize-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +npm-run-path@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" + integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== + dependencies: + path-key "^3.0.0" + +nwsapi@^2.2.2: + version "2.2.13" + resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.13.tgz#e56b4e98960e7a040e5474536587e599c4ff4655" + integrity sha512-cTGB9ptp9dY9A5VbMSe7fQBcl/tt22Vcqdq8+eN93rblOuE0aCFu4aZ2vMwct/2t+lFnosm8RkQW1I0Omb1UtQ== + +object-inspect@^1.13.1: + version "1.13.2" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" + integrity sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +onetime@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +p-limit@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-limit@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +parse-json@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" + integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== + dependencies: + "@babel/code-frame" "^7.0.0" + error-ex "^1.3.1" + json-parse-even-better-errors "^2.3.0" + lines-and-columns "^1.1.6" + +parse5@^7.0.0, parse5@^7.1.1: + version "7.2.1" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.2.1.tgz#8928f55915e6125f430cc44309765bf17556a33a" + integrity sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ== + dependencies: + entities "^4.5.0" + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-key@^3.0.0, path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== + +path-to-regexp@^2.2.1: + version "2.4.0" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-2.4.0.tgz#35ce7f333d5616f1c1e1bfe266c3aba2e5b2e704" + integrity sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w== + +picocolors@^1.0.0, picocolors@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== + +picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +pirates@^4.0.4: + version "4.0.6" + resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9" + integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg== + +pkg-dir@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + +prettier@2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" + integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== + +pretty-format@^29.0.0, pretty-format@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812" + integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ== + dependencies: + "@jest/schemas" "^29.6.3" + ansi-styles "^5.0.0" + react-is "^18.0.0" + +process@^0.11.10: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== + +prompts@^2.0.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" + integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== + dependencies: + kleur "^3.0.3" + sisteransi "^1.0.5" + +psl@^1.1.33: + version "1.9.0" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" + integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== + +punycode@^2.1.0, punycode@^2.1.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + +pure-rand@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-6.1.0.tgz#d173cf23258231976ccbdb05247c9787957604f2" + integrity sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA== + +qs@6.11.2: + version "6.11.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.2.tgz#64bea51f12c1f5da1bc01496f48ffcff7c69d7d9" + integrity sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA== + dependencies: + side-channel "^1.0.4" + +querystring@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd" + integrity sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg== + +querystringify@^2.1.1: + version "2.2.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" + integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== + +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +react-is@^18.0.0: + version "18.3.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" + integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== + +readable-stream@^4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-4.5.2.tgz#9e7fc4c45099baeed934bff6eb97ba6cf2729e09" + integrity sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g== + dependencies: + abort-controller "^3.0.0" + buffer "^6.0.3" + events "^3.3.0" + process "^0.11.10" + string_decoder "^1.3.0" + +regenerator-runtime@^0.14.0: + version "0.14.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" + integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +requires-port@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== + +resolve-cwd@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" + integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== + dependencies: + resolve-from "^5.0.0" + +resolve-from@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" + integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== + +resolve.exports@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-2.0.2.tgz#f8c934b8e6a13f539e38b7098e2e36134f01e800" + integrity sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg== + +resolve@^1.20.0: + version "1.22.8" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" + integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== + dependencies: + is-core-module "^2.13.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +safe-buffer@^5.1.0, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +"safer-buffer@>= 2.1.2 < 3.0.0": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +saxes@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/saxes/-/saxes-6.0.0.tgz#fe5b4a4768df4f14a201b1ba6a65c1f3d9988cc5" + integrity sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA== + dependencies: + xmlchars "^2.2.0" + +schema-utils@^3.1.1, schema-utils@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe" + integrity sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg== + dependencies: + "@types/json-schema" "^7.0.8" + ajv "^6.12.5" + ajv-keywords "^3.5.2" + +semver@^6.3.0, semver@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== + +semver@^7.3.4, semver@^7.5.3, semver@^7.5.4: + version "7.6.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" + integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== + +serialize-javascript@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" + integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== + dependencies: + randombytes "^2.1.0" + +set-function-length@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +side-channel@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2" + integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA== + dependencies: + call-bind "^1.0.7" + es-errors "^1.3.0" + get-intrinsic "^1.2.4" + object-inspect "^1.13.1" + +signal-exit@^3.0.3, signal-exit@^3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +sisteransi@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" + integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== + +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== + +source-map-support@0.5.13: + version "0.5.13" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" + integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map-support@~0.5.20: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +source-map@^0.7.4: + version "0.7.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656" + integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA== + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + +stack-utils@^2.0.3: + version "2.0.6" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" + integrity sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ== + dependencies: + escape-string-regexp "^2.0.0" + +string-length@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a" + integrity sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ== + dependencies: + char-regex "^1.0.2" + strip-ansi "^6.0.0" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string_decoder@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-bom@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" + integrity sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w== + +strip-final-newline@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" + integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== + +strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-color@^8.0.0: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + +symbol-tree@^3.2.4: + version "3.2.4" + resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" + integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== + +tapable@^2.1.1, tapable@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" + integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== + +terser-webpack-plugin@^5.3.10: + version "5.3.10" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz#904f4c9193c6fd2a03f693a2150c62a92f40d199" + integrity sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w== + dependencies: + "@jridgewell/trace-mapping" "^0.3.20" + jest-worker "^27.4.5" + schema-utils "^3.1.1" + serialize-javascript "^6.0.1" + terser "^5.26.0" + +terser@^5.26.0: + version "5.36.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.36.0.tgz#8b0dbed459ac40ff7b4c9fd5a3a2029de105180e" + integrity sha512-IYV9eNMuFAV4THUspIRXkLakHnV6XO7FEdtKjf/mDyrnqUg9LnlOn6/RwRvM9SZjR4GUq8Nk8zj67FzVARr74w== + dependencies: + "@jridgewell/source-map" "^0.3.3" + acorn "^8.8.2" + commander "^2.20.0" + source-map-support "~0.5.20" + +test-exclude@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" + integrity sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w== + dependencies: + "@istanbuljs/schema" "^0.1.2" + glob "^7.1.4" + minimatch "^3.0.4" + +tmpl@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" + integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw== + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +tough-cookie@^4.1.2: + version "4.1.4" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.4.tgz#945f1461b45b5a8c76821c33ea49c3ac192c1b36" + integrity sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag== + dependencies: + psl "^1.1.33" + punycode "^2.1.1" + universalify "^0.2.0" + url-parse "^1.5.3" + +tr46@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" + integrity sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA== + dependencies: + punycode "^2.1.0" + +tr46@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9" + integrity sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA== + dependencies: + punycode "^2.1.1" + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + +ts-jest@29.1.1: + version "29.1.1" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.1.1.tgz#f58fe62c63caf7bfcc5cc6472082f79180f0815b" + integrity sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA== + dependencies: + bs-logger "0.x" + fast-json-stable-stringify "2.x" + jest-util "^29.0.0" + json5 "^2.2.3" + lodash.memoize "4.x" + make-error "1.x" + semver "^7.5.3" + yargs-parser "^21.0.1" + +ts-loader@^9.3.1: + version "9.5.1" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.5.1.tgz#63d5912a86312f1fbe32cef0859fb8b2193d9b89" + integrity sha512-rNH3sK9kGZcH9dYzC7CewQm4NtxJTjSEVRJ2DyBZR7f8/wcta+iV44UPCXc5+nzDzivKtlzV6c9P4e+oFhDLYg== + dependencies: + chalk "^4.1.0" + enhanced-resolve "^5.0.0" + micromatch "^4.0.0" + semver "^7.3.4" + source-map "^0.7.4" + +type-detect@4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + +type-fest@^0.21.3: + version "0.21.3" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" + integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== + +typescript@4.6.4: + version "4.6.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" + integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== + +undici-types@~6.19.8: + version "6.19.8" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" + integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== + +universalify@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0" + integrity sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg== + +update-browserslist-db@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz#80846fba1d79e82547fb661f8d141e0945755fe5" + integrity sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A== + dependencies: + escalade "^3.2.0" + picocolors "^1.1.0" + +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +url-join@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7" + integrity sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA== + +url-parse@^1.5.3: + version "1.5.10" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1" + integrity sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ== + dependencies: + querystringify "^2.1.1" + requires-port "^1.0.0" + +v8-to-istanbul@^9.0.1: + version "9.3.0" + resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz#b9572abfa62bd556c16d75fdebc1a411d5ff3175" + integrity sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA== + dependencies: + "@jridgewell/trace-mapping" "^0.3.12" + "@types/istanbul-lib-coverage" "^2.0.1" + convert-source-map "^2.0.0" + +w3c-xmlserializer@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz#aebdc84920d806222936e3cdce408e32488a3073" + integrity sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw== + dependencies: + xml-name-validator "^4.0.0" + +walker@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.8.tgz#bd498db477afe573dc04185f011d3ab8a8d7653f" + integrity sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ== + dependencies: + makeerror "1.0.12" + +watchpack@^2.4.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.2.tgz#2feeaed67412e7c33184e5a79ca738fbd38564da" + integrity sha512-TnbFSbcOCcDgjZ4piURLCbJ3nJhznVh9kw6F6iokjiFPl8ONxe9A6nMDVXDiNbrSfLILs6vB07F7wLBrwPYzJw== + dependencies: + glob-to-regexp "^0.4.1" + graceful-fs "^4.1.2" + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +webidl-conversions@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" + integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== + +webidl-conversions@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a" + integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== + +webpack-sources@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" + integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== + +webpack@^5.94.0: + version "5.96.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.96.1.tgz#3676d1626d8312b6b10d0c18cc049fba7ac01f0c" + integrity sha512-l2LlBSvVZGhL4ZrPwyr8+37AunkcYj5qh8o6u2/2rzoPc8gxFJkLj1WxNgooi9pnoc06jh0BjuXnamM4qlujZA== + dependencies: + "@types/eslint-scope" "^3.7.7" + "@types/estree" "^1.0.6" + "@webassemblyjs/ast" "^1.12.1" + "@webassemblyjs/wasm-edit" "^1.12.1" + "@webassemblyjs/wasm-parser" "^1.12.1" + acorn "^8.14.0" + browserslist "^4.24.0" + chrome-trace-event "^1.0.2" + enhanced-resolve "^5.17.1" + es-module-lexer "^1.2.1" + eslint-scope "5.1.1" + events "^3.2.0" + glob-to-regexp "^0.4.1" + graceful-fs "^4.2.11" + json-parse-even-better-errors "^2.3.1" + loader-runner "^4.2.0" + mime-types "^2.1.27" + neo-async "^2.6.2" + schema-utils "^3.2.0" + tapable "^2.1.1" + terser-webpack-plugin "^5.3.10" + watchpack "^2.4.1" + webpack-sources "^3.2.3" + +whatwg-encoding@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz#e7635f597fd87020858626805a2729fa7698ac53" + integrity sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg== + dependencies: + iconv-lite "0.6.3" + +whatwg-mimetype@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz#5fa1a7623867ff1af6ca3dc72ad6b8a4208beba7" + integrity sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q== + +whatwg-url@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-11.0.0.tgz#0a849eebb5faf2119b901bb76fd795c2848d4018" + integrity sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ== + dependencies: + tr46 "^3.0.0" + webidl-conversions "^7.0.0" + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +whatwg-url@^6.5.0: + version "6.5.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.5.0.tgz#f2df02bff176fd65070df74ad5ccbb5a199965a8" + integrity sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ== + dependencies: + lodash.sortby "^4.7.0" + tr46 "^1.0.1" + webidl-conversions "^4.0.2" + +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +write-file-atomic@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-4.0.2.tgz#a9df01ae5b77858a027fd2e80768ee433555fcfd" + integrity sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg== + dependencies: + imurmurhash "^0.1.4" + signal-exit "^3.0.7" + +ws@^8.11.0: + version "8.18.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" + integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== + +xml-name-validator@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz#79a006e2e63149a8600f15430f0a4725d1524835" + integrity sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw== + +xmlchars@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" + integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + +yargs-parser@^21.0.1, yargs-parser@^21.1.1: + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== + +yargs@^17.3.1: + version "17.7.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" + integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== + dependencies: + cliui "^8.0.1" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.3" + y18n "^5.0.5" + yargs-parser "^21.1.1" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==