diff --git a/README.md b/README.md index 0c9ce27..e5efcca 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ npm i -s @monite/node-client ## Reference -A full reference for this library is available [here](./reference.md). +A full reference for this library is available [here](https://github.com/team-monite/monite-node-client/blob/HEAD/./reference.md). ## Usage diff --git a/jest.config.mjs b/jest.config.mjs index c724821..3ad4cdb 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -3,6 +3,7 @@ export default { preset: "ts-jest", testEnvironment: "node", moduleNameMapper: { - "(.+)\.js$": "$1", + "^(\.{1,2}/.*)\.js$": "$1", }, + setupFilesAfterEnv: ["/tests/mock-server/setup.ts"], }; diff --git a/package.json b/package.json index b39fcca..00eb392 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,40 @@ { "name": "@monite/node-client", - "version": "0.3.3", + "version": "0.3.4", "private": false, "repository": "https://github.com/team-monite/monite-node-client", "license": "MIT", - "main": "./index.js", - "types": "./index.d.ts", + "type": "commonjs", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.mjs", + "types": "./dist/cjs/index.d.ts", + "exports": { + ".": { + "types": "./dist/cjs/index.d.ts", + "import": { + "types": "./dist/esm/index.d.mts", + "default": "./dist/esm/index.mjs" + }, + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "default": "./dist/cjs/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist", + "reference.md" + ], "scripts": { "format": "prettier . --write --ignore-unknown", - "build": "tsc", - "prepack": "cp -rv dist/. .", - "test": "jest" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc --project ./tsconfig.cjs.json", + "build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm", + "test": "jest tests/unit --passWithNoTests", + "test:wire": "jest tests/wire --passWithNoTests", + "wire:test": "yarn test:wire" }, "dependencies": { "url-join": "4.0.1", @@ -30,9 +54,11 @@ "webpack": "^5.97.1", "ts-loader": "^9.5.1", "jest": "^29.7.0", + "@jest/globals": "^29.7.0", "@types/jest": "^29.5.14", - "ts-jest": "^29.1.1", + "ts-jest": "^29.3.4", "jest-environment-jsdom": "^29.7.0", + "msw": "^2.8.4", "@types/node": "^18.19.70", "prettier": "^3.4.2", "typescript": "~5.7.2" diff --git a/reference.md b/reference.md index da5fe71..140bfb4 100644 --- a/reference.md +++ b/reference.md @@ -1959,6 +1959,256 @@ await client.counterpartEInvoicingCredentials.patchCounterpartsIdEinvoicingCrede +## Custom VAT rates + +
client.customVatRates.getCustomVatRates() -> Monite.CustomVatRateResponseList +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.customVatRates.getCustomVatRates(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `CustomVatRates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.customVatRates.postCustomVatRates({ ...params }) -> Monite.CustomVatRateResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.customVatRates.postCustomVatRates({ + components: [ + { + name: "name", + value: 1.1, + }, + ], + name: "name", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.CustomVatRateRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomVatRates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.customVatRates.getCustomVatRatesId(customVatRateId) -> Monite.CustomVatRateResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.customVatRates.getCustomVatRatesId("custom_vat_rate_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customVatRateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `CustomVatRates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.customVatRates.deleteCustomVatRatesId(customVatRateId) -> void +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.customVatRates.deleteCustomVatRatesId("custom_vat_rate_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customVatRateId:** `string` + +
+
+ +
+
+ +**requestOptions:** `CustomVatRates.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.customVatRates.patchCustomVatRatesId(customVatRateId, { ...params }) -> Monite.CustomVatRateResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.customVatRates.patchCustomVatRatesId("custom_vat_rate_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customVatRateId:** `string` + +
+
+ +
+
+ +**request:** `Monite.CustomVatRateUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomVatRates.RequestOptions` + +
+
+
+
+ +
+
+
+ ## DataExports
client.dataExports.get({ ...params }) -> Monite.AllDocumentExportResponseSchema @@ -2956,6 +3206,62 @@ await client.eInvoicingConnections.deleteEinvoicingConnectionsId("einvoicing_con
+
client.eInvoicingConnections.patchEinvoicingConnectionsId(einvoicingConnectionId, { ...params }) -> Monite.EinvoicingConnectionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.eInvoicingConnections.patchEinvoicingConnectionsId("einvoicing_connection_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**einvoicingConnectionId:** `string` + +
+
+ +
+
+ +**request:** `Monite.EinvoicingConnectionUpdateRequest` + +
+
+ +
+
+ +**requestOptions:** `EInvoicingConnections.RequestOptions` + +
+
+
+
+ +
+
+
+
client.eInvoicingConnections.postEinvoicingConnectionsIdNetworkCredentials(einvoicingConnectionId, { ...params }) -> Monite.EinvoicingNetworkCredentialsResponse
@@ -3530,7 +3836,7 @@ await client.entities.postEntitiesIdDeactivate("ea837e28-509b-4b6a-a600-d54b6aa0
-
client.entities.uploadLogoById(file, entityId) -> Monite.FileSchema2 +
client.entities.uploadLogoById(entityId, { ...params }) -> Monite.FileSchema2
@@ -3558,7 +3864,9 @@ Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for
```typescript -await client.entities.uploadLogoById(fs.createReadStream("/path/to/your/file"), "ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); +await client.entities.uploadLogoById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5", { + file: fs.createReadStream("/path/to/your/file"), +}); ```
@@ -3574,7 +3882,7 @@ await client.entities.uploadLogoById(fs.createReadStream("/path/to/your/file"),
-**file:** `File | fs.ReadStream | Blob` +**entityId:** `string`
@@ -3582,7 +3890,7 @@ await client.entities.uploadLogoById(fs.createReadStream("/path/to/your/file"),
-**entityId:** `string` +**request:** `Monite.BodyPutEntitiesIdLogo`
@@ -4825,7 +5133,7 @@ await client.files.get();
-
client.files.upload(file, { ...params }) -> Monite.FileResponse +
client.files.upload({ ...params }) -> Monite.FileResponse
@@ -4838,7 +5146,8 @@ await client.files.get();
```typescript -await client.files.upload(fs.createReadStream("/path/to/your/file"), { +await client.files.upload({ + file: fs.createReadStream("/path/to/your/file"), file_type: "ocr_results", }); ``` @@ -4856,14 +5165,6 @@ await client.files.upload(fs.createReadStream("/path/to/your/file"), {
-**file:** `File | fs.ReadStream | Blob` - -
-
- -
-
- **request:** `Monite.UploadFile`
@@ -6076,7 +6377,6 @@ Create a new mailbox await client.mailboxes.create({ mailbox_domain_id: "mailbox_domain_id", mailbox_name: "mailbox_name", - related_object_type: "payable", }); ``` @@ -6584,7 +6884,7 @@ await client.ocr.postOcrTasks({
-
client.ocr.postOcrTasksUploadFromFile(file, { ...params }) -> Monite.OcrTaskResponseSchema +
client.ocr.postOcrTasksUploadFromFile({ ...params }) -> Monite.OcrTaskResponseSchema
@@ -6597,7 +6897,9 @@ await client.ocr.postOcrTasks({
```typescript -await client.ocr.postOcrTasksUploadFromFile(fs.createReadStream("/path/to/your/file"), {}); +await client.ocr.postOcrTasksUploadFromFile({ + file: fs.createReadStream("/path/to/your/file"), +}); ```
@@ -6613,14 +6915,6 @@ await client.ocr.postOcrTasksUploadFromFile(fs.createReadStream("/path/to/your/f
-**file:** `File | fs.ReadStream | Blob` - -
-
- -
-
- **request:** `Monite.OcrFileUpload`
@@ -7033,7 +7327,7 @@ await client.creditNotes.postPayableCreditNotes({
-
client.creditNotes.postPayableCreditNotesUploadFromFile(file) -> Monite.CreditNoteResponse +
client.creditNotes.postPayableCreditNotesUploadFromFile({ ...params }) -> Monite.CreditNoteResponse
@@ -7045,7 +7339,7 @@ await client.creditNotes.postPayableCreditNotes({
-Upload an incoming credit note (payable) in PDF, PNG, JPEG, or TIFF format and scan its contents. The maximum file size is 10MB. +Upload an incoming credit note (payable) in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB.
@@ -7061,7 +7355,9 @@ Upload an incoming credit note (payable) in PDF, PNG, JPEG, or TIFF format and s
```typescript -await client.creditNotes.postPayableCreditNotesUploadFromFile(fs.createReadStream("/path/to/your/file")); +await client.creditNotes.postPayableCreditNotesUploadFromFile({ + file: fs.createReadStream("/path/to/your/file"), +}); ```
@@ -7077,7 +7373,7 @@ await client.creditNotes.postPayableCreditNotesUploadFromFile(fs.createReadStrea
-**file:** `File | fs.ReadStream | Blob` +**request:** `Monite.CreditNoteUploadFile`
@@ -8797,7 +9093,7 @@ await client.payables.getAnalytics();
-
client.payables.uploadFromFile(file) -> Monite.PayableResponseSchema +
client.payables.uploadFromFile({ ...params }) -> Monite.PayableResponseSchema
@@ -8809,7 +9105,7 @@ await client.payables.getAnalytics();
-Upload an incoming invoice (payable) in PDF, PNG, JPEG, or TIFF format and scan its contents. The maximum file size is 10MB. +Upload an incoming invoice (payable) in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB.
@@ -8825,7 +9121,9 @@ Upload an incoming invoice (payable) in PDF, PNG, JPEG, or TIFF format and scan
```typescript -await client.payables.uploadFromFile(fs.createReadStream("/path/to/your/file")); +await client.payables.uploadFromFile({ + file: fs.createReadStream("/path/to/your/file"), +}); ```
@@ -8841,7 +9139,7 @@ await client.payables.uploadFromFile(fs.createReadStream("/path/to/your/file"));
-**file:** `File | fs.ReadStream | Blob` +**request:** `Monite.PayableUploadFile`
@@ -9350,7 +9648,7 @@ await client.payables.approvePaymentById("payable_id");
-
client.payables.attachFileById(file, payableId) -> Monite.PayableResponseSchema +
client.payables.attachFileById(payableId, { ...params }) -> Monite.PayableResponseSchema
@@ -9378,7 +9676,9 @@ Attach file to payable without existing attachment.
```typescript -await client.payables.attachFileById(fs.createReadStream("/path/to/your/file"), "payable_id"); +await client.payables.attachFileById("payable_id", { + file: fs.createReadStream("/path/to/your/file"), +}); ```
@@ -9394,7 +9694,7 @@ await client.payables.attachFileById(fs.createReadStream("/path/to/your/file"),
-**file:** `File | fs.ReadStream | Blob` +**payableId:** `string`
@@ -9402,7 +9702,7 @@ await client.payables.attachFileById(fs.createReadStream("/path/to/your/file"),
-**payableId:** `string` +**request:** `Monite.PayableAttachFile`
@@ -9547,6 +9847,62 @@ await client.payables.postPayablesIdCancelOcr("payable_id");
+
client.payables.getPayablesIdHistory(payableId, { ...params }) -> Monite.PayableHistoryPaginationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.payables.getPayablesIdHistory("payable_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payableId:** `string` + +
+
+ +
+
+ +**request:** `Monite.GetPayablesIdHistoryRequest` + +
+
+ +
+
+ +**requestOptions:** `Payables.RequestOptions` + +
+
+
+
+ +
+
+
+
client.payables.markAsPaidById(payableId, { ...params }) -> Monite.PayableResponseSchema
@@ -12047,6 +12403,69 @@ await client.receivables.getReceivablesRequiredFields();
+
client.receivables.postReceivablesSearch({ ...params }) -> Monite.ReceivablePaginationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This is a POST version of the `GET /receivables` endpoint. Use it to send search and filter parameters in the request body instead of the URL query string in case the query is too long and exceeds the URL length limit of your HTTP client. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.receivables.postReceivablesSearch(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Monite.ReceivablesSearchRequest` + +
+
+ +
+
+ +**requestOptions:** `Receivables.RequestOptions` + +
+
+
+
+ +
+
+
+
client.receivables.getVariables() -> Monite.ReceivableTemplatesVariablesObjectList
@@ -13304,7 +13723,7 @@ await client.receivables.verifyById("receivable_id"); ## Recurrences -
client.recurrences.get() -> Monite.GetAllRecurrences +
client.recurrences.get() -> Monite.RecurrenceResponseList
@@ -13344,7 +13763,7 @@ await client.recurrences.get();
-
client.recurrences.create({ ...params }) -> Monite.Recurrence +
client.recurrences.create({ ...params }) -> Monite.RecurrenceResponse
@@ -13358,12 +13777,7 @@ await client.recurrences.get(); ```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, }); ``` @@ -13399,7 +13813,7 @@ await client.recurrences.create({
-
client.recurrences.getById(recurrenceId) -> Monite.Recurrence +
client.recurrences.getById(recurrenceId) -> Monite.RecurrenceResponse
@@ -13447,7 +13861,7 @@ await client.recurrences.getById("recurrence_id");
-
client.recurrences.updateById(recurrenceId, { ...params }) -> Monite.Recurrence +
client.recurrences.updateById(recurrenceId, { ...params }) -> Monite.RecurrenceResponse
@@ -13551,6 +13965,102 @@ await client.recurrences.cancelById("recurrence_id");
+
client.recurrences.postRecurrencesIdPause(recurrenceId) -> unknown +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.recurrences.postRecurrencesIdPause("recurrence_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**recurrenceId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Recurrences.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.recurrences.postRecurrencesIdResume(recurrenceId) -> unknown +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.recurrences.postRecurrencesIdResume("recurrence_id"); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**recurrenceId:** `string` + +
+
+ +
+
+ +**requestOptions:** `Recurrences.RequestOptions` + +
+
+
+
+ +
+
+
+ ## Roles
client.roles.get({ ...params }) -> Monite.RolePaginationResponse diff --git a/scripts/rename-to-esm-files.js b/scripts/rename-to-esm-files.js index 81dac6a..dc1df1c 100644 --- a/scripts/rename-to-esm-files.js +++ b/scripts/rename-to-esm-files.js @@ -50,8 +50,16 @@ async function updateFileContents(file) { let newContent = content; // Update each extension type defined in the map for (const [oldExt, newExt] of Object.entries(extensionMap)) { - const regex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g"); - newContent = newContent.replace(regex, `$1$2$3${newExt}$5`); + // Handle static imports/exports + const staticRegex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g"); + newContent = newContent.replace(staticRegex, `$1$2$3${newExt}$5`); + + // Handle dynamic imports (yield import, await import, regular import()) + const dynamicRegex = new RegExp( + `(yield\\s+import|await\\s+import|import)\\s*\\(\\s*['"](\\.\\.\?\\/[^'"]+)(\\${oldExt})['"]\\s*\\)`, + "g", + ); + newContent = newContent.replace(dynamicRegex, `$1("$2${newExt}")`); } if (content !== newContent) { diff --git a/src/Client.ts b/src/Client.ts index 8b242e1..d3d0ab4 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -2,50 +2,52 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as environments from "./environments"; -import * as core from "./core"; -import { Analytics } from "./api/resources/analytics/client/Client"; -import { ApprovalPolicies } from "./api/resources/approvalPolicies/client/Client"; -import { ApprovalRequests } from "./api/resources/approvalRequests/client/Client"; -import { AccessTokens } from "./api/resources/accessTokens/client/Client"; -import { Comments } from "./api/resources/comments/client/Client"; -import { Counterparts } from "./api/resources/counterparts/client/Client"; -import { CounterpartEInvoicingCredentials } from "./api/resources/counterpartEInvoicingCredentials/client/Client"; -import { DataExports } from "./api/resources/dataExports/client/Client"; -import { DeliveryNotes } from "./api/resources/deliveryNotes/client/Client"; -import { PdfTemplates } from "./api/resources/pdfTemplates/client/Client"; -import { EInvoicingConnections } from "./api/resources/eInvoicingConnections/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 { Financing } from "./api/resources/financing/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 { Ocr } from "./api/resources/ocr/client/Client"; -import { OverdueReminders } from "./api/resources/overdueReminders/client/Client"; -import { CreditNotes } from "./api/resources/creditNotes/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"; +import * as environments from "./environments.js"; +import * as core from "./core/index.js"; +import { mergeHeaders } from "./core/headers.js"; +import { Analytics } from "./api/resources/analytics/client/Client.js"; +import { ApprovalPolicies } from "./api/resources/approvalPolicies/client/Client.js"; +import { ApprovalRequests } from "./api/resources/approvalRequests/client/Client.js"; +import { AccessTokens } from "./api/resources/accessTokens/client/Client.js"; +import { Comments } from "./api/resources/comments/client/Client.js"; +import { Counterparts } from "./api/resources/counterparts/client/Client.js"; +import { CounterpartEInvoicingCredentials } from "./api/resources/counterpartEInvoicingCredentials/client/Client.js"; +import { CustomVatRates } from "./api/resources/customVatRates/client/Client.js"; +import { DataExports } from "./api/resources/dataExports/client/Client.js"; +import { DeliveryNotes } from "./api/resources/deliveryNotes/client/Client.js"; +import { PdfTemplates } from "./api/resources/pdfTemplates/client/Client.js"; +import { EInvoicingConnections } from "./api/resources/eInvoicingConnections/client/Client.js"; +import { Entities } from "./api/resources/entities/client/Client.js"; +import { EntityUsers } from "./api/resources/entityUsers/client/Client.js"; +import { Events } from "./api/resources/events/client/Client.js"; +import { Files } from "./api/resources/files/client/Client.js"; +import { Financing } from "./api/resources/financing/client/Client.js"; +import { MailTemplates } from "./api/resources/mailTemplates/client/Client.js"; +import { MailboxDomains } from "./api/resources/mailboxDomains/client/Client.js"; +import { Mailboxes } from "./api/resources/mailboxes/client/Client.js"; +import { MeasureUnits } from "./api/resources/measureUnits/client/Client.js"; +import { Ocr } from "./api/resources/ocr/client/Client.js"; +import { OverdueReminders } from "./api/resources/overdueReminders/client/Client.js"; +import { CreditNotes } from "./api/resources/creditNotes/client/Client.js"; +import { PurchaseOrders } from "./api/resources/purchaseOrders/client/Client.js"; +import { Payables } from "./api/resources/payables/client/Client.js"; +import { PaymentIntents } from "./api/resources/paymentIntents/client/Client.js"; +import { PaymentLinks } from "./api/resources/paymentLinks/client/Client.js"; +import { PaymentRecords } from "./api/resources/paymentRecords/client/Client.js"; +import { PaymentReminders } from "./api/resources/paymentReminders/client/Client.js"; +import { PaymentTerms } from "./api/resources/paymentTerms/client/Client.js"; +import { Products } from "./api/resources/products/client/Client.js"; +import { Projects } from "./api/resources/projects/client/Client.js"; +import { Receivables } from "./api/resources/receivables/client/Client.js"; +import { Recurrences } from "./api/resources/recurrences/client/Client.js"; +import { Roles } from "./api/resources/roles/client/Client.js"; +import { PartnerSettings } from "./api/resources/partnerSettings/client/Client.js"; +import { Tags } from "./api/resources/tags/client/Client.js"; +import { TextTemplates } from "./api/resources/textTemplates/client/Client.js"; +import { VatRates } from "./api/resources/vatRates/client/Client.js"; +import { WebhookDeliveries } from "./api/resources/webhookDeliveries/client/Client.js"; +import { WebhookSubscriptions } from "./api/resources/webhookSubscriptions/client/Client.js"; +import { Accounting } from "./api/resources/accounting/client/Client.js"; export declare namespace MoniteClient { export interface Options { @@ -57,6 +59,8 @@ export declare namespace MoniteClient { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -72,11 +76,12 @@ export declare namespace MoniteClient { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class MoniteClient { + protected readonly _options: MoniteClient.Options; protected _analytics: Analytics | undefined; protected _approvalPolicies: ApprovalPolicies | undefined; protected _approvalRequests: ApprovalRequests | undefined; @@ -84,6 +89,7 @@ export class MoniteClient { protected _comments: Comments | undefined; protected _counterparts: Counterparts | undefined; protected _counterpartEInvoicingCredentials: CounterpartEInvoicingCredentials | undefined; + protected _customVatRates: CustomVatRates | undefined; protected _dataExports: DataExports | undefined; protected _deliveryNotes: DeliveryNotes | undefined; protected _pdfTemplates: PdfTemplates | undefined; @@ -120,7 +126,24 @@ export class MoniteClient { protected _webhookSubscriptions: WebhookSubscriptions | undefined; protected _accounting: Accounting | undefined; - constructor(protected readonly _options: MoniteClient.Options) {} + constructor(_options: MoniteClient.Options) { + this._options = { + ..._options, + headers: mergeHeaders( + { + "x-monite-version": _options?.moniteVersion, + "x-monite-entity-id": _options?.moniteEntityId, + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@monite/node-client", + "X-Fern-SDK-Version": "0.3.4", + "User-Agent": "@monite/node-client/0.3.4", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + _options?.headers, + ), + }; + } public get analytics(): Analytics { return (this._analytics ??= new Analytics(this._options)); @@ -150,6 +173,10 @@ export class MoniteClient { return (this._counterpartEInvoicingCredentials ??= new CounterpartEInvoicingCredentials(this._options)); } + public get customVatRates(): CustomVatRates { + return (this._customVatRates ??= new CustomVatRates(this._options)); + } + public get dataExports(): DataExports { return (this._dataExports ??= new DataExports(this._options)); } diff --git a/src/api/errors/BadRequestError.ts b/src/api/errors/BadRequestError.ts index b867a90..276464d 100644 --- a/src/api/errors/BadRequestError.ts +++ b/src/api/errors/BadRequestError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class BadRequestError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/ConflictError.ts b/src/api/errors/ConflictError.ts index 7a36dce..d2ed4b3 100644 --- a/src/api/errors/ConflictError.ts +++ b/src/api/errors/ConflictError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class ConflictError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/ContentTooLargeError.ts b/src/api/errors/ContentTooLargeError.ts index 70df937..c2690ac 100644 --- a/src/api/errors/ContentTooLargeError.ts +++ b/src/api/errors/ContentTooLargeError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class ContentTooLargeError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/FailedDependencyError.ts b/src/api/errors/FailedDependencyError.ts index 2cb0b45..119dd23 100644 --- a/src/api/errors/FailedDependencyError.ts +++ b/src/api/errors/FailedDependencyError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class FailedDependencyError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/ForbiddenError.ts b/src/api/errors/ForbiddenError.ts index c80a942..6513072 100644 --- a/src/api/errors/ForbiddenError.ts +++ b/src/api/errors/ForbiddenError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class ForbiddenError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/InternalServerError.ts b/src/api/errors/InternalServerError.ts index cbe2d83..5ca288c 100644 --- a/src/api/errors/InternalServerError.ts +++ b/src/api/errors/InternalServerError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class InternalServerError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/MisdirectedRequestError.ts b/src/api/errors/MisdirectedRequestError.ts index cf875ef..f1acdac 100644 --- a/src/api/errors/MisdirectedRequestError.ts +++ b/src/api/errors/MisdirectedRequestError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class MisdirectedRequestError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/NotAcceptableError.ts b/src/api/errors/NotAcceptableError.ts index b44d727..5a2acd5 100644 --- a/src/api/errors/NotAcceptableError.ts +++ b/src/api/errors/NotAcceptableError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class NotAcceptableError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/NotFoundError.ts b/src/api/errors/NotFoundError.ts index 08a9428..aee3e2e 100644 --- a/src/api/errors/NotFoundError.ts +++ b/src/api/errors/NotFoundError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class NotFoundError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/UnauthorizedError.ts b/src/api/errors/UnauthorizedError.ts index f49064f..421b519 100644 --- a/src/api/errors/UnauthorizedError.ts +++ b/src/api/errors/UnauthorizedError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class UnauthorizedError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/UnprocessableEntityError.ts b/src/api/errors/UnprocessableEntityError.ts index ae07122..5be08fd 100644 --- a/src/api/errors/UnprocessableEntityError.ts +++ b/src/api/errors/UnprocessableEntityError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class UnprocessableEntityError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/UnsupportedMediaTypeError.ts b/src/api/errors/UnsupportedMediaTypeError.ts index 307adab..32e8a86 100644 --- a/src/api/errors/UnsupportedMediaTypeError.ts +++ b/src/api/errors/UnsupportedMediaTypeError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as errors from "../../errors/index"; -import * as core from "../../core"; +import * as errors from "../../errors/index.js"; +import * as core from "../../core/index.js"; export class UnsupportedMediaTypeError extends errors.MoniteError { constructor(body?: unknown, rawResponse?: core.RawResponse) { diff --git a/src/api/errors/index.ts b/src/api/errors/index.ts index 2835a3c..5bda1ac 100644 --- a/src/api/errors/index.ts +++ b/src/api/errors/index.ts @@ -1,12 +1,12 @@ -export * from "./UnprocessableEntityError"; -export * from "./InternalServerError"; -export * from "./UnauthorizedError"; -export * from "./ForbiddenError"; -export * from "./BadRequestError"; -export * from "./ConflictError"; -export * from "./NotFoundError"; -export * from "./NotAcceptableError"; -export * from "./ContentTooLargeError"; -export * from "./UnsupportedMediaTypeError"; -export * from "./MisdirectedRequestError"; -export * from "./FailedDependencyError"; +export * from "./UnprocessableEntityError.js"; +export * from "./InternalServerError.js"; +export * from "./UnauthorizedError.js"; +export * from "./ForbiddenError.js"; +export * from "./BadRequestError.js"; +export * from "./ConflictError.js"; +export * from "./NotFoundError.js"; +export * from "./NotAcceptableError.js"; +export * from "./ContentTooLargeError.js"; +export * from "./UnsupportedMediaTypeError.js"; +export * from "./MisdirectedRequestError.js"; +export * from "./FailedDependencyError.js"; diff --git a/src/api/index.ts b/src/api/index.ts index 3006072..72cddbe 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,3 +1,3 @@ -export * from "./resources"; -export * from "./types"; -export * from "./errors"; +export * from "./resources/index.js"; +export * from "./types/index.js"; +export * from "./errors/index.js"; diff --git a/src/api/resources/accessTokens/client/Client.ts b/src/api/resources/accessTokens/client/Client.ts index 2d3b25f..0753fee 100644 --- a/src/api/resources/accessTokens/client/Client.ts +++ b/src/api/resources/accessTokens/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace AccessTokens { export interface Options { @@ -18,6 +19,8 @@ export declare namespace AccessTokens { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace AccessTokens { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class AccessTokens { - constructor(protected readonly _options: AccessTokens.Options) {} + protected readonly _options: AccessTokens.Options; + + constructor(_options: AccessTokens.Options) { + this._options = _options; + } /** * Revoke an existing token immediately. @@ -75,21 +82,15 @@ export class AccessTokens { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -169,21 +170,15 @@ export class AccessTokens { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/accessTokens/client/index.ts b/src/api/resources/accessTokens/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/accessTokens/client/index.ts +++ b/src/api/resources/accessTokens/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/accessTokens/client/requests/ObtainTokenPayload.ts b/src/api/resources/accessTokens/client/requests/ObtainTokenPayload.ts index 7469ff3..617adfc 100644 --- a/src/api/resources/accessTokens/client/requests/ObtainTokenPayload.ts +++ b/src/api/resources/accessTokens/client/requests/ObtainTokenPayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/accessTokens/client/requests/index.ts b/src/api/resources/accessTokens/client/requests/index.ts index bcdd0bc..737ab6f 100644 --- a/src/api/resources/accessTokens/client/requests/index.ts +++ b/src/api/resources/accessTokens/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type RevokeTokenPayload } from "./RevokeTokenPayload"; -export { type ObtainTokenPayload } from "./ObtainTokenPayload"; +export { type RevokeTokenPayload } from "./RevokeTokenPayload.js"; +export { type ObtainTokenPayload } from "./ObtainTokenPayload.js"; diff --git a/src/api/resources/accessTokens/index.ts b/src/api/resources/accessTokens/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/accessTokens/index.ts +++ b/src/api/resources/accessTokens/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/accounting/client/Client.ts b/src/api/resources/accounting/client/Client.ts index 6a9cd6c..b7709c4 100644 --- a/src/api/resources/accounting/client/Client.ts +++ b/src/api/resources/accounting/client/Client.ts @@ -2,14 +2,14 @@ * 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"; +import * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import { Payables } from "../resources/payables/client/Client.js"; +import { Receivables } from "../resources/receivables/client/Client.js"; +import { Connections } from "../resources/connections/client/Client.js"; +import { SyncedRecords } from "../resources/syncedRecords/client/Client.js"; +import { TaxRates } from "../resources/taxRates/client/Client.js"; +import { LedgerAccounts } from "../resources/ledgerAccounts/client/Client.js"; export declare namespace Accounting { export interface Options { @@ -21,11 +21,14 @@ export declare namespace Accounting { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } } export class Accounting { + protected readonly _options: Accounting.Options; protected _payables: Payables | undefined; protected _receivables: Receivables | undefined; protected _connections: Connections | undefined; @@ -33,7 +36,9 @@ export class Accounting { protected _taxRates: TaxRates | undefined; protected _ledgerAccounts: LedgerAccounts | undefined; - constructor(protected readonly _options: Accounting.Options) {} + constructor(_options: Accounting.Options) { + this._options = _options; + } public get payables(): Payables { return (this._payables ??= new Payables(this._options)); diff --git a/src/api/resources/accounting/index.ts b/src/api/resources/accounting/index.ts index 33a87f1..9eb1192 100644 --- a/src/api/resources/accounting/index.ts +++ b/src/api/resources/accounting/index.ts @@ -1,2 +1,2 @@ -export * from "./client"; -export * from "./resources"; +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/accounting/resources/connections/client/Client.ts b/src/api/resources/accounting/resources/connections/client/Client.ts index cc99b6a..ac6de5a 100644 --- a/src/api/resources/accounting/resources/connections/client/Client.ts +++ b/src/api/resources/accounting/resources/connections/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace Connections { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Connections { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Connections { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Connections { - constructor(protected readonly _options: Connections.Options) {} + protected readonly _options: Connections.Options; + + constructor(_options: Connections.Options) { + this._options = _options; + } /** * Get all connections @@ -66,23 +73,15 @@ export class Connections { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -151,23 +150,15 @@ export class Connections { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -239,23 +230,15 @@ export class Connections { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -329,23 +312,15 @@ export class Connections { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -417,23 +392,15 @@ export class Connections { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/accounting/resources/connections/index.ts b/src/api/resources/accounting/resources/connections/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/accounting/resources/connections/index.ts +++ b/src/api/resources/accounting/resources/connections/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/accounting/resources/index.ts b/src/api/resources/accounting/resources/index.ts index 5afd189..1bacbda 100644 --- a/src/api/resources/accounting/resources/index.ts +++ b/src/api/resources/accounting/resources/index.ts @@ -1,11 +1,11 @@ -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 "./syncedRecords/client/requests"; -export * from "./taxRates/client/requests"; -export * from "./ledgerAccounts/client/requests"; +export * as payables from "./payables/index.js"; +export * as receivables from "./receivables/index.js"; +export * as connections from "./connections/index.js"; +export * as syncedRecords from "./syncedRecords/index.js"; +export * as taxRates from "./taxRates/index.js"; +export * as ledgerAccounts from "./ledgerAccounts/index.js"; +export * from "./payables/client/requests/index.js"; +export * from "./receivables/client/requests/index.js"; +export * from "./syncedRecords/client/requests/index.js"; +export * from "./taxRates/client/requests/index.js"; +export * from "./ledgerAccounts/client/requests/index.js"; diff --git a/src/api/resources/accounting/resources/ledgerAccounts/client/Client.ts b/src/api/resources/accounting/resources/ledgerAccounts/client/Client.ts index e870b26..cb4fbe4 100644 --- a/src/api/resources/accounting/resources/ledgerAccounts/client/Client.ts +++ b/src/api/resources/accounting/resources/ledgerAccounts/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace LedgerAccounts { export interface Options { @@ -18,6 +19,8 @@ export declare namespace LedgerAccounts { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace LedgerAccounts { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class LedgerAccounts { - constructor(protected readonly _options: LedgerAccounts.Options) {} + protected readonly _options: LedgerAccounts.Options; + + constructor(_options: LedgerAccounts.Options) { + this._options = _options; + } /** * Get all ledger accounts @@ -89,24 +96,16 @@ export class LedgerAccounts { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -178,23 +177,15 @@ export class LedgerAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/accounting/resources/ledgerAccounts/client/index.ts b/src/api/resources/accounting/resources/ledgerAccounts/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/accounting/resources/ledgerAccounts/client/index.ts +++ b/src/api/resources/accounting/resources/ledgerAccounts/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/accounting/resources/ledgerAccounts/client/requests/LedgerAccountsGetRequest.ts b/src/api/resources/accounting/resources/ledgerAccounts/client/requests/LedgerAccountsGetRequest.ts index bfb948f..cad40a5 100644 --- a/src/api/resources/accounting/resources/ledgerAccounts/client/requests/LedgerAccountsGetRequest.ts +++ b/src/api/resources/accounting/resources/ledgerAccounts/client/requests/LedgerAccountsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example @@ -14,11 +14,13 @@ export interface LedgerAccountsGetRequest { */ order?: Monite.OrderEnum; /** - * 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. + * The number of items (0 .. 250) to return in a single page of the response. Default is 100. 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 are ignored and inferred from the initial query. + * 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. */ diff --git a/src/api/resources/accounting/resources/ledgerAccounts/client/requests/index.ts b/src/api/resources/accounting/resources/ledgerAccounts/client/requests/index.ts index f70a0ef..a691c74 100644 --- a/src/api/resources/accounting/resources/ledgerAccounts/client/requests/index.ts +++ b/src/api/resources/accounting/resources/ledgerAccounts/client/requests/index.ts @@ -1 +1 @@ -export { type LedgerAccountsGetRequest } from "./LedgerAccountsGetRequest"; +export { type LedgerAccountsGetRequest } from "./LedgerAccountsGetRequest.js"; diff --git a/src/api/resources/accounting/resources/ledgerAccounts/index.ts b/src/api/resources/accounting/resources/ledgerAccounts/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/accounting/resources/ledgerAccounts/index.ts +++ b/src/api/resources/accounting/resources/ledgerAccounts/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/accounting/resources/payables/client/Client.ts b/src/api/resources/accounting/resources/payables/client/Client.ts index e37a53f..d8709d6 100644 --- a/src/api/resources/accounting/resources/payables/client/Client.ts +++ b/src/api/resources/accounting/resources/payables/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace Payables { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Payables { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Payables { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Payables { - constructor(protected readonly _options: Payables.Options) {} + protected readonly _options: Payables.Options; + + constructor(_options: Payables.Options) { + this._options = _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. @@ -85,24 +92,16 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -174,23 +173,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/accounting/resources/payables/client/index.ts b/src/api/resources/accounting/resources/payables/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/accounting/resources/payables/client/index.ts +++ b/src/api/resources/accounting/resources/payables/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/accounting/resources/payables/client/requests/index.ts b/src/api/resources/accounting/resources/payables/client/requests/index.ts index ac4bf74..5f4b0a6 100644 --- a/src/api/resources/accounting/resources/payables/client/requests/index.ts +++ b/src/api/resources/accounting/resources/payables/client/requests/index.ts @@ -1 +1 @@ -export { type PayablesGetRequest } from "./PayablesGetRequest"; +export { type PayablesGetRequest } from "./PayablesGetRequest.js"; diff --git a/src/api/resources/accounting/resources/payables/index.ts b/src/api/resources/accounting/resources/payables/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/accounting/resources/payables/index.ts +++ b/src/api/resources/accounting/resources/payables/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/accounting/resources/receivables/client/Client.ts b/src/api/resources/accounting/resources/receivables/client/Client.ts index e5657c7..354c345 100644 --- a/src/api/resources/accounting/resources/receivables/client/Client.ts +++ b/src/api/resources/accounting/resources/receivables/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace Receivables { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Receivables { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Receivables { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Receivables { - constructor(protected readonly _options: Receivables.Options) {} + protected readonly _options: Receivables.Options; + + constructor(_options: Receivables.Options) { + this._options = _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. @@ -85,24 +92,16 @@ export class Receivables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -174,23 +173,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/accounting/resources/receivables/client/index.ts b/src/api/resources/accounting/resources/receivables/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/accounting/resources/receivables/client/index.ts +++ b/src/api/resources/accounting/resources/receivables/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/accounting/resources/receivables/client/requests/index.ts b/src/api/resources/accounting/resources/receivables/client/requests/index.ts index 3a6d011..7dedeb3 100644 --- a/src/api/resources/accounting/resources/receivables/client/requests/index.ts +++ b/src/api/resources/accounting/resources/receivables/client/requests/index.ts @@ -1 +1 @@ -export { type ReceivablesGetRequest } from "./ReceivablesGetRequest"; +export { type ReceivablesGetRequest } from "./ReceivablesGetRequest.js"; diff --git a/src/api/resources/accounting/resources/receivables/index.ts b/src/api/resources/accounting/resources/receivables/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/accounting/resources/receivables/index.ts +++ b/src/api/resources/accounting/resources/receivables/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/accounting/resources/syncedRecords/client/Client.ts b/src/api/resources/accounting/resources/syncedRecords/client/Client.ts index 9b746b4..be25059 100644 --- a/src/api/resources/accounting/resources/syncedRecords/client/Client.ts +++ b/src/api/resources/accounting/resources/syncedRecords/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace SyncedRecords { export interface Options { @@ -18,6 +19,8 @@ export declare namespace SyncedRecords { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace SyncedRecords { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class SyncedRecords { - constructor(protected readonly _options: SyncedRecords.Options) {} + protected readonly _options: SyncedRecords.Options; + + constructor(_options: SyncedRecords.Options) { + this._options = _options; + } /** * Get synchronized records @@ -152,24 +159,16 @@ export class SyncedRecords { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -241,23 +240,15 @@ export class SyncedRecords { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -331,23 +322,15 @@ export class SyncedRecords { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/accounting/resources/syncedRecords/client/index.ts b/src/api/resources/accounting/resources/syncedRecords/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/accounting/resources/syncedRecords/client/index.ts +++ b/src/api/resources/accounting/resources/syncedRecords/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/accounting/resources/syncedRecords/client/requests/SyncedRecordsGetRequest.ts b/src/api/resources/accounting/resources/syncedRecords/client/requests/SyncedRecordsGetRequest.ts index 3990d8c..27843e9 100644 --- a/src/api/resources/accounting/resources/syncedRecords/client/requests/SyncedRecordsGetRequest.ts +++ b/src/api/resources/accounting/resources/syncedRecords/client/requests/SyncedRecordsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example @@ -17,11 +17,13 @@ export interface SyncedRecordsGetRequest { */ order?: Monite.OrderEnum; /** - * 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. + * The number of items (0 .. 250) to return in a single page of the response. Default is 100. 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 are ignored and inferred from the initial query. + * 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. */ diff --git a/src/api/resources/accounting/resources/syncedRecords/client/requests/index.ts b/src/api/resources/accounting/resources/syncedRecords/client/requests/index.ts index 8bd3725..04e671a 100644 --- a/src/api/resources/accounting/resources/syncedRecords/client/requests/index.ts +++ b/src/api/resources/accounting/resources/syncedRecords/client/requests/index.ts @@ -1 +1 @@ -export { type SyncedRecordsGetRequest } from "./SyncedRecordsGetRequest"; +export { type SyncedRecordsGetRequest } from "./SyncedRecordsGetRequest.js"; diff --git a/src/api/resources/accounting/resources/syncedRecords/index.ts b/src/api/resources/accounting/resources/syncedRecords/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/accounting/resources/syncedRecords/index.ts +++ b/src/api/resources/accounting/resources/syncedRecords/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/accounting/resources/taxRates/client/Client.ts b/src/api/resources/accounting/resources/taxRates/client/Client.ts index 23afaeb..eeb7042 100644 --- a/src/api/resources/accounting/resources/taxRates/client/Client.ts +++ b/src/api/resources/accounting/resources/taxRates/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace TaxRates { export interface Options { @@ -18,6 +19,8 @@ export declare namespace TaxRates { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace TaxRates { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class TaxRates { - constructor(protected readonly _options: TaxRates.Options) {} + protected readonly _options: TaxRates.Options; + + constructor(_options: TaxRates.Options) { + this._options = _options; + } /** * Get all tax rate accounts @@ -89,24 +96,16 @@ export class TaxRates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -178,23 +177,15 @@ export class TaxRates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/accounting/resources/taxRates/client/index.ts b/src/api/resources/accounting/resources/taxRates/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/accounting/resources/taxRates/client/index.ts +++ b/src/api/resources/accounting/resources/taxRates/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/accounting/resources/taxRates/client/requests/TaxRatesGetRequest.ts b/src/api/resources/accounting/resources/taxRates/client/requests/TaxRatesGetRequest.ts index 321f13f..6524538 100644 --- a/src/api/resources/accounting/resources/taxRates/client/requests/TaxRatesGetRequest.ts +++ b/src/api/resources/accounting/resources/taxRates/client/requests/TaxRatesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example @@ -14,11 +14,13 @@ export interface TaxRatesGetRequest { */ order?: Monite.OrderEnum; /** - * 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. + * The number of items (0 .. 250) to return in a single page of the response. Default is 100. 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 are ignored and inferred from the initial query. + * 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. */ diff --git a/src/api/resources/accounting/resources/taxRates/client/requests/index.ts b/src/api/resources/accounting/resources/taxRates/client/requests/index.ts index 4f12a9a..15252ec 100644 --- a/src/api/resources/accounting/resources/taxRates/client/requests/index.ts +++ b/src/api/resources/accounting/resources/taxRates/client/requests/index.ts @@ -1 +1 @@ -export { type TaxRatesGetRequest } from "./TaxRatesGetRequest"; +export { type TaxRatesGetRequest } from "./TaxRatesGetRequest.js"; diff --git a/src/api/resources/accounting/resources/taxRates/index.ts b/src/api/resources/accounting/resources/taxRates/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/accounting/resources/taxRates/index.ts +++ b/src/api/resources/accounting/resources/taxRates/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/analytics/client/Client.ts b/src/api/resources/analytics/client/Client.ts index 96156fd..3a3a0f6 100644 --- a/src/api/resources/analytics/client/Client.ts +++ b/src/api/resources/analytics/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Analytics { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Analytics { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Analytics { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Analytics { - constructor(protected readonly _options: Analytics.Options) {} + protected readonly _options: Analytics.Options; + + constructor(_options: Analytics.Options) { + this._options = _options; + } /** * Retrieve aggregated statistics for payables with different breakdowns. @@ -270,24 +277,16 @@ export class Analytics { "analytics/credit_notes", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -411,6 +410,7 @@ export class Analytics { project_id__in: projectIdIn, tag_ids: tagIds, tag_ids__not_in: tagIdsNotIn, + has_tags: hasTags, origin, has_file: hasFile, } = request; @@ -629,6 +629,10 @@ export class Analytics { } } + if (hasTags != null) { + _queryParams["has_tags"] = hasTags.toString(); + } + if (origin != null) { _queryParams["origin"] = origin; } @@ -645,24 +649,16 @@ export class Analytics { "analytics/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -774,6 +770,11 @@ export class Analytics { total_amount__lt: totalAmountLt, total_amount__gte: totalAmountGte, total_amount__lte: totalAmountLte, + discounted_subtotal: discountedSubtotal, + discounted_subtotal__gt: discountedSubtotalGt, + discounted_subtotal__lt: discountedSubtotalLt, + discounted_subtotal__gte: discountedSubtotalGte, + discounted_subtotal__lte: discountedSubtotalLte, status, entity_user_id: entityUserId, based_on: basedOn, @@ -958,6 +959,26 @@ export class Analytics { _queryParams["total_amount__lte"] = totalAmountLte.toString(); } + if (discountedSubtotal != null) { + _queryParams["discounted_subtotal"] = discountedSubtotal.toString(); + } + + if (discountedSubtotalGt != null) { + _queryParams["discounted_subtotal__gt"] = discountedSubtotalGt.toString(); + } + + if (discountedSubtotalLt != null) { + _queryParams["discounted_subtotal__lt"] = discountedSubtotalLt.toString(); + } + + if (discountedSubtotalGte != null) { + _queryParams["discounted_subtotal__gte"] = discountedSubtotalGte.toString(); + } + + if (discountedSubtotalLte != null) { + _queryParams["discounted_subtotal__lte"] = discountedSubtotalLte.toString(); + } + if (status != null) { _queryParams["status"] = status; } @@ -998,24 +1019,16 @@ export class Analytics { "analytics/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/analytics/client/index.ts b/src/api/resources/analytics/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/analytics/client/index.ts +++ b/src/api/resources/analytics/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/analytics/client/requests/GetAnalyticsCreditNotesRequest.ts b/src/api/resources/analytics/client/requests/GetAnalyticsCreditNotesRequest.ts index 0e8b59e..76327d0 100644 --- a/src/api/resources/analytics/client/requests/GetAnalyticsCreditNotesRequest.ts +++ b/src/api/resources/analytics/client/requests/GetAnalyticsCreditNotesRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/analytics/client/requests/GetAnalyticsPayablesRequest.ts b/src/api/resources/analytics/client/requests/GetAnalyticsPayablesRequest.ts index 51434e1..2792b2d 100644 --- a/src/api/resources/analytics/client/requests/GetAnalyticsPayablesRequest.ts +++ b/src/api/resources/analytics/client/requests/GetAnalyticsPayablesRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -216,6 +216,10 @@ export interface GetAnalyticsPayablesRequest { * Return only payables whose `tags` do not include any of the tags with the specified IDs. Valid but nonexistent tag IDs do not raise errors but produce the results. */ tag_ids__not_in?: string | string[]; + /** + * Filter objects based on whether they have tags. If true, only objects with tags are returned. If false, only objects without tags are returned. + */ + has_tags?: boolean; /** * Return only payables from a given origin ['einvoice', 'upload', 'email'] */ diff --git a/src/api/resources/analytics/client/requests/GetAnalyticsReceivablesRequest.ts b/src/api/resources/analytics/client/requests/GetAnalyticsReceivablesRequest.ts index 2d5af3d..b908446 100644 --- a/src/api/resources/analytics/client/requests/GetAnalyticsReceivablesRequest.ts +++ b/src/api/resources/analytics/client/requests/GetAnalyticsReceivablesRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -150,6 +150,11 @@ export interface GetAnalyticsReceivablesRequest { total_amount__lt?: number; total_amount__gte?: number; total_amount__lte?: number; + discounted_subtotal?: number; + discounted_subtotal__gt?: number; + discounted_subtotal__lt?: number; + discounted_subtotal__gte?: number; + discounted_subtotal__lte?: number; status?: Monite.GetAnalyticsReceivablesRequestStatus; entity_user_id?: string; based_on?: string; diff --git a/src/api/resources/analytics/client/requests/index.ts b/src/api/resources/analytics/client/requests/index.ts index ec6e37a..dd2a956 100644 --- a/src/api/resources/analytics/client/requests/index.ts +++ b/src/api/resources/analytics/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type GetAnalyticsCreditNotesRequest } from "./GetAnalyticsCreditNotesRequest"; -export { type GetAnalyticsPayablesRequest } from "./GetAnalyticsPayablesRequest"; -export { type GetAnalyticsReceivablesRequest } from "./GetAnalyticsReceivablesRequest"; +export { type GetAnalyticsCreditNotesRequest } from "./GetAnalyticsCreditNotesRequest.js"; +export { type GetAnalyticsPayablesRequest } from "./GetAnalyticsPayablesRequest.js"; +export { type GetAnalyticsReceivablesRequest } from "./GetAnalyticsReceivablesRequest.js"; diff --git a/src/api/resources/analytics/index.ts b/src/api/resources/analytics/index.ts index c9240f8..f095e14 100644 --- a/src/api/resources/analytics/index.ts +++ b/src/api/resources/analytics/index.ts @@ -1,2 +1,2 @@ -export * from "./types"; -export * from "./client"; +export * from "./types/index.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/analytics/types/index.ts b/src/api/resources/analytics/types/index.ts index dd5cd2b..2337336 100644 --- a/src/api/resources/analytics/types/index.ts +++ b/src/api/resources/analytics/types/index.ts @@ -1,2 +1,2 @@ -export * from "./GetAnalyticsReceivablesRequestStatusInItem"; -export * from "./GetAnalyticsReceivablesRequestStatus"; +export * from "./GetAnalyticsReceivablesRequestStatusInItem.js"; +export * from "./GetAnalyticsReceivablesRequestStatus.js"; diff --git a/src/api/resources/approvalPolicies/client/Client.ts b/src/api/resources/approvalPolicies/client/Client.ts index 3fb52c7..0a0d03f 100644 --- a/src/api/resources/approvalPolicies/client/Client.ts +++ b/src/api/resources/approvalPolicies/client/Client.ts @@ -2,12 +2,13 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; -import { Processes } from "../resources/processes/client/Client"; +import * as errors from "../../../../errors/index.js"; +import { Processes } from "../resources/processes/client/Client.js"; export declare namespace ApprovalPolicies { export interface Options { @@ -19,6 +20,8 @@ export declare namespace ApprovalPolicies { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -34,14 +37,17 @@ export declare namespace ApprovalPolicies { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class ApprovalPolicies { + protected readonly _options: ApprovalPolicies.Options; protected _processes: Processes | undefined; - constructor(protected readonly _options: ApprovalPolicies.Options) {} + constructor(_options: ApprovalPolicies.Options) { + this._options = _options; + } public get processes(): Processes { return (this._processes ??= new Processes(this._options)); @@ -191,24 +197,16 @@ export class ApprovalPolicies { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -290,21 +288,15 @@ export class ApprovalPolicies { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -388,23 +380,15 @@ export class ApprovalPolicies { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -487,23 +471,15 @@ export class ApprovalPolicies { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -590,21 +566,15 @@ export class ApprovalPolicies { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/approvalPolicies/client/index.ts b/src/api/resources/approvalPolicies/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/approvalPolicies/client/index.ts +++ b/src/api/resources/approvalPolicies/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/approvalPolicies/client/requests/ApprovalPoliciesGetRequest.ts b/src/api/resources/approvalPolicies/client/requests/ApprovalPoliciesGetRequest.ts index 8055362..e928806 100644 --- a/src/api/resources/approvalPolicies/client/requests/ApprovalPoliciesGetRequest.ts +++ b/src/api/resources/approvalPolicies/client/requests/ApprovalPoliciesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyCreate.ts b/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyCreate.ts index 568c3d5..972c04e 100644 --- a/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyCreate.ts +++ b/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyCreate.ts @@ -2,8 +2,6 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; - /** * @example * { @@ -19,9 +17,22 @@ export interface ApprovalPolicyCreate { /** The name of the approval policy. */ name: 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[]; + script: ApprovalPolicyCreate.Script.Item[]; /** The date and time (in the ISO 8601 format) when the approval policy becomes active. Only payables submitted for approval during the policy's active period will trigger this policy. If omitted or `null`, the policy is effective immediately. The value will be converted to UTC. */ starts_at?: string; /** 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; + trigger?: ApprovalPolicyCreate.Trigger; +} + +export namespace ApprovalPolicyCreate { + export type Script = Script.Item[]; + + export namespace Script { + export type Item = boolean | number | string | unknown[] | Record; + } + + /** + * 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 Trigger = boolean | number | string | unknown[] | Record; } diff --git a/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyUpdate.ts b/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyUpdate.ts index 6a6b168..63d3b63 100644 --- a/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyUpdate.ts +++ b/src/api/resources/approvalPolicies/client/requests/ApprovalPolicyUpdate.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -16,11 +16,24 @@ export interface ApprovalPolicyUpdate { /** The name of the approval policy. */ name?: 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[]; + script?: ApprovalPolicyUpdate.Script.Item[]; /** The date and time (in the ISO 8601 format) when the approval policy becomes active. Only payables submitted for approval during the policy's active period will trigger this policy. If omitted or `null`, the policy is effective immediately. The value will be converted to UTC. */ starts_at?: string; /** A string that represents the current status of the approval policy. */ status?: Monite.ApprovalPolicyStatus; /** 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; + trigger?: ApprovalPolicyUpdate.Trigger; +} + +export namespace ApprovalPolicyUpdate { + export type Script = Script.Item[]; + + export namespace Script { + export type Item = boolean | number | string | unknown[] | Record; + } + + /** + * 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 Trigger = boolean | number | string | unknown[] | Record; } diff --git a/src/api/resources/approvalPolicies/client/requests/index.ts b/src/api/resources/approvalPolicies/client/requests/index.ts index ea52561..9cd3379 100644 --- a/src/api/resources/approvalPolicies/client/requests/index.ts +++ b/src/api/resources/approvalPolicies/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type ApprovalPoliciesGetRequest } from "./ApprovalPoliciesGetRequest"; -export { type ApprovalPolicyCreate } from "./ApprovalPolicyCreate"; -export { type ApprovalPolicyUpdate } from "./ApprovalPolicyUpdate"; +export { type ApprovalPoliciesGetRequest } from "./ApprovalPoliciesGetRequest.js"; +export { type ApprovalPolicyCreate } from "./ApprovalPolicyCreate.js"; +export { type ApprovalPolicyUpdate } from "./ApprovalPolicyUpdate.js"; diff --git a/src/api/resources/approvalPolicies/index.ts b/src/api/resources/approvalPolicies/index.ts index 848e75a..31ac50a 100644 --- a/src/api/resources/approvalPolicies/index.ts +++ b/src/api/resources/approvalPolicies/index.ts @@ -1,3 +1,3 @@ -export * from "./types"; -export * from "./client"; -export * from "./resources"; +export * from "./types/index.js"; +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/approvalPolicies/resources/index.ts b/src/api/resources/approvalPolicies/resources/index.ts index 148fe85..0d56be9 100644 --- a/src/api/resources/approvalPolicies/resources/index.ts +++ b/src/api/resources/approvalPolicies/resources/index.ts @@ -1 +1 @@ -export * as processes from "./processes"; +export * as processes from "./processes/index.js"; diff --git a/src/api/resources/approvalPolicies/resources/processes/client/Client.ts b/src/api/resources/approvalPolicies/resources/processes/client/Client.ts index 65d1c21..8c2e420 100644 --- a/src/api/resources/approvalPolicies/resources/processes/client/Client.ts +++ b/src/api/resources/approvalPolicies/resources/processes/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace Processes { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Processes { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Processes { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Processes { - constructor(protected readonly _options: Processes.Options) {} + protected readonly _options: Processes.Options; + + constructor(_options: Processes.Options) { + this._options = _options; + } /** * Retrieve a list of all approval policy processes. @@ -74,23 +81,15 @@ export class Processes { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -176,23 +175,15 @@ export class Processes { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -278,23 +269,15 @@ export class Processes { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -380,23 +363,15 @@ export class Processes { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/approvalPolicies/resources/processes/index.ts b/src/api/resources/approvalPolicies/resources/processes/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/approvalPolicies/resources/processes/index.ts +++ b/src/api/resources/approvalPolicies/resources/processes/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateScriptItem.ts b/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateScriptItem.ts deleted file mode 100644 index 7317ce5..0000000 --- a/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateScriptItem.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * 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 deleted file mode 100644 index 29dda8f..0000000 --- a/src/api/resources/approvalPolicies/types/ApprovalPolicyCreateTrigger.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 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 deleted file mode 100644 index ca820cb..0000000 --- a/src/api/resources/approvalPolicies/types/ApprovalPolicyUpdateScriptItem.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * 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 deleted file mode 100644 index 8296072..0000000 --- a/src/api/resources/approvalPolicies/types/ApprovalPolicyUpdateTrigger.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 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 index fd8bc1d..c7a87da 100644 --- a/src/api/resources/approvalPolicies/types/index.ts +++ b/src/api/resources/approvalPolicies/types/index.ts @@ -1,6 +1,2 @@ -export * from "./ApprovalPoliciesGetRequestStatus"; -export * from "./ApprovalPoliciesGetRequestStatusInItem"; -export * from "./ApprovalPolicyCreateScriptItem"; -export * from "./ApprovalPolicyCreateTrigger"; -export * from "./ApprovalPolicyUpdateScriptItem"; -export * from "./ApprovalPolicyUpdateTrigger"; +export * from "./ApprovalPoliciesGetRequestStatus.js"; +export * from "./ApprovalPoliciesGetRequestStatusInItem.js"; diff --git a/src/api/resources/approvalRequests/client/Client.ts b/src/api/resources/approvalRequests/client/Client.ts index 6b6634d..651e2b0 100644 --- a/src/api/resources/approvalRequests/client/Client.ts +++ b/src/api/resources/approvalRequests/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace ApprovalRequests { export interface Options { @@ -18,6 +19,8 @@ export declare namespace ApprovalRequests { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace ApprovalRequests { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class ApprovalRequests { - constructor(protected readonly _options: ApprovalRequests.Options) {} + protected readonly _options: ApprovalRequests.Options; + + constructor(_options: ApprovalRequests.Options) { + this._options = _options; + } /** * @param {Monite.ApprovalRequestsGetRequest} request @@ -193,24 +200,16 @@ export class ApprovalRequests { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -298,21 +297,15 @@ export class ApprovalRequests { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -403,23 +396,15 @@ export class ApprovalRequests { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -509,23 +494,15 @@ export class ApprovalRequests { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -615,23 +592,15 @@ export class ApprovalRequests { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -721,23 +690,15 @@ export class ApprovalRequests { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/approvalRequests/client/index.ts b/src/api/resources/approvalRequests/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/approvalRequests/client/index.ts +++ b/src/api/resources/approvalRequests/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/approvalRequests/client/requests/ApprovalRequestsGetRequest.ts b/src/api/resources/approvalRequests/client/requests/ApprovalRequestsGetRequest.ts index bdedacf..0a20649 100644 --- a/src/api/resources/approvalRequests/client/requests/ApprovalRequestsGetRequest.ts +++ b/src/api/resources/approvalRequests/client/requests/ApprovalRequestsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/approvalRequests/client/requests/index.ts b/src/api/resources/approvalRequests/client/requests/index.ts index 884f342..8669052 100644 --- a/src/api/resources/approvalRequests/client/requests/index.ts +++ b/src/api/resources/approvalRequests/client/requests/index.ts @@ -1 +1 @@ -export { type ApprovalRequestsGetRequest } from "./ApprovalRequestsGetRequest"; +export { type ApprovalRequestsGetRequest } from "./ApprovalRequestsGetRequest.js"; diff --git a/src/api/resources/approvalRequests/index.ts b/src/api/resources/approvalRequests/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/approvalRequests/index.ts +++ b/src/api/resources/approvalRequests/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/comments/client/Client.ts b/src/api/resources/comments/client/Client.ts index ebf5afe..b01001c 100644 --- a/src/api/resources/comments/client/Client.ts +++ b/src/api/resources/comments/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Comments { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Comments { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Comments { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Comments { - constructor(protected readonly _options: Comments.Options) {} + protected readonly _options: Comments.Options; + + constructor(_options: Comments.Options) { + this._options = _options; + } /** * Get comments @@ -124,24 +131,16 @@ export class Comments { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -227,21 +226,15 @@ export class Comments { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -328,23 +321,15 @@ export class Comments { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -425,23 +410,15 @@ export class Comments { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -528,21 +505,15 @@ export class Comments { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/comments/client/index.ts b/src/api/resources/comments/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/comments/client/index.ts +++ b/src/api/resources/comments/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/comments/client/requests/CommentsGetRequest.ts b/src/api/resources/comments/client/requests/CommentsGetRequest.ts index e2e4987..9ab49c8 100644 --- a/src/api/resources/comments/client/requests/CommentsGetRequest.ts +++ b/src/api/resources/comments/client/requests/CommentsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/comments/client/requests/index.ts b/src/api/resources/comments/client/requests/index.ts index abd2be4..c775b9e 100644 --- a/src/api/resources/comments/client/requests/index.ts +++ b/src/api/resources/comments/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type CommentsGetRequest } from "./CommentsGetRequest"; -export { type CommentCreateRequest } from "./CommentCreateRequest"; -export { type CommentUpdateRequest } from "./CommentUpdateRequest"; +export { type CommentsGetRequest } from "./CommentsGetRequest.js"; +export { type CommentCreateRequest } from "./CommentCreateRequest.js"; +export { type CommentUpdateRequest } from "./CommentUpdateRequest.js"; diff --git a/src/api/resources/comments/index.ts b/src/api/resources/comments/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/comments/index.ts +++ b/src/api/resources/comments/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/counterpartEInvoicingCredentials/client/Client.ts b/src/api/resources/counterpartEInvoicingCredentials/client/Client.ts index b7e104a..2a67bc3 100644 --- a/src/api/resources/counterpartEInvoicingCredentials/client/Client.ts +++ b/src/api/resources/counterpartEInvoicingCredentials/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace CounterpartEInvoicingCredentials { export interface Options { @@ -18,6 +19,8 @@ export declare namespace CounterpartEInvoicingCredentials { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace CounterpartEInvoicingCredentials { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class CounterpartEInvoicingCredentials { - constructor(protected readonly _options: CounterpartEInvoicingCredentials.Options) {} + protected readonly _options: CounterpartEInvoicingCredentials.Options; + + constructor(_options: CounterpartEInvoicingCredentials.Options) { + this._options = _options; + } /** * @param {string} counterpartId @@ -72,23 +79,15 @@ export class CounterpartEInvoicingCredentials { `counterparts/${encodeURIComponent(counterpartId)}/einvoicing_credentials`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -173,21 +172,15 @@ export class CounterpartEInvoicingCredentials { `counterparts/${encodeURIComponent(counterpartId)}/einvoicing_credentials`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -273,23 +266,15 @@ export class CounterpartEInvoicingCredentials { `counterparts/${encodeURIComponent(counterpartId)}/einvoicing_credentials/${encodeURIComponent(credentialId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -372,23 +357,15 @@ export class CounterpartEInvoicingCredentials { `counterparts/${encodeURIComponent(counterpartId)}/einvoicing_credentials/${encodeURIComponent(credentialId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -471,21 +448,15 @@ export class CounterpartEInvoicingCredentials { `counterparts/${encodeURIComponent(counterpartId)}/einvoicing_credentials/${encodeURIComponent(credentialId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/counterpartEInvoicingCredentials/client/index.ts b/src/api/resources/counterpartEInvoicingCredentials/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/counterpartEInvoicingCredentials/client/index.ts +++ b/src/api/resources/counterpartEInvoicingCredentials/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/counterpartEInvoicingCredentials/client/requests/UpdateCounterpartEinvoicingCredentialSchema.ts b/src/api/resources/counterpartEInvoicingCredentials/client/requests/UpdateCounterpartEinvoicingCredentialSchema.ts index a56001b..ce16f3a 100644 --- a/src/api/resources/counterpartEInvoicingCredentials/client/requests/UpdateCounterpartEinvoicingCredentialSchema.ts +++ b/src/api/resources/counterpartEInvoicingCredentials/client/requests/UpdateCounterpartEinvoicingCredentialSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/counterpartEInvoicingCredentials/client/requests/index.ts b/src/api/resources/counterpartEInvoicingCredentials/client/requests/index.ts index 1aab20e..c3fd85b 100644 --- a/src/api/resources/counterpartEInvoicingCredentials/client/requests/index.ts +++ b/src/api/resources/counterpartEInvoicingCredentials/client/requests/index.ts @@ -1 +1 @@ -export { type UpdateCounterpartEinvoicingCredentialSchema } from "./UpdateCounterpartEinvoicingCredentialSchema"; +export { type UpdateCounterpartEinvoicingCredentialSchema } from "./UpdateCounterpartEinvoicingCredentialSchema.js"; diff --git a/src/api/resources/counterpartEInvoicingCredentials/index.ts b/src/api/resources/counterpartEInvoicingCredentials/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/counterpartEInvoicingCredentials/index.ts +++ b/src/api/resources/counterpartEInvoicingCredentials/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/counterparts/client/Client.ts b/src/api/resources/counterparts/client/Client.ts index c573c69..645820f 100644 --- a/src/api/resources/counterparts/client/Client.ts +++ b/src/api/resources/counterparts/client/Client.ts @@ -2,15 +2,16 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; 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"; +import * as errors from "../../../../errors/index.js"; +import { Addresses } from "../resources/addresses/client/Client.js"; +import { BankAccounts } from "../resources/bankAccounts/client/Client.js"; +import { Contacts } from "../resources/contacts/client/Client.js"; +import { VatIds } from "../resources/vatIds/client/Client.js"; export declare namespace Counterparts { export interface Options { @@ -22,6 +23,8 @@ export declare namespace Counterparts { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -37,17 +40,20 @@ export declare namespace Counterparts { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Counterparts { + protected readonly _options: Counterparts.Options; protected _addresses: Addresses | undefined; protected _bankAccounts: BankAccounts | undefined; protected _contacts: Contacts | undefined; protected _vatIds: VatIds | undefined; - constructor(protected readonly _options: Counterparts.Options) {} + constructor(_options: Counterparts.Options) { + this._options = _options; + } public get addresses(): Addresses { return (this._addresses ??= new Addresses(this._options)); @@ -263,24 +269,16 @@ export class Counterparts { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -365,21 +363,15 @@ export class Counterparts { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -453,23 +445,15 @@ export class Counterparts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -544,23 +528,15 @@ export class Counterparts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -640,21 +616,15 @@ export class Counterparts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -731,23 +701,15 @@ export class Counterparts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -828,21 +790,15 @@ export class Counterparts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/counterparts/client/index.ts b/src/api/resources/counterparts/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/counterparts/client/index.ts +++ b/src/api/resources/counterparts/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/counterparts/client/requests/CounterpartsGetRequest.ts b/src/api/resources/counterparts/client/requests/CounterpartsGetRequest.ts index f71fcb0..b2d89d5 100644 --- a/src/api/resources/counterparts/client/requests/CounterpartsGetRequest.ts +++ b/src/api/resources/counterparts/client/requests/CounterpartsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/counterparts/client/requests/index.ts b/src/api/resources/counterparts/client/requests/index.ts index 1243c04..2aa7061 100644 --- a/src/api/resources/counterparts/client/requests/index.ts +++ b/src/api/resources/counterparts/client/requests/index.ts @@ -1 +1 @@ -export { type CounterpartsGetRequest } from "./CounterpartsGetRequest"; +export { type CounterpartsGetRequest } from "./CounterpartsGetRequest.js"; diff --git a/src/api/resources/counterparts/index.ts b/src/api/resources/counterparts/index.ts index 33a87f1..9eb1192 100644 --- a/src/api/resources/counterparts/index.ts +++ b/src/api/resources/counterparts/index.ts @@ -1,2 +1,2 @@ -export * from "./client"; -export * from "./resources"; +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/counterparts/resources/addresses/client/Client.ts b/src/api/resources/counterparts/resources/addresses/client/Client.ts index 5a81c60..37749cf 100644 --- a/src/api/resources/counterparts/resources/addresses/client/Client.ts +++ b/src/api/resources/counterparts/resources/addresses/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace Addresses { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Addresses { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Addresses { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Addresses { - constructor(protected readonly _options: Addresses.Options) {} + protected readonly _options: Addresses.Options; + + constructor(_options: Addresses.Options) { + this._options = _options; + } /** * @param {string} counterpartId @@ -70,23 +77,15 @@ export class Addresses { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -172,21 +171,15 @@ export class Addresses { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -270,23 +263,15 @@ export class Addresses { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -367,23 +352,15 @@ export class Addresses { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -466,21 +443,15 @@ export class Addresses { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/counterparts/resources/addresses/client/index.ts b/src/api/resources/counterparts/resources/addresses/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/counterparts/resources/addresses/client/index.ts +++ b/src/api/resources/counterparts/resources/addresses/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/counterparts/resources/addresses/client/requests/CounterpartUpdateAddress.ts b/src/api/resources/counterparts/resources/addresses/client/requests/CounterpartUpdateAddress.ts index 375e2f0..6c6bac3 100644 --- a/src/api/resources/counterparts/resources/addresses/client/requests/CounterpartUpdateAddress.ts +++ b/src/api/resources/counterparts/resources/addresses/client/requests/CounterpartUpdateAddress.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/counterparts/resources/addresses/client/requests/index.ts b/src/api/resources/counterparts/resources/addresses/client/requests/index.ts index 99b2e21..b978143 100644 --- a/src/api/resources/counterparts/resources/addresses/client/requests/index.ts +++ b/src/api/resources/counterparts/resources/addresses/client/requests/index.ts @@ -1 +1 @@ -export { type CounterpartUpdateAddress } from "./CounterpartUpdateAddress"; +export { type CounterpartUpdateAddress } from "./CounterpartUpdateAddress.js"; diff --git a/src/api/resources/counterparts/resources/addresses/index.ts b/src/api/resources/counterparts/resources/addresses/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/counterparts/resources/addresses/index.ts +++ b/src/api/resources/counterparts/resources/addresses/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/Client.ts b/src/api/resources/counterparts/resources/bankAccounts/client/Client.ts index fb65ea5..7836bd3 100644 --- a/src/api/resources/counterparts/resources/bankAccounts/client/Client.ts +++ b/src/api/resources/counterparts/resources/bankAccounts/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace BankAccounts { export interface Options { @@ -18,6 +19,8 @@ export declare namespace BankAccounts { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace BankAccounts { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class BankAccounts { - constructor(protected readonly _options: BankAccounts.Options) {} + protected readonly _options: BankAccounts.Options; + + constructor(_options: BankAccounts.Options) { + this._options = _options; + } /** * @param {string} counterpartId @@ -69,23 +76,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -167,21 +166,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -265,23 +258,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -362,23 +347,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -461,21 +438,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -560,23 +531,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/index.ts b/src/api/resources/counterparts/resources/bankAccounts/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/counterparts/resources/bankAccounts/client/index.ts +++ b/src/api/resources/counterparts/resources/bankAccounts/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/requests/CreateCounterpartBankAccount.ts b/src/api/resources/counterparts/resources/bankAccounts/client/requests/CreateCounterpartBankAccount.ts index fd236d5..05dd103 100644 --- a/src/api/resources/counterparts/resources/bankAccounts/client/requests/CreateCounterpartBankAccount.ts +++ b/src/api/resources/counterparts/resources/bankAccounts/client/requests/CreateCounterpartBankAccount.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/requests/UpdateCounterpartBankAccount.ts b/src/api/resources/counterparts/resources/bankAccounts/client/requests/UpdateCounterpartBankAccount.ts index c5cea4e..60d7f07 100644 --- a/src/api/resources/counterparts/resources/bankAccounts/client/requests/UpdateCounterpartBankAccount.ts +++ b/src/api/resources/counterparts/resources/bankAccounts/client/requests/UpdateCounterpartBankAccount.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/counterparts/resources/bankAccounts/client/requests/index.ts b/src/api/resources/counterparts/resources/bankAccounts/client/requests/index.ts index a99d6fa..84e7cd6 100644 --- a/src/api/resources/counterparts/resources/bankAccounts/client/requests/index.ts +++ b/src/api/resources/counterparts/resources/bankAccounts/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type CreateCounterpartBankAccount } from "./CreateCounterpartBankAccount"; -export { type UpdateCounterpartBankAccount } from "./UpdateCounterpartBankAccount"; +export { type CreateCounterpartBankAccount } from "./CreateCounterpartBankAccount.js"; +export { type UpdateCounterpartBankAccount } from "./UpdateCounterpartBankAccount.js"; diff --git a/src/api/resources/counterparts/resources/bankAccounts/index.ts b/src/api/resources/counterparts/resources/bankAccounts/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/counterparts/resources/bankAccounts/index.ts +++ b/src/api/resources/counterparts/resources/bankAccounts/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/counterparts/resources/contacts/client/Client.ts b/src/api/resources/counterparts/resources/contacts/client/Client.ts index cd34f7b..4087fb4 100644 --- a/src/api/resources/counterparts/resources/contacts/client/Client.ts +++ b/src/api/resources/counterparts/resources/contacts/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace Contacts { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Contacts { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Contacts { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Contacts { - constructor(protected readonly _options: Contacts.Options) {} + protected readonly _options: Contacts.Options; + + constructor(_options: Contacts.Options) { + this._options = _options; + } /** * @param {string} counterpartId @@ -69,23 +76,15 @@ export class Contacts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -173,21 +172,15 @@ export class Contacts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -268,23 +261,15 @@ export class Contacts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -362,23 +347,15 @@ export class Contacts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -461,21 +438,15 @@ export class Contacts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -556,23 +527,15 @@ export class Contacts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/counterparts/resources/contacts/client/index.ts b/src/api/resources/counterparts/resources/contacts/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/counterparts/resources/contacts/client/index.ts +++ b/src/api/resources/counterparts/resources/contacts/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/counterparts/resources/contacts/client/requests/CreateCounterpartContactPayload.ts b/src/api/resources/counterparts/resources/contacts/client/requests/CreateCounterpartContactPayload.ts index 2db3fba..0cef85e 100644 --- a/src/api/resources/counterparts/resources/contacts/client/requests/CreateCounterpartContactPayload.ts +++ b/src/api/resources/counterparts/resources/contacts/client/requests/CreateCounterpartContactPayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/counterparts/resources/contacts/client/requests/UpdateCounterpartContactPayload.ts b/src/api/resources/counterparts/resources/contacts/client/requests/UpdateCounterpartContactPayload.ts index dc71dbd..5cc83dd 100644 --- a/src/api/resources/counterparts/resources/contacts/client/requests/UpdateCounterpartContactPayload.ts +++ b/src/api/resources/counterparts/resources/contacts/client/requests/UpdateCounterpartContactPayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/counterparts/resources/contacts/client/requests/index.ts b/src/api/resources/counterparts/resources/contacts/client/requests/index.ts index af0868f..0ca8c11 100644 --- a/src/api/resources/counterparts/resources/contacts/client/requests/index.ts +++ b/src/api/resources/counterparts/resources/contacts/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type CreateCounterpartContactPayload } from "./CreateCounterpartContactPayload"; -export { type UpdateCounterpartContactPayload } from "./UpdateCounterpartContactPayload"; +export { type CreateCounterpartContactPayload } from "./CreateCounterpartContactPayload.js"; +export { type UpdateCounterpartContactPayload } from "./UpdateCounterpartContactPayload.js"; diff --git a/src/api/resources/counterparts/resources/contacts/index.ts b/src/api/resources/counterparts/resources/contacts/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/counterparts/resources/contacts/index.ts +++ b/src/api/resources/counterparts/resources/contacts/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/counterparts/resources/index.ts b/src/api/resources/counterparts/resources/index.ts index 0464014..14dc706 100644 --- a/src/api/resources/counterparts/resources/index.ts +++ b/src/api/resources/counterparts/resources/index.ts @@ -1,8 +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"; +export * as addresses from "./addresses/index.js"; +export * as bankAccounts from "./bankAccounts/index.js"; +export * as contacts from "./contacts/index.js"; +export * as vatIds from "./vatIds/index.js"; +export * from "./addresses/client/requests/index.js"; +export * from "./bankAccounts/client/requests/index.js"; +export * from "./contacts/client/requests/index.js"; +export * from "./vatIds/client/requests/index.js"; diff --git a/src/api/resources/counterparts/resources/vatIds/client/Client.ts b/src/api/resources/counterparts/resources/vatIds/client/Client.ts index eec20a0..650a100 100644 --- a/src/api/resources/counterparts/resources/vatIds/client/Client.ts +++ b/src/api/resources/counterparts/resources/vatIds/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace VatIds { export interface Options { @@ -18,6 +19,8 @@ export declare namespace VatIds { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace VatIds { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class VatIds { - constructor(protected readonly _options: VatIds.Options) {} + protected readonly _options: VatIds.Options; + + constructor(_options: VatIds.Options) { + this._options = _options; + } /** * @param {string} counterpartId @@ -69,23 +76,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -163,21 +162,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -258,23 +251,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -352,23 +337,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -449,21 +426,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/counterparts/resources/vatIds/client/index.ts b/src/api/resources/counterparts/resources/vatIds/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/counterparts/resources/vatIds/client/index.ts +++ b/src/api/resources/counterparts/resources/vatIds/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartUpdateVatId.ts b/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartUpdateVatId.ts index b9d39e4..7407a4d 100644 --- a/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartUpdateVatId.ts +++ b/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartUpdateVatId.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartVatId.ts b/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartVatId.ts index c0d38c5..b3e43fe 100644 --- a/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartVatId.ts +++ b/src/api/resources/counterparts/resources/vatIds/client/requests/CounterpartVatId.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/counterparts/resources/vatIds/client/requests/index.ts b/src/api/resources/counterparts/resources/vatIds/client/requests/index.ts index 21c9ada..c47b459 100644 --- a/src/api/resources/counterparts/resources/vatIds/client/requests/index.ts +++ b/src/api/resources/counterparts/resources/vatIds/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type CounterpartVatId } from "./CounterpartVatId"; -export { type CounterpartUpdateVatId } from "./CounterpartUpdateVatId"; +export { type CounterpartVatId } from "./CounterpartVatId.js"; +export { type CounterpartUpdateVatId } from "./CounterpartUpdateVatId.js"; diff --git a/src/api/resources/counterparts/resources/vatIds/index.ts b/src/api/resources/counterparts/resources/vatIds/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/counterparts/resources/vatIds/index.ts +++ b/src/api/resources/counterparts/resources/vatIds/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/creditNotes/client/Client.ts b/src/api/resources/creditNotes/client/Client.ts index 24c30c4..9c5d981 100644 --- a/src/api/resources/creditNotes/client/Client.ts +++ b/src/api/resources/creditNotes/client/Client.ts @@ -2,13 +2,13 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; import * as fs from "fs"; -import { Blob } from "buffer"; export declare namespace CreditNotes { export interface Options { @@ -20,6 +20,8 @@ export declare namespace CreditNotes { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -35,12 +37,16 @@ export declare namespace CreditNotes { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class CreditNotes { - constructor(protected readonly _options: CreditNotes.Options) {} + protected readonly _options: CreditNotes.Options; + + constructor(_options: CreditNotes.Options) { + this._options = _options; + } /** * @param {Monite.GetPayableCreditNotesRequest} request @@ -270,24 +276,16 @@ export class CreditNotes { "payable_credit_notes", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -371,21 +369,15 @@ export class CreditNotes { "payable_credit_notes", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -436,9 +428,9 @@ export class CreditNotes { } /** - * Upload an incoming credit note (payable) in PDF, PNG, JPEG, or TIFF format and scan its contents. The maximum file size is 10MB. + * Upload an incoming credit note (payable) in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB. * - * @param {File | fs.ReadStream | Blob} file + * @param {Monite.CreditNoteUploadFile} request * @param {CreditNotes.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Monite.BadRequestError} @@ -449,21 +441,25 @@ export class CreditNotes { * @throws {@link Monite.InternalServerError} * * @example - * await client.creditNotes.postPayableCreditNotesUploadFromFile(fs.createReadStream("/path/to/your/file")) + * await client.creditNotes.postPayableCreditNotesUploadFromFile({ + * file: fs.createReadStream("/path/to/your/file") + * }) */ public postPayableCreditNotesUploadFromFile( - file: File | fs.ReadStream | Blob, + request: Monite.CreditNoteUploadFile, requestOptions?: CreditNotes.RequestOptions, ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__postPayableCreditNotesUploadFromFile(file, requestOptions)); + return core.HttpResponsePromise.fromPromise( + this.__postPayableCreditNotesUploadFromFile(request, requestOptions), + ); } private async __postPayableCreditNotesUploadFromFile( - file: File | fs.ReadStream | Blob, + request: Monite.CreditNoteUploadFile, requestOptions?: CreditNotes.RequestOptions, ): Promise> { const _request = await core.newFormData(); - await _request.appendFile("file", file); + await _request.appendFile("file", request.file); const _maybeEncodedRequest = await _request.getRequest(); const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -473,22 +469,16 @@ export class CreditNotes { "payable_credit_notes/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ..._maybeEncodedRequest.headers, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + ..._maybeEncodedRequest.headers, + }), + requestOptions?.headers, + ), requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, @@ -573,23 +563,15 @@ export class CreditNotes { "payable_credit_notes/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -674,21 +656,15 @@ export class CreditNotes { "payable_credit_notes/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -771,23 +747,15 @@ export class CreditNotes { "payable_credit_notes/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -868,23 +836,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -966,23 +926,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1070,21 +1022,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1173,23 +1119,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1277,23 +1215,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1382,23 +1312,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/cancel_ocr`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1711,24 +1633,16 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1817,21 +1731,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1922,21 +1830,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2028,23 +1930,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2130,23 +2024,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2238,21 +2124,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2341,23 +2221,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2445,23 +2317,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2546,23 +2410,15 @@ export class CreditNotes { `payable_credit_notes/${encodeURIComponent(creditNoteId)}/validate`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/creditNotes/client/index.ts b/src/api/resources/creditNotes/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/creditNotes/client/index.ts +++ b/src/api/resources/creditNotes/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/creditNotes/client/requests/CreditNoteCreateRequest.ts b/src/api/resources/creditNotes/client/requests/CreditNoteCreateRequest.ts index 45e277f..7871c6f 100644 --- a/src/api/resources/creditNotes/client/requests/CreditNoteCreateRequest.ts +++ b/src/api/resources/creditNotes/client/requests/CreditNoteCreateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/creditNotes/client/requests/CreditNoteLineItemReplaceRequest.ts b/src/api/resources/creditNotes/client/requests/CreditNoteLineItemReplaceRequest.ts index 106cab7..c094036 100644 --- a/src/api/resources/creditNotes/client/requests/CreditNoteLineItemReplaceRequest.ts +++ b/src/api/resources/creditNotes/client/requests/CreditNoteLineItemReplaceRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/creditNotes/client/requests/CreditNoteUpdateRequest.ts b/src/api/resources/creditNotes/client/requests/CreditNoteUpdateRequest.ts index c8c3a07..e13434d 100644 --- a/src/api/resources/creditNotes/client/requests/CreditNoteUpdateRequest.ts +++ b/src/api/resources/creditNotes/client/requests/CreditNoteUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/creditNotes/client/requests/CreditNoteUploadFile.ts b/src/api/resources/creditNotes/client/requests/CreditNoteUploadFile.ts index 84e0c30..6e99e07 100644 --- a/src/api/resources/creditNotes/client/requests/CreditNoteUploadFile.ts +++ b/src/api/resources/creditNotes/client/requests/CreditNoteUploadFile.ts @@ -2,8 +2,14 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as fs from "fs"; + /** * @example - * {} + * { + * file: fs.createReadStream("/path/to/your/file") + * } */ -export interface CreditNoteUploadFile {} +export interface CreditNoteUploadFile { + file: File | fs.ReadStream | Blob; +} diff --git a/src/api/resources/creditNotes/client/requests/GetPayableCreditNotesIdLineItemsRequest.ts b/src/api/resources/creditNotes/client/requests/GetPayableCreditNotesIdLineItemsRequest.ts index f854201..f8ff546 100644 --- a/src/api/resources/creditNotes/client/requests/GetPayableCreditNotesIdLineItemsRequest.ts +++ b/src/api/resources/creditNotes/client/requests/GetPayableCreditNotesIdLineItemsRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/creditNotes/client/requests/GetPayableCreditNotesRequest.ts b/src/api/resources/creditNotes/client/requests/GetPayableCreditNotesRequest.ts index 110a242..8d7d1da 100644 --- a/src/api/resources/creditNotes/client/requests/GetPayableCreditNotesRequest.ts +++ b/src/api/resources/creditNotes/client/requests/GetPayableCreditNotesRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/creditNotes/client/requests/index.ts b/src/api/resources/creditNotes/client/requests/index.ts index b5326e3..ef03428 100644 --- a/src/api/resources/creditNotes/client/requests/index.ts +++ b/src/api/resources/creditNotes/client/requests/index.ts @@ -1,7 +1,7 @@ -export { type GetPayableCreditNotesRequest } from "./GetPayableCreditNotesRequest"; -export { type CreditNoteCreateRequest } from "./CreditNoteCreateRequest"; -export { type CreditNoteUploadFile } from "./CreditNoteUploadFile"; -export { type CreditNoteUpdateRequest } from "./CreditNoteUpdateRequest"; -export { type GetPayableCreditNotesIdLineItemsRequest } from "./GetPayableCreditNotesIdLineItemsRequest"; -export { type CreditNoteLineItemReplaceRequest } from "./CreditNoteLineItemReplaceRequest"; -export { type CreditNoteLineItemUpdateRequest } from "./CreditNoteLineItemUpdateRequest"; +export { type GetPayableCreditNotesRequest } from "./GetPayableCreditNotesRequest.js"; +export { type CreditNoteCreateRequest } from "./CreditNoteCreateRequest.js"; +export { type CreditNoteUploadFile } from "./CreditNoteUploadFile.js"; +export { type CreditNoteUpdateRequest } from "./CreditNoteUpdateRequest.js"; +export { type GetPayableCreditNotesIdLineItemsRequest } from "./GetPayableCreditNotesIdLineItemsRequest.js"; +export { type CreditNoteLineItemReplaceRequest } from "./CreditNoteLineItemReplaceRequest.js"; +export { type CreditNoteLineItemUpdateRequest } from "./CreditNoteLineItemUpdateRequest.js"; diff --git a/src/api/resources/creditNotes/index.ts b/src/api/resources/creditNotes/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/creditNotes/index.ts +++ b/src/api/resources/creditNotes/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/customVatRates/client/Client.ts b/src/api/resources/customVatRates/client/Client.ts new file mode 100644 index 0000000..23e02ee --- /dev/null +++ b/src/api/resources/customVatRates/client/Client.ts @@ -0,0 +1,522 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index.js"; + +export declare namespace CustomVatRates { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the x-monite-version header */ + moniteVersion: core.Supplier; + /** Override the x-monite-entity-id header */ + moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; + fetcher?: core.FetchFunction; + } + + export 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; + /** Additional headers to include in the request. */ + headers?: Record | undefined>; + } +} + +export class CustomVatRates { + protected readonly _options: CustomVatRates.Options; + + constructor(_options: CustomVatRates.Options) { + this._options = _options; + } + + /** + * @param {CustomVatRates.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.customVatRates.getCustomVatRates() + */ + public getCustomVatRates( + requestOptions?: CustomVatRates.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getCustomVatRates(requestOptions)); + } + + private async __getCustomVatRates( + requestOptions?: CustomVatRates.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + "custom_vat_rates", + ), + method: "GET", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Monite.CustomVatRateResponseList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError("Timeout exceeded when calling GET /custom_vat_rates."); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * @param {Monite.CustomVatRateRequest} request + * @param {CustomVatRates.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.customVatRates.postCustomVatRates({ + * components: [{ + * name: "name", + * value: 1.1 + * }], + * name: "name" + * }) + */ + public postCustomVatRates( + request: Monite.CustomVatRateRequest, + requestOptions?: CustomVatRates.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__postCustomVatRates(request, requestOptions)); + } + + private async __postCustomVatRates( + request: Monite.CustomVatRateRequest, + requestOptions?: CustomVatRates.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + "custom_vat_rates", + ), + method: "POST", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + 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 { data: _response.body as Monite.CustomVatRateResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError("Timeout exceeded when calling POST /custom_vat_rates."); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * @param {string} customVatRateId + * @param {CustomVatRates.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.customVatRates.getCustomVatRatesId("custom_vat_rate_id") + */ + public getCustomVatRatesId( + customVatRateId: string, + requestOptions?: CustomVatRates.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getCustomVatRatesId(customVatRateId, requestOptions)); + } + + private async __getCustomVatRatesId( + customVatRateId: string, + requestOptions?: CustomVatRates.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + `custom_vat_rates/${encodeURIComponent(customVatRateId)}`, + ), + method: "GET", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Monite.CustomVatRateResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError( + "Timeout exceeded when calling GET /custom_vat_rates/{custom_vat_rate_id}.", + ); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * @param {string} customVatRateId + * @param {CustomVatRates.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.customVatRates.deleteCustomVatRatesId("custom_vat_rate_id") + */ + public deleteCustomVatRatesId( + customVatRateId: string, + requestOptions?: CustomVatRates.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteCustomVatRatesId(customVatRateId, requestOptions)); + } + + private async __deleteCustomVatRatesId( + customVatRateId: string, + requestOptions?: CustomVatRates.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + `custom_vat_rates/${encodeURIComponent(customVatRateId)}`, + ), + method: "DELETE", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError( + "Timeout exceeded when calling DELETE /custom_vat_rates/{custom_vat_rate_id}.", + ); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * @param {string} customVatRateId + * @param {Monite.CustomVatRateUpdateRequest} request + * @param {CustomVatRates.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.customVatRates.patchCustomVatRatesId("custom_vat_rate_id") + */ + public patchCustomVatRatesId( + customVatRateId: string, + request: Monite.CustomVatRateUpdateRequest = {}, + requestOptions?: CustomVatRates.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise( + this.__patchCustomVatRatesId(customVatRateId, request, requestOptions), + ); + } + + private async __patchCustomVatRatesId( + customVatRateId: string, + request: Monite.CustomVatRateUpdateRequest = {}, + requestOptions?: CustomVatRates.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + `custom_vat_rates/${encodeURIComponent(customVatRateId)}`, + ), + method: "PATCH", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + 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 { data: _response.body as Monite.CustomVatRateResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError( + "Timeout exceeded when calling PATCH /custom_vat_rates/{custom_vat_rate_id}.", + ); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + 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/customVatRates/client/index.ts b/src/api/resources/customVatRates/client/index.ts new file mode 100644 index 0000000..82648c6 --- /dev/null +++ b/src/api/resources/customVatRates/client/index.ts @@ -0,0 +1,2 @@ +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/customVatRates/client/requests/CustomVatRateRequest.ts b/src/api/resources/customVatRates/client/requests/CustomVatRateRequest.ts new file mode 100644 index 0000000..7057c6a --- /dev/null +++ b/src/api/resources/customVatRates/client/requests/CustomVatRateRequest.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index.js"; + +/** + * @example + * { + * components: [{ + * name: "name", + * value: 1.1 + * }], + * name: "name" + * } + */ +export interface CustomVatRateRequest { + /** Sub-taxes included in the Custom VAT. */ + components: Monite.VatRateComponent[]; + /** Display name of the Custom VAT. */ + name: string; +} diff --git a/src/api/resources/customVatRates/client/requests/CustomVatRateUpdateRequest.ts b/src/api/resources/customVatRates/client/requests/CustomVatRateUpdateRequest.ts new file mode 100644 index 0000000..b5506e3 --- /dev/null +++ b/src/api/resources/customVatRates/client/requests/CustomVatRateUpdateRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index.js"; + +/** + * @example + * {} + */ +export interface CustomVatRateUpdateRequest { + /** Sub-taxes included in the Custom VAT. */ + components?: Monite.VatRateComponent[]; + /** Display name of the Custom VAT. */ + name?: string; +} diff --git a/src/api/resources/customVatRates/client/requests/index.ts b/src/api/resources/customVatRates/client/requests/index.ts new file mode 100644 index 0000000..b504077 --- /dev/null +++ b/src/api/resources/customVatRates/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type CustomVatRateRequest } from "./CustomVatRateRequest.js"; +export { type CustomVatRateUpdateRequest } from "./CustomVatRateUpdateRequest.js"; diff --git a/src/api/resources/customVatRates/index.ts b/src/api/resources/customVatRates/index.ts new file mode 100644 index 0000000..914b8c3 --- /dev/null +++ b/src/api/resources/customVatRates/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/dataExports/client/Client.ts b/src/api/resources/dataExports/client/Client.ts index a8df7eb..bffcc7f 100644 --- a/src/api/resources/dataExports/client/Client.ts +++ b/src/api/resources/dataExports/client/Client.ts @@ -2,12 +2,13 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; -import { ExtraData } from "../resources/extraData/client/Client"; +import * as errors from "../../../../errors/index.js"; +import { ExtraData } from "../resources/extraData/client/Client.js"; export declare namespace DataExports { export interface Options { @@ -19,6 +20,8 @@ export declare namespace DataExports { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -34,14 +37,17 @@ export declare namespace DataExports { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class DataExports { + protected readonly _options: DataExports.Options; protected _extraData: ExtraData | undefined; - constructor(protected readonly _options: DataExports.Options) {} + constructor(_options: DataExports.Options) { + this._options = _options; + } public get extraData(): ExtraData { return (this._extraData ??= new ExtraData(this._options)); @@ -128,24 +134,16 @@ export class DataExports { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -241,21 +239,15 @@ export class DataExports { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -338,23 +330,15 @@ export class DataExports { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -430,23 +414,15 @@ export class DataExports { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/dataExports/client/index.ts b/src/api/resources/dataExports/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/dataExports/client/index.ts +++ b/src/api/resources/dataExports/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/dataExports/client/requests/DataExportsGetRequest.ts b/src/api/resources/dataExports/client/requests/DataExportsGetRequest.ts index 843f4e9..82e33b5 100644 --- a/src/api/resources/dataExports/client/requests/DataExportsGetRequest.ts +++ b/src/api/resources/dataExports/client/requests/DataExportsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/dataExports/client/requests/ExportPayloadSchema.ts b/src/api/resources/dataExports/client/requests/ExportPayloadSchema.ts index c02373d..305524b 100644 --- a/src/api/resources/dataExports/client/requests/ExportPayloadSchema.ts +++ b/src/api/resources/dataExports/client/requests/ExportPayloadSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/dataExports/client/requests/index.ts b/src/api/resources/dataExports/client/requests/index.ts index c27373e..0565fcf 100644 --- a/src/api/resources/dataExports/client/requests/index.ts +++ b/src/api/resources/dataExports/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type DataExportsGetRequest } from "./DataExportsGetRequest"; -export { type ExportPayloadSchema } from "./ExportPayloadSchema"; +export { type DataExportsGetRequest } from "./DataExportsGetRequest.js"; +export { type ExportPayloadSchema } from "./ExportPayloadSchema.js"; diff --git a/src/api/resources/dataExports/index.ts b/src/api/resources/dataExports/index.ts index 33a87f1..9eb1192 100644 --- a/src/api/resources/dataExports/index.ts +++ b/src/api/resources/dataExports/index.ts @@ -1,2 +1,2 @@ -export * from "./client"; -export * from "./resources"; +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/dataExports/resources/extraData/client/Client.ts b/src/api/resources/dataExports/resources/extraData/client/Client.ts index 09e2018..31336df 100644 --- a/src/api/resources/dataExports/resources/extraData/client/Client.ts +++ b/src/api/resources/dataExports/resources/extraData/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace ExtraData { export interface Options { @@ -18,6 +19,8 @@ export declare namespace ExtraData { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace ExtraData { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class ExtraData { - constructor(protected readonly _options: ExtraData.Options) {} + protected readonly _options: ExtraData.Options; + + constructor(_options: ExtraData.Options) { + this._options = _options; + } /** * @param {Monite.dataExports.ExtraDataGetRequest} request @@ -149,24 +156,16 @@ export class ExtraData { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -247,21 +246,15 @@ export class ExtraData { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: { ...request, object_type: "counterpart" }, @@ -343,23 +336,15 @@ export class ExtraData { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -440,23 +425,15 @@ export class ExtraData { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -541,21 +518,15 @@ export class ExtraData { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/dataExports/resources/extraData/client/index.ts b/src/api/resources/dataExports/resources/extraData/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/dataExports/resources/extraData/client/index.ts +++ b/src/api/resources/dataExports/resources/extraData/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataCreateRequest.ts b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataCreateRequest.ts index 7ced08e..30de792 100644 --- a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataCreateRequest.ts +++ b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataCreateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataGetRequest.ts b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataGetRequest.ts index 859d50b..c87b307 100644 --- a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataGetRequest.ts +++ b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataUpdateRequest.ts b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataUpdateRequest.ts index 8893401..7d5395f 100644 --- a/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataUpdateRequest.ts +++ b/src/api/resources/dataExports/resources/extraData/client/requests/ExtraDataUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/dataExports/resources/extraData/client/requests/index.ts b/src/api/resources/dataExports/resources/extraData/client/requests/index.ts index e0f9cfe..fa7a5d1 100644 --- a/src/api/resources/dataExports/resources/extraData/client/requests/index.ts +++ b/src/api/resources/dataExports/resources/extraData/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type ExtraDataGetRequest } from "./ExtraDataGetRequest"; -export { type ExtraDataCreateRequest } from "./ExtraDataCreateRequest"; -export { type ExtraDataUpdateRequest } from "./ExtraDataUpdateRequest"; +export { type ExtraDataGetRequest } from "./ExtraDataGetRequest.js"; +export { type ExtraDataCreateRequest } from "./ExtraDataCreateRequest.js"; +export { type ExtraDataUpdateRequest } from "./ExtraDataUpdateRequest.js"; diff --git a/src/api/resources/dataExports/resources/extraData/index.ts b/src/api/resources/dataExports/resources/extraData/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/dataExports/resources/extraData/index.ts +++ b/src/api/resources/dataExports/resources/extraData/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/dataExports/resources/index.ts b/src/api/resources/dataExports/resources/index.ts index 075edd4..7aa37e2 100644 --- a/src/api/resources/dataExports/resources/index.ts +++ b/src/api/resources/dataExports/resources/index.ts @@ -1,2 +1,2 @@ -export * as extraData from "./extraData"; -export * from "./extraData/client/requests"; +export * as extraData from "./extraData/index.js"; +export * from "./extraData/client/requests/index.js"; diff --git a/src/api/resources/deliveryNotes/client/Client.ts b/src/api/resources/deliveryNotes/client/Client.ts index f7a3ae7..c0d0c5c 100644 --- a/src/api/resources/deliveryNotes/client/Client.ts +++ b/src/api/resources/deliveryNotes/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace DeliveryNotes { export interface Options { @@ -18,6 +19,8 @@ export declare namespace DeliveryNotes { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace DeliveryNotes { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class DeliveryNotes { - constructor(protected readonly _options: DeliveryNotes.Options) {} + protected readonly _options: DeliveryNotes.Options; + + constructor(_options: DeliveryNotes.Options) { + this._options = _options; + } /** * Get all delivery notes with filtering and pagination. @@ -205,24 +212,16 @@ export class DeliveryNotes { "delivery_notes", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -324,21 +323,15 @@ export class DeliveryNotes { "delivery_notes", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -425,23 +418,15 @@ export class DeliveryNotes { `delivery_notes/${encodeURIComponent(deliveryNoteId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -525,23 +510,15 @@ export class DeliveryNotes { `delivery_notes/${encodeURIComponent(deliveryNoteId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -631,21 +608,15 @@ export class DeliveryNotes { `delivery_notes/${encodeURIComponent(deliveryNoteId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -735,23 +706,15 @@ export class DeliveryNotes { `delivery_notes/${encodeURIComponent(deliveryNoteId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -840,23 +803,15 @@ export class DeliveryNotes { `delivery_notes/${encodeURIComponent(deliveryNoteId)}/mark_as_delivered`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/deliveryNotes/client/index.ts b/src/api/resources/deliveryNotes/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/deliveryNotes/client/index.ts +++ b/src/api/resources/deliveryNotes/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/deliveryNotes/client/requests/DeliveryNoteUpdateRequest.ts b/src/api/resources/deliveryNotes/client/requests/DeliveryNoteUpdateRequest.ts index 174a632..9e6625d 100644 --- a/src/api/resources/deliveryNotes/client/requests/DeliveryNoteUpdateRequest.ts +++ b/src/api/resources/deliveryNotes/client/requests/DeliveryNoteUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/deliveryNotes/client/requests/GetDeliveryNotesRequest.ts b/src/api/resources/deliveryNotes/client/requests/GetDeliveryNotesRequest.ts index 0ecac46..63bb5cc 100644 --- a/src/api/resources/deliveryNotes/client/requests/GetDeliveryNotesRequest.ts +++ b/src/api/resources/deliveryNotes/client/requests/GetDeliveryNotesRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/deliveryNotes/client/requests/index.ts b/src/api/resources/deliveryNotes/client/requests/index.ts index 8b86a5b..a91aed2 100644 --- a/src/api/resources/deliveryNotes/client/requests/index.ts +++ b/src/api/resources/deliveryNotes/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type GetDeliveryNotesRequest } from "./GetDeliveryNotesRequest"; -export { type DeliveryNoteUpdateRequest } from "./DeliveryNoteUpdateRequest"; +export { type GetDeliveryNotesRequest } from "./GetDeliveryNotesRequest.js"; +export { type DeliveryNoteUpdateRequest } from "./DeliveryNoteUpdateRequest.js"; diff --git a/src/api/resources/deliveryNotes/index.ts b/src/api/resources/deliveryNotes/index.ts index c9240f8..f095e14 100644 --- a/src/api/resources/deliveryNotes/index.ts +++ b/src/api/resources/deliveryNotes/index.ts @@ -1,2 +1,2 @@ -export * from "./types"; -export * from "./client"; +export * from "./types/index.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/deliveryNotes/types/Payload.ts b/src/api/resources/deliveryNotes/types/Payload.ts index 4e933e9..e395554 100644 --- a/src/api/resources/deliveryNotes/types/Payload.ts +++ b/src/api/resources/deliveryNotes/types/Payload.ts @@ -2,6 +2,6 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../index"; +import * as Monite from "../../../index.js"; export type Payload = Monite.DeliveryNoteCreateRequest | Monite.DeliveryNoteCreateBasedOnRequest; diff --git a/src/api/resources/deliveryNotes/types/index.ts b/src/api/resources/deliveryNotes/types/index.ts index 25d8d88..f1d64d3 100644 --- a/src/api/resources/deliveryNotes/types/index.ts +++ b/src/api/resources/deliveryNotes/types/index.ts @@ -1 +1 @@ -export * from "./Payload"; +export * from "./Payload.js"; diff --git a/src/api/resources/eInvoicingConnections/client/Client.ts b/src/api/resources/eInvoicingConnections/client/Client.ts index a5198a4..deaab38 100644 --- a/src/api/resources/eInvoicingConnections/client/Client.ts +++ b/src/api/resources/eInvoicingConnections/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace EInvoicingConnections { export interface Options { @@ -18,6 +19,8 @@ export declare namespace EInvoicingConnections { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace EInvoicingConnections { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class EInvoicingConnections { - constructor(protected readonly _options: EInvoicingConnections.Options) {} + protected readonly _options: EInvoicingConnections.Options; + + constructor(_options: EInvoicingConnections.Options) { + this._options = _options; + } /** * @param {EInvoicingConnections.RequestOptions} requestOptions - Request-specific configuration. @@ -69,23 +76,15 @@ export class EInvoicingConnections { "einvoicing_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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -172,21 +171,15 @@ export class EInvoicingConnections { "einvoicing_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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -273,23 +266,15 @@ export class EInvoicingConnections { `einvoicing_connections/${encodeURIComponent(einvoicingConnectionId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -375,23 +360,15 @@ export class EInvoicingConnections { `einvoicing_connections/${encodeURIComponent(einvoicingConnectionId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -442,6 +419,109 @@ export class EInvoicingConnections { } } + /** + * @param {string} einvoicingConnectionId + * @param {Monite.EinvoicingConnectionUpdateRequest} request + * @param {EInvoicingConnections.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.eInvoicingConnections.patchEinvoicingConnectionsId("einvoicing_connection_id") + */ + public patchEinvoicingConnectionsId( + einvoicingConnectionId: string, + request: Monite.EinvoicingConnectionUpdateRequest = {}, + requestOptions?: EInvoicingConnections.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise( + this.__patchEinvoicingConnectionsId(einvoicingConnectionId, request, requestOptions), + ); + } + + private async __patchEinvoicingConnectionsId( + einvoicingConnectionId: string, + request: Monite.EinvoicingConnectionUpdateRequest = {}, + requestOptions?: EInvoicingConnections.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + `einvoicing_connections/${encodeURIComponent(einvoicingConnectionId)}`, + ), + method: "PATCH", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + 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 { data: _response.body as Monite.EinvoicingConnectionResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError( + "Timeout exceeded when calling PATCH /einvoicing_connections/{einvoicing_connection_id}.", + ); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + /** * @param {string} einvoicingConnectionId * @param {Monite.EinvoicingNetworkCredentialsCreateRequest} request @@ -484,21 +564,15 @@ export class EInvoicingConnections { `einvoicing_connections/${encodeURIComponent(einvoicingConnectionId)}/network_credentials`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/eInvoicingConnections/client/index.ts b/src/api/resources/eInvoicingConnections/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/eInvoicingConnections/client/index.ts +++ b/src/api/resources/eInvoicingConnections/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/eInvoicingConnections/client/requests/EinvoicingConnectionCreateRequest.ts b/src/api/resources/eInvoicingConnections/client/requests/EinvoicingConnectionCreateRequest.ts index 5398316..a5961d1 100644 --- a/src/api/resources/eInvoicingConnections/client/requests/EinvoicingConnectionCreateRequest.ts +++ b/src/api/resources/eInvoicingConnections/client/requests/EinvoicingConnectionCreateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -20,4 +20,8 @@ export interface EinvoicingConnectionCreateRequest { address: Monite.EinvoicingAddress; /** Entity VAT ID identifier for the integration */ entity_vat_id_id?: string; + /** Set to `true` if the entity needs to receive e-invoices. */ + is_receiver?: boolean; + /** Set to `true` if the entity needs to send e-invoices. Either `is_sender` or `is_receiver` or both must be `true`. */ + is_sender?: boolean; } diff --git a/src/api/resources/eInvoicingConnections/client/requests/EinvoicingConnectionUpdateRequest.ts b/src/api/resources/eInvoicingConnections/client/requests/EinvoicingConnectionUpdateRequest.ts new file mode 100644 index 0000000..6430ff7 --- /dev/null +++ b/src/api/resources/eInvoicingConnections/client/requests/EinvoicingConnectionUpdateRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index.js"; + +/** + * @example + * {} + */ +export interface EinvoicingConnectionUpdateRequest { + /** Integration Address */ + address?: Monite.UpdateEinvoicingAddress; + /** Set to `true` if the entity needs to receive e-invoices. */ + is_receiver?: boolean; + /** Set to `true` if the entity needs to send e-invoices. Either `is_sender` or `is_receiver` or both must be `true`. */ + is_sender?: boolean; +} diff --git a/src/api/resources/eInvoicingConnections/client/requests/EinvoicingNetworkCredentialsCreateRequest.ts b/src/api/resources/eInvoicingConnections/client/requests/EinvoicingNetworkCredentialsCreateRequest.ts index 4f3b185..5031b68 100644 --- a/src/api/resources/eInvoicingConnections/client/requests/EinvoicingNetworkCredentialsCreateRequest.ts +++ b/src/api/resources/eInvoicingConnections/client/requests/EinvoicingNetworkCredentialsCreateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/eInvoicingConnections/client/requests/index.ts b/src/api/resources/eInvoicingConnections/client/requests/index.ts index 334ddeb..7056dd6 100644 --- a/src/api/resources/eInvoicingConnections/client/requests/index.ts +++ b/src/api/resources/eInvoicingConnections/client/requests/index.ts @@ -1,2 +1,3 @@ -export { type EinvoicingConnectionCreateRequest } from "./EinvoicingConnectionCreateRequest"; -export { type EinvoicingNetworkCredentialsCreateRequest } from "./EinvoicingNetworkCredentialsCreateRequest"; +export { type EinvoicingConnectionCreateRequest } from "./EinvoicingConnectionCreateRequest.js"; +export { type EinvoicingConnectionUpdateRequest } from "./EinvoicingConnectionUpdateRequest.js"; +export { type EinvoicingNetworkCredentialsCreateRequest } from "./EinvoicingNetworkCredentialsCreateRequest.js"; diff --git a/src/api/resources/eInvoicingConnections/index.ts b/src/api/resources/eInvoicingConnections/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/eInvoicingConnections/index.ts +++ b/src/api/resources/eInvoicingConnections/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/entities/client/Client.ts b/src/api/resources/entities/client/Client.ts index 7f8555e..6283484 100644 --- a/src/api/resources/entities/client/Client.ts +++ b/src/api/resources/entities/client/Client.ts @@ -2,18 +2,18 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; 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"; +import { BankAccounts } from "../resources/bankAccounts/client/Client.js"; +import { OnboardingData } from "../resources/onboardingData/client/Client.js"; +import { PaymentMethods } from "../resources/paymentMethods/client/Client.js"; +import { VatIds } from "../resources/vatIds/client/Client.js"; +import { Persons } from "../resources/persons/client/Client.js"; export declare namespace Entities { export interface Options { @@ -25,6 +25,8 @@ export declare namespace Entities { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -40,18 +42,21 @@ export declare namespace Entities { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Entities { + protected readonly _options: Entities.Options; protected _bankAccounts: BankAccounts | undefined; protected _onboardingData: OnboardingData | undefined; protected _paymentMethods: PaymentMethods | undefined; protected _vatIds: VatIds | undefined; protected _persons: Persons | undefined; - constructor(protected readonly _options: Entities.Options) {} + constructor(_options: Entities.Options) { + this._options = _options; + } public get bankAccounts(): BankAccounts { return (this._bankAccounts ??= new BankAccounts(this._options)); @@ -202,24 +207,16 @@ export class Entities { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -275,6 +272,7 @@ export class Entities { * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} * @throws {@link Monite.UnprocessableEntityError} * @throws {@link Monite.InternalServerError} * @@ -309,21 +307,15 @@ export class Entities { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -339,6 +331,8 @@ export class Entities { switch (_response.error.statusCode) { case 400: throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); case 422: throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); case 500: @@ -396,23 +390,15 @@ export class Entities { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -487,21 +473,15 @@ export class Entities { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -579,23 +559,15 @@ export class Entities { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -646,6 +618,7 @@ export class Entities { * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} * @throws {@link Monite.UnprocessableEntityError} * @throws {@link Monite.InternalServerError} * @@ -673,21 +646,15 @@ export class Entities { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -703,6 +670,8 @@ export class Entities { switch (_response.error.statusCode) { case 400: throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); case 422: throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); case 500: @@ -740,6 +709,7 @@ export class Entities { * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} * @throws {@link Monite.UnprocessableEntityError} * @throws {@link Monite.InternalServerError} * @@ -765,23 +735,15 @@ export class Entities { `entities/${encodeURIComponent(entityId)}/activate`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -794,6 +756,8 @@ export class Entities { switch (_response.error.statusCode) { case 400: throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); case 422: throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); case 500: @@ -833,6 +797,7 @@ export class Entities { * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Monite.BadRequestError} + * @throws {@link Monite.ForbiddenError} * @throws {@link Monite.UnprocessableEntityError} * @throws {@link Monite.InternalServerError} * @@ -858,23 +823,15 @@ export class Entities { `entities/${encodeURIComponent(entityId)}/deactivate`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -887,6 +844,8 @@ export class Entities { switch (_response.error.statusCode) { case 400: throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); case 422: throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); case 500: @@ -922,8 +881,8 @@ export class Entities { /** * 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 {Monite.BodyPutEntitiesIdLogo} request * @param {Entities.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Monite.BadRequestError} @@ -931,23 +890,25 @@ export class Entities { * @throws {@link Monite.InternalServerError} * * @example - * await client.entities.uploadLogoById(fs.createReadStream("/path/to/your/file"), "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + * await client.entities.uploadLogoById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5", { + * file: fs.createReadStream("/path/to/your/file") + * }) */ public uploadLogoById( - file: File | fs.ReadStream | Blob, entityId: string, + request: Monite.BodyPutEntitiesIdLogo, requestOptions?: Entities.RequestOptions, ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__uploadLogoById(file, entityId, requestOptions)); + return core.HttpResponsePromise.fromPromise(this.__uploadLogoById(entityId, request, requestOptions)); } private async __uploadLogoById( - file: File | fs.ReadStream | Blob, entityId: string, + request: Monite.BodyPutEntitiesIdLogo, requestOptions?: Entities.RequestOptions, ): Promise> { const _request = await core.newFormData(); - await _request.appendFile("file", file); + await _request.appendFile("file", request.file); const _maybeEncodedRequest = await _request.getRequest(); const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -957,22 +918,16 @@ export class Entities { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ..._maybeEncodedRequest.headers, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + ..._maybeEncodedRequest.headers, + }), + requestOptions?.headers, + ), requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, @@ -1045,23 +1000,15 @@ export class Entities { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1135,23 +1082,15 @@ export class Entities { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1234,21 +1173,15 @@ export class Entities { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1326,23 +1259,15 @@ export class Entities { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1422,21 +1347,15 @@ export class Entities { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1515,21 +1434,15 @@ export class Entities { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1601,23 +1514,15 @@ export class Entities { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/entities/client/index.ts b/src/api/resources/entities/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/entities/client/index.ts +++ b/src/api/resources/entities/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/entities/client/requests/BodyPutEntitiesIdLogo.ts b/src/api/resources/entities/client/requests/BodyPutEntitiesIdLogo.ts new file mode 100644 index 0000000..b3b79df --- /dev/null +++ b/src/api/resources/entities/client/requests/BodyPutEntitiesIdLogo.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as fs from "fs"; + +/** + * @example + * { + * file: fs.createReadStream("/path/to/your/file") + * } + */ +export interface BodyPutEntitiesIdLogo { + file: File | fs.ReadStream | Blob; +} diff --git a/src/api/resources/entities/client/requests/CreateEntityRequest.ts b/src/api/resources/entities/client/requests/CreateEntityRequest.ts index ffe6927..b07e307 100644 --- a/src/api/resources/entities/client/requests/CreateEntityRequest.ts +++ b/src/api/resources/entities/client/requests/CreateEntityRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/client/requests/EntitiesGetRequest.ts b/src/api/resources/entities/client/requests/EntitiesGetRequest.ts index b1aebbe..807f340 100644 --- a/src/api/resources/entities/client/requests/EntitiesGetRequest.ts +++ b/src/api/resources/entities/client/requests/EntitiesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/client/requests/PatchSettingsPayload.ts b/src/api/resources/entities/client/requests/PatchSettingsPayload.ts index d614582..84a8157 100644 --- a/src/api/resources/entities/client/requests/PatchSettingsPayload.ts +++ b/src/api/resources/entities/client/requests/PatchSettingsPayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/client/requests/index.ts b/src/api/resources/entities/client/requests/index.ts index aa4d51e..9e465b5 100644 --- a/src/api/resources/entities/client/requests/index.ts +++ b/src/api/resources/entities/client/requests/index.ts @@ -1,5 +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"; +export { type EntitiesGetRequest } from "./EntitiesGetRequest.js"; +export { type CreateEntityRequest } from "./CreateEntityRequest.js"; +export { type BodyPutEntitiesIdLogo } from "./BodyPutEntitiesIdLogo.js"; +export { type PatchSettingsPayload } from "./PatchSettingsPayload.js"; +export { type EntityOnboardingDocumentsPayload } from "./EntityOnboardingDocumentsPayload.js"; diff --git a/src/api/resources/entities/index.ts b/src/api/resources/entities/index.ts index 33a87f1..9eb1192 100644 --- a/src/api/resources/entities/index.ts +++ b/src/api/resources/entities/index.ts @@ -1,2 +1,2 @@ -export * from "./client"; -export * from "./resources"; +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/entities/resources/bankAccounts/client/Client.ts b/src/api/resources/entities/resources/bankAccounts/client/Client.ts index 414fe2b..a2e58ba 100644 --- a/src/api/resources/entities/resources/bankAccounts/client/Client.ts +++ b/src/api/resources/entities/resources/bankAccounts/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace BankAccounts { export interface Options { @@ -18,6 +19,8 @@ export declare namespace BankAccounts { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace BankAccounts { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class BankAccounts { - constructor(protected readonly _options: BankAccounts.Options) {} + protected readonly _options: BankAccounts.Options; + + constructor(_options: BankAccounts.Options) { + this._options = _options; + } /** * Get all bank accounts of this entity. @@ -69,23 +76,15 @@ export class BankAccounts { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -179,21 +178,15 @@ export class BankAccounts { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -272,23 +265,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -368,23 +353,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -467,21 +444,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -564,23 +535,15 @@ export class BankAccounts { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/entities/resources/bankAccounts/client/index.ts b/src/api/resources/entities/resources/bankAccounts/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/entities/resources/bankAccounts/client/index.ts +++ b/src/api/resources/entities/resources/bankAccounts/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/entities/resources/bankAccounts/client/requests/CreateEntityBankAccountRequest.ts b/src/api/resources/entities/resources/bankAccounts/client/requests/CreateEntityBankAccountRequest.ts index 66cd92e..0a87acb 100644 --- a/src/api/resources/entities/resources/bankAccounts/client/requests/CreateEntityBankAccountRequest.ts +++ b/src/api/resources/entities/resources/bankAccounts/client/requests/CreateEntityBankAccountRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/resources/bankAccounts/client/requests/index.ts b/src/api/resources/entities/resources/bankAccounts/client/requests/index.ts index adfed84..dd9efde 100644 --- a/src/api/resources/entities/resources/bankAccounts/client/requests/index.ts +++ b/src/api/resources/entities/resources/bankAccounts/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type CreateEntityBankAccountRequest } from "./CreateEntityBankAccountRequest"; -export { type UpdateEntityBankAccountRequest } from "./UpdateEntityBankAccountRequest"; +export { type CreateEntityBankAccountRequest } from "./CreateEntityBankAccountRequest.js"; +export { type UpdateEntityBankAccountRequest } from "./UpdateEntityBankAccountRequest.js"; diff --git a/src/api/resources/entities/resources/bankAccounts/index.ts b/src/api/resources/entities/resources/bankAccounts/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/entities/resources/bankAccounts/index.ts +++ b/src/api/resources/entities/resources/bankAccounts/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/entities/resources/index.ts b/src/api/resources/entities/resources/index.ts index 791b011..61becf1 100644 --- a/src/api/resources/entities/resources/index.ts +++ b/src/api/resources/entities/resources/index.ts @@ -1,10 +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"; +export * as bankAccounts from "./bankAccounts/index.js"; +export * as onboardingData from "./onboardingData/index.js"; +export * as paymentMethods from "./paymentMethods/index.js"; +export * as vatIds from "./vatIds/index.js"; +export * as persons from "./persons/index.js"; +export * from "./bankAccounts/client/requests/index.js"; +export * from "./onboardingData/client/requests/index.js"; +export * from "./paymentMethods/client/requests/index.js"; +export * from "./vatIds/client/requests/index.js"; +export * from "./persons/client/requests/index.js"; diff --git a/src/api/resources/entities/resources/onboardingData/client/Client.ts b/src/api/resources/entities/resources/onboardingData/client/Client.ts index d46999e..27104a1 100644 --- a/src/api/resources/entities/resources/onboardingData/client/Client.ts +++ b/src/api/resources/entities/resources/onboardingData/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace OnboardingData { export interface Options { @@ -18,6 +19,8 @@ export declare namespace OnboardingData { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace OnboardingData { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class OnboardingData { - constructor(protected readonly _options: OnboardingData.Options) {} + protected readonly _options: OnboardingData.Options; + + constructor(_options: OnboardingData.Options) { + this._options = _options; + } /** * @param {string} entityId @@ -71,23 +78,15 @@ export class OnboardingData { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -168,21 +167,15 @@ export class OnboardingData { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/entities/resources/onboardingData/client/index.ts b/src/api/resources/entities/resources/onboardingData/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/entities/resources/onboardingData/client/index.ts +++ b/src/api/resources/entities/resources/onboardingData/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/entities/resources/onboardingData/client/requests/EntityOnboardingDataRequest.ts b/src/api/resources/entities/resources/onboardingData/client/requests/EntityOnboardingDataRequest.ts index a9e5dd7..e6e4540 100644 --- a/src/api/resources/entities/resources/onboardingData/client/requests/EntityOnboardingDataRequest.ts +++ b/src/api/resources/entities/resources/onboardingData/client/requests/EntityOnboardingDataRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/resources/onboardingData/client/requests/index.ts b/src/api/resources/entities/resources/onboardingData/client/requests/index.ts index d7bd248..490264c 100644 --- a/src/api/resources/entities/resources/onboardingData/client/requests/index.ts +++ b/src/api/resources/entities/resources/onboardingData/client/requests/index.ts @@ -1 +1 @@ -export { type EntityOnboardingDataRequest } from "./EntityOnboardingDataRequest"; +export { type EntityOnboardingDataRequest } from "./EntityOnboardingDataRequest.js"; diff --git a/src/api/resources/entities/resources/onboardingData/index.ts b/src/api/resources/entities/resources/onboardingData/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/entities/resources/onboardingData/index.ts +++ b/src/api/resources/entities/resources/onboardingData/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/entities/resources/paymentMethods/client/Client.ts b/src/api/resources/entities/resources/paymentMethods/client/Client.ts index 2167582..fbb94d1 100644 --- a/src/api/resources/entities/resources/paymentMethods/client/Client.ts +++ b/src/api/resources/entities/resources/paymentMethods/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace PaymentMethods { export interface Options { @@ -18,6 +19,8 @@ export declare namespace PaymentMethods { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace PaymentMethods { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PaymentMethods { - constructor(protected readonly _options: PaymentMethods.Options) {} + protected readonly _options: PaymentMethods.Options; + + constructor(_options: PaymentMethods.Options) { + this._options = _options; + } /** * Get all enabled payment methods. @@ -71,23 +78,15 @@ export class PaymentMethods { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -167,21 +166,15 @@ export class PaymentMethods { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/entities/resources/paymentMethods/client/index.ts b/src/api/resources/entities/resources/paymentMethods/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/entities/resources/paymentMethods/client/index.ts +++ b/src/api/resources/entities/resources/paymentMethods/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/entities/resources/paymentMethods/client/requests/EnabledPaymentMethods.ts b/src/api/resources/entities/resources/paymentMethods/client/requests/EnabledPaymentMethods.ts index fdfe195..ea9719b 100644 --- a/src/api/resources/entities/resources/paymentMethods/client/requests/EnabledPaymentMethods.ts +++ b/src/api/resources/entities/resources/paymentMethods/client/requests/EnabledPaymentMethods.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/resources/paymentMethods/client/requests/index.ts b/src/api/resources/entities/resources/paymentMethods/client/requests/index.ts index 21557a9..82c9454 100644 --- a/src/api/resources/entities/resources/paymentMethods/client/requests/index.ts +++ b/src/api/resources/entities/resources/paymentMethods/client/requests/index.ts @@ -1 +1 @@ -export { type EnabledPaymentMethods } from "./EnabledPaymentMethods"; +export { type EnabledPaymentMethods } from "./EnabledPaymentMethods.js"; diff --git a/src/api/resources/entities/resources/paymentMethods/index.ts b/src/api/resources/entities/resources/paymentMethods/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/entities/resources/paymentMethods/index.ts +++ b/src/api/resources/entities/resources/paymentMethods/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/entities/resources/persons/client/Client.ts b/src/api/resources/entities/resources/persons/client/Client.ts index b6b9493..0f78d34 100644 --- a/src/api/resources/entities/resources/persons/client/Client.ts +++ b/src/api/resources/entities/resources/persons/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace Persons { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Persons { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Persons { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Persons { - constructor(protected readonly _options: Persons.Options) {} + protected readonly _options: Persons.Options; + + constructor(_options: Persons.Options) { + this._options = _options; + } /** * @param {Persons.RequestOptions} requestOptions - Request-specific configuration. @@ -64,23 +71,15 @@ export class Persons { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -156,21 +155,15 @@ export class Persons { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -246,23 +239,15 @@ export class Persons { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -333,23 +318,15 @@ export class Persons { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -428,21 +405,15 @@ export class Persons { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -526,21 +497,15 @@ export class Persons { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/entities/resources/persons/client/index.ts b/src/api/resources/entities/resources/persons/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/entities/resources/persons/client/index.ts +++ b/src/api/resources/entities/resources/persons/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/entities/resources/persons/client/requests/OptionalPersonRequest.ts b/src/api/resources/entities/resources/persons/client/requests/OptionalPersonRequest.ts index 2e92bc3..ef0c08c 100644 --- a/src/api/resources/entities/resources/persons/client/requests/OptionalPersonRequest.ts +++ b/src/api/resources/entities/resources/persons/client/requests/OptionalPersonRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/resources/persons/client/requests/PersonRequest.ts b/src/api/resources/entities/resources/persons/client/requests/PersonRequest.ts index 5a2d3e5..7e02c62 100644 --- a/src/api/resources/entities/resources/persons/client/requests/PersonRequest.ts +++ b/src/api/resources/entities/resources/persons/client/requests/PersonRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/resources/persons/client/requests/index.ts b/src/api/resources/entities/resources/persons/client/requests/index.ts index e4f56a0..90f625c 100644 --- a/src/api/resources/entities/resources/persons/client/requests/index.ts +++ b/src/api/resources/entities/resources/persons/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type PersonRequest } from "./PersonRequest"; -export { type OptionalPersonRequest } from "./OptionalPersonRequest"; -export { type PersonOnboardingDocumentsPayload } from "./PersonOnboardingDocumentsPayload"; +export { type PersonRequest } from "./PersonRequest.js"; +export { type OptionalPersonRequest } from "./OptionalPersonRequest.js"; +export { type PersonOnboardingDocumentsPayload } from "./PersonOnboardingDocumentsPayload.js"; diff --git a/src/api/resources/entities/resources/persons/index.ts b/src/api/resources/entities/resources/persons/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/entities/resources/persons/index.ts +++ b/src/api/resources/entities/resources/persons/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/entities/resources/vatIds/client/Client.ts b/src/api/resources/entities/resources/vatIds/client/Client.ts index f8ad8c4..a76b02b 100644 --- a/src/api/resources/entities/resources/vatIds/client/Client.ts +++ b/src/api/resources/entities/resources/vatIds/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace VatIds { export interface Options { @@ -18,6 +19,8 @@ export declare namespace VatIds { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace VatIds { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class VatIds { - constructor(protected readonly _options: VatIds.Options) {} + protected readonly _options: VatIds.Options; + + constructor(_options: VatIds.Options) { + this._options = _options; + } /** * @param {string} entityId @@ -69,23 +76,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -162,21 +161,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -257,23 +250,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -351,23 +336,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -448,21 +425,15 @@ export class VatIds { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/entities/resources/vatIds/client/index.ts b/src/api/resources/entities/resources/vatIds/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/entities/resources/vatIds/client/index.ts +++ b/src/api/resources/entities/resources/vatIds/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/entities/resources/vatIds/client/requests/EntityUpdateVatId.ts b/src/api/resources/entities/resources/vatIds/client/requests/EntityUpdateVatId.ts index 2395e79..87d9c44 100644 --- a/src/api/resources/entities/resources/vatIds/client/requests/EntityUpdateVatId.ts +++ b/src/api/resources/entities/resources/vatIds/client/requests/EntityUpdateVatId.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/resources/vatIds/client/requests/EntityVatId.ts b/src/api/resources/entities/resources/vatIds/client/requests/EntityVatId.ts index 96b5334..6516098 100644 --- a/src/api/resources/entities/resources/vatIds/client/requests/EntityVatId.ts +++ b/src/api/resources/entities/resources/vatIds/client/requests/EntityVatId.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/entities/resources/vatIds/client/requests/index.ts b/src/api/resources/entities/resources/vatIds/client/requests/index.ts index bde42db..d334e05 100644 --- a/src/api/resources/entities/resources/vatIds/client/requests/index.ts +++ b/src/api/resources/entities/resources/vatIds/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type EntityVatId } from "./EntityVatId"; -export { type EntityUpdateVatId } from "./EntityUpdateVatId"; +export { type EntityVatId } from "./EntityVatId.js"; +export { type EntityUpdateVatId } from "./EntityUpdateVatId.js"; diff --git a/src/api/resources/entities/resources/vatIds/index.ts b/src/api/resources/entities/resources/vatIds/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/entities/resources/vatIds/index.ts +++ b/src/api/resources/entities/resources/vatIds/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/entityUsers/client/Client.ts b/src/api/resources/entityUsers/client/Client.ts index f495d9a..e85972e 100644 --- a/src/api/resources/entityUsers/client/Client.ts +++ b/src/api/resources/entityUsers/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace EntityUsers { export interface Options { @@ -18,6 +19,8 @@ export declare namespace EntityUsers { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace EntityUsers { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class EntityUsers { - constructor(protected readonly _options: EntityUsers.Options) {} + protected readonly _options: EntityUsers.Options; + + constructor(_options: EntityUsers.Options) { + this._options = _options; + } /** * Retrieve a list of all entity users. @@ -170,24 +177,16 @@ export class EntityUsers { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -271,21 +270,15 @@ export class EntityUsers { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -360,23 +353,15 @@ export class EntityUsers { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -451,21 +436,15 @@ export class EntityUsers { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -540,23 +519,15 @@ export class EntityUsers { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -631,21 +602,15 @@ export class EntityUsers { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -717,23 +682,15 @@ export class EntityUsers { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -806,23 +763,15 @@ export class EntityUsers { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -897,23 +846,15 @@ export class EntityUsers { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -993,21 +934,15 @@ export class EntityUsers { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/entityUsers/client/index.ts b/src/api/resources/entityUsers/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/entityUsers/client/index.ts +++ b/src/api/resources/entityUsers/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/entityUsers/client/requests/EntityUsersGetRequest.ts b/src/api/resources/entityUsers/client/requests/EntityUsersGetRequest.ts index eaa72b6..b6251de 100644 --- a/src/api/resources/entityUsers/client/requests/EntityUsersGetRequest.ts +++ b/src/api/resources/entityUsers/client/requests/EntityUsersGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/entityUsers/client/requests/index.ts b/src/api/resources/entityUsers/client/requests/index.ts index 57e3126..a9e0e7b 100644 --- a/src/api/resources/entityUsers/client/requests/index.ts +++ b/src/api/resources/entityUsers/client/requests/index.ts @@ -1,4 +1,4 @@ -export { type EntityUsersGetRequest } from "./EntityUsersGetRequest"; -export { type CreateEntityUserRequest } from "./CreateEntityUserRequest"; -export { type UpdateMeEntityUserRequest } from "./UpdateMeEntityUserRequest"; -export { type UpdateEntityUserRequest } from "./UpdateEntityUserRequest"; +export { type EntityUsersGetRequest } from "./EntityUsersGetRequest.js"; +export { type CreateEntityUserRequest } from "./CreateEntityUserRequest.js"; +export { type UpdateMeEntityUserRequest } from "./UpdateMeEntityUserRequest.js"; +export { type UpdateEntityUserRequest } from "./UpdateEntityUserRequest.js"; diff --git a/src/api/resources/entityUsers/index.ts b/src/api/resources/entityUsers/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/entityUsers/index.ts +++ b/src/api/resources/entityUsers/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/events/client/Client.ts b/src/api/resources/events/client/Client.ts index 0209507..e95534e 100644 --- a/src/api/resources/events/client/Client.ts +++ b/src/api/resources/events/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Events { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Events { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Events { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Events { - constructor(protected readonly _options: Events.Options) {} + protected readonly _options: Events.Options; + + constructor(_options: Events.Options) { + this._options = _options; + } /** * Returns all webhook events that were triggered for the specified entity based on your enabled webhook subscriptions. These are the same events that were sent to your configured webhook listener endpoints, aggregated into a single list. Results can be filtered by the related object type or time period. @@ -123,24 +130,16 @@ export class Events { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -212,23 +211,15 @@ export class Events { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/events/client/index.ts b/src/api/resources/events/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/events/client/index.ts +++ b/src/api/resources/events/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/events/client/requests/EventsGetRequest.ts b/src/api/resources/events/client/requests/EventsGetRequest.ts index 116ecf2..f9714e3 100644 --- a/src/api/resources/events/client/requests/EventsGetRequest.ts +++ b/src/api/resources/events/client/requests/EventsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/events/client/requests/index.ts b/src/api/resources/events/client/requests/index.ts index 757bafd..6ea0be4 100644 --- a/src/api/resources/events/client/requests/index.ts +++ b/src/api/resources/events/client/requests/index.ts @@ -1 +1 @@ -export { type EventsGetRequest } from "./EventsGetRequest"; +export { type EventsGetRequest } from "./EventsGetRequest.js"; diff --git a/src/api/resources/events/index.ts b/src/api/resources/events/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/events/index.ts +++ b/src/api/resources/events/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/files/client/Client.ts b/src/api/resources/files/client/Client.ts index 272ddd3..1b7bf05 100644 --- a/src/api/resources/files/client/Client.ts +++ b/src/api/resources/files/client/Client.ts @@ -2,13 +2,13 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; import * as fs from "fs"; -import { Blob } from "buffer"; export declare namespace Files { export interface Options { @@ -20,6 +20,8 @@ export declare namespace Files { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -35,12 +37,16 @@ export declare namespace Files { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Files { - constructor(protected readonly _options: Files.Options) {} + protected readonly _options: Files.Options; + + constructor(_options: Files.Options) { + this._options = _options; + } /** * @param {Monite.FilesGetRequest} request @@ -81,24 +87,16 @@ export class Files { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -140,7 +138,6 @@ export class Files { } /** - * @param {File | fs.ReadStream | Blob} file * @param {Monite.UploadFile} request * @param {Files.RequestOptions} requestOptions - Request-specific configuration. * @@ -148,25 +145,24 @@ export class Files { * @throws {@link Monite.InternalServerError} * * @example - * await client.files.upload(fs.createReadStream("/path/to/your/file"), { + * await client.files.upload({ + * file: fs.createReadStream("/path/to/your/file"), * file_type: "ocr_results" * }) */ public upload( - file: File | fs.ReadStream | Blob, request: Monite.UploadFile, requestOptions?: Files.RequestOptions, ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__upload(file, request, requestOptions)); + return core.HttpResponsePromise.fromPromise(this.__upload(request, requestOptions)); } private 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.appendFile("file", request.file); _request.append("file_type", request.file_type); const _maybeEncodedRequest = await _request.getRequest(); const _response = await (this._options.fetcher ?? core.fetcher)({ @@ -177,22 +173,16 @@ export class Files { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ..._maybeEncodedRequest.headers, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + ..._maybeEncodedRequest.headers, + }), + requestOptions?.headers, + ), requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, @@ -265,23 +255,15 @@ export class Files { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -345,23 +327,15 @@ export class Files { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/files/client/index.ts b/src/api/resources/files/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/files/client/index.ts +++ b/src/api/resources/files/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/files/client/requests/UploadFile.ts b/src/api/resources/files/client/requests/UploadFile.ts index acef852..5702fd3 100644 --- a/src/api/resources/files/client/requests/UploadFile.ts +++ b/src/api/resources/files/client/requests/UploadFile.ts @@ -2,14 +2,17 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as fs from "fs"; +import * as Monite from "../../../../index.js"; /** * @example * { + * file: fs.createReadStream("/path/to/your/file"), * file_type: "ocr_results" * } */ export interface UploadFile { + file: File | fs.ReadStream | Blob; file_type: Monite.AllowedFileTypes; } diff --git a/src/api/resources/files/client/requests/index.ts b/src/api/resources/files/client/requests/index.ts index 0f18cae..f7d8388 100644 --- a/src/api/resources/files/client/requests/index.ts +++ b/src/api/resources/files/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type FilesGetRequest } from "./FilesGetRequest"; -export { type UploadFile } from "./UploadFile"; +export { type FilesGetRequest } from "./FilesGetRequest.js"; +export { type UploadFile } from "./UploadFile.js"; diff --git a/src/api/resources/files/index.ts b/src/api/resources/files/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/files/index.ts +++ b/src/api/resources/files/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/financing/client/Client.ts b/src/api/resources/financing/client/Client.ts index 3903a4d..ba0e2ea 100644 --- a/src/api/resources/financing/client/Client.ts +++ b/src/api/resources/financing/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Financing { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Financing { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Financing { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Financing { - constructor(protected readonly _options: Financing.Options) {} + protected readonly _options: Financing.Options; + + constructor(_options: Financing.Options) { + this._options = _options; + } /** * Returns a list of invoices requested for financing @@ -235,24 +242,16 @@ export class Financing { "financing_invoices", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -329,21 +328,15 @@ export class Financing { "financing_invoices", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -415,23 +408,15 @@ export class Financing { "financing_offers", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -500,23 +485,15 @@ export class Financing { "financing_tokens", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/financing/client/index.ts b/src/api/resources/financing/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/financing/client/index.ts +++ b/src/api/resources/financing/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/financing/client/requests/FinancingPushInvoicesRequest.ts b/src/api/resources/financing/client/requests/FinancingPushInvoicesRequest.ts index 90795b6..260e129 100644 --- a/src/api/resources/financing/client/requests/FinancingPushInvoicesRequest.ts +++ b/src/api/resources/financing/client/requests/FinancingPushInvoicesRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/financing/client/requests/GetFinancingInvoicesRequest.ts b/src/api/resources/financing/client/requests/GetFinancingInvoicesRequest.ts index a07879e..e05262c 100644 --- a/src/api/resources/financing/client/requests/GetFinancingInvoicesRequest.ts +++ b/src/api/resources/financing/client/requests/GetFinancingInvoicesRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -10,19 +10,21 @@ import * as Monite from "../../../../index"; */ export interface GetFinancingInvoicesRequest { /** - * Order by + * Sort order (ascending by default). Typically used together with the `sort` parameter. */ order?: Monite.OrderEnum; /** - * Max is 100 + * 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. */ limit?: number; /** - * A token, obtained from previous page. Prior over other filters + * 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 are ignored and inferred from the initial query. + * + * If not specified, the first page of results will be returned. */ pagination_token?: string; /** - * Allowed sort fields + * The field to sort the results by. Typically used together with the `order` parameter. */ sort?: Monite.FinancingInvoiceCursorFields; /** diff --git a/src/api/resources/financing/client/requests/index.ts b/src/api/resources/financing/client/requests/index.ts index c5d90c1..ed704b7 100644 --- a/src/api/resources/financing/client/requests/index.ts +++ b/src/api/resources/financing/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type GetFinancingInvoicesRequest } from "./GetFinancingInvoicesRequest"; -export { type FinancingPushInvoicesRequest } from "./FinancingPushInvoicesRequest"; +export { type GetFinancingInvoicesRequest } from "./GetFinancingInvoicesRequest.js"; +export { type FinancingPushInvoicesRequest } from "./FinancingPushInvoicesRequest.js"; diff --git a/src/api/resources/financing/index.ts b/src/api/resources/financing/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/financing/index.ts +++ b/src/api/resources/financing/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 4f439b9..b9003ec 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -1,87 +1,88 @@ -export * as analytics from "./analytics"; -export * from "./analytics/types"; -export * as approvalPolicies from "./approvalPolicies"; -export * from "./approvalPolicies/types"; -export * as deliveryNotes from "./deliveryNotes"; -export * from "./deliveryNotes/types"; -export * as paymentRecords from "./paymentRecords"; -export * from "./paymentRecords/types"; -export * as receivables from "./receivables"; -export * from "./receivables/types"; -export * as approvalRequests from "./approvalRequests"; -export * as accessTokens from "./accessTokens"; -export * as comments from "./comments"; -export * as counterparts from "./counterparts"; -export * as counterpartEInvoicingCredentials from "./counterpartEInvoicingCredentials"; -export * as dataExports from "./dataExports"; -export * as pdfTemplates from "./pdfTemplates"; -export * as eInvoicingConnections from "./eInvoicingConnections"; -export * as entities from "./entities"; -export * as entityUsers from "./entityUsers"; -export * as events from "./events"; -export * as files from "./files"; -export * as financing from "./financing"; -export * as mailTemplates from "./mailTemplates"; -export * as mailboxDomains from "./mailboxDomains"; -export * as mailboxes from "./mailboxes"; -export * as measureUnits from "./measureUnits"; -export * as ocr from "./ocr"; -export * as overdueReminders from "./overdueReminders"; -export * as creditNotes from "./creditNotes"; -export * as purchaseOrders from "./purchaseOrders"; -export * as payables from "./payables"; -export * as paymentIntents from "./paymentIntents"; -export * as paymentLinks from "./paymentLinks"; -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 "./analytics/client/requests"; -export * from "./approvalPolicies/client/requests"; -export * from "./approvalRequests/client/requests"; -export * from "./accessTokens/client/requests"; -export * from "./comments/client/requests"; -export * from "./counterparts/client/requests"; -export * from "./counterpartEInvoicingCredentials/client/requests"; -export * from "./dataExports/client/requests"; -export * from "./deliveryNotes/client/requests"; -export * from "./eInvoicingConnections/client/requests"; -export * from "./entities/client/requests"; -export * from "./entityUsers/client/requests"; -export * from "./events/client/requests"; -export * from "./files/client/requests"; -export * from "./financing/client/requests"; -export * from "./mailTemplates/client/requests"; -export * from "./mailboxDomains/client/requests"; -export * from "./mailboxes/client/requests"; -export * from "./measureUnits/client/requests"; -export * from "./ocr/client/requests"; -export * from "./overdueReminders/client/requests"; -export * from "./creditNotes/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"; +export * as analytics from "./analytics/index.js"; +export * from "./analytics/types/index.js"; +export * as approvalPolicies from "./approvalPolicies/index.js"; +export * from "./approvalPolicies/types/index.js"; +export * as deliveryNotes from "./deliveryNotes/index.js"; +export * from "./deliveryNotes/types/index.js"; +export * as receivables from "./receivables/index.js"; +export * from "./receivables/types/index.js"; +export * as approvalRequests from "./approvalRequests/index.js"; +export * as accessTokens from "./accessTokens/index.js"; +export * as comments from "./comments/index.js"; +export * as counterparts from "./counterparts/index.js"; +export * as counterpartEInvoicingCredentials from "./counterpartEInvoicingCredentials/index.js"; +export * as customVatRates from "./customVatRates/index.js"; +export * as dataExports from "./dataExports/index.js"; +export * as pdfTemplates from "./pdfTemplates/index.js"; +export * as eInvoicingConnections from "./eInvoicingConnections/index.js"; +export * as entities from "./entities/index.js"; +export * as entityUsers from "./entityUsers/index.js"; +export * as events from "./events/index.js"; +export * as files from "./files/index.js"; +export * as financing from "./financing/index.js"; +export * as mailTemplates from "./mailTemplates/index.js"; +export * as mailboxDomains from "./mailboxDomains/index.js"; +export * as mailboxes from "./mailboxes/index.js"; +export * as measureUnits from "./measureUnits/index.js"; +export * as ocr from "./ocr/index.js"; +export * as overdueReminders from "./overdueReminders/index.js"; +export * as creditNotes from "./creditNotes/index.js"; +export * as purchaseOrders from "./purchaseOrders/index.js"; +export * as payables from "./payables/index.js"; +export * as paymentIntents from "./paymentIntents/index.js"; +export * as paymentLinks from "./paymentLinks/index.js"; +export * as paymentRecords from "./paymentRecords/index.js"; +export * as paymentReminders from "./paymentReminders/index.js"; +export * as paymentTerms from "./paymentTerms/index.js"; +export * as products from "./products/index.js"; +export * as projects from "./projects/index.js"; +export * as recurrences from "./recurrences/index.js"; +export * as roles from "./roles/index.js"; +export * as partnerSettings from "./partnerSettings/index.js"; +export * as tags from "./tags/index.js"; +export * as textTemplates from "./textTemplates/index.js"; +export * as vatRates from "./vatRates/index.js"; +export * as webhookDeliveries from "./webhookDeliveries/index.js"; +export * as webhookSubscriptions from "./webhookSubscriptions/index.js"; +export * as accounting from "./accounting/index.js"; +export * from "./analytics/client/requests/index.js"; +export * from "./approvalPolicies/client/requests/index.js"; +export * from "./approvalRequests/client/requests/index.js"; +export * from "./accessTokens/client/requests/index.js"; +export * from "./comments/client/requests/index.js"; +export * from "./counterparts/client/requests/index.js"; +export * from "./counterpartEInvoicingCredentials/client/requests/index.js"; +export * from "./customVatRates/client/requests/index.js"; +export * from "./dataExports/client/requests/index.js"; +export * from "./deliveryNotes/client/requests/index.js"; +export * from "./eInvoicingConnections/client/requests/index.js"; +export * from "./entities/client/requests/index.js"; +export * from "./entityUsers/client/requests/index.js"; +export * from "./events/client/requests/index.js"; +export * from "./files/client/requests/index.js"; +export * from "./financing/client/requests/index.js"; +export * from "./mailTemplates/client/requests/index.js"; +export * from "./mailboxDomains/client/requests/index.js"; +export * from "./mailboxes/client/requests/index.js"; +export * from "./measureUnits/client/requests/index.js"; +export * from "./ocr/client/requests/index.js"; +export * from "./overdueReminders/client/requests/index.js"; +export * from "./creditNotes/client/requests/index.js"; +export * from "./purchaseOrders/client/requests/index.js"; +export * from "./payables/client/requests/index.js"; +export * from "./paymentIntents/client/requests/index.js"; +export * from "./paymentLinks/client/requests/index.js"; +export * from "./paymentRecords/client/requests/index.js"; +export * from "./paymentReminders/client/requests/index.js"; +export * from "./paymentTerms/client/requests/index.js"; +export * from "./products/client/requests/index.js"; +export * from "./projects/client/requests/index.js"; +export * from "./receivables/client/requests/index.js"; +export * from "./recurrences/client/requests/index.js"; +export * from "./roles/client/requests/index.js"; +export * from "./partnerSettings/client/requests/index.js"; +export * from "./tags/client/requests/index.js"; +export * from "./textTemplates/client/requests/index.js"; +export * from "./vatRates/client/requests/index.js"; +export * from "./webhookDeliveries/client/requests/index.js"; +export * from "./webhookSubscriptions/client/requests/index.js"; diff --git a/src/api/resources/mailTemplates/client/Client.ts b/src/api/resources/mailTemplates/client/Client.ts index c35f145..0361b3a 100644 --- a/src/api/resources/mailTemplates/client/Client.ts +++ b/src/api/resources/mailTemplates/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace MailTemplates { export interface Options { @@ -18,6 +19,8 @@ export declare namespace MailTemplates { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace MailTemplates { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class MailTemplates { - constructor(protected readonly _options: MailTemplates.Options) {} + protected readonly _options: MailTemplates.Options; + + constructor(_options: MailTemplates.Options) { + this._options = _options; + } /** * Get all custom templates @@ -142,24 +149,16 @@ export class MailTemplates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -239,21 +238,15 @@ export class MailTemplates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -333,21 +326,15 @@ export class MailTemplates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -417,23 +404,15 @@ export class MailTemplates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -505,23 +484,15 @@ export class MailTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -593,23 +564,15 @@ export class MailTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -686,21 +649,15 @@ export class MailTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -777,23 +734,15 @@ export class MailTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/mailTemplates/client/index.ts b/src/api/resources/mailTemplates/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/mailTemplates/client/index.ts +++ b/src/api/resources/mailTemplates/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/mailTemplates/client/requests/AddCustomTemplateSchema.ts b/src/api/resources/mailTemplates/client/requests/AddCustomTemplateSchema.ts index 3fa01f5..54cc0cc 100644 --- a/src/api/resources/mailTemplates/client/requests/AddCustomTemplateSchema.ts +++ b/src/api/resources/mailTemplates/client/requests/AddCustomTemplateSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/mailTemplates/client/requests/MailTemplatesGetRequest.ts b/src/api/resources/mailTemplates/client/requests/MailTemplatesGetRequest.ts index 20c1efc..008afd5 100644 --- a/src/api/resources/mailTemplates/client/requests/MailTemplatesGetRequest.ts +++ b/src/api/resources/mailTemplates/client/requests/MailTemplatesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/mailTemplates/client/requests/PreviewTemplateRequest.ts b/src/api/resources/mailTemplates/client/requests/PreviewTemplateRequest.ts index 17308d5..e2bd41c 100644 --- a/src/api/resources/mailTemplates/client/requests/PreviewTemplateRequest.ts +++ b/src/api/resources/mailTemplates/client/requests/PreviewTemplateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/mailTemplates/client/requests/UpdateCustomTemplateSchemaRequest.ts b/src/api/resources/mailTemplates/client/requests/UpdateCustomTemplateSchemaRequest.ts index fcc9742..af57034 100644 --- a/src/api/resources/mailTemplates/client/requests/UpdateCustomTemplateSchemaRequest.ts +++ b/src/api/resources/mailTemplates/client/requests/UpdateCustomTemplateSchemaRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/mailTemplates/client/requests/index.ts b/src/api/resources/mailTemplates/client/requests/index.ts index e1ca7ec..9085dba 100644 --- a/src/api/resources/mailTemplates/client/requests/index.ts +++ b/src/api/resources/mailTemplates/client/requests/index.ts @@ -1,4 +1,4 @@ -export { type MailTemplatesGetRequest } from "./MailTemplatesGetRequest"; -export { type AddCustomTemplateSchema } from "./AddCustomTemplateSchema"; -export { type PreviewTemplateRequest } from "./PreviewTemplateRequest"; -export { type UpdateCustomTemplateSchemaRequest } from "./UpdateCustomTemplateSchemaRequest"; +export { type MailTemplatesGetRequest } from "./MailTemplatesGetRequest.js"; +export { type AddCustomTemplateSchema } from "./AddCustomTemplateSchema.js"; +export { type PreviewTemplateRequest } from "./PreviewTemplateRequest.js"; +export { type UpdateCustomTemplateSchemaRequest } from "./UpdateCustomTemplateSchemaRequest.js"; diff --git a/src/api/resources/mailTemplates/index.ts b/src/api/resources/mailTemplates/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/mailTemplates/index.ts +++ b/src/api/resources/mailTemplates/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/mailboxDomains/client/Client.ts b/src/api/resources/mailboxDomains/client/Client.ts index 13fc186..fbed2ac 100644 --- a/src/api/resources/mailboxDomains/client/Client.ts +++ b/src/api/resources/mailboxDomains/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace MailboxDomains { export interface Options { @@ -18,6 +19,8 @@ export declare namespace MailboxDomains { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace MailboxDomains { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class MailboxDomains { - constructor(protected readonly _options: MailboxDomains.Options) {} + protected readonly _options: MailboxDomains.Options; + + constructor(_options: MailboxDomains.Options) { + this._options = _options; + } /** * Get all domains owned by partner_id @@ -68,23 +75,15 @@ export class MailboxDomains { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -166,21 +165,15 @@ export class MailboxDomains { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -266,23 +259,15 @@ export class MailboxDomains { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -367,23 +352,15 @@ export class MailboxDomains { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/mailboxDomains/client/index.ts b/src/api/resources/mailboxDomains/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/mailboxDomains/client/index.ts +++ b/src/api/resources/mailboxDomains/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/mailboxDomains/client/requests/index.ts b/src/api/resources/mailboxDomains/client/requests/index.ts index 6a6caec..8cbece4 100644 --- a/src/api/resources/mailboxDomains/client/requests/index.ts +++ b/src/api/resources/mailboxDomains/client/requests/index.ts @@ -1 +1 @@ -export { type DomainRequest } from "./DomainRequest"; +export { type DomainRequest } from "./DomainRequest.js"; diff --git a/src/api/resources/mailboxDomains/index.ts b/src/api/resources/mailboxDomains/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/mailboxDomains/index.ts +++ b/src/api/resources/mailboxDomains/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/mailboxes/client/Client.ts b/src/api/resources/mailboxes/client/Client.ts index e7af79b..6df1d86 100644 --- a/src/api/resources/mailboxes/client/Client.ts +++ b/src/api/resources/mailboxes/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Mailboxes { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Mailboxes { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Mailboxes { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Mailboxes { - constructor(protected readonly _options: Mailboxes.Options) {} + protected readonly _options: Mailboxes.Options; + + constructor(_options: Mailboxes.Options) { + this._options = _options; + } /** * Get all mailboxes owned by Entity @@ -68,23 +75,15 @@ export class Mailboxes { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -144,8 +143,7 @@ export class Mailboxes { * @example * await client.mailboxes.create({ * mailbox_domain_id: "mailbox_domain_id", - * mailbox_name: "mailbox_name", - * related_object_type: "payable" + * mailbox_name: "mailbox_name" * }) */ public create( @@ -167,21 +165,15 @@ export class Mailboxes { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: { ...request, related_object_type: "payable" }, @@ -266,21 +258,15 @@ export class Mailboxes { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -359,23 +345,15 @@ export class Mailboxes { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/mailboxes/client/index.ts b/src/api/resources/mailboxes/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/mailboxes/client/index.ts +++ b/src/api/resources/mailboxes/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/mailboxes/client/requests/MailboxDomainRequest.ts b/src/api/resources/mailboxes/client/requests/MailboxDomainRequest.ts index 03304fe..8c86035 100644 --- a/src/api/resources/mailboxes/client/requests/MailboxDomainRequest.ts +++ b/src/api/resources/mailboxes/client/requests/MailboxDomainRequest.ts @@ -6,8 +6,7 @@ * @example * { * mailbox_domain_id: "mailbox_domain_id", - * mailbox_name: "mailbox_name", - * related_object_type: "payable" + * mailbox_name: "mailbox_name" * } */ export interface MailboxDomainRequest { diff --git a/src/api/resources/mailboxes/client/requests/index.ts b/src/api/resources/mailboxes/client/requests/index.ts index e68e9e3..01f6872 100644 --- a/src/api/resources/mailboxes/client/requests/index.ts +++ b/src/api/resources/mailboxes/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type MailboxDomainRequest } from "./MailboxDomainRequest"; -export { type MailboxMultipleEntitiesRequest } from "./MailboxMultipleEntitiesRequest"; +export { type MailboxDomainRequest } from "./MailboxDomainRequest.js"; +export { type MailboxMultipleEntitiesRequest } from "./MailboxMultipleEntitiesRequest.js"; diff --git a/src/api/resources/mailboxes/index.ts b/src/api/resources/mailboxes/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/mailboxes/index.ts +++ b/src/api/resources/mailboxes/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/measureUnits/client/Client.ts b/src/api/resources/measureUnits/client/Client.ts index 65ea522..3b7f90b 100644 --- a/src/api/resources/measureUnits/client/Client.ts +++ b/src/api/resources/measureUnits/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace MeasureUnits { export interface Options { @@ -18,6 +19,8 @@ export declare namespace MeasureUnits { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace MeasureUnits { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class MeasureUnits { - constructor(protected readonly _options: MeasureUnits.Options) {} + protected readonly _options: MeasureUnits.Options; + + constructor(_options: MeasureUnits.Options) { + this._options = _options; + } /** * @param {MeasureUnits.RequestOptions} requestOptions - Request-specific configuration. @@ -67,23 +74,15 @@ export class MeasureUnits { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -164,21 +163,15 @@ export class MeasureUnits { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -261,23 +254,15 @@ export class MeasureUnits { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -356,23 +341,15 @@ export class MeasureUnits { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -457,21 +434,15 @@ export class MeasureUnits { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/measureUnits/client/index.ts b/src/api/resources/measureUnits/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/measureUnits/client/index.ts +++ b/src/api/resources/measureUnits/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/measureUnits/client/requests/index.ts b/src/api/resources/measureUnits/client/requests/index.ts index 0159256..356f823 100644 --- a/src/api/resources/measureUnits/client/requests/index.ts +++ b/src/api/resources/measureUnits/client/requests/index.ts @@ -1 +1 @@ -export { type UnitUpdate } from "./UnitUpdate"; +export { type UnitUpdate } from "./UnitUpdate.js"; diff --git a/src/api/resources/measureUnits/index.ts b/src/api/resources/measureUnits/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/measureUnits/index.ts +++ b/src/api/resources/measureUnits/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/ocr/client/Client.ts b/src/api/resources/ocr/client/Client.ts index 8985881..6740325 100644 --- a/src/api/resources/ocr/client/Client.ts +++ b/src/api/resources/ocr/client/Client.ts @@ -2,13 +2,13 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; import * as fs from "fs"; -import { Blob } from "buffer"; export declare namespace Ocr { export interface Options { @@ -20,6 +20,8 @@ export declare namespace Ocr { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -35,12 +37,16 @@ export declare namespace Ocr { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Ocr { - constructor(protected readonly _options: Ocr.Options) {} + protected readonly _options: Ocr.Options; + + constructor(_options: Ocr.Options) { + this._options = _options; + } /** * @param {Monite.GetOcrTasksRequest} request @@ -134,24 +140,16 @@ export class Ocr { "ocr_tasks", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -230,21 +228,15 @@ export class Ocr { "ocr_tasks", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -299,7 +291,6 @@ export class Ocr { } /** - * @param {File | fs.ReadStream | Blob} file * @param {Monite.OcrFileUpload} request * @param {Ocr.RequestOptions} requestOptions - Request-specific configuration. * @@ -310,18 +301,18 @@ export class Ocr { * @throws {@link Monite.InternalServerError} * * @example - * await client.ocr.postOcrTasksUploadFromFile(fs.createReadStream("/path/to/your/file"), {}) + * await client.ocr.postOcrTasksUploadFromFile({ + * file: fs.createReadStream("/path/to/your/file") + * }) */ public postOcrTasksUploadFromFile( - file: File | fs.ReadStream | Blob, request: Monite.OcrFileUpload, requestOptions?: Ocr.RequestOptions, ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__postOcrTasksUploadFromFile(file, request, requestOptions)); + return core.HttpResponsePromise.fromPromise(this.__postOcrTasksUploadFromFile(request, requestOptions)); } private async __postOcrTasksUploadFromFile( - file: File | fs.ReadStream | Blob, request: Monite.OcrFileUpload, requestOptions?: Ocr.RequestOptions, ): Promise> { @@ -331,7 +322,7 @@ export class Ocr { } const _request = await core.newFormData(); - await _request.appendFile("file", file); + await _request.appendFile("file", request.file); const _maybeEncodedRequest = await _request.getRequest(); const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -341,22 +332,16 @@ export class Ocr { "ocr_tasks/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ..._maybeEncodedRequest.headers, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + ..._maybeEncodedRequest.headers, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, requestType: "file", duplex: _maybeEncodedRequest.duplex, @@ -437,23 +422,15 @@ export class Ocr { `ocr_tasks/${encodeURIComponent(taskId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/ocr/client/index.ts b/src/api/resources/ocr/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/ocr/client/index.ts +++ b/src/api/resources/ocr/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/ocr/client/requests/CreateOcrRequestPayload.ts b/src/api/resources/ocr/client/requests/CreateOcrRequestPayload.ts index 1f2f4c6..0ab5b9f 100644 --- a/src/api/resources/ocr/client/requests/CreateOcrRequestPayload.ts +++ b/src/api/resources/ocr/client/requests/CreateOcrRequestPayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/ocr/client/requests/GetOcrTasksRequest.ts b/src/api/resources/ocr/client/requests/GetOcrTasksRequest.ts index 1342741..1dba53c 100644 --- a/src/api/resources/ocr/client/requests/GetOcrTasksRequest.ts +++ b/src/api/resources/ocr/client/requests/GetOcrTasksRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/ocr/client/requests/OcrFileUpload.ts b/src/api/resources/ocr/client/requests/OcrFileUpload.ts index f18df1c..96f1a15 100644 --- a/src/api/resources/ocr/client/requests/OcrFileUpload.ts +++ b/src/api/resources/ocr/client/requests/OcrFileUpload.ts @@ -2,12 +2,16 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as fs from "fs"; +import * as Monite from "../../../../index.js"; /** * @example - * {} + * { + * file: fs.createReadStream("/path/to/your/file") + * } */ export interface OcrFileUpload { document_type?: Monite.OcrDocumentTypeEnum; + file: File | fs.ReadStream | Blob; } diff --git a/src/api/resources/ocr/client/requests/index.ts b/src/api/resources/ocr/client/requests/index.ts index ec49e80..52a7ef8 100644 --- a/src/api/resources/ocr/client/requests/index.ts +++ b/src/api/resources/ocr/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type GetOcrTasksRequest } from "./GetOcrTasksRequest"; -export { type CreateOcrRequestPayload } from "./CreateOcrRequestPayload"; -export { type OcrFileUpload } from "./OcrFileUpload"; +export { type GetOcrTasksRequest } from "./GetOcrTasksRequest.js"; +export { type CreateOcrRequestPayload } from "./CreateOcrRequestPayload.js"; +export { type OcrFileUpload } from "./OcrFileUpload.js"; diff --git a/src/api/resources/ocr/index.ts b/src/api/resources/ocr/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/ocr/index.ts +++ b/src/api/resources/ocr/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/overdueReminders/client/Client.ts b/src/api/resources/overdueReminders/client/Client.ts index 36d7fcd..e300652 100644 --- a/src/api/resources/overdueReminders/client/Client.ts +++ b/src/api/resources/overdueReminders/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace OverdueReminders { export interface Options { @@ -18,6 +19,8 @@ export declare namespace OverdueReminders { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace OverdueReminders { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class OverdueReminders { - constructor(protected readonly _options: OverdueReminders.Options) {} + protected readonly _options: OverdueReminders.Options; + + constructor(_options: OverdueReminders.Options) { + this._options = _options; + } /** * @param {OverdueReminders.RequestOptions} requestOptions - Request-specific configuration. @@ -68,23 +75,15 @@ export class OverdueReminders { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -163,21 +162,15 @@ export class OverdueReminders { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -259,23 +252,15 @@ export class OverdueReminders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -357,23 +342,15 @@ export class OverdueReminders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -460,21 +437,15 @@ export class OverdueReminders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/overdueReminders/client/index.ts b/src/api/resources/overdueReminders/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/overdueReminders/client/index.ts +++ b/src/api/resources/overdueReminders/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/overdueReminders/client/requests/OverdueReminderRequest.ts b/src/api/resources/overdueReminders/client/requests/OverdueReminderRequest.ts index 9089364..f691dc5 100644 --- a/src/api/resources/overdueReminders/client/requests/OverdueReminderRequest.ts +++ b/src/api/resources/overdueReminders/client/requests/OverdueReminderRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/overdueReminders/client/requests/OverdueReminderUpdateRequest.ts b/src/api/resources/overdueReminders/client/requests/OverdueReminderUpdateRequest.ts index e3f9577..aa07ebf 100644 --- a/src/api/resources/overdueReminders/client/requests/OverdueReminderUpdateRequest.ts +++ b/src/api/resources/overdueReminders/client/requests/OverdueReminderUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/overdueReminders/client/requests/index.ts b/src/api/resources/overdueReminders/client/requests/index.ts index 7f92a07..e2e1823 100644 --- a/src/api/resources/overdueReminders/client/requests/index.ts +++ b/src/api/resources/overdueReminders/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type OverdueReminderRequest } from "./OverdueReminderRequest"; -export { type OverdueReminderUpdateRequest } from "./OverdueReminderUpdateRequest"; +export { type OverdueReminderRequest } from "./OverdueReminderRequest.js"; +export { type OverdueReminderUpdateRequest } from "./OverdueReminderUpdateRequest.js"; diff --git a/src/api/resources/overdueReminders/index.ts b/src/api/resources/overdueReminders/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/overdueReminders/index.ts +++ b/src/api/resources/overdueReminders/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/partnerSettings/client/Client.ts b/src/api/resources/partnerSettings/client/Client.ts index d78ae19..9e21875 100644 --- a/src/api/resources/partnerSettings/client/Client.ts +++ b/src/api/resources/partnerSettings/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace PartnerSettings { export interface Options { @@ -18,6 +19,8 @@ export declare namespace PartnerSettings { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace PartnerSettings { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PartnerSettings { - constructor(protected readonly _options: PartnerSettings.Options) {} + protected readonly _options: PartnerSettings.Options; + + constructor(_options: PartnerSettings.Options) { + this._options = _options; + } /** * Retrieve all settings for this partner. @@ -69,23 +76,15 @@ export class PartnerSettings { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -163,21 +162,15 @@ export class PartnerSettings { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/partnerSettings/client/index.ts b/src/api/resources/partnerSettings/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/partnerSettings/client/index.ts +++ b/src/api/resources/partnerSettings/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/partnerSettings/client/requests/PartnerProjectSettingsPayloadInput.ts b/src/api/resources/partnerSettings/client/requests/PartnerProjectSettingsPayloadInput.ts index c095d8a..6a9423a 100644 --- a/src/api/resources/partnerSettings/client/requests/PartnerProjectSettingsPayloadInput.ts +++ b/src/api/resources/partnerSettings/client/requests/PartnerProjectSettingsPayloadInput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/partnerSettings/client/requests/index.ts b/src/api/resources/partnerSettings/client/requests/index.ts index 9bffb12..e934bea 100644 --- a/src/api/resources/partnerSettings/client/requests/index.ts +++ b/src/api/resources/partnerSettings/client/requests/index.ts @@ -1 +1 @@ -export { type PartnerProjectSettingsPayloadInput } from "./PartnerProjectSettingsPayloadInput"; +export { type PartnerProjectSettingsPayloadInput } from "./PartnerProjectSettingsPayloadInput.js"; diff --git a/src/api/resources/partnerSettings/index.ts b/src/api/resources/partnerSettings/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/partnerSettings/index.ts +++ b/src/api/resources/partnerSettings/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/payables/client/Client.ts b/src/api/resources/payables/client/Client.ts index e907398..090c131 100644 --- a/src/api/resources/payables/client/Client.ts +++ b/src/api/resources/payables/client/Client.ts @@ -2,14 +2,14 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; import * as fs from "fs"; -import { Blob } from "buffer"; -import { LineItems } from "../resources/lineItems/client/Client"; +import { LineItems } from "../resources/lineItems/client/Client.js"; export declare namespace Payables { export interface Options { @@ -21,6 +21,8 @@ export declare namespace Payables { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -36,14 +38,17 @@ export declare namespace Payables { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Payables { + protected readonly _options: Payables.Options; protected _lineItems: LineItems | undefined; - constructor(protected readonly _options: Payables.Options) {} + constructor(_options: Payables.Options) { + this._options = _options; + } public get lineItems(): LineItems { return (this._lineItems ??= new LineItems(this._options)); @@ -157,6 +162,7 @@ export class Payables { project_id__in: projectIdIn, tag_ids: tagIds, tag_ids__not_in: tagIdsNotIn, + has_tags: hasTags, origin, has_file: hasFile, } = request; @@ -377,6 +383,10 @@ export class Payables { } } + if (hasTags != null) { + _queryParams["has_tags"] = hasTags.toString(); + } + if (origin != null) { _queryParams["origin"] = origin; } @@ -393,24 +403,16 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -499,21 +501,15 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -636,6 +632,7 @@ export class Payables { project_id__in: projectIdIn, tag_ids: tagIds, tag_ids__not_in: tagIdsNotIn, + has_tags: hasTags, origin, has_file: hasFile, } = request; @@ -840,6 +837,10 @@ export class Payables { } } + if (hasTags != null) { + _queryParams["has_tags"] = hasTags.toString(); + } + if (origin != null) { _queryParams["origin"] = origin; } @@ -856,24 +857,16 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -919,9 +912,9 @@ export class Payables { } /** - * Upload an incoming invoice (payable) in PDF, PNG, JPEG, or TIFF format and scan its contents. The maximum file size is 10MB. + * Upload an incoming invoice (payable) in PDF, PNG, or JPEG format and scan its contents. The maximum file size is 20MB. * - * @param {File | fs.ReadStream | Blob} file + * @param {Monite.PayableUploadFile} request * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Monite.BadRequestError} @@ -932,21 +925,23 @@ export class Payables { * @throws {@link Monite.InternalServerError} * * @example - * await client.payables.uploadFromFile(fs.createReadStream("/path/to/your/file")) + * await client.payables.uploadFromFile({ + * file: fs.createReadStream("/path/to/your/file") + * }) */ public uploadFromFile( - file: File | fs.ReadStream | Blob, + request: Monite.PayableUploadFile, requestOptions?: Payables.RequestOptions, ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__uploadFromFile(file, requestOptions)); + return core.HttpResponsePromise.fromPromise(this.__uploadFromFile(request, requestOptions)); } private async __uploadFromFile( - file: File | fs.ReadStream | Blob, + request: Monite.PayableUploadFile, requestOptions?: Payables.RequestOptions, ): Promise> { const _request = await core.newFormData(); - await _request.appendFile("file", file); + await _request.appendFile("file", request.file); const _maybeEncodedRequest = await _request.getRequest(); const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -956,22 +951,16 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ..._maybeEncodedRequest.headers, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + ..._maybeEncodedRequest.headers, + }), + requestOptions?.headers, + ), requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, @@ -1054,23 +1043,15 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1153,21 +1134,15 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1248,23 +1223,15 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1340,23 +1307,15 @@ export class Payables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1437,23 +1396,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1534,23 +1485,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1637,21 +1580,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1739,23 +1676,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1811,8 +1740,8 @@ export class Payables { /** * Attach file to payable without existing attachment. * - * @param {File | fs.ReadStream | Blob} file * @param {string} payableId + * @param {Monite.PayableAttachFile} request * @param {Payables.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Monite.BadRequestError} @@ -1823,23 +1752,25 @@ export class Payables { * @throws {@link Monite.InternalServerError} * * @example - * await client.payables.attachFileById(fs.createReadStream("/path/to/your/file"), "payable_id") + * await client.payables.attachFileById("payable_id", { + * file: fs.createReadStream("/path/to/your/file") + * }) */ public attachFileById( - file: File | fs.ReadStream | Blob, payableId: string, + request: Monite.PayableAttachFile, requestOptions?: Payables.RequestOptions, ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachFileById(file, payableId, requestOptions)); + return core.HttpResponsePromise.fromPromise(this.__attachFileById(payableId, request, requestOptions)); } private async __attachFileById( - file: File | fs.ReadStream | Blob, payableId: string, + request: Monite.PayableAttachFile, requestOptions?: Payables.RequestOptions, ): Promise> { const _request = await core.newFormData(); - await _request.appendFile("file", file); + await _request.appendFile("file", request.file); const _maybeEncodedRequest = await _request.getRequest(); const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -1849,22 +1780,16 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ..._maybeEncodedRequest.headers, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + ..._maybeEncodedRequest.headers, + }), + requestOptions?.headers, + ), requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, @@ -1954,23 +1879,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2059,23 +1976,15 @@ export class Payables { `payables/${encodeURIComponent(payableId)}/cancel_ocr`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2128,6 +2037,166 @@ export class Payables { } } + /** + * @param {string} payableId + * @param {Monite.GetPayablesIdHistoryRequest} 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.UnprocessableEntityError} + * @throws {@link Monite.InternalServerError} + * + * @example + * await client.payables.getPayablesIdHistory("payable_id") + */ + public getPayablesIdHistory( + payableId: string, + request: Monite.GetPayablesIdHistoryRequest = {}, + requestOptions?: Payables.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getPayablesIdHistory(payableId, request, requestOptions)); + } + + private async __getPayablesIdHistory( + payableId: string, + request: Monite.GetPayablesIdHistoryRequest = {}, + requestOptions?: Payables.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.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + `payables/${encodeURIComponent(payableId)}/history`, + ), + method: "GET", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Monite.PayableHistoryPaginationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError( + "Timeout exceeded when calling GET /payables/{payable_id}/history.", + ); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + /** * Mark a payable as paid. * @@ -2188,21 +2257,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2322,21 +2385,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2428,23 +2485,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2533,23 +2582,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2638,23 +2679,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2742,23 +2775,15 @@ export class Payables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/payables/client/index.ts b/src/api/resources/payables/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/payables/client/index.ts +++ b/src/api/resources/payables/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/payables/client/requests/GetPayablesIdHistoryRequest.ts b/src/api/resources/payables/client/requests/GetPayablesIdHistoryRequest.ts new file mode 100644 index 0000000..8499a2c --- /dev/null +++ b/src/api/resources/payables/client/requests/GetPayablesIdHistoryRequest.ts @@ -0,0 +1,55 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index.js"; + +/** + * @example + * {} + */ +export interface GetPayablesIdHistoryRequest { + /** + * Sort order (ascending by default). Typically used together with the `sort` parameter. + */ + order?: Monite.OrderEnum; + /** + * 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. + */ + 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 are ignored and inferred from the initial query. + * + * If not specified, the first page of results will be returned. + */ + pagination_token?: string; + /** + * The field to sort the results by. Typically used together with the `order` parameter. + */ + sort?: Monite.PayableHistoryCursorFields; + /** + * Return only the specified event types + */ + event_type__in?: Monite.PayableHistoryEventTypeEnum | Monite.PayableHistoryEventTypeEnum[]; + /** + * Return only events caused 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=` + */ + entity_user_id__in?: string | string[]; + /** + * Return only events that occurred after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. + */ + timestamp__gt?: string; + /** + * Return only events that occurred before the specified date and time. + */ + timestamp__lt?: string; + /** + * Return only events that occurred on or after the specified date and time. + */ + timestamp__gte?: string; + /** + * Return only events that occurred before or on the specified date and time. + */ + timestamp__lte?: string; +} diff --git a/src/api/resources/payables/client/requests/PayableAttachFile.ts b/src/api/resources/payables/client/requests/PayableAttachFile.ts index 468109b..e78b413 100644 --- a/src/api/resources/payables/client/requests/PayableAttachFile.ts +++ b/src/api/resources/payables/client/requests/PayableAttachFile.ts @@ -2,8 +2,14 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as fs from "fs"; + /** * @example - * {} + * { + * file: fs.createReadStream("/path/to/your/file") + * } */ -export interface PayableAttachFile {} +export interface PayableAttachFile { + file: File | fs.ReadStream | Blob; +} diff --git a/src/api/resources/payables/client/requests/PayableUpdateSchema.ts b/src/api/resources/payables/client/requests/PayableUpdateSchema.ts index 7a795d8..6868677 100644 --- a/src/api/resources/payables/client/requests/PayableUpdateSchema.ts +++ b/src/api/resources/payables/client/requests/PayableUpdateSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/payables/client/requests/PayableUploadFile.ts b/src/api/resources/payables/client/requests/PayableUploadFile.ts index 562ec39..50f5ad1 100644 --- a/src/api/resources/payables/client/requests/PayableUploadFile.ts +++ b/src/api/resources/payables/client/requests/PayableUploadFile.ts @@ -2,8 +2,14 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as fs from "fs"; + /** * @example - * {} + * { + * file: fs.createReadStream("/path/to/your/file") + * } */ -export interface PayableUploadFile {} +export interface PayableUploadFile { + file: File | fs.ReadStream | Blob; +} diff --git a/src/api/resources/payables/client/requests/PayableUploadWithDataSchema.ts b/src/api/resources/payables/client/requests/PayableUploadWithDataSchema.ts index e349894..244e8ff 100644 --- a/src/api/resources/payables/client/requests/PayableUploadWithDataSchema.ts +++ b/src/api/resources/payables/client/requests/PayableUploadWithDataSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/payables/client/requests/PayableValidationsUpdateRequest.ts b/src/api/resources/payables/client/requests/PayableValidationsUpdateRequest.ts index aa0c600..2e6012b 100644 --- a/src/api/resources/payables/client/requests/PayableValidationsUpdateRequest.ts +++ b/src/api/resources/payables/client/requests/PayableValidationsUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/payables/client/requests/PayablesGetAnalyticsRequest.ts b/src/api/resources/payables/client/requests/PayablesGetAnalyticsRequest.ts index 15dccd9..47381eb 100644 --- a/src/api/resources/payables/client/requests/PayablesGetAnalyticsRequest.ts +++ b/src/api/resources/payables/client/requests/PayablesGetAnalyticsRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -205,6 +205,10 @@ export interface PayablesGetAnalyticsRequest { * Return only payables whose `tags` do not include any of the tags with the specified IDs. Valid but nonexistent tag IDs do not raise errors but produce the results. */ tag_ids__not_in?: string | string[]; + /** + * Filter objects based on whether they have tags. If true, only objects with tags are returned. If false, only objects without tags are returned. + */ + has_tags?: boolean; /** * Return only payables from a given origin ['einvoice', 'upload', 'email'] */ diff --git a/src/api/resources/payables/client/requests/PayablesGetRequest.ts b/src/api/resources/payables/client/requests/PayablesGetRequest.ts index fedb119..999f603 100644 --- a/src/api/resources/payables/client/requests/PayablesGetRequest.ts +++ b/src/api/resources/payables/client/requests/PayablesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -223,6 +223,10 @@ export interface PayablesGetRequest { * Return only payables whose `tags` do not include any of the tags with the specified IDs. Valid but nonexistent tag IDs do not raise errors but produce the results. */ tag_ids__not_in?: string | string[]; + /** + * Filter objects based on whether they have tags. If true, only objects with tags are returned. If false, only objects without tags are returned. + */ + has_tags?: boolean; /** * Return only payables from a given origin ['einvoice', 'upload', 'email'] */ diff --git a/src/api/resources/payables/client/requests/index.ts b/src/api/resources/payables/client/requests/index.ts index bbdf792..24ffc8e 100644 --- a/src/api/resources/payables/client/requests/index.ts +++ b/src/api/resources/payables/client/requests/index.ts @@ -1,9 +1,10 @@ -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"; +export { type PayablesGetRequest } from "./PayablesGetRequest.js"; +export { type PayableUploadWithDataSchema } from "./PayableUploadWithDataSchema.js"; +export { type PayablesGetAnalyticsRequest } from "./PayablesGetAnalyticsRequest.js"; +export { type PayableUploadFile } from "./PayableUploadFile.js"; +export { type PayableValidationsUpdateRequest } from "./PayableValidationsUpdateRequest.js"; +export { type PayableUpdateSchema } from "./PayableUpdateSchema.js"; +export { type PayableAttachFile } from "./PayableAttachFile.js"; +export { type GetPayablesIdHistoryRequest } from "./GetPayablesIdHistoryRequest.js"; +export { type CommentPayload } from "./CommentPayload.js"; +export { type PartiallyPaidPayload } from "./PartiallyPaidPayload.js"; diff --git a/src/api/resources/payables/index.ts b/src/api/resources/payables/index.ts index 33a87f1..9eb1192 100644 --- a/src/api/resources/payables/index.ts +++ b/src/api/resources/payables/index.ts @@ -1,2 +1,2 @@ -export * from "./client"; -export * from "./resources"; +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/payables/resources/index.ts b/src/api/resources/payables/resources/index.ts index 020e0d8..1b5354b 100644 --- a/src/api/resources/payables/resources/index.ts +++ b/src/api/resources/payables/resources/index.ts @@ -1,2 +1,2 @@ -export * as lineItems from "./lineItems"; -export * from "./lineItems/client/requests"; +export * as lineItems from "./lineItems/index.js"; +export * from "./lineItems/client/requests/index.js"; diff --git a/src/api/resources/payables/resources/lineItems/client/Client.ts b/src/api/resources/payables/resources/lineItems/client/Client.ts index a779647..c3cf343 100644 --- a/src/api/resources/payables/resources/lineItems/client/Client.ts +++ b/src/api/resources/payables/resources/lineItems/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../../../environments.js"; +import * as core from "../../../../../../core/index.js"; +import * as Monite from "../../../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../../../errors/index"; +import * as errors from "../../../../../../errors/index.js"; export declare namespace LineItems { export interface Options { @@ -18,6 +19,8 @@ export declare namespace LineItems { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace LineItems { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class LineItems { - constructor(protected readonly _options: LineItems.Options) {} + protected readonly _options: LineItems.Options; + + constructor(_options: LineItems.Options) { + this._options = _options; + } /** * Get a list of all line items related to a specific payable. @@ -113,24 +120,16 @@ export class LineItems { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -232,21 +231,15 @@ export class LineItems { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -352,21 +345,15 @@ export class LineItems { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -471,23 +458,15 @@ export class LineItems { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -586,23 +565,15 @@ export class LineItems { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -703,21 +674,15 @@ export class LineItems { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/payables/resources/lineItems/client/index.ts b/src/api/resources/payables/resources/lineItems/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/payables/resources/lineItems/client/index.ts +++ b/src/api/resources/payables/resources/lineItems/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/payables/resources/lineItems/client/requests/LineItemsGetRequest.ts b/src/api/resources/payables/resources/lineItems/client/requests/LineItemsGetRequest.ts index 658b9c9..2ada352 100644 --- a/src/api/resources/payables/resources/lineItems/client/requests/LineItemsGetRequest.ts +++ b/src/api/resources/payables/resources/lineItems/client/requests/LineItemsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/payables/resources/lineItems/client/requests/LineItemsReplaceRequest.ts b/src/api/resources/payables/resources/lineItems/client/requests/LineItemsReplaceRequest.ts index bcf9259..b6c4d25 100644 --- a/src/api/resources/payables/resources/lineItems/client/requests/LineItemsReplaceRequest.ts +++ b/src/api/resources/payables/resources/lineItems/client/requests/LineItemsReplaceRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../../../index"; +import * as Monite from "../../../../../../index.js"; /** * @example diff --git a/src/api/resources/payables/resources/lineItems/client/requests/index.ts b/src/api/resources/payables/resources/lineItems/client/requests/index.ts index db3449c..fbfea1a 100644 --- a/src/api/resources/payables/resources/lineItems/client/requests/index.ts +++ b/src/api/resources/payables/resources/lineItems/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type LineItemsGetRequest } from "./LineItemsGetRequest"; -export { type LineItemsReplaceRequest } from "./LineItemsReplaceRequest"; +export { type LineItemsGetRequest } from "./LineItemsGetRequest.js"; +export { type LineItemsReplaceRequest } from "./LineItemsReplaceRequest.js"; diff --git a/src/api/resources/payables/resources/lineItems/index.ts b/src/api/resources/payables/resources/lineItems/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/payables/resources/lineItems/index.ts +++ b/src/api/resources/payables/resources/lineItems/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/paymentIntents/client/Client.ts b/src/api/resources/paymentIntents/client/Client.ts index 4763614..1164080 100644 --- a/src/api/resources/paymentIntents/client/Client.ts +++ b/src/api/resources/paymentIntents/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace PaymentIntents { export interface Options { @@ -18,6 +19,8 @@ export declare namespace PaymentIntents { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace PaymentIntents { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PaymentIntents { - constructor(protected readonly _options: PaymentIntents.Options) {} + protected readonly _options: PaymentIntents.Options; + + constructor(_options: PaymentIntents.Options) { + this._options = _options; + } /** * @param {Monite.PaymentIntentsGetRequest} request @@ -106,24 +113,16 @@ export class PaymentIntents { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -193,23 +192,15 @@ export class PaymentIntents { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -286,21 +277,15 @@ export class PaymentIntents { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -375,23 +360,15 @@ export class PaymentIntents { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/paymentIntents/client/index.ts b/src/api/resources/paymentIntents/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/paymentIntents/client/index.ts +++ b/src/api/resources/paymentIntents/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/paymentIntents/client/requests/PaymentIntentsGetRequest.ts b/src/api/resources/paymentIntents/client/requests/PaymentIntentsGetRequest.ts index d590f83..d7f9e50 100644 --- a/src/api/resources/paymentIntents/client/requests/PaymentIntentsGetRequest.ts +++ b/src/api/resources/paymentIntents/client/requests/PaymentIntentsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -10,19 +10,21 @@ import * as Monite from "../../../../index"; */ export interface PaymentIntentsGetRequest { /** - * Order by + * Sort order (ascending by default). Typically used together with the `sort` parameter. */ order?: Monite.OrderEnum; /** - * Max is 100 + * 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. */ limit?: number; /** - * A token, obtained from previous page. Prior over other filters + * 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 are ignored and inferred from the initial query. + * + * If not specified, the first page of results will be returned. */ pagination_token?: string; /** - * Allowed sort fields + * The field to sort the results by. Typically used together with the `order` parameter. */ sort?: Monite.PaymentIntentCursorFields; /** diff --git a/src/api/resources/paymentIntents/client/requests/index.ts b/src/api/resources/paymentIntents/client/requests/index.ts index a54c95c..0eafb7b 100644 --- a/src/api/resources/paymentIntents/client/requests/index.ts +++ b/src/api/resources/paymentIntents/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type PaymentIntentsGetRequest } from "./PaymentIntentsGetRequest"; -export { type UpdatePaymentIntentPayload } from "./UpdatePaymentIntentPayload"; +export { type PaymentIntentsGetRequest } from "./PaymentIntentsGetRequest.js"; +export { type UpdatePaymentIntentPayload } from "./UpdatePaymentIntentPayload.js"; diff --git a/src/api/resources/paymentIntents/index.ts b/src/api/resources/paymentIntents/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/paymentIntents/index.ts +++ b/src/api/resources/paymentIntents/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/paymentLinks/client/Client.ts b/src/api/resources/paymentLinks/client/Client.ts index 19ba99a..ff25f69 100644 --- a/src/api/resources/paymentLinks/client/Client.ts +++ b/src/api/resources/paymentLinks/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace PaymentLinks { export interface Options { @@ -18,6 +19,8 @@ export declare namespace PaymentLinks { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace PaymentLinks { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PaymentLinks { - constructor(protected readonly _options: PaymentLinks.Options) {} + protected readonly _options: PaymentLinks.Options; + + constructor(_options: PaymentLinks.Options) { + this._options = _options; + } /** * @param {Monite.CreatePaymentLinkRequest} request @@ -75,21 +82,15 @@ export class PaymentLinks { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -162,23 +163,15 @@ export class PaymentLinks { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -250,23 +243,15 @@ export class PaymentLinks { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/paymentLinks/client/index.ts b/src/api/resources/paymentLinks/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/paymentLinks/client/index.ts +++ b/src/api/resources/paymentLinks/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/paymentLinks/client/requests/CreatePaymentLinkRequest.ts b/src/api/resources/paymentLinks/client/requests/CreatePaymentLinkRequest.ts index 64ca561..73eb9aa 100644 --- a/src/api/resources/paymentLinks/client/requests/CreatePaymentLinkRequest.ts +++ b/src/api/resources/paymentLinks/client/requests/CreatePaymentLinkRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/paymentLinks/client/requests/index.ts b/src/api/resources/paymentLinks/client/requests/index.ts index 5219eed..d49eafd 100644 --- a/src/api/resources/paymentLinks/client/requests/index.ts +++ b/src/api/resources/paymentLinks/client/requests/index.ts @@ -1 +1 @@ -export { type CreatePaymentLinkRequest } from "./CreatePaymentLinkRequest"; +export { type CreatePaymentLinkRequest } from "./CreatePaymentLinkRequest.js"; diff --git a/src/api/resources/paymentLinks/index.ts b/src/api/resources/paymentLinks/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/paymentLinks/index.ts +++ b/src/api/resources/paymentLinks/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/paymentRecords/client/Client.ts b/src/api/resources/paymentRecords/client/Client.ts index cb81a3f..4888076 100644 --- a/src/api/resources/paymentRecords/client/Client.ts +++ b/src/api/resources/paymentRecords/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace PaymentRecords { export interface Options { @@ -18,6 +19,8 @@ export declare namespace PaymentRecords { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace PaymentRecords { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PaymentRecords { - constructor(protected readonly _options: PaymentRecords.Options) {} + protected readonly _options: PaymentRecords.Options; + + constructor(_options: PaymentRecords.Options) { + this._options = _options; + } /** * @param {Monite.PaymentRecordsGetRequest} request @@ -68,6 +75,7 @@ export class PaymentRecords { sort, is_external: isExternal, object_id: objectId, + object_id__in: objectIdIn, object_type: objectType, created_at__gt: createdAtGt, created_at__lt: createdAtLt, @@ -109,6 +117,14 @@ export class PaymentRecords { _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 (objectType != null) { _queryParams["object_type"] = objectType; } @@ -177,24 +193,16 @@ export class PaymentRecords { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -272,21 +280,15 @@ export class PaymentRecords { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -359,23 +361,15 @@ export class PaymentRecords { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -452,21 +446,15 @@ export class PaymentRecords { `payment_records/${encodeURIComponent(paymentRecordId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -546,21 +534,15 @@ export class PaymentRecords { `payment_records/${encodeURIComponent(paymentRecordId)}/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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -642,21 +624,15 @@ export class PaymentRecords { `payment_records/${encodeURIComponent(paymentRecordId)}/mark_as_succeeded`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -736,21 +712,15 @@ export class PaymentRecords { `payment_records/${encodeURIComponent(paymentRecordId)}/start_processing`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/paymentRecords/client/index.ts b/src/api/resources/paymentRecords/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/paymentRecords/client/index.ts +++ b/src/api/resources/paymentRecords/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/paymentRecords/client/requests/PaymentRecordRequest.ts b/src/api/resources/paymentRecords/client/requests/PaymentRecordRequest.ts index 6b4d200..5832a55 100644 --- a/src/api/resources/paymentRecords/client/requests/PaymentRecordRequest.ts +++ b/src/api/resources/paymentRecords/client/requests/PaymentRecordRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -36,5 +36,17 @@ export interface PaymentRecordRequest { /** Scheduled date for future payments, required when the payment is planned but not yet executed. */ planned_payment_date?: string; /** Status of the payment record indicating its current stage (e.g., created, processing, succeeded). */ - status?: Monite.PaymentRecordRequestStatus; + status?: PaymentRecordRequest.Status; +} + +export namespace PaymentRecordRequest { + /** + * Status of the payment record indicating its current stage (e.g., created, processing, succeeded). + */ + export type Status = "created" | "processing" | "succeeded"; + export const Status = { + Created: "created", + Processing: "processing", + Succeeded: "succeeded", + } as const; } diff --git a/src/api/resources/paymentRecords/client/requests/PaymentRecordUpdateRequest.ts b/src/api/resources/paymentRecords/client/requests/PaymentRecordUpdateRequest.ts index 78e24a4..190d57e 100644 --- a/src/api/resources/paymentRecords/client/requests/PaymentRecordUpdateRequest.ts +++ b/src/api/resources/paymentRecords/client/requests/PaymentRecordUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/paymentRecords/client/requests/PaymentRecordsGetRequest.ts b/src/api/resources/paymentRecords/client/requests/PaymentRecordsGetRequest.ts index b13df38..9e8e39e 100644 --- a/src/api/resources/paymentRecords/client/requests/PaymentRecordsGetRequest.ts +++ b/src/api/resources/paymentRecords/client/requests/PaymentRecordsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -33,6 +33,10 @@ export interface PaymentRecordsGetRequest { * ID of the object, that is connected to payment */ object_id?: string; + /** + * List of IDs of the objects, that are connected to payments + */ + object_id__in?: string | string[]; /** * Type of an object, which is connected with payment */ diff --git a/src/api/resources/paymentRecords/client/requests/index.ts b/src/api/resources/paymentRecords/client/requests/index.ts index 4144d6a..a16274f 100644 --- a/src/api/resources/paymentRecords/client/requests/index.ts +++ b/src/api/resources/paymentRecords/client/requests/index.ts @@ -1,4 +1,4 @@ -export { type PaymentRecordsGetRequest } from "./PaymentRecordsGetRequest"; -export { type PaymentRecordRequest } from "./PaymentRecordRequest"; -export { type PaymentRecordUpdateRequest } from "./PaymentRecordUpdateRequest"; -export { type PaymentRecordMarkAsSucceededRequest } from "./PaymentRecordMarkAsSucceededRequest"; +export { type PaymentRecordsGetRequest } from "./PaymentRecordsGetRequest.js"; +export { type PaymentRecordRequest } from "./PaymentRecordRequest.js"; +export { type PaymentRecordUpdateRequest } from "./PaymentRecordUpdateRequest.js"; +export { type PaymentRecordMarkAsSucceededRequest } from "./PaymentRecordMarkAsSucceededRequest.js"; diff --git a/src/api/resources/paymentRecords/index.ts b/src/api/resources/paymentRecords/index.ts index c9240f8..914b8c3 100644 --- a/src/api/resources/paymentRecords/index.ts +++ b/src/api/resources/paymentRecords/index.ts @@ -1,2 +1 @@ -export * from "./types"; -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/paymentRecords/types/PaymentRecordRequestStatus.ts b/src/api/resources/paymentRecords/types/PaymentRecordRequestStatus.ts deleted file mode 100644 index bf018a5..0000000 --- a/src/api/resources/paymentRecords/types/PaymentRecordRequestStatus.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * Status of the payment record indicating its current stage (e.g., created, processing, succeeded). - */ -export type PaymentRecordRequestStatus = "created" | "processing" | "succeeded"; -export const PaymentRecordRequestStatus = { - Created: "created", - Processing: "processing", - Succeeded: "succeeded", -} as const; diff --git a/src/api/resources/paymentRecords/types/index.ts b/src/api/resources/paymentRecords/types/index.ts deleted file mode 100644 index 6013d21..0000000 --- a/src/api/resources/paymentRecords/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./PaymentRecordRequestStatus"; diff --git a/src/api/resources/paymentReminders/client/Client.ts b/src/api/resources/paymentReminders/client/Client.ts index 98e5364..bfed32f 100644 --- a/src/api/resources/paymentReminders/client/Client.ts +++ b/src/api/resources/paymentReminders/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace PaymentReminders { export interface Options { @@ -18,6 +19,8 @@ export declare namespace PaymentReminders { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace PaymentReminders { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PaymentReminders { - constructor(protected readonly _options: PaymentReminders.Options) {} + protected readonly _options: PaymentReminders.Options; + + constructor(_options: PaymentReminders.Options) { + this._options = _options; + } /** * @param {PaymentReminders.RequestOptions} requestOptions - Request-specific configuration. @@ -68,23 +75,15 @@ export class PaymentReminders { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -163,21 +162,15 @@ export class PaymentReminders { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -259,23 +252,15 @@ export class PaymentReminders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -357,23 +342,15 @@ export class PaymentReminders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -460,21 +437,15 @@ export class PaymentReminders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/paymentReminders/client/index.ts b/src/api/resources/paymentReminders/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/paymentReminders/client/index.ts +++ b/src/api/resources/paymentReminders/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/paymentReminders/client/requests/PaymentReminder.ts b/src/api/resources/paymentReminders/client/requests/PaymentReminder.ts index 4e52460..44836e2 100644 --- a/src/api/resources/paymentReminders/client/requests/PaymentReminder.ts +++ b/src/api/resources/paymentReminders/client/requests/PaymentReminder.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/paymentReminders/client/requests/PaymentReminderUpdateRequest.ts b/src/api/resources/paymentReminders/client/requests/PaymentReminderUpdateRequest.ts index a875af7..d727a97 100644 --- a/src/api/resources/paymentReminders/client/requests/PaymentReminderUpdateRequest.ts +++ b/src/api/resources/paymentReminders/client/requests/PaymentReminderUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/paymentReminders/client/requests/index.ts b/src/api/resources/paymentReminders/client/requests/index.ts index 18adbb3..e2565cb 100644 --- a/src/api/resources/paymentReminders/client/requests/index.ts +++ b/src/api/resources/paymentReminders/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type PaymentReminder } from "./PaymentReminder"; -export { type PaymentReminderUpdateRequest } from "./PaymentReminderUpdateRequest"; +export { type PaymentReminder } from "./PaymentReminder.js"; +export { type PaymentReminderUpdateRequest } from "./PaymentReminderUpdateRequest.js"; diff --git a/src/api/resources/paymentReminders/index.ts b/src/api/resources/paymentReminders/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/paymentReminders/index.ts +++ b/src/api/resources/paymentReminders/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/paymentTerms/client/Client.ts b/src/api/resources/paymentTerms/client/Client.ts index 79be21d..82d7d70 100644 --- a/src/api/resources/paymentTerms/client/Client.ts +++ b/src/api/resources/paymentTerms/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace PaymentTerms { export interface Options { @@ -18,6 +19,8 @@ export declare namespace PaymentTerms { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace PaymentTerms { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PaymentTerms { - constructor(protected readonly _options: PaymentTerms.Options) {} + protected readonly _options: PaymentTerms.Options; + + constructor(_options: PaymentTerms.Options) { + this._options = _options; + } /** * @param {PaymentTerms.RequestOptions} requestOptions - Request-specific configuration. @@ -68,23 +75,15 @@ export class PaymentTerms { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -166,21 +165,15 @@ export class PaymentTerms { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -262,23 +255,15 @@ export class PaymentTerms { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -360,23 +345,15 @@ export class PaymentTerms { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -463,21 +440,15 @@ export class PaymentTerms { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/paymentTerms/client/index.ts b/src/api/resources/paymentTerms/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/paymentTerms/client/index.ts +++ b/src/api/resources/paymentTerms/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/paymentTerms/client/requests/PaymentTermsCreatePayload.ts b/src/api/resources/paymentTerms/client/requests/PaymentTermsCreatePayload.ts index 8233657..e729bd8 100644 --- a/src/api/resources/paymentTerms/client/requests/PaymentTermsCreatePayload.ts +++ b/src/api/resources/paymentTerms/client/requests/PaymentTermsCreatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -17,9 +17,9 @@ 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; + term_1?: Monite.TermDiscountDays; /** The second tier of the payment term. Defines the terms of the second early discount. */ - term_2?: Monite.PaymentTermDiscount; + term_2?: Monite.TermDiscountDays; /** The final tier of the payment term. Defines the invoice due date. */ - term_final: Monite.PaymentTerm; + term_final: Monite.TermFinalDays; } diff --git a/src/api/resources/paymentTerms/client/requests/PaymentTermsUpdatePayload.ts b/src/api/resources/paymentTerms/client/requests/PaymentTermsUpdatePayload.ts index 2619870..39ad9a1 100644 --- a/src/api/resources/paymentTerms/client/requests/PaymentTermsUpdatePayload.ts +++ b/src/api/resources/paymentTerms/client/requests/PaymentTermsUpdatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -12,9 +12,9 @@ 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; + term_1?: Monite.TermDiscountDays; /** The second tier of the payment term. Defines the terms of the second early discount. */ - term_2?: Monite.PaymentTermDiscount; + term_2?: Monite.TermDiscountDays; /** The final tier of the payment term. Defines the invoice due date. */ - term_final?: Monite.PaymentTerm; + term_final?: Monite.TermFinalDays; } diff --git a/src/api/resources/paymentTerms/client/requests/index.ts b/src/api/resources/paymentTerms/client/requests/index.ts index 5b11436..6924785 100644 --- a/src/api/resources/paymentTerms/client/requests/index.ts +++ b/src/api/resources/paymentTerms/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type PaymentTermsCreatePayload } from "./PaymentTermsCreatePayload"; -export { type PaymentTermsUpdatePayload } from "./PaymentTermsUpdatePayload"; +export { type PaymentTermsCreatePayload } from "./PaymentTermsCreatePayload.js"; +export { type PaymentTermsUpdatePayload } from "./PaymentTermsUpdatePayload.js"; diff --git a/src/api/resources/paymentTerms/index.ts b/src/api/resources/paymentTerms/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/paymentTerms/index.ts +++ b/src/api/resources/paymentTerms/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/pdfTemplates/client/Client.ts b/src/api/resources/pdfTemplates/client/Client.ts index e5fd9ab..3586ccb 100644 --- a/src/api/resources/pdfTemplates/client/Client.ts +++ b/src/api/resources/pdfTemplates/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; import * as stream from "stream"; export declare namespace PdfTemplates { @@ -19,6 +20,8 @@ export declare namespace PdfTemplates { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -34,12 +37,16 @@ export declare namespace PdfTemplates { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PdfTemplates { - constructor(protected readonly _options: PdfTemplates.Options) {} + protected readonly _options: PdfTemplates.Options; + + constructor(_options: PdfTemplates.Options) { + this._options = _options; + } /** * This API call returns all supported templates with language codes. @@ -67,23 +74,15 @@ export class PdfTemplates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -152,23 +151,15 @@ export class PdfTemplates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -238,23 +229,15 @@ export class PdfTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -326,23 +309,15 @@ export class PdfTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -409,23 +384,15 @@ export class PdfTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), responseType: "streaming", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, diff --git a/src/api/resources/pdfTemplates/index.ts b/src/api/resources/pdfTemplates/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/pdfTemplates/index.ts +++ b/src/api/resources/pdfTemplates/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/products/client/Client.ts b/src/api/resources/products/client/Client.ts index 2c8dc20..de7a5a3 100644 --- a/src/api/resources/products/client/Client.ts +++ b/src/api/resources/products/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Products { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Products { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Products { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Products { - constructor(protected readonly _options: Products.Options) {} + protected readonly _options: Products.Options; + + constructor(_options: Products.Options) { + this._options = _options; + } /** * @param {Monite.ProductsGetRequest} request @@ -188,24 +195,16 @@ export class Products { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -289,21 +288,15 @@ export class Products { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -386,23 +379,15 @@ export class Products { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -481,23 +466,15 @@ export class Products { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -582,21 +559,15 @@ export class Products { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/products/client/index.ts b/src/api/resources/products/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/products/client/index.ts +++ b/src/api/resources/products/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/products/client/requests/ProductServiceRequest.ts b/src/api/resources/products/client/requests/ProductServiceRequest.ts index d87e8c6..ddaff96 100644 --- a/src/api/resources/products/client/requests/ProductServiceRequest.ts +++ b/src/api/resources/products/client/requests/ProductServiceRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -13,6 +13,8 @@ import * as Monite from "../../../../index"; export interface ProductServiceRequest { /** Description of the product. */ description?: string; + /** A user-defined identifier of the product. For example, an internal product code or SKU (stock keeping unit). Client applications can use this field to map the products in Monite to an external product catalog. */ + external_reference?: 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; diff --git a/src/api/resources/products/client/requests/ProductServiceUpdate.ts b/src/api/resources/products/client/requests/ProductServiceUpdate.ts index 94f6545..1cb8437 100644 --- a/src/api/resources/products/client/requests/ProductServiceUpdate.ts +++ b/src/api/resources/products/client/requests/ProductServiceUpdate.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -11,6 +11,8 @@ import * as Monite from "../../../../index"; export interface ProductServiceUpdate { /** Description of the product. */ description?: string; + /** A user-defined identifier of the product. For example, an internal product code or SKU (stock keeping unit). Client applications can use this field to map the products in Monite to an external product catalog. */ + external_reference?: 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; diff --git a/src/api/resources/products/client/requests/ProductsGetRequest.ts b/src/api/resources/products/client/requests/ProductsGetRequest.ts index c9cd81e..b1e8e73 100644 --- a/src/api/resources/products/client/requests/ProductsGetRequest.ts +++ b/src/api/resources/products/client/requests/ProductsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/products/client/requests/index.ts b/src/api/resources/products/client/requests/index.ts index 27f3d75..2349d74 100644 --- a/src/api/resources/products/client/requests/index.ts +++ b/src/api/resources/products/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type ProductsGetRequest } from "./ProductsGetRequest"; -export { type ProductServiceRequest } from "./ProductServiceRequest"; -export { type ProductServiceUpdate } from "./ProductServiceUpdate"; +export { type ProductsGetRequest } from "./ProductsGetRequest.js"; +export { type ProductServiceRequest } from "./ProductServiceRequest.js"; +export { type ProductServiceUpdate } from "./ProductServiceUpdate.js"; diff --git a/src/api/resources/products/index.ts b/src/api/resources/products/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/products/index.ts +++ b/src/api/resources/products/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/projects/client/Client.ts b/src/api/resources/projects/client/Client.ts index 9ff9a36..827a2a7 100644 --- a/src/api/resources/projects/client/Client.ts +++ b/src/api/resources/projects/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Projects { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Projects { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Projects { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Projects { - constructor(protected readonly _options: Projects.Options) {} + protected readonly _options: Projects.Options; + + constructor(_options: Projects.Options) { + this._options = _options; + } /** * Get all projects for an entity @@ -199,24 +206,16 @@ export class Projects { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -303,21 +302,15 @@ export class Projects { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -402,23 +395,15 @@ export class Projects { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -499,23 +484,15 @@ export class Projects { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -602,21 +579,15 @@ export class Projects { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/projects/client/index.ts b/src/api/resources/projects/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/projects/client/index.ts +++ b/src/api/resources/projects/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/projects/client/requests/ProjectsGetRequest.ts b/src/api/resources/projects/client/requests/ProjectsGetRequest.ts index 1766161..3b60854 100644 --- a/src/api/resources/projects/client/requests/ProjectsGetRequest.ts +++ b/src/api/resources/projects/client/requests/ProjectsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/projects/client/requests/index.ts b/src/api/resources/projects/client/requests/index.ts index 928294e..a8b8d13 100644 --- a/src/api/resources/projects/client/requests/index.ts +++ b/src/api/resources/projects/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type ProjectsGetRequest } from "./ProjectsGetRequest"; -export { type ProjectCreateRequest } from "./ProjectCreateRequest"; -export { type ProjectUpdateRequest } from "./ProjectUpdateRequest"; +export { type ProjectsGetRequest } from "./ProjectsGetRequest.js"; +export { type ProjectCreateRequest } from "./ProjectCreateRequest.js"; +export { type ProjectUpdateRequest } from "./ProjectUpdateRequest.js"; diff --git a/src/api/resources/projects/index.ts b/src/api/resources/projects/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/projects/index.ts +++ b/src/api/resources/projects/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/purchaseOrders/client/Client.ts b/src/api/resources/purchaseOrders/client/Client.ts index 7ad5b6f..5e69332 100644 --- a/src/api/resources/purchaseOrders/client/Client.ts +++ b/src/api/resources/purchaseOrders/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace PurchaseOrders { export interface Options { @@ -18,6 +19,8 @@ export declare namespace PurchaseOrders { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace PurchaseOrders { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class PurchaseOrders { - constructor(protected readonly _options: PurchaseOrders.Options) {} + protected readonly _options: PurchaseOrders.Options; + + constructor(_options: PurchaseOrders.Options) { + this._options = _options; + } /** * @param {Monite.PurchaseOrdersGetRequest} request @@ -216,24 +223,16 @@ export class PurchaseOrders { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -325,21 +324,15 @@ export class PurchaseOrders { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -416,23 +409,15 @@ export class PurchaseOrders { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -508,23 +493,15 @@ export class PurchaseOrders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -602,23 +579,15 @@ export class PurchaseOrders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -699,21 +668,15 @@ export class PurchaseOrders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -802,21 +765,15 @@ export class PurchaseOrders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -913,21 +870,15 @@ export class PurchaseOrders { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/purchaseOrders/client/index.ts b/src/api/resources/purchaseOrders/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/purchaseOrders/client/index.ts +++ b/src/api/resources/purchaseOrders/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/purchaseOrders/client/requests/PurchaseOrderPayloadSchema.ts b/src/api/resources/purchaseOrders/client/requests/PurchaseOrderPayloadSchema.ts index c30dd99..1265092 100644 --- a/src/api/resources/purchaseOrders/client/requests/PurchaseOrderPayloadSchema.ts +++ b/src/api/resources/purchaseOrders/client/requests/PurchaseOrderPayloadSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/purchaseOrders/client/requests/PurchaseOrdersGetRequest.ts b/src/api/resources/purchaseOrders/client/requests/PurchaseOrdersGetRequest.ts index d413e1d..ddd9975 100644 --- a/src/api/resources/purchaseOrders/client/requests/PurchaseOrdersGetRequest.ts +++ b/src/api/resources/purchaseOrders/client/requests/PurchaseOrdersGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/purchaseOrders/client/requests/UpdatePurchaseOrderPayloadSchema.ts b/src/api/resources/purchaseOrders/client/requests/UpdatePurchaseOrderPayloadSchema.ts index 9c7600d..e08c5d3 100644 --- a/src/api/resources/purchaseOrders/client/requests/UpdatePurchaseOrderPayloadSchema.ts +++ b/src/api/resources/purchaseOrders/client/requests/UpdatePurchaseOrderPayloadSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/purchaseOrders/client/requests/index.ts b/src/api/resources/purchaseOrders/client/requests/index.ts index b38d4e1..ae68aa2 100644 --- a/src/api/resources/purchaseOrders/client/requests/index.ts +++ b/src/api/resources/purchaseOrders/client/requests/index.ts @@ -1,5 +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"; +export { type PurchaseOrdersGetRequest } from "./PurchaseOrdersGetRequest.js"; +export { type PurchaseOrderPayloadSchema } from "./PurchaseOrderPayloadSchema.js"; +export { type UpdatePurchaseOrderPayloadSchema } from "./UpdatePurchaseOrderPayloadSchema.js"; +export { type PurchaseOrderEmailPreviewRequest } from "./PurchaseOrderEmailPreviewRequest.js"; +export { type SendPurchaseOrderViaEmailRequest } from "./SendPurchaseOrderViaEmailRequest.js"; diff --git a/src/api/resources/purchaseOrders/index.ts b/src/api/resources/purchaseOrders/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/purchaseOrders/index.ts +++ b/src/api/resources/purchaseOrders/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/receivables/client/Client.ts b/src/api/resources/receivables/client/Client.ts index 9c8d43c..dca75ac 100644 --- a/src/api/resources/receivables/client/Client.ts +++ b/src/api/resources/receivables/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Receivables { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Receivables { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Receivables { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Receivables { - constructor(protected readonly _options: Receivables.Options) {} + protected readonly _options: Receivables.Options; + + constructor(_options: Receivables.Options) { + this._options = _options; + } /** * Returns a list of [accounts receivable](https://docs.monite.com/accounts-receivable/index) documents - invoices, quotes, and credit notes - of the specified entity. @@ -166,6 +173,11 @@ export class Receivables { total_amount__lt: totalAmountLt, total_amount__gte: totalAmountGte, total_amount__lte: totalAmountLte, + discounted_subtotal: discountedSubtotal, + discounted_subtotal__gt: discountedSubtotalGt, + discounted_subtotal__lt: discountedSubtotalLt, + discounted_subtotal__gte: discountedSubtotalGte, + discounted_subtotal__lte: discountedSubtotalLte, status, entity_user_id: entityUserId, based_on: basedOn, @@ -340,6 +352,26 @@ export class Receivables { _queryParams["total_amount__lte"] = totalAmountLte.toString(); } + if (discountedSubtotal != null) { + _queryParams["discounted_subtotal"] = discountedSubtotal.toString(); + } + + if (discountedSubtotalGt != null) { + _queryParams["discounted_subtotal__gt"] = discountedSubtotalGt.toString(); + } + + if (discountedSubtotalLt != null) { + _queryParams["discounted_subtotal__lt"] = discountedSubtotalLt.toString(); + } + + if (discountedSubtotalGte != null) { + _queryParams["discounted_subtotal__gte"] = discountedSubtotalGte.toString(); + } + + if (discountedSubtotalLte != null) { + _queryParams["discounted_subtotal__lte"] = discountedSubtotalLte.toString(); + } + if (status != null) { _queryParams["status"] = status; } @@ -380,24 +412,16 @@ export class Receivables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -488,21 +512,15 @@ export class Receivables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -620,24 +638,16 @@ export class Receivables { "receivables/required_fields", ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -678,6 +688,101 @@ export class Receivables { } } + /** + * This is a POST version of the `GET /receivables` endpoint. Use it to send search and filter parameters in the request body instead of the URL query string in case the query is too long and exceeds the URL length limit of your HTTP client. + * + * @param {Monite.ReceivablesSearchRequest} 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.postReceivablesSearch() + */ + public postReceivablesSearch( + request: Monite.ReceivablesSearchRequest = {}, + requestOptions?: Receivables.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__postReceivablesSearch(request, requestOptions)); + } + + private async __postReceivablesSearch( + request: Monite.ReceivablesSearchRequest = {}, + requestOptions?: Receivables.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + "receivables/search", + ), + method: "POST", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + 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 { data: _response.body as Monite.ReceivablePaginationResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 406: + throw new Monite.NotAcceptableError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError("Timeout exceeded when calling POST /receivables/search."); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + /** * Get a list of placeholders that can be used in email templates for customization. * @@ -708,23 +813,15 @@ export class Receivables { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -805,23 +902,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -904,23 +993,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1012,21 +1093,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1119,21 +1194,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1223,23 +1292,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1326,23 +1387,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1432,21 +1485,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -1603,24 +1650,16 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1714,23 +1753,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1815,23 +1846,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -1927,21 +1950,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2090,24 +2107,16 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2197,23 +2206,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2301,21 +2302,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2414,21 +2409,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2523,21 +2512,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2626,23 +2609,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -2732,21 +2707,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2840,21 +2809,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -2949,21 +2912,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -3052,23 +3009,15 @@ export class Receivables { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/receivables/client/index.ts b/src/api/resources/receivables/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/receivables/client/index.ts +++ b/src/api/resources/receivables/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/receivables/client/requests/GetReceivablesRequiredFieldsRequest.ts b/src/api/resources/receivables/client/requests/GetReceivablesRequiredFieldsRequest.ts index e793646..d310b31 100644 --- a/src/api/resources/receivables/client/requests/GetReceivablesRequiredFieldsRequest.ts +++ b/src/api/resources/receivables/client/requests/GetReceivablesRequiredFieldsRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/receivables/client/requests/QuoteAcceptRequest.ts b/src/api/resources/receivables/client/requests/QuoteAcceptRequest.ts index 108cb57..a5d22b3 100644 --- a/src/api/resources/receivables/client/requests/QuoteAcceptRequest.ts +++ b/src/api/resources/receivables/client/requests/QuoteAcceptRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/receivables/client/requests/ReceivablePreviewRequest.ts b/src/api/resources/receivables/client/requests/ReceivablePreviewRequest.ts index ca7b7d5..a457aed 100644 --- a/src/api/resources/receivables/client/requests/ReceivablePreviewRequest.ts +++ b/src/api/resources/receivables/client/requests/ReceivablePreviewRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/receivables/client/requests/ReceivableSendRequest.ts b/src/api/resources/receivables/client/requests/ReceivableSendRequest.ts index f3d4e9c..e9e0198 100644 --- a/src/api/resources/receivables/client/requests/ReceivableSendRequest.ts +++ b/src/api/resources/receivables/client/requests/ReceivableSendRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/receivables/client/requests/ReceivableSendTestReminderPayload.ts b/src/api/resources/receivables/client/requests/ReceivableSendTestReminderPayload.ts index 8c29b4c..ee271db 100644 --- a/src/api/resources/receivables/client/requests/ReceivableSendTestReminderPayload.ts +++ b/src/api/resources/receivables/client/requests/ReceivableSendTestReminderPayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/receivables/client/requests/ReceivablesGetHistoryRequest.ts b/src/api/resources/receivables/client/requests/ReceivablesGetHistoryRequest.ts index 8ee3f87..8ddd6e8 100644 --- a/src/api/resources/receivables/client/requests/ReceivablesGetHistoryRequest.ts +++ b/src/api/resources/receivables/client/requests/ReceivablesGetHistoryRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/receivables/client/requests/ReceivablesGetMailsRequest.ts b/src/api/resources/receivables/client/requests/ReceivablesGetMailsRequest.ts index 437ca9d..7a973f6 100644 --- a/src/api/resources/receivables/client/requests/ReceivablesGetMailsRequest.ts +++ b/src/api/resources/receivables/client/requests/ReceivablesGetMailsRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/receivables/client/requests/ReceivablesGetRequest.ts b/src/api/resources/receivables/client/requests/ReceivablesGetRequest.ts index a675ec8..e76fd05 100644 --- a/src/api/resources/receivables/client/requests/ReceivablesGetRequest.ts +++ b/src/api/resources/receivables/client/requests/ReceivablesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -141,6 +141,11 @@ export interface ReceivablesGetRequest { total_amount__lt?: number; total_amount__gte?: number; total_amount__lte?: number; + discounted_subtotal?: number; + discounted_subtotal__gt?: number; + discounted_subtotal__lt?: number; + discounted_subtotal__gte?: number; + discounted_subtotal__lte?: number; status?: Monite.ReceivablesGetRequestStatus; entity_user_id?: string; based_on?: string; diff --git a/src/api/resources/receivables/client/requests/ReceivablesSearchRequest.ts b/src/api/resources/receivables/client/requests/ReceivablesSearchRequest.ts new file mode 100644 index 0000000..becf392 --- /dev/null +++ b/src/api/resources/receivables/client/requests/ReceivablesSearchRequest.ts @@ -0,0 +1,168 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../../../../index.js"; + +/** + * @example + * {} + */ +export interface ReceivablesSearchRequest { + /** Return only receivables with the exact specified discounted subtotal. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. */ + discounted_subtotal?: number; + /** Return only receivables whose discounted subtotal (in minor units) is greater than the specified value. */ + discounted_subtotal__gt?: number; + /** Return only receivables whose discounted subtotal (in minor units) is greater than or equal to the specified value. */ + discounted_subtotal__gte?: number; + /** Return only receivables whose discounted subtotal (in minor units) is less than the specified value. */ + discounted_subtotal__lt?: number; + /** Return only receivables whose discounted subtotal (in minor units) is less than or equal to the specified value. */ + discounted_subtotal__lte?: number; + /** + * This parameter accepts a quote ID or an invoice ID. + * + * * Specify a quote ID to find invoices created from this quote. + * * Specify an invoice ID to find credit notes created for this invoice. + * + * Valid but nonexistent IDs do not raise errors but produce no results. + */ + based_on?: string; + /** + * Return only receivables created for the counterpart with the specified ID. + * + * Counterparts that have been deleted but have associated receivables will still return results here because the receivables contain a frozen copy of the counterpart data. + * + * If the specified counterpart ID does not exist and never existed, no results are returned. + */ + counterpart_id?: string; + /** Return only receivables created for counterparts with the specified name (exact match, case-sensitive). For counterparts of `type` = `individual`, the full name is formatted as `first_name last_name`. */ + counterpart_name?: string; + /** Return only receivables created for counterparts whose name contains the specified string (case-sensitive). */ + counterpart_name__contains?: string; + /** Return only receivables created for counterparts whose name contains the specified string (case-insensitive). */ + counterpart_name__icontains?: string; + /** Return only receivables created after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. */ + created_at__gt?: string; + /** Return only receivables created on or after the specified date and time. */ + created_at__gte?: string; + /** Return only receivables created before the specified date and time. */ + created_at__lt?: string; + /** Return only receivables created before or on the specified date and time. */ + created_at__lte?: string; + /** Return a receivable with the exact specified document number (case-sensitive). The `document_id` is the user-facing document number such as INV-00042, not to be confused with Monite resource IDs (`id`). */ + document_id?: string; + /** Return only receivables whose document number (`document_id`) contains the specified string (case-sensitive). */ + document_id__contains?: string; + /** Return only receivables whose document number (`document_id`) contains the specified string (case-insensitive). */ + document_id__icontains?: string; + /** + * Return invoices that are due after the specified date (exclusive, `YYYY-MM-DD`). + * + * This filter excludes quotes, credit notes, and draft invoices. + */ + due_date__gt?: string; + /** + * Return invoices that are due on or after the specified date (`YYYY-MM-DD`). + * + * This filter excludes quotes, credit notes, and draft invoices. + */ + due_date__gte?: string; + /** + * Return invoices that are due before the specified date (exclusive, `YYYY-MM-DD`). + * + * This filter excludes quotes, credit notes, and draft invoices. + */ + due_date__lt?: string; + /** + * Return invoices that are due before or on the specified date (`YYYY-MM-DD`). + * + * This filter excludes quotes, credit notes, and draft invoices. + */ + due_date__lte?: string; + /** + * Return only receivables created by the entity user with the specified ID. To query receivables by multiple user IDs at once, use the `entity_user_id__in` parameter instead. + * + * 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?: string; + entity_user_id__in?: string[]; + id__in?: string[]; + /** Return only non-draft receivables that were issued after the specified date and time. The value must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. */ + issue_date__gt?: string; + /** Return only non-draft receivables that were issued on or after the specified date and time. */ + issue_date__gte?: string; + /** Return only non-draft receivables that were issued before the specified date and time. */ + issue_date__lt?: string; + /** Return only non-draft receivables that were issued before or on the specified date and time. */ + issue_date__lte?: string; + limit?: number; + order?: Monite.OrderEnum; + pagination_token?: string; + product_ids?: string[]; + product_ids__in?: string[]; + /** Return only receivables assigned to the project with the specified ID. Valid but nonexistent project IDs do not raise errors but return no results. */ + project_id?: string; + project_id__in?: string[]; + sort?: Monite.ReceivableCursorFields2; + /** + * Return only receivables that have the specified status. 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 query multiple statuses at once, use the `status__in` parameter instead. + */ + status?: ReceivablesSearchRequest.Status; + status__in?: string[]; + tag_ids?: string[]; + tag_ids__in?: string[]; + /** Return only receivables with the exact specified total amount. The amount must be specified in the [minor units](https://docs.monite.com/references/currencies#minor-units) of currency. For example, $12.5 is represented as 1250. */ + total_amount?: number; + /** Return only receivables whose total amount (in minor units) exceeds the specified value. */ + total_amount__gt?: number; + /** Return only receivables whose total amount (in minor units) is greater than or equal to the specified value. */ + total_amount__gte?: number; + /** Return only receivables whose total amount (in minor units) is less than the specified value. */ + total_amount__lt?: number; + /** Return only receivables whose total amount (in minor units) is less than or equal to the specified value. */ + total_amount__lte?: number; + /** Return only receivables of the specified type. Use this parameter to get only invoices, or only quotes, or only credit notes. */ + type?: Monite.ReceivableType; +} + +export namespace ReceivablesSearchRequest { + /** + * Return only receivables that have the specified status. 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 query multiple statuses at once, use the `status__in` parameter instead. + */ + export type Status = + | "draft" + | "issuing" + | "issued" + | "failed" + | "accepted" + | "expired" + | "declined" + | "recurring" + | "partially_paid" + | "paid" + | "overdue" + | "uncollectible" + | "canceled"; + export const Status = { + Draft: "draft", + Issuing: "issuing", + Issued: "issued", + Failed: "failed", + 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/client/requests/UpdateLineItems.ts b/src/api/resources/receivables/client/requests/UpdateLineItems.ts index 4051ca2..2bc0160 100644 --- a/src/api/resources/receivables/client/requests/UpdateLineItems.ts +++ b/src/api/resources/receivables/client/requests/UpdateLineItems.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/receivables/client/requests/index.ts b/src/api/resources/receivables/client/requests/index.ts index a213e8a..2be9f61 100644 --- a/src/api/resources/receivables/client/requests/index.ts +++ b/src/api/resources/receivables/client/requests/index.ts @@ -1,13 +1,14 @@ -export { type ReceivablesGetRequest } from "./ReceivablesGetRequest"; -export { type GetReceivablesRequiredFieldsRequest } from "./GetReceivablesRequiredFieldsRequest"; -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"; +export { type ReceivablesGetRequest } from "./ReceivablesGetRequest.js"; +export { type GetReceivablesRequiredFieldsRequest } from "./GetReceivablesRequiredFieldsRequest.js"; +export { type ReceivablesSearchRequest } from "./ReceivablesSearchRequest.js"; +export { type QuoteAcceptRequest } from "./QuoteAcceptRequest.js"; +export { type ReceivableDeclinePayload } from "./ReceivableDeclinePayload.js"; +export { type ReceivablesGetHistoryRequest } from "./ReceivablesGetHistoryRequest.js"; +export { type UpdateLineItems } from "./UpdateLineItems.js"; +export { type ReceivablesGetMailsRequest } from "./ReceivablesGetMailsRequest.js"; +export { type ReceivablePaidPayload } from "./ReceivablePaidPayload.js"; +export { type ReceivablePartiallyPaidPayload } from "./ReceivablePartiallyPaidPayload.js"; +export { type ReceivableUncollectiblePayload } from "./ReceivableUncollectiblePayload.js"; +export { type ReceivablePreviewRequest } from "./ReceivablePreviewRequest.js"; +export { type ReceivableSendRequest } from "./ReceivableSendRequest.js"; +export { type ReceivableSendTestReminderPayload } from "./ReceivableSendTestReminderPayload.js"; diff --git a/src/api/resources/receivables/index.ts b/src/api/resources/receivables/index.ts index c9240f8..f095e14 100644 --- a/src/api/resources/receivables/index.ts +++ b/src/api/resources/receivables/index.ts @@ -1,2 +1,2 @@ -export * from "./types"; -export * from "./client"; +export * from "./types/index.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/receivables/types/index.ts b/src/api/resources/receivables/types/index.ts index 8522221..4ea201b 100644 --- a/src/api/resources/receivables/types/index.ts +++ b/src/api/resources/receivables/types/index.ts @@ -1,2 +1,2 @@ -export * from "./ReceivablesGetRequestStatusInItem"; -export * from "./ReceivablesGetRequestStatus"; +export * from "./ReceivablesGetRequestStatusInItem.js"; +export * from "./ReceivablesGetRequestStatus.js"; diff --git a/src/api/resources/recurrences/client/Client.ts b/src/api/resources/recurrences/client/Client.ts index 7e92a60..9c05b95 100644 --- a/src/api/resources/recurrences/client/Client.ts +++ b/src/api/resources/recurrences/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Recurrences { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Recurrences { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Recurrences { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Recurrences { - constructor(protected readonly _options: Recurrences.Options) {} + protected readonly _options: Recurrences.Options; + + constructor(_options: Recurrences.Options) { + this._options = _options; + } /** * @param {Recurrences.RequestOptions} requestOptions - Request-specific configuration. @@ -53,13 +60,13 @@ export class Recurrences { * @example * await client.recurrences.get() */ - public get(requestOptions?: Recurrences.RequestOptions): core.HttpResponsePromise { + public get(requestOptions?: Recurrences.RequestOptions): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__get(requestOptions)); } private async __get( requestOptions?: Recurrences.RequestOptions, - ): Promise> { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -68,29 +75,21 @@ export class Recurrences { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return { data: _response.body as Monite.GetAllRecurrences, rawResponse: _response.rawResponse }; + return { data: _response.body as Monite.RecurrenceResponseList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -146,25 +145,20 @@ export class Recurrences { * * @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 + * invoice_id: "invoice_id" * }) */ public create( request: Monite.CreateRecurrencePayload, requestOptions?: Recurrences.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); } private async __create( request: Monite.CreateRecurrencePayload, requestOptions?: Recurrences.RequestOptions, - ): Promise> { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -173,21 +167,15 @@ export class Recurrences { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -196,7 +184,7 @@ export class Recurrences { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return { data: _response.body as Monite.Recurrence, rawResponse: _response.rawResponse }; + return { data: _response.body as Monite.RecurrenceResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -256,14 +244,14 @@ export class Recurrences { public getById( recurrenceId: string, requestOptions?: Recurrences.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getById(recurrenceId, requestOptions)); } private async __getById( recurrenceId: string, requestOptions?: Recurrences.RequestOptions, - ): Promise> { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -272,29 +260,21 @@ export class Recurrences { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return { data: _response.body as Monite.Recurrence, rawResponse: _response.rawResponse }; + return { data: _response.body as Monite.RecurrenceResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -356,7 +336,7 @@ export class Recurrences { recurrenceId: string, request: Monite.UpdateRecurrencePayload = {}, requestOptions?: Recurrences.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__updateById(recurrenceId, request, requestOptions)); } @@ -364,7 +344,7 @@ export class Recurrences { recurrenceId: string, request: Monite.UpdateRecurrencePayload = {}, requestOptions?: Recurrences.RequestOptions, - ): Promise> { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -373,21 +353,15 @@ export class Recurrences { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -396,7 +370,7 @@ export class Recurrences { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return { data: _response.body as Monite.Recurrence, rawResponse: _response.rawResponse }; + return { data: _response.body as Monite.RecurrenceResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { @@ -475,23 +449,15 @@ export class Recurrences { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -544,6 +510,196 @@ export class Recurrences { } } + /** + * @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.postRecurrencesIdPause("recurrence_id") + */ + public postRecurrencesIdPause( + recurrenceId: string, + requestOptions?: Recurrences.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__postRecurrencesIdPause(recurrenceId, requestOptions)); + } + + private async __postRecurrencesIdPause( + recurrenceId: string, + requestOptions?: Recurrences.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + `recurrences/${encodeURIComponent(recurrenceId)}/pause`, + ), + method: "POST", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError( + "Timeout exceeded when calling POST /recurrences/{recurrence_id}/pause.", + ); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * @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.postRecurrencesIdResume("recurrence_id") + */ + public postRecurrencesIdResume( + recurrenceId: string, + requestOptions?: Recurrences.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__postRecurrencesIdResume(recurrenceId, requestOptions)); + } + + private async __postRecurrencesIdResume( + recurrenceId: string, + requestOptions?: Recurrences.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.MoniteEnvironment.Sandbox, + `recurrences/${encodeURIComponent(recurrenceId)}/resume`, + ), + method: "POST", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Monite.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Monite.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Monite.ForbiddenError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Monite.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Monite.ConflictError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Monite.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Monite.InternalServerError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.MoniteError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.MoniteTimeoutError( + "Timeout exceeded when calling POST /recurrences/{recurrence_id}/resume.", + ); + case "unknown": + throw new errors.MoniteError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + protected async _getAuthorizationHeader(): Promise { const bearer = await core.Supplier.get(this._options.token); if (bearer != null) { diff --git a/src/api/resources/recurrences/client/index.ts b/src/api/resources/recurrences/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/recurrences/client/index.ts +++ b/src/api/resources/recurrences/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/recurrences/client/requests/CreateRecurrencePayload.ts b/src/api/resources/recurrences/client/requests/CreateRecurrencePayload.ts index 1cef007..27e46a4 100644 --- a/src/api/resources/recurrences/client/requests/CreateRecurrencePayload.ts +++ b/src/api/resources/recurrences/client/requests/CreateRecurrencePayload.ts @@ -2,17 +2,12 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example * { - * day_of_month: "first_day", - * end_month: 1, - * end_year: 1, - * invoice_id: "invoice_id", - * start_month: 1, - * start_year: 1 + * invoice_id: "invoice_id" * } */ export interface CreateRecurrencePayload { @@ -27,13 +22,32 @@ export interface CreateRecurrencePayload { * Note: When using "issue_and_send", both subject_text and body_text must be provided. */ automation_level?: Monite.AutomationLevel; + /** The body text for the email that will be sent with the recurring invoice. */ body_text?: string; - day_of_month: Monite.DayOfMonth; - end_month: number; - end_year: number; + /** Deprecated, use `start_date` instead */ + day_of_month?: Monite.DayOfMonth; + /** The end date of the recurring invoice, in the `yyyy-mm-dd` format. The end date is inclusive, that is, the last invoice will be created on this date if the last occurrence falls on this date. `end_date` is mutually exclusive with `max_occurrences`. Either `end_date` or `max_occurrences` must be specified. */ + end_date?: string; + /** Deprecated, use `end_date` instead */ + end_month?: number; + /** Deprecated, use `end_date` instead */ + end_year?: number; + /** How often the invoice will be created. */ + frequency?: Monite.RecurrenceFrequency; + /** The interval between each occurrence of the invoice. For example, when using monthly frequency, an interval of 1 means invoices will be created every month, an interval of 2 means invoices will be created every 2 months. */ + interval?: number; + /** ID of the base invoice that will be used as a template for creating recurring invoices. */ invoice_id: string; + /** How many times the recurring invoice will be created. The recurrence will stop after this number is reached. `max_occurrences` is mutually exclusive with `end_date`. Either `max_occurrences` or `end_date` must be specified. */ + max_occurrences?: number; + /** An object containing the recipients (To, CC, BCC) of the recurring invoices. Can be omitted if the base invoice has the counterpart contact email specified in the `counterpart_contact.email` field. */ recipients?: Monite.Recipients; - start_month: number; - start_year: number; + /** The date when the first invoice will be created, in the `yyyy-mm-dd` format. Cannot be a past date. Subsequent invoice dates will be calculated based on `start_date`, `frequency`, and `interval`. */ + start_date?: string; + /** Deprecated, use `start_date` instead */ + start_month?: number; + /** Deprecated, use `start_date` instead */ + start_year?: number; + /** The subject for the email that will be sent with the recurring invoice. */ subject_text?: string; } diff --git a/src/api/resources/recurrences/client/requests/UpdateRecurrencePayload.ts b/src/api/resources/recurrences/client/requests/UpdateRecurrencePayload.ts index 8005efe..608b6ac 100644 --- a/src/api/resources/recurrences/client/requests/UpdateRecurrencePayload.ts +++ b/src/api/resources/recurrences/client/requests/UpdateRecurrencePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example @@ -20,10 +20,26 @@ export interface UpdateRecurrencePayload { * Note: When using "issue_and_send", both subject_text and body_text must be provided. */ automation_level?: Monite.AutomationLevel; + /** The body text for the email that will be sent with the recurring invoice. */ body_text?: string; + /** Deprecated, use `start_date` instead */ day_of_month?: Monite.DayOfMonth; + /** The end date of the recurring invoice, in the `yyyy-mm-dd` format. The end date is inclusive, that is, the last invoice will be created on this date if the last occurrence falls on this date. `end_date` is mutually exclusive with `max_occurrences`. Either `end_date` or `max_occurrences` must be specified. */ + end_date?: string; + /** Deprecated, use `end_date` instead */ end_month?: number; + /** Deprecated, use `end_date` instead */ end_year?: number; + /** How often the invoice will be created. */ + frequency?: Monite.RecurrenceFrequency; + /** The interval between each occurrence of the invoice. For example, when using monthly frequency, an interval of 1 means invoices will be created every month, an interval of 2 means invoices will be created every 2 months. */ + interval?: number; + /** How many times the recurring invoice will be created. The recurrence will stop after this number is reached. `max_occurrences` is mutually exclusive with `end_date`. Either `max_occurrences` or `end_date` must be specified. */ + max_occurrences?: number; + /** An object containing the recipients (To, CC, BCC) of the recurring invoices. Can be omitted if the base invoice has the counterpart contact email specified in the `counterpart_contact.email` field. */ recipients?: Monite.Recipients; + /** The date when the first invoice will be created, in the `yyyy-mm-dd` format. Cannot be a past date. Subsequent invoice dates will be calculated based on `start_date`, `frequency`, and `interval`. */ + start_date?: string; + /** The subject for the email that will be sent with the recurring invoice. */ subject_text?: string; } diff --git a/src/api/resources/recurrences/client/requests/index.ts b/src/api/resources/recurrences/client/requests/index.ts index 5d38bf5..6ec615e 100644 --- a/src/api/resources/recurrences/client/requests/index.ts +++ b/src/api/resources/recurrences/client/requests/index.ts @@ -1,2 +1,2 @@ -export { type CreateRecurrencePayload } from "./CreateRecurrencePayload"; -export { type UpdateRecurrencePayload } from "./UpdateRecurrencePayload"; +export { type CreateRecurrencePayload } from "./CreateRecurrencePayload.js"; +export { type UpdateRecurrencePayload } from "./UpdateRecurrencePayload.js"; diff --git a/src/api/resources/recurrences/index.ts b/src/api/resources/recurrences/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/recurrences/index.ts +++ b/src/api/resources/recurrences/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/roles/client/Client.ts b/src/api/resources/roles/client/Client.ts index 0719dd3..2dfc5f0 100644 --- a/src/api/resources/roles/client/Client.ts +++ b/src/api/resources/roles/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Roles { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Roles { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Roles { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Roles { - constructor(protected readonly _options: Roles.Options) {} + protected readonly _options: Roles.Options; + + constructor(_options: Roles.Options) { + this._options = _options; + } /** * Find all roles that match the search criteria. @@ -137,24 +144,16 @@ export class Roles { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -238,21 +237,15 @@ export class Roles { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -328,23 +321,15 @@ export class Roles { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -418,23 +403,15 @@ export class Roles { `roles/${encodeURIComponent(roleId)}`, ), 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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -516,21 +493,15 @@ export class Roles { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/roles/client/index.ts b/src/api/resources/roles/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/roles/client/index.ts +++ b/src/api/resources/roles/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/roles/client/requests/CreateRoleRequest.ts b/src/api/resources/roles/client/requests/CreateRoleRequest.ts index 4cc8348..ba7a6cb 100644 --- a/src/api/resources/roles/client/requests/CreateRoleRequest.ts +++ b/src/api/resources/roles/client/requests/CreateRoleRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/roles/client/requests/RolesGetRequest.ts b/src/api/resources/roles/client/requests/RolesGetRequest.ts index e8cea05..79d8053 100644 --- a/src/api/resources/roles/client/requests/RolesGetRequest.ts +++ b/src/api/resources/roles/client/requests/RolesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/roles/client/requests/UpdateRoleRequest.ts b/src/api/resources/roles/client/requests/UpdateRoleRequest.ts index 844e438..a77a441 100644 --- a/src/api/resources/roles/client/requests/UpdateRoleRequest.ts +++ b/src/api/resources/roles/client/requests/UpdateRoleRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/roles/client/requests/index.ts b/src/api/resources/roles/client/requests/index.ts index 2226656..e92118a 100644 --- a/src/api/resources/roles/client/requests/index.ts +++ b/src/api/resources/roles/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type RolesGetRequest } from "./RolesGetRequest"; -export { type CreateRoleRequest } from "./CreateRoleRequest"; -export { type UpdateRoleRequest } from "./UpdateRoleRequest"; +export { type RolesGetRequest } from "./RolesGetRequest.js"; +export { type CreateRoleRequest } from "./CreateRoleRequest.js"; +export { type UpdateRoleRequest } from "./UpdateRoleRequest.js"; diff --git a/src/api/resources/roles/index.ts b/src/api/resources/roles/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/roles/index.ts +++ b/src/api/resources/roles/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/tags/client/Client.ts b/src/api/resources/tags/client/Client.ts index 8976bae..3b1c215 100644 --- a/src/api/resources/tags/client/Client.ts +++ b/src/api/resources/tags/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace Tags { export interface Options { @@ -18,6 +19,8 @@ export declare namespace Tags { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace Tags { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class Tags { - constructor(protected readonly _options: Tags.Options) {} + protected readonly _options: Tags.Options; + + constructor(_options: Tags.Options) { + this._options = _options; + } /** * Get a list of all tags. Tags can be assigned to resources to assist with searching and filtering. @@ -122,24 +129,16 @@ export class Tags { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -231,21 +230,15 @@ export class Tags { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -335,23 +328,15 @@ export class Tags { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -434,23 +419,15 @@ export class Tags { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -539,21 +516,15 @@ export class Tags { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, diff --git a/src/api/resources/tags/client/index.ts b/src/api/resources/tags/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/tags/client/index.ts +++ b/src/api/resources/tags/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/tags/client/requests/TagCreateSchema.ts b/src/api/resources/tags/client/requests/TagCreateSchema.ts index 7431b1d..4a67aa4 100644 --- a/src/api/resources/tags/client/requests/TagCreateSchema.ts +++ b/src/api/resources/tags/client/requests/TagCreateSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/tags/client/requests/TagUpdateSchema.ts b/src/api/resources/tags/client/requests/TagUpdateSchema.ts index 47e0dcd..9bc689e 100644 --- a/src/api/resources/tags/client/requests/TagUpdateSchema.ts +++ b/src/api/resources/tags/client/requests/TagUpdateSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/tags/client/requests/TagsGetRequest.ts b/src/api/resources/tags/client/requests/TagsGetRequest.ts index 90f01f0..4e5298d 100644 --- a/src/api/resources/tags/client/requests/TagsGetRequest.ts +++ b/src/api/resources/tags/client/requests/TagsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/tags/client/requests/index.ts b/src/api/resources/tags/client/requests/index.ts index 5fc8dfa..92cacfd 100644 --- a/src/api/resources/tags/client/requests/index.ts +++ b/src/api/resources/tags/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type TagsGetRequest } from "./TagsGetRequest"; -export { type TagCreateSchema } from "./TagCreateSchema"; -export { type TagUpdateSchema } from "./TagUpdateSchema"; +export { type TagsGetRequest } from "./TagsGetRequest.js"; +export { type TagCreateSchema } from "./TagCreateSchema.js"; +export { type TagUpdateSchema } from "./TagUpdateSchema.js"; diff --git a/src/api/resources/tags/index.ts b/src/api/resources/tags/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/tags/index.ts +++ b/src/api/resources/tags/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/textTemplates/client/Client.ts b/src/api/resources/textTemplates/client/Client.ts index 2ab9ffd..ef61bed 100644 --- a/src/api/resources/textTemplates/client/Client.ts +++ b/src/api/resources/textTemplates/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace TextTemplates { export interface Options { @@ -18,6 +19,8 @@ export declare namespace TextTemplates { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace TextTemplates { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class TextTemplates { - constructor(protected readonly _options: TextTemplates.Options) {} + protected readonly _options: TextTemplates.Options; + + constructor(_options: TextTemplates.Options) { + this._options = _options; + } /** * Get text templates @@ -85,24 +92,16 @@ export class TextTemplates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -179,21 +178,15 @@ export class TextTemplates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -268,23 +261,15 @@ export class TextTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -358,23 +343,15 @@ export class TextTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -451,21 +428,15 @@ export class TextTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -542,23 +513,15 @@ export class TextTemplates { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/textTemplates/client/index.ts b/src/api/resources/textTemplates/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/textTemplates/client/index.ts +++ b/src/api/resources/textTemplates/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/textTemplates/client/requests/CreateTextTemplatePayload.ts b/src/api/resources/textTemplates/client/requests/CreateTextTemplatePayload.ts index 5470a6a..0cbb67c 100644 --- a/src/api/resources/textTemplates/client/requests/CreateTextTemplatePayload.ts +++ b/src/api/resources/textTemplates/client/requests/CreateTextTemplatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/textTemplates/client/requests/TextTemplatesGetRequest.ts b/src/api/resources/textTemplates/client/requests/TextTemplatesGetRequest.ts index 6a284cf..12b0f0f 100644 --- a/src/api/resources/textTemplates/client/requests/TextTemplatesGetRequest.ts +++ b/src/api/resources/textTemplates/client/requests/TextTemplatesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/textTemplates/client/requests/index.ts b/src/api/resources/textTemplates/client/requests/index.ts index e61936b..8e1441d 100644 --- a/src/api/resources/textTemplates/client/requests/index.ts +++ b/src/api/resources/textTemplates/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type TextTemplatesGetRequest } from "./TextTemplatesGetRequest"; -export { type CreateTextTemplatePayload } from "./CreateTextTemplatePayload"; -export { type UpdateTextTemplatePayload } from "./UpdateTextTemplatePayload"; +export { type TextTemplatesGetRequest } from "./TextTemplatesGetRequest.js"; +export { type CreateTextTemplatePayload } from "./CreateTextTemplatePayload.js"; +export { type UpdateTextTemplatePayload } from "./UpdateTextTemplatePayload.js"; diff --git a/src/api/resources/textTemplates/index.ts b/src/api/resources/textTemplates/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/textTemplates/index.ts +++ b/src/api/resources/textTemplates/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/vatRates/client/Client.ts b/src/api/resources/vatRates/client/Client.ts index 07e8d30..0fc1b73 100644 --- a/src/api/resources/vatRates/client/Client.ts +++ b/src/api/resources/vatRates/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace VatRates { export interface Options { @@ -18,6 +19,8 @@ export declare namespace VatRates { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace VatRates { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class VatRates { - constructor(protected readonly _options: VatRates.Options) {} + protected readonly _options: VatRates.Options; + + constructor(_options: VatRates.Options) { + this._options = _options; + } /** * @param {Monite.VatRatesGetRequest} request @@ -101,24 +108,16 @@ export class VatRates { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/vatRates/client/index.ts b/src/api/resources/vatRates/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/vatRates/client/index.ts +++ b/src/api/resources/vatRates/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/vatRates/client/requests/VatRatesGetRequest.ts b/src/api/resources/vatRates/client/requests/VatRatesGetRequest.ts index fa8f5b1..c057667 100644 --- a/src/api/resources/vatRates/client/requests/VatRatesGetRequest.ts +++ b/src/api/resources/vatRates/client/requests/VatRatesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/vatRates/client/requests/index.ts b/src/api/resources/vatRates/client/requests/index.ts index 93d6ce1..fb16f4d 100644 --- a/src/api/resources/vatRates/client/requests/index.ts +++ b/src/api/resources/vatRates/client/requests/index.ts @@ -1 +1 @@ -export { type VatRatesGetRequest } from "./VatRatesGetRequest"; +export { type VatRatesGetRequest } from "./VatRatesGetRequest.js"; diff --git a/src/api/resources/vatRates/index.ts b/src/api/resources/vatRates/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/vatRates/index.ts +++ b/src/api/resources/vatRates/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/webhookDeliveries/client/Client.ts b/src/api/resources/webhookDeliveries/client/Client.ts index 643ec56..ff77d17 100644 --- a/src/api/resources/webhookDeliveries/client/Client.ts +++ b/src/api/resources/webhookDeliveries/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace WebhookDeliveries { export interface Options { @@ -18,6 +19,8 @@ export declare namespace WebhookDeliveries { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace WebhookDeliveries { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class WebhookDeliveries { - constructor(protected readonly _options: WebhookDeliveries.Options) {} + protected readonly _options: WebhookDeliveries.Options; + + constructor(_options: WebhookDeliveries.Options) { + this._options = _options; + } /** * Returns an aggregated log of webhook delivery attempts. The data contains a list of triggered webhook events, how many times Monite tried to send each event to your server, the last HTTP status code returned by your webhook listener endpoint, and whether the final attempt to deliver that event was successful. @@ -133,24 +140,16 @@ export class WebhookDeliveries { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/webhookDeliveries/client/index.ts b/src/api/resources/webhookDeliveries/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/webhookDeliveries/client/index.ts +++ b/src/api/resources/webhookDeliveries/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/webhookDeliveries/client/requests/WebhookDeliveriesGetRequest.ts b/src/api/resources/webhookDeliveries/client/requests/WebhookDeliveriesGetRequest.ts index 09bf828..bed61b4 100644 --- a/src/api/resources/webhookDeliveries/client/requests/WebhookDeliveriesGetRequest.ts +++ b/src/api/resources/webhookDeliveries/client/requests/WebhookDeliveriesGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/webhookDeliveries/client/requests/index.ts b/src/api/resources/webhookDeliveries/client/requests/index.ts index 339df60..4249683 100644 --- a/src/api/resources/webhookDeliveries/client/requests/index.ts +++ b/src/api/resources/webhookDeliveries/client/requests/index.ts @@ -1 +1 @@ -export { type WebhookDeliveriesGetRequest } from "./WebhookDeliveriesGetRequest"; +export { type WebhookDeliveriesGetRequest } from "./WebhookDeliveriesGetRequest.js"; diff --git a/src/api/resources/webhookDeliveries/index.ts b/src/api/resources/webhookDeliveries/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/webhookDeliveries/index.ts +++ b/src/api/resources/webhookDeliveries/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/resources/webhookSubscriptions/client/Client.ts b/src/api/resources/webhookSubscriptions/client/Client.ts index 6a49c9c..c58ced0 100644 --- a/src/api/resources/webhookSubscriptions/client/Client.ts +++ b/src/api/resources/webhookSubscriptions/client/Client.ts @@ -2,11 +2,12 @@ * 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 * as environments from "../../../../environments.js"; +import * as core from "../../../../core/index.js"; +import * as Monite from "../../../index.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../errors/index.js"; export declare namespace WebhookSubscriptions { export interface Options { @@ -18,6 +19,8 @@ export declare namespace WebhookSubscriptions { moniteVersion: core.Supplier; /** Override the x-monite-entity-id header */ moniteEntityId?: core.Supplier; + /** Additional headers to include in requests. */ + headers?: Record | undefined>; fetcher?: core.FetchFunction; } @@ -33,12 +36,16 @@ export declare namespace WebhookSubscriptions { /** Override the x-monite-entity-id header */ moniteEntityId?: string | undefined; /** Additional headers to include in the request. */ - headers?: Record; + headers?: Record | undefined>; } } export class WebhookSubscriptions { - constructor(protected readonly _options: WebhookSubscriptions.Options) {} + protected readonly _options: WebhookSubscriptions.Options; + + constructor(_options: WebhookSubscriptions.Options) { + this._options = _options; + } /** * @param {Monite.WebhookSubscriptionsGetRequest} request @@ -117,24 +124,16 @@ export class WebhookSubscriptions { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), queryParameters: _queryParams, - requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -210,21 +209,15 @@ export class WebhookSubscriptions { "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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -300,23 +293,15 @@ export class WebhookSubscriptions { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -388,23 +373,15 @@ export class WebhookSubscriptions { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -479,21 +456,15 @@ export class WebhookSubscriptions { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), contentType: "application/json", requestType: "json", body: request, @@ -568,23 +539,15 @@ export class WebhookSubscriptions { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -656,23 +619,15 @@ export class WebhookSubscriptions { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -744,23 +699,15 @@ export class WebhookSubscriptions { `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": "@monite/node-client", - "X-Fern-SDK-Version": "0.3.3", - "User-Agent": "@monite/node-client/0.3.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", + headers: mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + Authorization: await this._getAuthorizationHeader(), + "x-monite-version": requestOptions?.moniteVersion, + "x-monite-entity-id": requestOptions?.moniteEntityId, + }), + requestOptions?.headers, + ), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/api/resources/webhookSubscriptions/client/index.ts b/src/api/resources/webhookSubscriptions/client/index.ts index 415726b..82648c6 100644 --- a/src/api/resources/webhookSubscriptions/client/index.ts +++ b/src/api/resources/webhookSubscriptions/client/index.ts @@ -1 +1,2 @@ -export * from "./requests"; +export {}; +export * from "./requests/index.js"; diff --git a/src/api/resources/webhookSubscriptions/client/requests/CreateWebhookSubscriptionRequest.ts b/src/api/resources/webhookSubscriptions/client/requests/CreateWebhookSubscriptionRequest.ts index 6487fa9..ad8aad5 100644 --- a/src/api/resources/webhookSubscriptions/client/requests/CreateWebhookSubscriptionRequest.ts +++ b/src/api/resources/webhookSubscriptions/client/requests/CreateWebhookSubscriptionRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/webhookSubscriptions/client/requests/UpdateWebhookSubscriptionRequest.ts b/src/api/resources/webhookSubscriptions/client/requests/UpdateWebhookSubscriptionRequest.ts index 8d1df65..5d56a6f 100644 --- a/src/api/resources/webhookSubscriptions/client/requests/UpdateWebhookSubscriptionRequest.ts +++ b/src/api/resources/webhookSubscriptions/client/requests/UpdateWebhookSubscriptionRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/webhookSubscriptions/client/requests/WebhookSubscriptionsGetRequest.ts b/src/api/resources/webhookSubscriptions/client/requests/WebhookSubscriptionsGetRequest.ts index 9b79e51..dea8bd3 100644 --- a/src/api/resources/webhookSubscriptions/client/requests/WebhookSubscriptionsGetRequest.ts +++ b/src/api/resources/webhookSubscriptions/client/requests/WebhookSubscriptionsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../../../../index"; +import * as Monite from "../../../../index.js"; /** * @example diff --git a/src/api/resources/webhookSubscriptions/client/requests/index.ts b/src/api/resources/webhookSubscriptions/client/requests/index.ts index 8c230a7..664b64e 100644 --- a/src/api/resources/webhookSubscriptions/client/requests/index.ts +++ b/src/api/resources/webhookSubscriptions/client/requests/index.ts @@ -1,3 +1,3 @@ -export { type WebhookSubscriptionsGetRequest } from "./WebhookSubscriptionsGetRequest"; -export { type CreateWebhookSubscriptionRequest } from "./CreateWebhookSubscriptionRequest"; -export { type UpdateWebhookSubscriptionRequest } from "./UpdateWebhookSubscriptionRequest"; +export { type WebhookSubscriptionsGetRequest } from "./WebhookSubscriptionsGetRequest.js"; +export { type CreateWebhookSubscriptionRequest } from "./CreateWebhookSubscriptionRequest.js"; +export { type UpdateWebhookSubscriptionRequest } from "./UpdateWebhookSubscriptionRequest.js"; diff --git a/src/api/resources/webhookSubscriptions/index.ts b/src/api/resources/webhookSubscriptions/index.ts index 5ec7692..914b8c3 100644 --- a/src/api/resources/webhookSubscriptions/index.ts +++ b/src/api/resources/webhookSubscriptions/index.ts @@ -1 +1 @@ -export * from "./client"; +export * from "./client/index.js"; diff --git a/src/api/types/AccountingConnectionList.ts b/src/api/types/AccountingConnectionList.ts index 79c1cf6..f9b9d7a 100644 --- a/src/api/types/AccountingConnectionList.ts +++ b/src/api/types/AccountingConnectionList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AccountingConnectionList { data: Monite.AccountingConnectionResponse[]; diff --git a/src/api/types/AccountingConnectionResponse.ts b/src/api/types/AccountingConnectionResponse.ts index dcd0043..e25573d 100644 --- a/src/api/types/AccountingConnectionResponse.ts +++ b/src/api/types/AccountingConnectionResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AccountingConnectionResponse { id: string; diff --git a/src/api/types/AccountingLineItem.ts b/src/api/types/AccountingLineItem.ts index 782ab75..a309ad3 100644 --- a/src/api/types/AccountingLineItem.ts +++ b/src/api/types/AccountingLineItem.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Contains the details of an invoice line item retrieved from an accounting system. diff --git a/src/api/types/AccountingPayable.ts b/src/api/types/AccountingPayable.ts index 61abfbb..4300433 100644 --- a/src/api/types/AccountingPayable.ts +++ b/src/api/types/AccountingPayable.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Details of an accounts payable invoice (bill) retrieved from an accounting system. @@ -17,7 +17,7 @@ export interface AccountingPayable { /** 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; + due_date?: AccountingPayable.DueDate; /** Invoice number of the payable. */ invoice_number?: string; lines?: Monite.AccountingLineItem[]; @@ -38,3 +38,10 @@ export interface AccountingPayable { /** Information about the vendor from whom the payable was received. */ vendor_ref?: Monite.AccountingVendorRefObject; } + +export namespace AccountingPayable { + /** + * The payable's due date. + */ + export type DueDate = string | string; +} diff --git a/src/api/types/AccountingPayableDueDate.ts b/src/api/types/AccountingPayableDueDate.ts deleted file mode 100644 index 99beb7f..0000000 --- a/src/api/types/AccountingPayableDueDate.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 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 index 9e35c91..2429960 100644 --- a/src/api/types/AccountingPayableList.ts +++ b/src/api/types/AccountingPayableList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AccountingPayableList { data: Monite.AccountingPayable[]; diff --git a/src/api/types/AccountingReceivable.ts b/src/api/types/AccountingReceivable.ts index 380d062..c5138f4 100644 --- a/src/api/types/AccountingReceivable.ts +++ b/src/api/types/AccountingReceivable.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Invoice details retrieved from an accounting system. @@ -17,7 +17,7 @@ export interface AccountingReceivable { /** Information about the customer that the invoice was sent to. */ customer_ref?: Monite.AccountingCustomerRefObject; /** Invoice due date. */ - due_date?: Monite.AccountingReceivableDueDate; + due_date?: AccountingReceivable.DueDate; /** Invoice document number. */ invoice_number?: string; lines?: Monite.AccountingLineItem[]; @@ -28,3 +28,10 @@ export interface AccountingReceivable { /** Date when the invoice was added to the accounting service. This may differ from the invoice creation date. */ posted_date?: string; } + +export namespace AccountingReceivable { + /** + * Invoice due date. + */ + export type DueDate = string | string; +} diff --git a/src/api/types/AccountingReceivableDueDate.ts b/src/api/types/AccountingReceivableDueDate.ts deleted file mode 100644 index 75e27df..0000000 --- a/src/api/types/AccountingReceivableDueDate.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 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 index 11b071b..31e5d0c 100644 --- a/src/api/types/AccountingReceivableList.ts +++ b/src/api/types/AccountingReceivableList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AccountingReceivableList { data: Monite.AccountingReceivable[]; diff --git a/src/api/types/AccountingSettings.ts b/src/api/types/AccountingSettings.ts index d1b49f6..e3f8233 100644 --- a/src/api/types/AccountingSettings.ts +++ b/src/api/types/AccountingSettings.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AccountingSettings { /** Default ledger accounts that will be used for various objects pushed into an accounting system. Use `GET /ledger_accounts` to get the IDs of these ledger accounts. */ diff --git a/src/api/types/AccountingTaxRateListResponse.ts b/src/api/types/AccountingTaxRateListResponse.ts index 478faf2..07cc056 100644 --- a/src/api/types/AccountingTaxRateListResponse.ts +++ b/src/api/types/AccountingTaxRateListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AccountingTaxRateListResponse { data: Monite.AccountingTaxRateResponse[]; diff --git a/src/api/types/AccountingTaxRateResponse.ts b/src/api/types/AccountingTaxRateResponse.ts index daaba59..2946223 100644 --- a/src/api/types/AccountingTaxRateResponse.ts +++ b/src/api/types/AccountingTaxRateResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AccountingTaxRateResponse { id: string; diff --git a/src/api/types/ActionSchema.ts b/src/api/types/ActionSchema.ts index d1478e6..e1e4095 100644 --- a/src/api/types/ActionSchema.ts +++ b/src/api/types/ActionSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ActionSchema { /** Action name */ diff --git a/src/api/types/AirwallexMandate.ts b/src/api/types/AirwallexMandate.ts index acff632..2beb470 100644 --- a/src/api/types/AirwallexMandate.ts +++ b/src/api/types/AirwallexMandate.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AirwallexMandate { /** PDF copy of mandate will be sent to the email by Airwallex */ diff --git a/src/api/types/AirwallexPlaidVerification.ts b/src/api/types/AirwallexPlaidVerification.ts index 4ab4d93..cbd1120 100644 --- a/src/api/types/AirwallexPlaidVerification.ts +++ b/src/api/types/AirwallexPlaidVerification.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AirwallexPlaidVerification { /** Status of the bank account verification */ diff --git a/src/api/types/AllDocumentExportResponseSchema.ts b/src/api/types/AllDocumentExportResponseSchema.ts index de6d533..8926e70 100644 --- a/src/api/types/AllDocumentExportResponseSchema.ts +++ b/src/api/types/AllDocumentExportResponseSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AllDocumentExportResponseSchema { /** A set of export objects returned per page. */ diff --git a/src/api/types/AllOverdueRemindersResponse.ts b/src/api/types/AllOverdueRemindersResponse.ts index 97fbfda..182ef88 100644 --- a/src/api/types/AllOverdueRemindersResponse.ts +++ b/src/api/types/AllOverdueRemindersResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface AllOverdueRemindersResponse { data: Monite.OverdueReminderResponse[]; diff --git a/src/api/types/ApprovalPolicyResource.ts b/src/api/types/ApprovalPolicyResource.ts index 1ec2303..afbcf86 100644 --- a/src/api/types/ApprovalPolicyResource.ts +++ b/src/api/types/ApprovalPolicyResource.ts @@ -2,8 +2,6 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; - export interface ApprovalPolicyResource { id: string; created_at: string; @@ -16,12 +14,33 @@ export interface ApprovalPolicyResource { /** The name of the approval policy. */ name: 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[]; + script: ApprovalPolicyResource.Script.Item[]; /** The date and time (in the ISO 8601 format) when the approval policy becomes active. Only payables submitted for approval during the policy's active period will trigger this policy. If omitted or `null`, the policy is effective immediately. The value will be converted to UTC. */ starts_at?: string; /** The current status of the approval policy. */ - status: Monite.ApprovalPolicyResourceStatus; + status: ApprovalPolicyResource.Status; /** 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; + trigger?: ApprovalPolicyResource.Trigger; updated_by?: string; } + +export namespace ApprovalPolicyResource { + export type Script = Script.Item[]; + + export namespace Script { + export type Item = boolean | number | string | unknown[] | Record; + } + + /** + * The current status of the approval policy. + */ + export type Status = "active" | "pending"; + export const Status = { + Active: "active", + Pending: "pending", + } as const; + /** + * 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 Trigger = boolean | number | string | unknown[] | Record; +} diff --git a/src/api/types/ApprovalPolicyResourceList.ts b/src/api/types/ApprovalPolicyResourceList.ts index c421e2d..56bf475 100644 --- a/src/api/types/ApprovalPolicyResourceList.ts +++ b/src/api/types/ApprovalPolicyResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ApprovalPolicyResourceList { data: Monite.ApprovalPolicyResource[]; diff --git a/src/api/types/ApprovalPolicyResourceScriptItem.ts b/src/api/types/ApprovalPolicyResourceScriptItem.ts deleted file mode 100644 index 48a1b4e..0000000 --- a/src/api/types/ApprovalPolicyResourceScriptItem.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * 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 deleted file mode 100644 index fd060e4..0000000 --- a/src/api/types/ApprovalPolicyResourceStatus.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * 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 deleted file mode 100644 index 77167f2..0000000 --- a/src/api/types/ApprovalPolicyResourceTrigger.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 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/ApprovalProcessResourceList.ts b/src/api/types/ApprovalProcessResourceList.ts index 967cf1f..62d784c 100644 --- a/src/api/types/ApprovalProcessResourceList.ts +++ b/src/api/types/ApprovalProcessResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ApprovalProcessResourceList { data: Monite.ProcessResource[]; diff --git a/src/api/types/ApprovalProcessStepResource.ts b/src/api/types/ApprovalProcessStepResource.ts index 284ec8e..c6f4d06 100644 --- a/src/api/types/ApprovalProcessStepResource.ts +++ b/src/api/types/ApprovalProcessStepResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ApprovalProcessStepResource { approved_by: string[]; diff --git a/src/api/types/ApprovalProcessStepResourceList.ts b/src/api/types/ApprovalProcessStepResourceList.ts index 3e48c28..96b071e 100644 --- a/src/api/types/ApprovalProcessStepResourceList.ts +++ b/src/api/types/ApprovalProcessStepResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ApprovalProcessStepResourceList { data: Monite.ApprovalProcessStepResource[]; diff --git a/src/api/types/ApprovalRequestCreateByRoleRequest.ts b/src/api/types/ApprovalRequestCreateByRoleRequest.ts index 16301d0..056b192 100644 --- a/src/api/types/ApprovalRequestCreateByRoleRequest.ts +++ b/src/api/types/ApprovalRequestCreateByRoleRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ApprovalRequestCreateByRoleRequest { object_id: string; diff --git a/src/api/types/ApprovalRequestCreateByUserRequest.ts b/src/api/types/ApprovalRequestCreateByUserRequest.ts index 17ba956..2a13f76 100644 --- a/src/api/types/ApprovalRequestCreateByUserRequest.ts +++ b/src/api/types/ApprovalRequestCreateByUserRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ApprovalRequestCreateByUserRequest { object_id: string; diff --git a/src/api/types/ApprovalRequestCreateRequest.ts b/src/api/types/ApprovalRequestCreateRequest.ts index 98a4044..b26d6bf 100644 --- a/src/api/types/ApprovalRequestCreateRequest.ts +++ b/src/api/types/ApprovalRequestCreateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type ApprovalRequestCreateRequest = | Monite.ApprovalRequestCreateByRoleRequest diff --git a/src/api/types/ApprovalRequestResourceList.ts b/src/api/types/ApprovalRequestResourceList.ts index f969895..8d63b38 100644 --- a/src/api/types/ApprovalRequestResourceList.ts +++ b/src/api/types/ApprovalRequestResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ApprovalRequestResourceList { data: Monite.ApprovalRequestResourceWithMetadata[]; diff --git a/src/api/types/ApprovalRequestResourceWithMetadata.ts b/src/api/types/ApprovalRequestResourceWithMetadata.ts index 64cb254..4342ee7 100644 --- a/src/api/types/ApprovalRequestResourceWithMetadata.ts +++ b/src/api/types/ApprovalRequestResourceWithMetadata.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ApprovalRequestResourceWithMetadata { id: string; diff --git a/src/api/types/BankAccount.ts b/src/api/types/BankAccount.ts index da156ce..2887e17 100644 --- a/src/api/types/BankAccount.ts +++ b/src/api/types/BankAccount.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface BankAccount { /** The ID of the bank account. */ diff --git a/src/api/types/BankAccountVerifications.ts b/src/api/types/BankAccountVerifications.ts index 607649f..087b833 100644 --- a/src/api/types/BankAccountVerifications.ts +++ b/src/api/types/BankAccountVerifications.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface BankAccountVerifications { /** Airwallex Plaid verification */ diff --git a/src/api/types/BasedOnReceivableCreatedEventData.ts b/src/api/types/BasedOnReceivableCreatedEventData.ts index df292fb..c81959c 100644 --- a/src/api/types/BasedOnReceivableCreatedEventData.ts +++ b/src/api/types/BasedOnReceivableCreatedEventData.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * In invoice history, this object contains information about a credit note created for this invoice. diff --git a/src/api/types/BizObjectsSchemaInput.ts b/src/api/types/BizObjectsSchemaInput.ts index 8025fb4..fa1c14f 100644 --- a/src/api/types/BizObjectsSchemaInput.ts +++ b/src/api/types/BizObjectsSchemaInput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface BizObjectsSchemaInput { /** List of objects */ diff --git a/src/api/types/BizObjectsSchemaOutput.ts b/src/api/types/BizObjectsSchemaOutput.ts index 035beab..75ef0fb 100644 --- a/src/api/types/BizObjectsSchemaOutput.ts +++ b/src/api/types/BizObjectsSchemaOutput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface BizObjectsSchemaOutput { /** List of objects */ diff --git a/src/api/types/BusinessProfileInput.ts b/src/api/types/BusinessProfileInput.ts index 64c611d..0d3924e 100644 --- a/src/api/types/BusinessProfileInput.ts +++ b/src/api/types/BusinessProfileInput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface BusinessProfileInput { /** 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. */ diff --git a/src/api/types/BusinessProfileOutput.ts b/src/api/types/BusinessProfileOutput.ts index 8cde9d5..211218a 100644 --- a/src/api/types/BusinessProfileOutput.ts +++ b/src/api/types/BusinessProfileOutput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface BusinessProfileOutput { /** 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. */ diff --git a/src/api/types/CommentResource.ts b/src/api/types/CommentResource.ts index 3586915..29bfdff 100644 --- a/src/api/types/CommentResource.ts +++ b/src/api/types/CommentResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CommentResource { id: string; diff --git a/src/api/types/CommentResourceList.ts b/src/api/types/CommentResourceList.ts index 5264637..0590d4e 100644 --- a/src/api/types/CommentResourceList.ts +++ b/src/api/types/CommentResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CommentResourceList { data: Monite.CommentResource[]; diff --git a/src/api/types/CommonSchemaInput.ts b/src/api/types/CommonSchemaInput.ts index af93bb1..72de418 100644 --- a/src/api/types/CommonSchemaInput.ts +++ b/src/api/types/CommonSchemaInput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CommonSchemaInput { /** List of actions */ diff --git a/src/api/types/CommonSchemaOutput.ts b/src/api/types/CommonSchemaOutput.ts index 1a5162e..c280116 100644 --- a/src/api/types/CommonSchemaOutput.ts +++ b/src/api/types/CommonSchemaOutput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CommonSchemaOutput { /** List of actions */ diff --git a/src/api/types/CompleteRefreshVerificationRequest.ts b/src/api/types/CompleteRefreshVerificationRequest.ts index c218cb8..f9bbaa0 100644 --- a/src/api/types/CompleteRefreshVerificationRequest.ts +++ b/src/api/types/CompleteRefreshVerificationRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CompleteRefreshVerificationRequest { type: Monite.BankAccountVerificationType; diff --git a/src/api/types/CompleteRefreshVerificationResponse.ts b/src/api/types/CompleteRefreshVerificationResponse.ts index 370ca9e..a3d4e8f 100644 --- a/src/api/types/CompleteRefreshVerificationResponse.ts +++ b/src/api/types/CompleteRefreshVerificationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CompleteRefreshVerificationResponse { verifications: Monite.BankAccountVerifications; diff --git a/src/api/types/CompleteVerificationAirwallexPlaidRequest.ts b/src/api/types/CompleteVerificationAirwallexPlaidRequest.ts index 1e54ed3..0f99a2d 100644 --- a/src/api/types/CompleteVerificationAirwallexPlaidRequest.ts +++ b/src/api/types/CompleteVerificationAirwallexPlaidRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CompleteVerificationAirwallexPlaidRequest { /** The bank account that was selected in the Plaid Modal */ diff --git a/src/api/types/CompleteVerificationRequest.ts b/src/api/types/CompleteVerificationRequest.ts index ef640dc..edbe64c 100644 --- a/src/api/types/CompleteVerificationRequest.ts +++ b/src/api/types/CompleteVerificationRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CompleteVerificationRequest { airwallex_plaid: Monite.CompleteVerificationAirwallexPlaidRequest; diff --git a/src/api/types/CompleteVerificationResponse.ts b/src/api/types/CompleteVerificationResponse.ts index 4c0bdd3..61baaec 100644 --- a/src/api/types/CompleteVerificationResponse.ts +++ b/src/api/types/CompleteVerificationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CompleteVerificationResponse { /** Deprecated. Use bank_account_id instead. */ diff --git a/src/api/types/CounterpartAddress.ts b/src/api/types/CounterpartAddress.ts index 84902b2..9c6645b 100644 --- a/src/api/types/CounterpartAddress.ts +++ b/src/api/types/CounterpartAddress.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Address information. diff --git a/src/api/types/CounterpartAddressResourceList.ts b/src/api/types/CounterpartAddressResourceList.ts index 218b5eb..26e3de3 100644 --- a/src/api/types/CounterpartAddressResourceList.ts +++ b/src/api/types/CounterpartAddressResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartAddressResourceList { data: Monite.CounterpartAddressResponseWithCounterpartId[]; diff --git a/src/api/types/CounterpartAddressResponseWithCounterpartId.ts b/src/api/types/CounterpartAddressResponseWithCounterpartId.ts index 5eaef3c..219f77e 100644 --- a/src/api/types/CounterpartAddressResponseWithCounterpartId.ts +++ b/src/api/types/CounterpartAddressResponseWithCounterpartId.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Address information. diff --git a/src/api/types/CounterpartBankAccountResourceList.ts b/src/api/types/CounterpartBankAccountResourceList.ts index 0697eb5..e5d64d1 100644 --- a/src/api/types/CounterpartBankAccountResourceList.ts +++ b/src/api/types/CounterpartBankAccountResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartBankAccountResourceList { data: Monite.CounterpartBankAccountResponse[]; diff --git a/src/api/types/CounterpartBankAccountResponse.ts b/src/api/types/CounterpartBankAccountResponse.ts index eda1faa..772afd0 100644 --- a/src/api/types/CounterpartBankAccountResponse.ts +++ b/src/api/types/CounterpartBankAccountResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartBankAccountResponse { id: string; diff --git a/src/api/types/CounterpartContactResponse.ts b/src/api/types/CounterpartContactResponse.ts index 3ffa3b0..3ffcad4 100644 --- a/src/api/types/CounterpartContactResponse.ts +++ b/src/api/types/CounterpartContactResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * The contact person for an organization. diff --git a/src/api/types/CounterpartContactsResourceList.ts b/src/api/types/CounterpartContactsResourceList.ts index 9a7d86f..e5758da 100644 --- a/src/api/types/CounterpartContactsResourceList.ts +++ b/src/api/types/CounterpartContactsResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartContactsResourceList { data: Monite.CounterpartContactResponse[]; diff --git a/src/api/types/CounterpartCreatePayload.ts b/src/api/types/CounterpartCreatePayload.ts index 5dedcae..e0b4358 100644 --- a/src/api/types/CounterpartCreatePayload.ts +++ b/src/api/types/CounterpartCreatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * This schema is used to create new counterparts (either organizations or individuals). diff --git a/src/api/types/CounterpartEinvoicingCredentialResponse.ts b/src/api/types/CounterpartEinvoicingCredentialResponse.ts index 527872a..1437249 100644 --- a/src/api/types/CounterpartEinvoicingCredentialResponse.ts +++ b/src/api/types/CounterpartEinvoicingCredentialResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartEinvoicingCredentialResponse { id: string; diff --git a/src/api/types/CounterpartEinvoicingCredentialResponseList.ts b/src/api/types/CounterpartEinvoicingCredentialResponseList.ts index 3068a5c..fa32c86 100644 --- a/src/api/types/CounterpartEinvoicingCredentialResponseList.ts +++ b/src/api/types/CounterpartEinvoicingCredentialResponseList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartEinvoicingCredentialResponseList { data: Monite.CounterpartEinvoicingCredentialResponse[]; diff --git a/src/api/types/CounterpartEinvoicingCredentialSchema.ts b/src/api/types/CounterpartEinvoicingCredentialSchema.ts index 13a6c6b..45664fb 100644 --- a/src/api/types/CounterpartEinvoicingCredentialSchema.ts +++ b/src/api/types/CounterpartEinvoicingCredentialSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartEinvoicingCredentialSchema { network_identifier: string; diff --git a/src/api/types/CounterpartFields.ts b/src/api/types/CounterpartFields.ts index 0db791a..05c3694 100644 --- a/src/api/types/CounterpartFields.ts +++ b/src/api/types/CounterpartFields.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartFields { /** Object describing the required field `tax_id` of an counterpart */ diff --git a/src/api/types/CounterpartIndividualCreatePayload.ts b/src/api/types/CounterpartIndividualCreatePayload.ts index 8180f14..777c197 100644 --- a/src/api/types/CounterpartIndividualCreatePayload.ts +++ b/src/api/types/CounterpartIndividualCreatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents counterparts that are individuals (natural persons). diff --git a/src/api/types/CounterpartIndividualResponse.ts b/src/api/types/CounterpartIndividualResponse.ts index 3978282..167a6fe 100644 --- a/src/api/types/CounterpartIndividualResponse.ts +++ b/src/api/types/CounterpartIndividualResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartIndividualResponse { /** The person's email address. */ diff --git a/src/api/types/CounterpartIndividualRootCreatePayload.ts b/src/api/types/CounterpartIndividualRootCreatePayload.ts index 7b2bf54..80fc90f 100644 --- a/src/api/types/CounterpartIndividualRootCreatePayload.ts +++ b/src/api/types/CounterpartIndividualRootCreatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * This schema is used to create counterparts that are individuals (natural persons). diff --git a/src/api/types/CounterpartIndividualRootResponse.ts b/src/api/types/CounterpartIndividualRootResponse.ts index 6dfc30e..7f7edb1 100644 --- a/src/api/types/CounterpartIndividualRootResponse.ts +++ b/src/api/types/CounterpartIndividualRootResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents counterparts that are individuals (natural persons). diff --git a/src/api/types/CounterpartIndividualRootUpdatePayload.ts b/src/api/types/CounterpartIndividualRootUpdatePayload.ts index d88135a..501c884 100644 --- a/src/api/types/CounterpartIndividualRootUpdatePayload.ts +++ b/src/api/types/CounterpartIndividualRootUpdatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents counterparts that are individuals (natural persons). diff --git a/src/api/types/CounterpartOrganizationCreatePayload.ts b/src/api/types/CounterpartOrganizationCreatePayload.ts index 50fbcd7..5b3adc2 100644 --- a/src/api/types/CounterpartOrganizationCreatePayload.ts +++ b/src/api/types/CounterpartOrganizationCreatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents counterparts that are organizations (juridical persons). diff --git a/src/api/types/CounterpartOrganizationResponse.ts b/src/api/types/CounterpartOrganizationResponse.ts index c624c5d..e32b9a5 100644 --- a/src/api/types/CounterpartOrganizationResponse.ts +++ b/src/api/types/CounterpartOrganizationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartOrganizationResponse { /** The email address of the organization */ diff --git a/src/api/types/CounterpartOrganizationRootCreatePayload.ts b/src/api/types/CounterpartOrganizationRootCreatePayload.ts index bca33ef..ad8b61c 100644 --- a/src/api/types/CounterpartOrganizationRootCreatePayload.ts +++ b/src/api/types/CounterpartOrganizationRootCreatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * This schema is used to create counterparts that are organizations (juridical persons). diff --git a/src/api/types/CounterpartOrganizationRootResponse.ts b/src/api/types/CounterpartOrganizationRootResponse.ts index 1171804..6de491f 100644 --- a/src/api/types/CounterpartOrganizationRootResponse.ts +++ b/src/api/types/CounterpartOrganizationRootResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents counterparts that are organizations (juridical persons). diff --git a/src/api/types/CounterpartOrganizationRootUpdatePayload.ts b/src/api/types/CounterpartOrganizationRootUpdatePayload.ts index 4887eb7..8d91c7a 100644 --- a/src/api/types/CounterpartOrganizationRootUpdatePayload.ts +++ b/src/api/types/CounterpartOrganizationRootUpdatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents counterparts that are organizations (juridical persons). diff --git a/src/api/types/CounterpartPaginationResponse.ts b/src/api/types/CounterpartPaginationResponse.ts index 0917756..df40aa6 100644 --- a/src/api/types/CounterpartPaginationResponse.ts +++ b/src/api/types/CounterpartPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of counterparts diff --git a/src/api/types/CounterpartRawAddress.ts b/src/api/types/CounterpartRawAddress.ts index f5621ad..a48084e 100644 --- a/src/api/types/CounterpartRawAddress.ts +++ b/src/api/types/CounterpartRawAddress.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Address information. diff --git a/src/api/types/CounterpartRawAddressUpdateRequest.ts b/src/api/types/CounterpartRawAddressUpdateRequest.ts index badacaf..a08c602 100644 --- a/src/api/types/CounterpartRawAddressUpdateRequest.ts +++ b/src/api/types/CounterpartRawAddressUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Address information. diff --git a/src/api/types/CounterpartRawData.ts b/src/api/types/CounterpartRawData.ts index 50a101b..58c3fcf 100644 --- a/src/api/types/CounterpartRawData.ts +++ b/src/api/types/CounterpartRawData.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartRawData { /** The address of the vendor or supplier. */ diff --git a/src/api/types/CounterpartRawDataUpdateRequest.ts b/src/api/types/CounterpartRawDataUpdateRequest.ts index 1d073b9..9c6ed89 100644 --- a/src/api/types/CounterpartRawDataUpdateRequest.ts +++ b/src/api/types/CounterpartRawDataUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartRawDataUpdateRequest { /** The address of the vendor or supplier. */ diff --git a/src/api/types/CounterpartRawVatId.ts b/src/api/types/CounterpartRawVatId.ts index 8ecf5dc..1505089 100644 --- a/src/api/types/CounterpartRawVatId.ts +++ b/src/api/types/CounterpartRawVatId.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartRawVatId { country?: Monite.AllowedCountries; diff --git a/src/api/types/CounterpartRawVatIdUpdateRequest.ts b/src/api/types/CounterpartRawVatIdUpdateRequest.ts index 098cb7c..aee375e 100644 --- a/src/api/types/CounterpartRawVatIdUpdateRequest.ts +++ b/src/api/types/CounterpartRawVatIdUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartRawVatIdUpdateRequest { country?: Monite.AllowedCountries; diff --git a/src/api/types/CounterpartResponse.ts b/src/api/types/CounterpartResponse.ts index 1c12034..23e273d 100644 --- a/src/api/types/CounterpartResponse.ts +++ b/src/api/types/CounterpartResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A Counterpart object contains information about an organization (juridical person) or diff --git a/src/api/types/CounterpartTagCategory.ts b/src/api/types/CounterpartTagCategory.ts deleted file mode 100644 index 9c12682..0000000 --- a/src/api/types/CounterpartTagCategory.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * 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 index 982455c..3373e3f 100644 --- a/src/api/types/CounterpartTagSchema.ts +++ b/src/api/types/CounterpartTagSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents a user-defined tag that can be assigned to resources to filter them. @@ -15,7 +15,7 @@ export interface CounterpartTagSchema { /** 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; + category?: Monite.TagCategory; /** ID of the user who created the tag. */ created_by_entity_user_id?: string; /** The tag description. */ diff --git a/src/api/types/CounterpartUpdatePayload.ts b/src/api/types/CounterpartUpdatePayload.ts index 4dba3b7..1741b5b 100644 --- a/src/api/types/CounterpartUpdatePayload.ts +++ b/src/api/types/CounterpartUpdatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * This schema is used to update existing counterparts (organizations or individuals). diff --git a/src/api/types/CounterpartVatIdResourceList.ts b/src/api/types/CounterpartVatIdResourceList.ts index 028549d..57c2c4f 100644 --- a/src/api/types/CounterpartVatIdResourceList.ts +++ b/src/api/types/CounterpartVatIdResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartVatIdResourceList { data: Monite.CounterpartVatIdResponse[]; diff --git a/src/api/types/CounterpartVatIdResponse.ts b/src/api/types/CounterpartVatIdResponse.ts index 4e81578..9c42e6a 100644 --- a/src/api/types/CounterpartVatIdResponse.ts +++ b/src/api/types/CounterpartVatIdResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CounterpartVatIdResponse { id: string; diff --git a/src/api/types/CreateCounterpartEinvoicingCredentialPayload.ts b/src/api/types/CreateCounterpartEinvoicingCredentialPayload.ts index bdf3b20..9d55e1b 100644 --- a/src/api/types/CreateCounterpartEinvoicingCredentialPayload.ts +++ b/src/api/types/CreateCounterpartEinvoicingCredentialPayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type CreateCounterpartEinvoicingCredentialPayload = | Monite.CreateCounterpartEinvoicingCredentialCounterpartVatId diff --git a/src/api/types/CreateOnboardingLinkRequest.ts b/src/api/types/CreateOnboardingLinkRequest.ts index 461e335..84bbd5c 100644 --- a/src/api/types/CreateOnboardingLinkRequest.ts +++ b/src/api/types/CreateOnboardingLinkRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CreateOnboardingLinkRequest { recipient: Monite.Recipient; diff --git a/src/api/types/CreditNoteLineItemPaginationResponse.ts b/src/api/types/CreditNoteLineItemPaginationResponse.ts index b01ba2c..82f6708 100644 --- a/src/api/types/CreditNoteLineItemPaginationResponse.ts +++ b/src/api/types/CreditNoteLineItemPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of credit note line items. diff --git a/src/api/types/CreditNotePaginationResponse.ts b/src/api/types/CreditNotePaginationResponse.ts index c6c2d3e..a585d0b 100644 --- a/src/api/types/CreditNotePaginationResponse.ts +++ b/src/api/types/CreditNotePaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of credit notes. diff --git a/src/api/types/CreditNoteResponse.ts b/src/api/types/CreditNoteResponse.ts index 24d1c51..5e999fe 100644 --- a/src/api/types/CreditNoteResponse.ts +++ b/src/api/types/CreditNoteResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Schema for credit note response. Includes all fields that can be returned from the API. diff --git a/src/api/types/CreditNoteResponsePayload.ts b/src/api/types/CreditNoteResponsePayload.ts index b789f32..616c043 100644 --- a/src/api/types/CreditNoteResponsePayload.ts +++ b/src/api/types/CreditNoteResponsePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CreditNoteResponsePayload { id: string; @@ -35,7 +35,7 @@ export interface CreditNoteResponsePayload { /** The VAT/TAX ID of the counterpart. */ counterpart_tax_id?: string; /** The type of the counterpart. */ - counterpart_type: Monite.ReceivableCounterpartType; + counterpart_type: Monite.CounterpartType; counterpart_vat_id?: Monite.ReceivableCounterpartVatIdResponse; /** The currency used in the receivable. */ currency: Monite.CurrencyEnum; @@ -44,7 +44,7 @@ export interface CreditNoteResponsePayload { /** A note with additional information about a tax deduction */ deduction_memo?: string; /** The discount for a receivable. */ - discount?: Monite.Discount; + discount?: Monite.DiscountResponse; /** Total price of the receivable with discounts before taxes [minor units](https://docs.monite.com/references/currencies#minor-units). */ discounted_subtotal?: number; /** The sequential code systematically assigned to invoices. */ diff --git a/src/api/types/CreditNoteResponsePayloadEntity.ts b/src/api/types/CreditNoteResponsePayloadEntity.ts index 47f06da..7c36cfd 100644 --- a/src/api/types/CreditNoteResponsePayloadEntity.ts +++ b/src/api/types/CreditNoteResponsePayloadEntity.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type CreditNoteResponsePayloadEntity = | Monite.CreditNoteResponsePayloadEntity.Organization diff --git a/src/api/types/CreditNoteValidationsResource.ts b/src/api/types/CreditNoteValidationsResource.ts index e99d489..0a74e01 100644 --- a/src/api/types/CreditNoteValidationsResource.ts +++ b/src/api/types/CreditNoteValidationsResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CreditNoteValidationsResource { required_fields: Monite.CreditNoteFieldsAllowedForValidate[]; diff --git a/src/api/types/CurrencySettingsInput.ts b/src/api/types/CurrencySettingsInput.ts index e300e2f..baf4ae6 100644 --- a/src/api/types/CurrencySettingsInput.ts +++ b/src/api/types/CurrencySettingsInput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CurrencySettingsInput { default: Monite.CurrencyEnum; diff --git a/src/api/types/CurrencySettingsOutput.ts b/src/api/types/CurrencySettingsOutput.ts index e324c86..65d28ee 100644 --- a/src/api/types/CurrencySettingsOutput.ts +++ b/src/api/types/CurrencySettingsOutput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CurrencySettingsOutput { default: Monite.CurrencyEnum; diff --git a/src/api/types/CustomTemplatesPaginationResponse.ts b/src/api/types/CustomTemplatesPaginationResponse.ts index 2232fc5..4cff454 100644 --- a/src/api/types/CustomTemplatesPaginationResponse.ts +++ b/src/api/types/CustomTemplatesPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface CustomTemplatesPaginationResponse { /** All user-defined email templates */ diff --git a/src/api/types/CustomVatRateResponse.ts b/src/api/types/CustomVatRateResponse.ts new file mode 100644 index 0000000..939628b --- /dev/null +++ b/src/api/types/CustomVatRateResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface CustomVatRateResponse { + id: string; + /** Time at which the Custom VAT rate was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the Custom VAT rate was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + /** Sub-taxes included in the Custom VAT. */ + components: Monite.VatRateComponent[]; + /** ID of the user that created the Custom VAT rate */ + created_by_entity_user_id?: string; + /** Display name of the Custom VAT. */ + name: string; + /** Total sum of the Custom VAT rate including components. Percent multiplied by a 100. Example: 12.125% is 1212.5. */ + value: number; +} diff --git a/src/api/types/CustomVatRateResponseList.ts b/src/api/types/CustomVatRateResponseList.ts new file mode 100644 index 0000000..1e15a63 --- /dev/null +++ b/src/api/types/CustomVatRateResponseList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface CustomVatRateResponseList { + data: Monite.CustomVatRateResponse[]; +} diff --git a/src/api/types/DeliveryNoteCounterpartResource.ts b/src/api/types/DeliveryNoteCounterpartResource.ts index df16f2d..b5621f4 100644 --- a/src/api/types/DeliveryNoteCounterpartResource.ts +++ b/src/api/types/DeliveryNoteCounterpartResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DeliveryNoteCounterpartResource { /** ID of the counterpart */ diff --git a/src/api/types/DeliveryNoteCreateLineItem.ts b/src/api/types/DeliveryNoteCreateLineItem.ts index 70a5a61..eba1d91 100644 --- a/src/api/types/DeliveryNoteCreateLineItem.ts +++ b/src/api/types/DeliveryNoteCreateLineItem.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DeliveryNoteCreateLineItem { /** Object of product. Can be used instead of product_id, created in product's catalog */ diff --git a/src/api/types/DeliveryNoteCreateRequest.ts b/src/api/types/DeliveryNoteCreateRequest.ts index 6cd26d4..1d85b1f 100644 --- a/src/api/types/DeliveryNoteCreateRequest.ts +++ b/src/api/types/DeliveryNoteCreateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Delivery Note creation request schema diff --git a/src/api/types/DeliveryNoteLineItemProduct.ts b/src/api/types/DeliveryNoteLineItemProduct.ts index 6b7186b..0b0b036 100644 --- a/src/api/types/DeliveryNoteLineItemProduct.ts +++ b/src/api/types/DeliveryNoteLineItemProduct.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DeliveryNoteLineItemProduct { /** Description of the product. */ diff --git a/src/api/types/DeliveryNoteLineItemResource.ts b/src/api/types/DeliveryNoteLineItemResource.ts index 683bb3f..06f00fe 100644 --- a/src/api/types/DeliveryNoteLineItemResource.ts +++ b/src/api/types/DeliveryNoteLineItemResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DeliveryNoteLineItemResource { product: Monite.DeliveryNoteLineItemProduct; diff --git a/src/api/types/DeliveryNoteResource.ts b/src/api/types/DeliveryNoteResource.ts index c8aac1e..9c9687e 100644 --- a/src/api/types/DeliveryNoteResource.ts +++ b/src/api/types/DeliveryNoteResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DeliveryNoteResource { /** Unique ID of the delivery note */ diff --git a/src/api/types/DeliveryNoteResourceEntity.ts b/src/api/types/DeliveryNoteResourceEntity.ts index 4a84cef..e0617c8 100644 --- a/src/api/types/DeliveryNoteResourceEntity.ts +++ b/src/api/types/DeliveryNoteResourceEntity.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Entity that created the delivery note diff --git a/src/api/types/DeliveryNoteResourceList.ts b/src/api/types/DeliveryNoteResourceList.ts index c960a07..9c192bf 100644 --- a/src/api/types/DeliveryNoteResourceList.ts +++ b/src/api/types/DeliveryNoteResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DeliveryNoteResourceList { /** List of delivery notes */ diff --git a/src/api/types/Discount.ts b/src/api/types/Discount.ts index a32b7bc..78828c4 100644 --- a/src/api/types/Discount.ts +++ b/src/api/types/Discount.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface Discount { /** The actual discount of the product in [minor units](https://docs.monite.com/references/currencies#minor-units) if type field equals amount, else in percent minor units */ diff --git a/src/api/types/DiscountResponse.ts b/src/api/types/DiscountResponse.ts new file mode 100644 index 0000000..464b5f8 --- /dev/null +++ b/src/api/types/DiscountResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface DiscountResponse { + /** The actual discount of the product in [minor units](https://docs.monite.com/references/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; + /** The monetary amount of the discount, in [minor units](https://docs.monite.com/references/currencies#minor-units). If the discount `type` is `amount`, this value is the same as the `amount` value. If `type` is `percentage`, the value is the calculated discount amount. */ + value?: number; +} diff --git a/src/api/types/DnsRecord.ts b/src/api/types/DnsRecord.ts index 8fc1edf..81cc2c5 100644 --- a/src/api/types/DnsRecord.ts +++ b/src/api/types/DnsRecord.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DnsRecord { is_active: boolean; diff --git a/src/api/types/DnsRecords.ts b/src/api/types/DnsRecords.ts index dc99156..dbbf1c0 100644 --- a/src/api/types/DnsRecords.ts +++ b/src/api/types/DnsRecords.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DnsRecords { /** Set of DNS settings required by Mailgun for domain verification before emails receiving is possible. */ diff --git a/src/api/types/DocumentIDsSettings.ts b/src/api/types/DocumentIDsSettings.ts index c86aa31..1d4c288 100644 --- a/src/api/types/DocumentIDsSettings.ts +++ b/src/api/types/DocumentIDsSettings.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DocumentIDsSettings { /** Prefixes for each document_type. */ diff --git a/src/api/types/DocumentIDsSettingsRequest.ts b/src/api/types/DocumentIDsSettingsRequest.ts index f1daa73..dd9c641 100644 --- a/src/api/types/DocumentIDsSettingsRequest.ts +++ b/src/api/types/DocumentIDsSettingsRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DocumentIDsSettingsRequest { /** Prefixes for each document_type. */ diff --git a/src/api/types/DocumentRenderingSettings.ts b/src/api/types/DocumentRenderingSettings.ts index 9bfac81..834fdc9 100644 --- a/src/api/types/DocumentRenderingSettings.ts +++ b/src/api/types/DocumentRenderingSettings.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DocumentRenderingSettings { /** Settings for rendering credit notes in PDF documents. */ diff --git a/src/api/types/DomainListResponse.ts b/src/api/types/DomainListResponse.ts index bdad4b8..cfb7464 100644 --- a/src/api/types/DomainListResponse.ts +++ b/src/api/types/DomainListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface DomainListResponse { data: Monite.DomainResponse[]; diff --git a/src/api/types/DomainResponse.ts b/src/api/types/DomainResponse.ts index 8b47a9b..12102ea 100644 --- a/src/api/types/DomainResponse.ts +++ b/src/api/types/DomainResponse.ts @@ -2,17 +2,21 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; 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; + dns_records: DomainResponse.DnsRecords; /** The domain name. */ domain: string; /** The time the domain was updated for the last time */ last_updated_at?: string; status: string; } + +export namespace DomainResponse { + export type DnsRecords = Monite.DnsRecords | Record; +} diff --git a/src/api/types/DomainResponseDnsRecords.ts b/src/api/types/DomainResponseDnsRecords.ts deleted file mode 100644 index 4bc4f6e..0000000 --- a/src/api/types/DomainResponseDnsRecords.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * 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/EInvoicingRetrieveListData.ts b/src/api/types/EInvoicingRetrieveListData.ts index 4fbe4a1..06fbd6c 100644 --- a/src/api/types/EInvoicingRetrieveListData.ts +++ b/src/api/types/EInvoicingRetrieveListData.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EInvoicingRetrieveListData { /** List of connections for the current page */ diff --git a/src/api/types/EinvoicingAddress.ts b/src/api/types/EinvoicingAddress.ts index 45be8be..6f34e21 100644 --- a/src/api/types/EinvoicingAddress.ts +++ b/src/api/types/EinvoicingAddress.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EinvoicingAddress { /** Street address line 1 */ diff --git a/src/api/types/EinvoicingConnectionResponse.ts b/src/api/types/EinvoicingConnectionResponse.ts index 6ae8764..da6be93 100644 --- a/src/api/types/EinvoicingConnectionResponse.ts +++ b/src/api/types/EinvoicingConnectionResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EinvoicingConnectionResponse { id: string; @@ -16,6 +16,10 @@ export interface EinvoicingConnectionResponse { credentials: Monite.EinvoicingNetworkCredentialsResponse[]; /** ID of the entity */ entity_id: string; + /** Set to `true` if the entity needs to receive e-invoices. */ + is_receiver?: boolean; + /** Set to `true` if the entity needs to send e-invoices. Either `is_sender` or `is_receiver` or both must be `true`. */ + is_sender?: boolean; /** Legal name of the Entity */ legal_name: string; /** ID assigned by integration partner */ diff --git a/src/api/types/EinvoicingNetworkCredentialsResponse.ts b/src/api/types/EinvoicingNetworkCredentialsResponse.ts index 9ec53f0..63e11ac 100644 --- a/src/api/types/EinvoicingNetworkCredentialsResponse.ts +++ b/src/api/types/EinvoicingNetworkCredentialsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EinvoicingNetworkCredentialsResponse { /** ID of the credentials */ diff --git a/src/api/types/EntityAddressResponseSchema.ts b/src/api/types/EntityAddressResponseSchema.ts index fd89523..5e06e61 100644 --- a/src/api/types/EntityAddressResponseSchema.ts +++ b/src/api/types/EntityAddressResponseSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema represents address info of the entity diff --git a/src/api/types/EntityAddressSchema.ts b/src/api/types/EntityAddressSchema.ts index c7ec355..3947651 100644 --- a/src/api/types/EntityAddressSchema.ts +++ b/src/api/types/EntityAddressSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema represents address info of the entity diff --git a/src/api/types/EntityBankAccountPaginationResponse.ts b/src/api/types/EntityBankAccountPaginationResponse.ts index 6f01cd3..da8eac1 100644 --- a/src/api/types/EntityBankAccountPaginationResponse.ts +++ b/src/api/types/EntityBankAccountPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of an entity's bank accounts. diff --git a/src/api/types/EntityBankAccountResponse.ts b/src/api/types/EntityBankAccountResponse.ts index fd7a14d..2932522 100644 --- a/src/api/types/EntityBankAccountResponse.ts +++ b/src/api/types/EntityBankAccountResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents a bank account owned by an entity. diff --git a/src/api/types/EntityFields.ts b/src/api/types/EntityFields.ts index 1f9a1c9..174540c 100644 --- a/src/api/types/EntityFields.ts +++ b/src/api/types/EntityFields.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EntityFields { /** Object describing the required field `tax_id` of an entity */ diff --git a/src/api/types/EntityIndividualResponse.ts b/src/api/types/EntityIndividualResponse.ts index 9af77af..10930e6 100644 --- a/src/api/types/EntityIndividualResponse.ts +++ b/src/api/types/EntityIndividualResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EntityIndividualResponse { /** UUID entity ID */ diff --git a/src/api/types/EntityOnboardingDataResponse.ts b/src/api/types/EntityOnboardingDataResponse.ts index a90ac6a..0295ea5 100644 --- a/src/api/types/EntityOnboardingDataResponse.ts +++ b/src/api/types/EntityOnboardingDataResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EntityOnboardingDataResponse { /** Business information about the entity. */ diff --git a/src/api/types/EntityOrganizationResponse.ts b/src/api/types/EntityOrganizationResponse.ts index f6a8e74..13efec2 100644 --- a/src/api/types/EntityOrganizationResponse.ts +++ b/src/api/types/EntityOrganizationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EntityOrganizationResponse { /** UUID entity ID */ diff --git a/src/api/types/EntityPaginationResponse.ts b/src/api/types/EntityPaginationResponse.ts index f0e4a86..da71339 100644 --- a/src/api/types/EntityPaginationResponse.ts +++ b/src/api/types/EntityPaginationResponse.ts @@ -2,13 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; 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 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; + /** 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 index cb525c8..0c38fee 100644 --- a/src/api/types/EntityResponse.ts +++ b/src/api/types/EntityResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema for a response after creation of an entity of different types diff --git a/src/api/types/EntityUserPaginationResponse.ts b/src/api/types/EntityUserPaginationResponse.ts index 4823d78..c02711e 100644 --- a/src/api/types/EntityUserPaginationResponse.ts +++ b/src/api/types/EntityUserPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EntityUserPaginationResponse { /** array of records */ diff --git a/src/api/types/EntityUserResponse.ts b/src/api/types/EntityUserResponse.ts index 4252613..a3bde04 100644 --- a/src/api/types/EntityUserResponse.ts +++ b/src/api/types/EntityUserResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EntityUserResponse { /** UUID entity user ID */ diff --git a/src/api/types/EntityVatIdResourceList.ts b/src/api/types/EntityVatIdResourceList.ts index 119a299..0a9dc5a 100644 --- a/src/api/types/EntityVatIdResourceList.ts +++ b/src/api/types/EntityVatIdResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EntityVatIdResourceList { data: Monite.EntityVatIdResponse[]; diff --git a/src/api/types/EntityVatIdResponse.ts b/src/api/types/EntityVatIdResponse.ts index 30edb45..1669644 100644 --- a/src/api/types/EntityVatIdResponse.ts +++ b/src/api/types/EntityVatIdResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EntityVatIdResponse { id: string; diff --git a/src/api/types/ErrorSchemaResponse.ts b/src/api/types/ErrorSchemaResponse.ts index c7e8035..b77fd1b 100644 --- a/src/api/types/ErrorSchemaResponse.ts +++ b/src/api/types/ErrorSchemaResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ErrorSchemaResponse { error: Monite.ErrorSchema; diff --git a/src/api/types/ErrorSchemaResponse2.ts b/src/api/types/ErrorSchemaResponse2.ts index 57577bf..eb08c1d 100644 --- a/src/api/types/ErrorSchemaResponse2.ts +++ b/src/api/types/ErrorSchemaResponse2.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ErrorSchemaResponse2 { error: Monite.ErrorSchema2; diff --git a/src/api/types/EstimatedMonthlyRevenue.ts b/src/api/types/EstimatedMonthlyRevenue.ts index 8c3ef05..fb357d7 100644 --- a/src/api/types/EstimatedMonthlyRevenue.ts +++ b/src/api/types/EstimatedMonthlyRevenue.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EstimatedMonthlyRevenue { /** The amount of the monthly revenue, in [minor units](https://docs.monite.com/references/currencies#minor-units). For example, $12.50 is represented as 1250. */ diff --git a/src/api/types/EventPaginationResource.ts b/src/api/types/EventPaginationResource.ts index 5e29d07..919e524 100644 --- a/src/api/types/EventPaginationResource.ts +++ b/src/api/types/EventPaginationResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EventPaginationResource { /** A set of events returned per page */ diff --git a/src/api/types/EventResource.ts b/src/api/types/EventResource.ts index 2a3073f..60408e7 100644 --- a/src/api/types/EventResource.ts +++ b/src/api/types/EventResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EventResource { id: string; diff --git a/src/api/types/EventResourceForWebhookClient.ts b/src/api/types/EventResourceForWebhookClient.ts index b9c1630..7349610 100644 --- a/src/api/types/EventResourceForWebhookClient.ts +++ b/src/api/types/EventResourceForWebhookClient.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface EventResourceForWebhookClient { id: string; diff --git a/src/api/types/ExchangeRate.ts b/src/api/types/ExchangeRate.ts index 7865ff3..15a6018 100644 --- a/src/api/types/ExchangeRate.ts +++ b/src/api/types/ExchangeRate.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ExchangeRate { base: Monite.CurrencyEnum; diff --git a/src/api/types/ExportObjectSchema.ts b/src/api/types/ExportObjectSchema.ts index c13c428..11f93c5 100644 --- a/src/api/types/ExportObjectSchema.ts +++ b/src/api/types/ExportObjectSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type ExportObjectSchema = Monite.ExportObjectSchema.Payable | Monite.ExportObjectSchema.Receivable; diff --git a/src/api/types/ExportPayableSchema.ts b/src/api/types/ExportPayableSchema.ts index b3e3363..f35865d 100644 --- a/src/api/types/ExportPayableSchema.ts +++ b/src/api/types/ExportPayableSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ExportPayableSchema { statuses: Monite.PayableStateEnum[]; diff --git a/src/api/types/ExportReceivableSchema.ts b/src/api/types/ExportReceivableSchema.ts index 0c67067..715b2c3 100644 --- a/src/api/types/ExportReceivableSchema.ts +++ b/src/api/types/ExportReceivableSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ExportReceivableSchema { statuses: Monite.ReceivablesStatusEnum[]; diff --git a/src/api/types/ExtraDataResource.ts b/src/api/types/ExtraDataResource.ts index 7ba0f67..19dc32a 100644 --- a/src/api/types/ExtraDataResource.ts +++ b/src/api/types/ExtraDataResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ExtraDataResource { id: string; diff --git a/src/api/types/ExtraDataResourceList.ts b/src/api/types/ExtraDataResourceList.ts index 5316300..b195dd0 100644 --- a/src/api/types/ExtraDataResourceList.ts +++ b/src/api/types/ExtraDataResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ExtraDataResourceList { data: Monite.ExtraDataResource[]; diff --git a/src/api/types/FileAttachedEventData.ts b/src/api/types/FileAttachedEventData.ts new file mode 100644 index 0000000..d99ee4b --- /dev/null +++ b/src/api/types/FileAttachedEventData.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface FileAttachedEventData { + file_name: string; + file_size: number; + url: string; +} diff --git a/src/api/types/FileSchema.ts b/src/api/types/FileSchema.ts index d0eeb25..e913fc7 100644 --- a/src/api/types/FileSchema.ts +++ b/src/api/types/FileSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents a file (such as a PDF invoice) that was uploaded to Monite. diff --git a/src/api/types/FileSchema2.ts b/src/api/types/FileSchema2.ts index 5fc8653..da4b0e5 100644 --- a/src/api/types/FileSchema2.ts +++ b/src/api/types/FileSchema2.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents a file (such as a PDF invoice) that was uploaded to Monite. diff --git a/src/api/types/FileSchema3.ts b/src/api/types/FileSchema3.ts index 8d9ab8b..8eedb71 100644 --- a/src/api/types/FileSchema3.ts +++ b/src/api/types/FileSchema3.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents a file (such as a PDF invoice) that was uploaded to Monite. diff --git a/src/api/types/FilesResponse.ts b/src/api/types/FilesResponse.ts index af04336..3d23f9b 100644 --- a/src/api/types/FilesResponse.ts +++ b/src/api/types/FilesResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface FilesResponse { data: Monite.FileResponse[]; diff --git a/src/api/types/FinancingInvoice.ts b/src/api/types/FinancingInvoice.ts index b2a5c5c..b19e693 100644 --- a/src/api/types/FinancingInvoice.ts +++ b/src/api/types/FinancingInvoice.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface FinancingInvoice { /** The type of the invoice i.e. receivable or payable. */ diff --git a/src/api/types/FinancingInvoiceListResponse.ts b/src/api/types/FinancingInvoiceListResponse.ts index a4c7344..df0ed45 100644 --- a/src/api/types/FinancingInvoiceListResponse.ts +++ b/src/api/types/FinancingInvoiceListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface FinancingInvoiceListResponse { /** A list of invoices requested for financing. */ diff --git a/src/api/types/FinancingOffer.ts b/src/api/types/FinancingOffer.ts index e2b03ed..5fdaa63 100644 --- a/src/api/types/FinancingOffer.ts +++ b/src/api/types/FinancingOffer.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface FinancingOffer { /** The status of the financing offer. */ diff --git a/src/api/types/FinancingOffersResponse.ts b/src/api/types/FinancingOffersResponse.ts index d45662a..e5cbdba 100644 --- a/src/api/types/FinancingOffersResponse.ts +++ b/src/api/types/FinancingOffersResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface FinancingOffersResponse { /** A list of financing offers extended to the business. */ diff --git a/src/api/types/FinancingPushInvoicesRequestInvoice.ts b/src/api/types/FinancingPushInvoicesRequestInvoice.ts index aac108b..8202ad8 100644 --- a/src/api/types/FinancingPushInvoicesRequestInvoice.ts +++ b/src/api/types/FinancingPushInvoicesRequestInvoice.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface FinancingPushInvoicesRequestInvoice { /** The invoice ID. */ diff --git a/src/api/types/GetAllPaymentReminders.ts b/src/api/types/GetAllPaymentReminders.ts index 35bd0d1..ec73eba 100644 --- a/src/api/types/GetAllPaymentReminders.ts +++ b/src/api/types/GetAllPaymentReminders.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface GetAllPaymentReminders { data: Monite.PaymentReminderResponse[]; diff --git a/src/api/types/GetAllRecurrences.ts b/src/api/types/GetAllRecurrences.ts deleted file mode 100644 index 6f8dae7..0000000 --- a/src/api/types/GetAllRecurrences.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 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 index f470060..24b2aa9 100644 --- a/src/api/types/GetOnboardingRequirementsResponse.ts +++ b/src/api/types/GetOnboardingRequirementsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface GetOnboardingRequirementsResponse { data: Monite.SingleOnboardingRequirementsResponse[]; diff --git a/src/api/types/HttpValidationError.ts b/src/api/types/HttpValidationError.ts index 1d0e607..2f18edc 100644 --- a/src/api/types/HttpValidationError.ts +++ b/src/api/types/HttpValidationError.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface HttpValidationError { detail?: Monite.ValidationError[]; diff --git a/src/api/types/InlinePaymentTermsRequestPayload.ts b/src/api/types/InlinePaymentTermsRequestPayload.ts new file mode 100644 index 0000000..30df173 --- /dev/null +++ b/src/api/types/InlinePaymentTermsRequestPayload.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface InlinePaymentTermsRequestPayload { + /** The first tier of the payment term. Represents the terms of the first early discount. */ + term_1?: Monite.InlineTermDiscount; + /** The second tier of the payment term. Defines the terms of the second early discount. */ + term_2?: Monite.InlineTermDiscount; + /** The final tier of the payment term. Defines the invoice due date. */ + term_final: Monite.InlineTermFinal; +} diff --git a/src/api/types/PaymentTermDiscountWithDate.ts b/src/api/types/InlineTermDiscount.ts similarity index 78% rename from src/api/types/PaymentTermDiscountWithDate.ts rename to src/api/types/InlineTermDiscount.ts index 993aa7a..9897fa4 100644 --- a/src/api/types/PaymentTermDiscountWithDate.ts +++ b/src/api/types/InlineTermDiscount.ts @@ -2,10 +2,10 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface PaymentTermDiscountWithDate { +export interface InlineTermDiscount { /** 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; + number_of_days?: number; } diff --git a/src/api/types/TermFinalWithDate.ts b/src/api/types/InlineTermFinal.ts similarity index 70% rename from src/api/types/TermFinalWithDate.ts rename to src/api/types/InlineTermFinal.ts index 1cf6acc..0258e27 100644 --- a/src/api/types/TermFinalWithDate.ts +++ b/src/api/types/InlineTermFinal.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface TermFinalWithDate { +export interface InlineTermFinal { end_date?: string; /** The amount of days after the invoice issue date. */ - number_of_days: number; + number_of_days?: number; } diff --git a/src/api/types/Invoice.ts b/src/api/types/Invoice.ts index 1b5130e..178a66f 100644 --- a/src/api/types/Invoice.ts +++ b/src/api/types/Invoice.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface Invoice { due_date?: string; diff --git a/src/api/types/InvoiceResponsePayload.ts b/src/api/types/InvoiceResponsePayload.ts index f352d1b..9e20b74 100644 --- a/src/api/types/InvoiceResponsePayload.ts +++ b/src/api/types/InvoiceResponsePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface InvoiceResponsePayload { id: string; @@ -43,7 +43,7 @@ export interface InvoiceResponsePayload { /** The VAT/TAX ID of the counterpart. */ counterpart_tax_id?: string; /** The type of the counterpart. */ - counterpart_type: Monite.ReceivableCounterpartType; + counterpart_type: Monite.CounterpartType; counterpart_vat_id?: Monite.ReceivableCounterpartVatIdResponse; /** The currency used in the receivable. */ currency: Monite.CurrencyEnum; @@ -52,7 +52,7 @@ export interface InvoiceResponsePayload { /** A note with additional information about a tax deduction */ deduction_memo?: string; /** The discount for a receivable. */ - discount?: Monite.Discount; + discount?: Monite.DiscountResponse; /** Total price of the receivable with discounts before taxes [minor units](https://docs.monite.com/references/currencies#minor-units). */ discounted_subtotal?: number; /** The sequential code systematically assigned to invoices. */ diff --git a/src/api/types/InvoiceResponsePayloadEntity.ts b/src/api/types/InvoiceResponsePayloadEntity.ts index 9864ac0..a9c7c42 100644 --- a/src/api/types/InvoiceResponsePayloadEntity.ts +++ b/src/api/types/InvoiceResponsePayloadEntity.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type InvoiceResponsePayloadEntity = | Monite.InvoiceResponsePayloadEntity.Organization diff --git a/src/api/types/Item.ts b/src/api/types/Item.ts index 62ca8cc..72c5168 100644 --- a/src/api/types/Item.ts +++ b/src/api/types/Item.ts @@ -6,9 +6,9 @@ * 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; + /** The text as recognized by OCR. */ + text: string; } diff --git a/src/api/types/IterationStatus.ts b/src/api/types/IterationStatus.ts index 97cace3..3ab5a97 100644 --- a/src/api/types/IterationStatus.ts +++ b/src/api/types/IterationStatus.ts @@ -2,11 +2,12 @@ * This file was auto-generated by Fern from our API Definition. */ -export type IterationStatus = "pending" | "completed" | "canceled" | "issue_failed" | "send_failed"; +export type IterationStatus = "pending" | "completed" | "canceled" | "skipped" | "issue_failed" | "send_failed"; export const IterationStatus = { Pending: "pending", Completed: "completed", Canceled: "canceled", + Skipped: "skipped", IssueFailed: "issue_failed", SendFailed: "send_failed", } as const; diff --git a/src/api/types/LabelNValue.ts b/src/api/types/LabelNValue.ts index ef7f7e8..f12f831 100644 --- a/src/api/types/LabelNValue.ts +++ b/src/api/types/LabelNValue.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A label-value pair extracted from an uploaded document by OCR. diff --git a/src/api/types/LedgerAccountListResponse.ts b/src/api/types/LedgerAccountListResponse.ts index ce31d69..38cf2b8 100644 --- a/src/api/types/LedgerAccountListResponse.ts +++ b/src/api/types/LedgerAccountListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of ledger accounts. diff --git a/src/api/types/LedgerAccountResponse.ts b/src/api/types/LedgerAccountResponse.ts index dad0ec2..6fcab68 100644 --- a/src/api/types/LedgerAccountResponse.ts +++ b/src/api/types/LedgerAccountResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents a general ledger account retrieved from an accounting system. diff --git a/src/api/types/LineItem.ts b/src/api/types/LineItem.ts index b31ff4d..a2ce9b2 100644 --- a/src/api/types/LineItem.ts +++ b/src/api/types/LineItem.ts @@ -2,11 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItem { /** ID of the tax rate in the connected accounting system, to be used when pushing the invoice to that accounting system. Use `GET /accounting_tax_rates` to get these IDs. If omitted, Monite will attempt to match the tax rates based on their numeric value. */ accounting_tax_rate_id?: string; + /** Unique identifier of the user-defined vat rate object. */ + custom_vat_rate_id?: string; /** The discount for a product. */ discount?: Monite.Discount; /** Object of product. Can be used instead of product_id, created in product's catalog */ @@ -15,6 +17,8 @@ export interface LineItem { product_id?: string; /** The quantity of each of the goods, materials, or services listed in the receivable. */ quantity: number; + /** Specifies the display name of the tax rate. This field is applicable only when tax_rate_value is also provided. */ + tax_rate_name?: string; /** 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. */ diff --git a/src/api/types/LineItemFields.ts b/src/api/types/LineItemFields.ts index 54e5e5c..528f5ad 100644 --- a/src/api/types/LineItemFields.ts +++ b/src/api/types/LineItemFields.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItemFields { /** Object describing the required field `measure_unit` of a line item's product */ diff --git a/src/api/types/LineItemPaginationResponse.ts b/src/api/types/LineItemPaginationResponse.ts index 62941c4..efd2550 100644 --- a/src/api/types/LineItemPaginationResponse.ts +++ b/src/api/types/LineItemPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItemPaginationResponse { data: Monite.LineItemResponse[]; diff --git a/src/api/types/LineItemProduct.ts b/src/api/types/LineItemProduct.ts index 2c81704..42ed0d2 100644 --- a/src/api/types/LineItemProduct.ts +++ b/src/api/types/LineItemProduct.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItemProduct { /** Unique ID of the product. */ @@ -11,6 +11,8 @@ export interface LineItemProduct { accounting_tax_rate_id?: string; /** Description of the product. */ description?: string; + /** A user-defined identifier of the product. For example, an internal product code or SKU (stock keeping unit). Client applications can use this field to map the products in Monite to an external product catalog. */ + external_reference?: string; /** Indicates whether the product is inline */ is_inline?: boolean; ledger_account_id?: string; diff --git a/src/api/types/LineItemProductCreate.ts b/src/api/types/LineItemProductCreate.ts index 80ee218..0d3081f 100644 --- a/src/api/types/LineItemProductCreate.ts +++ b/src/api/types/LineItemProductCreate.ts @@ -2,11 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItemProductCreate { /** Description of the product. */ description?: string; + /** A user-defined identifier of the product. For example, an internal product code or SKU (stock keeping unit). Client applications can use this field to map the products in Monite to an external product catalog. */ + external_reference?: string; ledger_account_id?: string; measure_unit?: Monite.UnitRequest; /** Name of the product. */ diff --git a/src/api/types/LineItemProductVatRate.ts b/src/api/types/LineItemProductVatRate.ts index e7aab1a..a486737 100644 --- a/src/api/types/LineItemProductVatRate.ts +++ b/src/api/types/LineItemProductVatRate.ts @@ -2,13 +2,19 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItemProductVatRate { /** Unique identifier of the vat rate object. */ id?: string; + /** Sub-taxes included in the VAT. */ + components?: Monite.VatRateComponent[]; /** Two-letter ISO country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). */ country: Monite.AllowedCountries; + /** Indicates whether this vat rate is defined by user. */ + is_custom?: boolean; + /** Display name of the vat rate. */ + name?: string; /** Percent minor units. Example: 12.5% is 1250. */ value: number; } diff --git a/src/api/types/LineItemUpdate.ts b/src/api/types/LineItemUpdate.ts index e09b90b..e621544 100644 --- a/src/api/types/LineItemUpdate.ts +++ b/src/api/types/LineItemUpdate.ts @@ -2,15 +2,19 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItemUpdate { + /** Unique identifier of the user-defined vat rate object. */ + custom_vat_rate_id?: string; /** The discount for a product. */ discount?: Monite.Discount; /** The actual price of the product in [minor units](https://docs.monite.com/references/currencies#minor-units). */ price?: number; /** The quantity of each of the goods, materials, or services listed in the receivable. */ quantity?: number; + /** Specifies the display name of the tax rate. This field is applicable only when tax_rate_value is also provided. */ + tax_rate_name?: string; /** 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. */ diff --git a/src/api/types/LineItemsReplaceResponse.ts b/src/api/types/LineItemsReplaceResponse.ts index 02abd24..db3afd3 100644 --- a/src/api/types/LineItemsReplaceResponse.ts +++ b/src/api/types/LineItemsReplaceResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItemsReplaceResponse { data: Monite.LineItemResponse[]; diff --git a/src/api/types/LineItemsResponse.ts b/src/api/types/LineItemsResponse.ts index 0dd2915..3f7b9e0 100644 --- a/src/api/types/LineItemsResponse.ts +++ b/src/api/types/LineItemsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface LineItemsResponse { data: Monite.ResponseItem[]; diff --git a/src/api/types/MailSentEventData.ts b/src/api/types/MailSentEventData.ts index 5216bdf..055b9e2 100644 --- a/src/api/types/MailSentEventData.ts +++ b/src/api/types/MailSentEventData.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Contains information about a sent email. diff --git a/src/api/types/MailboxDataResponse.ts b/src/api/types/MailboxDataResponse.ts index 8036e87..047aca9 100644 --- a/src/api/types/MailboxDataResponse.ts +++ b/src/api/types/MailboxDataResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface MailboxDataResponse { data?: Monite.MailboxResponse[]; diff --git a/src/api/types/MissingFields.ts b/src/api/types/MissingFields.ts index 6b8f151..9569361 100644 --- a/src/api/types/MissingFields.ts +++ b/src/api/types/MissingFields.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface MissingFields { /** Missing fields of counterpart. */ diff --git a/src/api/types/MoniteAllPaymentMethods.ts b/src/api/types/MoniteAllPaymentMethods.ts index 7aed24b..ae52688 100644 --- a/src/api/types/MoniteAllPaymentMethods.ts +++ b/src/api/types/MoniteAllPaymentMethods.ts @@ -16,7 +16,9 @@ export type MoniteAllPaymentMethods = | "SEPA Direct Debit" | "SOFORT" | "Apple Pay" - | "Google Pay"; + | "Google Pay" + | "Affirm" + | "Klarna"; export const MoniteAllPaymentMethods = { SepaPayments: "SEPA Payments", UsAchPayments: "US ACH Payments", @@ -32,4 +34,6 @@ export const MoniteAllPaymentMethods = { Sofort: "SOFORT", ApplePay: "Apple Pay", GooglePay: "Google Pay", + Affirm: "Affirm", + Klarna: "Klarna", } as const; diff --git a/src/api/types/MoniteAllPaymentMethodsTypes.ts b/src/api/types/MoniteAllPaymentMethodsTypes.ts index 2fe7f6f..9b81af1 100644 --- a/src/api/types/MoniteAllPaymentMethodsTypes.ts +++ b/src/api/types/MoniteAllPaymentMethodsTypes.ts @@ -16,7 +16,9 @@ export type MoniteAllPaymentMethodsTypes = | "sepa_debit" | "sofort" | "applepay" - | "googlepay"; + | "googlepay" + | "affirm" + | "klarna"; export const MoniteAllPaymentMethodsTypes = { SepaCredit: "sepa_credit", UsAch: "us_ach", @@ -32,4 +34,6 @@ export const MoniteAllPaymentMethodsTypes = { Sofort: "sofort", Applepay: "applepay", Googlepay: "googlepay", + Affirm: "affirm", + Klarna: "klarna", } as const; diff --git a/src/api/types/OcrAddress.ts b/src/api/types/OcrAddress.ts index 428cb79..be0ca65 100644 --- a/src/api/types/OcrAddress.ts +++ b/src/api/types/OcrAddress.ts @@ -8,18 +8,18 @@ * * There is an additional field original_country_name */ export interface OcrAddress { + /** 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?: string; + /** Street address. */ + line1?: string; + /** Additional address information (if any). */ + line2?: 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/OcrAddressDetails.ts b/src/api/types/OcrAddressDetails.ts index 843beaa..8567b0c 100644 --- a/src/api/types/OcrAddressDetails.ts +++ b/src/api/types/OcrAddressDetails.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OcrAddressDetails { street_and_number?: string; diff --git a/src/api/types/OcrCounterpartDetails.ts b/src/api/types/OcrCounterpartDetails.ts index d748aa8..2887e84 100644 --- a/src/api/types/OcrCounterpartDetails.ts +++ b/src/api/types/OcrCounterpartDetails.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OcrCounterpartDetails { vat_number?: string; diff --git a/src/api/types/OcrCreditNote.ts b/src/api/types/OcrCreditNote.ts index 077fac8..1dbe8d7 100644 --- a/src/api/types/OcrCreditNote.ts +++ b/src/api/types/OcrCreditNote.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OcrCreditNote { document_number?: string; diff --git a/src/api/types/OcrDocumentTypeEnum.ts b/src/api/types/OcrDocumentTypeEnum.ts index 1763587..4052212 100644 --- a/src/api/types/OcrDocumentTypeEnum.ts +++ b/src/api/types/OcrDocumentTypeEnum.ts @@ -2,20 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -export type OcrDocumentTypeEnum = - | "quote" - | "invoice" - | "credit_note" - | "discount_reminder" - | "final_reminder" - | "payables_purchase_order" - | "overdue_reminder"; +export type OcrDocumentTypeEnum = "invoice" | "credit_note" | "receipt"; export const OcrDocumentTypeEnum = { - Quote: "quote", Invoice: "invoice", CreditNote: "credit_note", - DiscountReminder: "discount_reminder", - FinalReminder: "final_reminder", - PayablesPurchaseOrder: "payables_purchase_order", - OverdueReminder: "overdue_reminder", + Receipt: "receipt", } as const; diff --git a/src/api/types/OcrInvoice.ts b/src/api/types/OcrInvoice.ts index 38b7122..6098b62 100644 --- a/src/api/types/OcrInvoice.ts +++ b/src/api/types/OcrInvoice.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OcrInvoice { currency?: Monite.CurrencyEnum; diff --git a/src/api/types/OcrReceipt.ts b/src/api/types/OcrReceipt.ts index af571a2..6824886 100644 --- a/src/api/types/OcrReceipt.ts +++ b/src/api/types/OcrReceipt.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OcrReceipt { document_number?: string; diff --git a/src/api/types/OcrRecognitionResponse.ts b/src/api/types/OcrRecognitionResponse.ts index 19f316a..c43ea28 100644 --- a/src/api/types/OcrRecognitionResponse.ts +++ b/src/api/types/OcrRecognitionResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Contains information about all text blocks extracted from an uploaded invoice by OCR. diff --git a/src/api/types/OcrResponseInvoiceReceiptData.ts b/src/api/types/OcrResponseInvoiceReceiptData.ts index 4639d8c..494b0f7 100644 --- a/src/api/types/OcrResponseInvoiceReceiptData.ts +++ b/src/api/types/OcrResponseInvoiceReceiptData.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OcrResponseInvoiceReceiptData { type?: "invoice"; diff --git a/src/api/types/OcrTaskResponseSchema.ts b/src/api/types/OcrTaskResponseSchema.ts index a657ca7..0af68c3 100644 --- a/src/api/types/OcrTaskResponseSchema.ts +++ b/src/api/types/OcrTaskResponseSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OcrTaskResponseSchema { id: string; diff --git a/src/api/types/OcrTaskResponseSchemaRecognizedData.ts b/src/api/types/OcrTaskResponseSchemaRecognizedData.ts index ca3e0f0..6aa233a 100644 --- a/src/api/types/OcrTaskResponseSchemaRecognizedData.ts +++ b/src/api/types/OcrTaskResponseSchemaRecognizedData.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type OcrTaskResponseSchemaRecognizedData = | Monite.OcrTaskResponseSchemaRecognizedData.Invoice diff --git a/src/api/types/OcrTasksPaginationResponse.ts b/src/api/types/OcrTasksPaginationResponse.ts index c4c8aab..2b14d60 100644 --- a/src/api/types/OcrTasksPaginationResponse.ts +++ b/src/api/types/OcrTasksPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of ocr requests. diff --git a/src/api/types/OnboardingLinkResponse.ts b/src/api/types/OnboardingLinkResponse.ts index 974794b..13e271e 100644 --- a/src/api/types/OnboardingLinkResponse.ts +++ b/src/api/types/OnboardingLinkResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OnboardingLinkResponse { id: string; diff --git a/src/api/types/OnboardingPaymentMethodsResponse.ts b/src/api/types/OnboardingPaymentMethodsResponse.ts index 63283dc..4509829 100644 --- a/src/api/types/OnboardingPaymentMethodsResponse.ts +++ b/src/api/types/OnboardingPaymentMethodsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OnboardingPaymentMethodsResponse { data: Monite.PaymentMethod[]; diff --git a/src/api/types/OnboardingRequirementsResponse.ts b/src/api/types/OnboardingRequirementsResponse.ts index 7787991..b0adac6 100644 --- a/src/api/types/OnboardingRequirementsResponse.ts +++ b/src/api/types/OnboardingRequirementsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OnboardingRequirementsResponse { disabled_reason?: Monite.AccountDisabledReason; diff --git a/src/api/types/OptionalOrganizationSchema.ts b/src/api/types/OptionalOrganizationSchema.ts index cb749cc..8343bc8 100644 --- a/src/api/types/OptionalOrganizationSchema.ts +++ b/src/api/types/OptionalOrganizationSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema contains metadata for updating an organization diff --git a/src/api/types/OptionalPersonAddressRequest.ts b/src/api/types/OptionalPersonAddressRequest.ts index fb0c76f..af475f3 100644 --- a/src/api/types/OptionalPersonAddressRequest.ts +++ b/src/api/types/OptionalPersonAddressRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OptionalPersonAddressRequest { /** City, district, suburb, town, or village */ diff --git a/src/api/types/OrganizationResponseSchema.ts b/src/api/types/OrganizationResponseSchema.ts index 5509d6b..acb3338 100644 --- a/src/api/types/OrganizationResponseSchema.ts +++ b/src/api/types/OrganizationResponseSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Contains data specific to entities of the `organization` type. diff --git a/src/api/types/OrganizationSchema.ts b/src/api/types/OrganizationSchema.ts index ff12de9..77287c7 100644 --- a/src/api/types/OrganizationSchema.ts +++ b/src/api/types/OrganizationSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema contains metadata for an organization diff --git a/src/api/types/OverdueReminderResponse.ts b/src/api/types/OverdueReminderResponse.ts index 175268b..43bc19e 100644 --- a/src/api/types/OverdueReminderResponse.ts +++ b/src/api/types/OverdueReminderResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface OverdueReminderResponse { id: string; diff --git a/src/api/types/PartnerProjectSettingsPayloadOutput.ts b/src/api/types/PartnerProjectSettingsPayloadOutput.ts index 0b206f9..1f42a9a 100644 --- a/src/api/types/PartnerProjectSettingsPayloadOutput.ts +++ b/src/api/types/PartnerProjectSettingsPayloadOutput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PartnerProjectSettingsPayloadOutput { /** Custom currency exchange rates. */ diff --git a/src/api/types/PayableActionSchema.ts b/src/api/types/PayableActionSchema.ts index 4b41b73..95e9e65 100644 --- a/src/api/types/PayableActionSchema.ts +++ b/src/api/types/PayableActionSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableActionSchema { /** Action name */ diff --git a/src/api/types/PayableAggregatedDataResponse.ts b/src/api/types/PayableAggregatedDataResponse.ts index 9644954..809b808 100644 --- a/src/api/types/PayableAggregatedDataResponse.ts +++ b/src/api/types/PayableAggregatedDataResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableAggregatedDataResponse { /** The total count of payables across all statuses. */ diff --git a/src/api/types/PayableAggregatedItem.ts b/src/api/types/PayableAggregatedItem.ts index a7e2224..cc50f93 100644 --- a/src/api/types/PayableAggregatedItem.ts +++ b/src/api/types/PayableAggregatedItem.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableAggregatedItem { /** The total count of payables with this specific status. */ diff --git a/src/api/types/PayableAnalyticsResponse.ts b/src/api/types/PayableAnalyticsResponse.ts index d455957..2950efa 100644 --- a/src/api/types/PayableAnalyticsResponse.ts +++ b/src/api/types/PayableAnalyticsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableAnalyticsResponse { data: Monite.AnalyticsDataPoint[]; diff --git a/src/api/types/PayableCreatedEventData.ts b/src/api/types/PayableCreatedEventData.ts new file mode 100644 index 0000000..57457eb --- /dev/null +++ b/src/api/types/PayableCreatedEventData.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface PayableCreatedEventData { + payable_source: Monite.PayableOriginEnum; +} diff --git a/src/api/types/PayableCreditNoteLinkedEventData.ts b/src/api/types/PayableCreditNoteLinkedEventData.ts new file mode 100644 index 0000000..7744b78 --- /dev/null +++ b/src/api/types/PayableCreditNoteLinkedEventData.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PayableCreditNoteLinkedEventData { + credit_note_document_id?: string; + credit_note_id: string; +} diff --git a/src/api/types/PayableCreditNoteUnlinkedEventData.ts b/src/api/types/PayableCreditNoteUnlinkedEventData.ts new file mode 100644 index 0000000..9149574 --- /dev/null +++ b/src/api/types/PayableCreditNoteUnlinkedEventData.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PayableCreditNoteUnlinkedEventData { + credit_note_document_id?: string; + credit_note_id: string; +} diff --git a/src/api/types/PayableEntityAddressSchema.ts b/src/api/types/PayableEntityAddressSchema.ts index 88af7f7..cdd1266 100644 --- a/src/api/types/PayableEntityAddressSchema.ts +++ b/src/api/types/PayableEntityAddressSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema represents address info of the entity diff --git a/src/api/types/PayableEntityIndividualResponse.ts b/src/api/types/PayableEntityIndividualResponse.ts index c6a17d4..a4bb32a 100644 --- a/src/api/types/PayableEntityIndividualResponse.ts +++ b/src/api/types/PayableEntityIndividualResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A base for an entity response schema diff --git a/src/api/types/PayableEntityOrganizationResponse.ts b/src/api/types/PayableEntityOrganizationResponse.ts index 2955371..3ecb67b 100644 --- a/src/api/types/PayableEntityOrganizationResponse.ts +++ b/src/api/types/PayableEntityOrganizationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A base for an entity response schema diff --git a/src/api/types/ValidationErrorLocItem.ts b/src/api/types/PayableHistoryCursorFields.ts similarity index 57% rename from src/api/types/ValidationErrorLocItem.ts rename to src/api/types/PayableHistoryCursorFields.ts index c97f7db..68bc601 100644 --- a/src/api/types/ValidationErrorLocItem.ts +++ b/src/api/types/PayableHistoryCursorFields.ts @@ -2,4 +2,4 @@ * This file was auto-generated by Fern from our API Definition. */ -export type ValidationErrorLocItem = string | number; +export type PayableHistoryCursorFields = "timestamp"; diff --git a/src/api/types/PayableHistoryEventTypeEnum.ts b/src/api/types/PayableHistoryEventTypeEnum.ts new file mode 100644 index 0000000..7b4899b --- /dev/null +++ b/src/api/types/PayableHistoryEventTypeEnum.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PayableHistoryEventTypeEnum = + | "status_changed" + | "payable_created" + | "payable_updated" + | "credit_note_linked" + | "credit_note_unlinked" + | "file_attached"; +export const PayableHistoryEventTypeEnum = { + StatusChanged: "status_changed", + PayableCreated: "payable_created", + PayableUpdated: "payable_updated", + CreditNoteLinked: "credit_note_linked", + CreditNoteUnlinked: "credit_note_unlinked", + FileAttached: "file_attached", +} as const; diff --git a/src/api/types/PayableHistoryPaginationResponse.ts b/src/api/types/PayableHistoryPaginationResponse.ts new file mode 100644 index 0000000..fef9979 --- /dev/null +++ b/src/api/types/PayableHistoryPaginationResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +/** + * A paginated list of change history records. + */ +export interface PayableHistoryPaginationResponse { + data: Monite.PayableHistoryResponse[]; + /** 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/PayableHistoryResponse.ts b/src/api/types/PayableHistoryResponse.ts new file mode 100644 index 0000000..d25834a --- /dev/null +++ b/src/api/types/PayableHistoryResponse.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface PayableHistoryResponse { + /** A unique ID of the history record. */ + id: string; + /** ID of the entity user who made the change or trigger the event, or `null` if it was done by using a partner access token. */ + entity_user_id?: string; + /** An object containing additional information about the event or change. The object structure varies based on the `event_type`. */ + event_data: PayableHistoryResponse.EventData; + /** The type of the event or change. */ + event_type: Monite.PayableHistoryEventTypeEnum; + /** ID of the payable document that was changed or triggered an event. */ + payable_id: string; + /** UTC date and time when the event or change occurred. */ + timestamp: string; +} + +export namespace PayableHistoryResponse { + /** + * An object containing additional information about the event or change. The object structure varies based on the `event_type`. + */ + export type EventData = + | Monite.PayableStatusChangedEventData + | Monite.PayableUpdatedEventData + | Monite.PayableCreatedEventData + | Monite.PayableCreditNoteLinkedEventData + | Monite.PayableCreditNoteUnlinkedEventData + | Monite.FileAttachedEventData; +} diff --git a/src/api/types/PayableOrganizationSchema.ts b/src/api/types/PayableOrganizationSchema.ts index be3bbaf..fe844fc 100644 --- a/src/api/types/PayableOrganizationSchema.ts +++ b/src/api/types/PayableOrganizationSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema contains metadata for an organization diff --git a/src/api/types/PayablePaginationResponse.ts b/src/api/types/PayablePaginationResponse.ts index 4d457cd..60457d0 100644 --- a/src/api/types/PayablePaginationResponse.ts +++ b/src/api/types/PayablePaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of payables. diff --git a/src/api/types/PayablePaymentTermsCreatePayload.ts b/src/api/types/PayablePaymentTermsCreatePayload.ts index 3c9e357..d6dec5d 100644 --- a/src/api/types/PayablePaymentTermsCreatePayload.ts +++ b/src/api/types/PayablePaymentTermsCreatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayablePaymentTermsCreatePayload { description?: string; diff --git a/src/api/types/PayableResponseSchema.ts b/src/api/types/PayableResponseSchema.ts index 98a9fa9..074b37e 100644 --- a/src/api/types/PayableResponseSchema.ts +++ b/src/api/types/PayableResponseSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents an Accounts Payable document received from a vendor or supplier. @@ -66,7 +66,7 @@ export interface PayableResponseSchema { /** 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; + other_extracted_data?: PayableResponseSchema.OtherExtractedData; /** The date by which the payable was paid */ paid_at?: string; /** Metadata for partner needs */ @@ -101,3 +101,10 @@ export interface PayableResponseSchema { total_amount_with_credit_notes?: number; was_created_by_user_id?: string; } + +export namespace PayableResponseSchema { + /** + * Data extracted from the uploaded payable by OCR. + */ + export type OtherExtractedData = Monite.OcrResponseInvoiceReceiptData | Monite.OcrRecognitionResponse; +} diff --git a/src/api/types/PayableResponseSchemaOtherExtractedData.ts b/src/api/types/PayableResponseSchemaOtherExtractedData.ts deleted file mode 100644 index 1d077f9..0000000 --- a/src/api/types/PayableResponseSchemaOtherExtractedData.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * 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/PayableSchemaInput.ts b/src/api/types/PayableSchemaInput.ts index c9844df..8515c0a 100644 --- a/src/api/types/PayableSchemaInput.ts +++ b/src/api/types/PayableSchemaInput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableSchemaInput { /** List of actions */ diff --git a/src/api/types/PayableSchemaOutput.ts b/src/api/types/PayableSchemaOutput.ts index aaff19f..d4d34c0 100644 --- a/src/api/types/PayableSchemaOutput.ts +++ b/src/api/types/PayableSchemaOutput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableSchemaOutput { /** List of actions */ diff --git a/src/api/types/PayableStatusChangedEventData.ts b/src/api/types/PayableStatusChangedEventData.ts new file mode 100644 index 0000000..673e3bf --- /dev/null +++ b/src/api/types/PayableStatusChangedEventData.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface PayableStatusChangedEventData { + new_status: Monite.PayableStateEnum; + old_status: Monite.PayableStateEnum; +} diff --git a/src/api/types/PayableTemplatesVariablesObject.ts b/src/api/types/PayableTemplatesVariablesObject.ts index d3b69fa..5b2333b 100644 --- a/src/api/types/PayableTemplatesVariablesObject.ts +++ b/src/api/types/PayableTemplatesVariablesObject.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableTemplatesVariablesObject { object_subtype: Monite.PayablesVariableType; diff --git a/src/api/types/PayableTemplatesVariablesObjectList.ts b/src/api/types/PayableTemplatesVariablesObjectList.ts index 677403c..ae61931 100644 --- a/src/api/types/PayableTemplatesVariablesObjectList.ts +++ b/src/api/types/PayableTemplatesVariablesObjectList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableTemplatesVariablesObjectList { data: Monite.PayableTemplatesVariablesObject[]; diff --git a/src/api/resources/entities/client/requests/EntityLogoUploadRequest.ts b/src/api/types/PayableUpdatedEventData.ts similarity index 50% rename from src/api/resources/entities/client/requests/EntityLogoUploadRequest.ts rename to src/api/types/PayableUpdatedEventData.ts index 8c638b6..a79a527 100644 --- a/src/api/resources/entities/client/requests/EntityLogoUploadRequest.ts +++ b/src/api/types/PayableUpdatedEventData.ts @@ -2,8 +2,4 @@ * This file was auto-generated by Fern from our API Definition. */ -/** - * @example - * {} - */ -export interface EntityLogoUploadRequest {} +export interface PayableUpdatedEventData {} diff --git a/src/api/types/PayableValidationsResource.ts b/src/api/types/PayableValidationsResource.ts index f4cf235..c970305 100644 --- a/src/api/types/PayableValidationsResource.ts +++ b/src/api/types/PayableValidationsResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayableValidationsResource { required_fields: Monite.PayablesFieldsAllowedForValidate[]; diff --git a/src/api/types/PayerAccountResponse.ts b/src/api/types/PayerAccountResponse.ts index 9d11b83..34ae69c 100644 --- a/src/api/types/PayerAccountResponse.ts +++ b/src/api/types/PayerAccountResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PayerAccountResponse { /** ID of a payment account */ diff --git a/src/api/types/PaymentAccountObject.ts b/src/api/types/PaymentAccountObject.ts index edf6422..04d0247 100644 --- a/src/api/types/PaymentAccountObject.ts +++ b/src/api/types/PaymentAccountObject.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentAccountObject { /** ID of a payment account */ diff --git a/src/api/types/PaymentIntent.ts b/src/api/types/PaymentIntent.ts index 3f14e42..5c9f8e2 100644 --- a/src/api/types/PaymentIntent.ts +++ b/src/api/types/PaymentIntent.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentIntent { id: string; diff --git a/src/api/types/PaymentIntentHistoryResponse.ts b/src/api/types/PaymentIntentHistoryResponse.ts index 850a989..693c96f 100644 --- a/src/api/types/PaymentIntentHistoryResponse.ts +++ b/src/api/types/PaymentIntentHistoryResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentIntentHistoryResponse { /** Payment intent history */ diff --git a/src/api/types/PaymentIntentResponse.ts b/src/api/types/PaymentIntentResponse.ts index c2d02d1..6fb507d 100644 --- a/src/api/types/PaymentIntentResponse.ts +++ b/src/api/types/PaymentIntentResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentIntentResponse { id: string; diff --git a/src/api/types/PaymentIntentsListResponse.ts b/src/api/types/PaymentIntentsListResponse.ts index 2c809cc..043e5c3 100644 --- a/src/api/types/PaymentIntentsListResponse.ts +++ b/src/api/types/PaymentIntentsListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentIntentsListResponse { data: Monite.PaymentIntentResponse[]; diff --git a/src/api/types/PaymentIntentsRecipient.ts b/src/api/types/PaymentIntentsRecipient.ts index 0c2aa59..27a99cd 100644 --- a/src/api/types/PaymentIntentsRecipient.ts +++ b/src/api/types/PaymentIntentsRecipient.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentIntentsRecipient { id: string; diff --git a/src/api/types/PaymentMethod.ts b/src/api/types/PaymentMethod.ts index 195550c..c94488a 100644 --- a/src/api/types/PaymentMethod.ts +++ b/src/api/types/PaymentMethod.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentMethod { direction: Monite.PaymentMethodDirection; diff --git a/src/api/types/PaymentObject.ts b/src/api/types/PaymentObject.ts index 760960c..c690c04 100644 --- a/src/api/types/PaymentObject.ts +++ b/src/api/types/PaymentObject.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentObject { id: string; diff --git a/src/api/types/PaymentPageTheme.ts b/src/api/types/PaymentPageTheme.ts index b537f41..115a5dc 100644 --- a/src/api/types/PaymentPageTheme.ts +++ b/src/api/types/PaymentPageTheme.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentPageTheme { background_color?: string; diff --git a/src/api/types/PaymentRecordHistoryResponse.ts b/src/api/types/PaymentRecordHistoryResponse.ts new file mode 100644 index 0000000..d4b4ebe --- /dev/null +++ b/src/api/types/PaymentRecordHistoryResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface PaymentRecordHistoryResponse { + entity_user_id?: string; + status: Monite.PaymentRecordStatusEnum; + /** Timestamp of the change in a history */ + timestamp: string; +} diff --git a/src/api/types/PaymentRecordObjectRequest.ts b/src/api/types/PaymentRecordObjectRequest.ts index 67ed4f0..e294968 100644 --- a/src/api/types/PaymentRecordObjectRequest.ts +++ b/src/api/types/PaymentRecordObjectRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentRecordObjectRequest { /** ID of the invoice */ diff --git a/src/api/types/PaymentRecordObjectResponse.ts b/src/api/types/PaymentRecordObjectResponse.ts index 91b65f1..0cd8fa6 100644 --- a/src/api/types/PaymentRecordObjectResponse.ts +++ b/src/api/types/PaymentRecordObjectResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentRecordObjectResponse { /** ID of the invoice */ diff --git a/src/api/types/PaymentRecordResponse.ts b/src/api/types/PaymentRecordResponse.ts index 4812339..ad1784c 100644 --- a/src/api/types/PaymentRecordResponse.ts +++ b/src/api/types/PaymentRecordResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentRecordResponse { id: string; @@ -12,6 +12,8 @@ export interface PaymentRecordResponse { currency: Monite.CurrencyEnum; /** ID of the user associated with the payment, if applicable. */ entity_user_id?: string; + /** History of the payment record. */ + history: Monite.PaymentRecordHistoryResponse[]; is_external: boolean; object: Monite.PaymentRecordObjectResponse; /** Filled in a case, if payment amount is more, than total_amount */ diff --git a/src/api/types/PaymentRecordResponseList.ts b/src/api/types/PaymentRecordResponseList.ts index 67556ed..c5564cd 100644 --- a/src/api/types/PaymentRecordResponseList.ts +++ b/src/api/types/PaymentRecordResponseList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentRecordResponseList { data: Monite.PaymentRecordResponse[]; diff --git a/src/api/types/PaymentReminderResponse.ts b/src/api/types/PaymentReminderResponse.ts index 8a8b7e0..8b54b03 100644 --- a/src/api/types/PaymentReminderResponse.ts +++ b/src/api/types/PaymentReminderResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentReminderResponse { id: string; diff --git a/src/api/types/PaymentTerms.ts b/src/api/types/PaymentTerms.ts index 6c7169f..9e95391 100644 --- a/src/api/types/PaymentTerms.ts +++ b/src/api/types/PaymentTerms.ts @@ -2,15 +2,17 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentTerms { - id: string; + id?: string; + /** Description of the payment term. */ + description?: string; name?: string; /** The first tier of the payment term. Represents the terms of the first early discount. */ - term_1?: Monite.PaymentTermDiscountWithDate; + term_1?: Monite.InlineTermDiscount; /** The second tier of the payment term. Defines the terms of the second early discount. */ - term_2?: Monite.PaymentTermDiscountWithDate; + term_2?: Monite.InlineTermDiscount; /** The final tier of the payment term. Defines the invoice due date. */ - term_final: Monite.TermFinalWithDate; + term_final: Monite.InlineTermFinal; } diff --git a/src/api/types/PaymentTermsListResponse.ts b/src/api/types/PaymentTermsListResponse.ts index 0ef2464..7fa017b 100644 --- a/src/api/types/PaymentTermsListResponse.ts +++ b/src/api/types/PaymentTermsListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentTermsListResponse { data?: Monite.PaymentTermsResponse[]; diff --git a/src/api/types/PaymentTermsResponse.ts b/src/api/types/PaymentTermsResponse.ts index 581d33d..26a99e1 100644 --- a/src/api/types/PaymentTermsResponse.ts +++ b/src/api/types/PaymentTermsResponse.ts @@ -2,16 +2,16 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; 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; + term_1?: Monite.TermDiscountDays; /** The second tier of the payment term. Defines the terms of the second early discount. */ - term_2?: Monite.PaymentTermDiscount; + term_2?: Monite.TermDiscountDays; /** The final tier of the payment term. Defines the invoice due date. */ - term_final: Monite.PaymentTerm; + term_final: Monite.TermFinalDays; } diff --git a/src/api/types/PaymentsBatchPaymentRequest.ts b/src/api/types/PaymentsBatchPaymentRequest.ts index 52903b0..556b4d8 100644 --- a/src/api/types/PaymentsBatchPaymentRequest.ts +++ b/src/api/types/PaymentsBatchPaymentRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentsBatchPaymentRequest { payer_bank_account_id: string; diff --git a/src/api/types/PaymentsBatchPaymentResponse.ts b/src/api/types/PaymentsBatchPaymentResponse.ts index 54e7f34..2fde415 100644 --- a/src/api/types/PaymentsBatchPaymentResponse.ts +++ b/src/api/types/PaymentsBatchPaymentResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentsBatchPaymentResponse { id: string; diff --git a/src/api/types/PaymentsSettingsInput.ts b/src/api/types/PaymentsSettingsInput.ts index 2b25248..7d0a1d3 100644 --- a/src/api/types/PaymentsSettingsInput.ts +++ b/src/api/types/PaymentsSettingsInput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentsSettingsInput { payment_page_domain?: string; diff --git a/src/api/types/PaymentsSettingsOutput.ts b/src/api/types/PaymentsSettingsOutput.ts index 19b20b5..29afe08 100644 --- a/src/api/types/PaymentsSettingsOutput.ts +++ b/src/api/types/PaymentsSettingsOutput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PaymentsSettingsOutput { payment_page_domain?: string; diff --git a/src/api/types/PersonAddressRequest.ts b/src/api/types/PersonAddressRequest.ts index 8b87a09..217609e 100644 --- a/src/api/types/PersonAddressRequest.ts +++ b/src/api/types/PersonAddressRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PersonAddressRequest { /** City, district, suburb, town, or village */ diff --git a/src/api/types/PersonResponse.ts b/src/api/types/PersonResponse.ts index 9533a4c..0ce49c0 100644 --- a/src/api/types/PersonResponse.ts +++ b/src/api/types/PersonResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PersonResponse { /** The person's unique identifier */ diff --git a/src/api/types/PersonsResponse.ts b/src/api/types/PersonsResponse.ts index 949dfac..70b0898 100644 --- a/src/api/types/PersonsResponse.ts +++ b/src/api/types/PersonsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PersonsResponse { /** array of objects of type person */ diff --git a/src/api/types/Price.ts b/src/api/types/Price.ts index fb775f6..480740f 100644 --- a/src/api/types/Price.ts +++ b/src/api/types/Price.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface Price { /** The currency in which the price of the product is set. */ diff --git a/src/api/types/PricingPlan.ts b/src/api/types/PricingPlan.ts index b58efe9..e78ef2f 100644 --- a/src/api/types/PricingPlan.ts +++ b/src/api/types/PricingPlan.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A pricing plan of a financing offer diff --git a/src/api/types/ProcessResource.ts b/src/api/types/ProcessResource.ts index 1bbb945..38f7ba6 100644 --- a/src/api/types/ProcessResource.ts +++ b/src/api/types/ProcessResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ProcessResource { id: string; @@ -16,8 +16,15 @@ export interface ProcessResource { /** The metadata for the process. */ metadata: Record; /** The script snapshot taken when script started. */ - script_snapshot?: Monite.ProcessResourceScriptSnapshot; + script_snapshot?: ProcessResource.ScriptSnapshot; /** Tthe current status of the approval policy process. */ status: Monite.ProcessStatusEnum; updated_by?: string; } + +export namespace ProcessResource { + /** + * The script snapshot taken when script started. + */ + export type ScriptSnapshot = boolean | number | string | unknown[] | Record; +} diff --git a/src/api/types/ProcessResourceScriptSnapshot.ts b/src/api/types/ProcessResourceScriptSnapshot.ts deleted file mode 100644 index 918e267..0000000 --- a/src/api/types/ProcessResourceScriptSnapshot.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 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/ProductServicePaginationResponse.ts b/src/api/types/ProductServicePaginationResponse.ts index 1f9227a..2160e70 100644 --- a/src/api/types/ProductServicePaginationResponse.ts +++ b/src/api/types/ProductServicePaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of products and services diff --git a/src/api/types/ProductServiceResponse.ts b/src/api/types/ProductServiceResponse.ts index 406c56b..ac346f3 100644 --- a/src/api/types/ProductServiceResponse.ts +++ b/src/api/types/ProductServiceResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ProductServiceResponse { /** Unique ID of the product. */ @@ -15,6 +15,8 @@ export interface ProductServiceResponse { description?: string; entity_id: string; entity_user_id?: string; + /** A user-defined identifier of the product. For example, an internal product code or SKU (stock keeping unit). Client applications can use this field to map the products in Monite to an external product catalog. */ + external_reference?: 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; diff --git a/src/api/types/ProjectPaginationResponse.ts b/src/api/types/ProjectPaginationResponse.ts index 585e25f..cb6df47 100644 --- a/src/api/types/ProjectPaginationResponse.ts +++ b/src/api/types/ProjectPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of projects. diff --git a/src/api/types/ProjectResource.ts b/src/api/types/ProjectResource.ts index ff77374..5f010f5 100644 --- a/src/api/types/ProjectResource.ts +++ b/src/api/types/ProjectResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ProjectResource { /** A unique ID assigned to this project. */ diff --git a/src/api/types/PublicPaymentLinkResponse.ts b/src/api/types/PublicPaymentLinkResponse.ts index 7da5f9c..f564cec 100644 --- a/src/api/types/PublicPaymentLinkResponse.ts +++ b/src/api/types/PublicPaymentLinkResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PublicPaymentLinkResponse { id: string; diff --git a/src/api/types/PurchaseOrderCounterpartAddressSchema.ts b/src/api/types/PurchaseOrderCounterpartAddressSchema.ts index 61c88ba..3514f82 100644 --- a/src/api/types/PurchaseOrderCounterpartAddressSchema.ts +++ b/src/api/types/PurchaseOrderCounterpartAddressSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Address information. diff --git a/src/api/types/PurchaseOrderCounterpartIndividualRootResponse.ts b/src/api/types/PurchaseOrderCounterpartIndividualRootResponse.ts index 181d6c1..3cdc8c7 100644 --- a/src/api/types/PurchaseOrderCounterpartIndividualRootResponse.ts +++ b/src/api/types/PurchaseOrderCounterpartIndividualRootResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents counterparts that are individuals (natural persons). diff --git a/src/api/types/PurchaseOrderCounterpartOrganizationRootResponse.ts b/src/api/types/PurchaseOrderCounterpartOrganizationRootResponse.ts index 4ad7c8b..2e23a65 100644 --- a/src/api/types/PurchaseOrderCounterpartOrganizationRootResponse.ts +++ b/src/api/types/PurchaseOrderCounterpartOrganizationRootResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents counterparts that are organizations (juridical persons). diff --git a/src/api/types/PurchaseOrderCounterpartSchema.ts b/src/api/types/PurchaseOrderCounterpartSchema.ts index ac44007..0b63911 100644 --- a/src/api/types/PurchaseOrderCounterpartSchema.ts +++ b/src/api/types/PurchaseOrderCounterpartSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A Counterpart object contains information about an organization (juridical person) or diff --git a/src/api/types/PurchaseOrderItem.ts b/src/api/types/PurchaseOrderItem.ts index b9a96da..0eaf02c 100644 --- a/src/api/types/PurchaseOrderItem.ts +++ b/src/api/types/PurchaseOrderItem.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface PurchaseOrderItem { /** The currency in which the price of the product is set. */ diff --git a/src/api/types/PurchaseOrderPaginationResponse.ts b/src/api/types/PurchaseOrderPaginationResponse.ts index 3e0aa94..d9ff6e9 100644 --- a/src/api/types/PurchaseOrderPaginationResponse.ts +++ b/src/api/types/PurchaseOrderPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of purchase orders. diff --git a/src/api/types/PurchaseOrderResponseSchema.ts b/src/api/types/PurchaseOrderResponseSchema.ts index fc08522..b17358d 100644 --- a/src/api/types/PurchaseOrderResponseSchema.ts +++ b/src/api/types/PurchaseOrderResponseSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents response for an Accounts Purchase Order document created by entity. @@ -28,7 +28,7 @@ export interface PurchaseOrderResponseSchema { currency: Monite.CurrencyEnum; document_id: string; /** Data of the entity (address, name, contact) */ - entity: Monite.PurchaseOrderResponseSchemaEntity; + entity: PurchaseOrderResponseSchema.Entity; /** The ID of the entity which issued the purchase order. */ entity_id: string; entity_vat_id?: Monite.PurchaseOrderVatId; @@ -47,3 +47,10 @@ export interface PurchaseOrderResponseSchema { /** Number of days for which purchase order is valid */ valid_for_days: number; } + +export namespace PurchaseOrderResponseSchema { + /** + * Data of the entity (address, name, contact) + */ + export type Entity = Monite.PayableEntityIndividualResponse | Monite.PayableEntityOrganizationResponse; +} diff --git a/src/api/types/PurchaseOrderResponseSchemaEntity.ts b/src/api/types/PurchaseOrderResponseSchemaEntity.ts deleted file mode 100644 index a5f8565..0000000 --- a/src/api/types/PurchaseOrderResponseSchemaEntity.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * 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/QuoteResponsePayload.ts b/src/api/types/QuoteResponsePayload.ts index b7f96f1..10e8401 100644 --- a/src/api/types/QuoteResponsePayload.ts +++ b/src/api/types/QuoteResponsePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface QuoteResponsePayload { id: string; @@ -35,7 +35,7 @@ export interface QuoteResponsePayload { /** The VAT/TAX ID of the counterpart. */ counterpart_tax_id?: string; /** The type of the counterpart. */ - counterpart_type: Monite.ReceivableCounterpartType; + counterpart_type: Monite.CounterpartType; counterpart_vat_id?: Monite.ReceivableCounterpartVatIdResponse; /** The currency used in the receivable. */ currency: Monite.CurrencyEnum; @@ -44,7 +44,7 @@ export interface QuoteResponsePayload { /** A note with additional information about a tax deduction */ deduction_memo?: string; /** The discount for a receivable. */ - discount?: Monite.Discount; + discount?: Monite.DiscountResponse; /** Total price of the receivable with discounts before taxes [minor units](https://docs.monite.com/references/currencies#minor-units). */ discounted_subtotal?: number; /** The sequential code systematically assigned to invoices. */ diff --git a/src/api/types/QuoteResponsePayloadEntity.ts b/src/api/types/QuoteResponsePayloadEntity.ts index 47023e6..5c655bc 100644 --- a/src/api/types/QuoteResponsePayloadEntity.ts +++ b/src/api/types/QuoteResponsePayloadEntity.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type QuoteResponsePayloadEntity = | Monite.QuoteResponsePayloadEntity.Organization diff --git a/src/api/types/ReceivableCounterpartContact.ts b/src/api/types/ReceivableCounterpartContact.ts index 6c6b941..ae6a360 100644 --- a/src/api/types/ReceivableCounterpartContact.ts +++ b/src/api/types/ReceivableCounterpartContact.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableCounterpartContact { /** The contact address of the counterpart */ diff --git a/src/api/types/ReceivableCounterpartType.ts b/src/api/types/ReceivableCounterpartType.ts deleted file mode 100644 index a8d2e3c..0000000 --- a/src/api/types/ReceivableCounterpartType.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 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 index cbc7960..0f3f6bd 100644 --- a/src/api/types/ReceivableCounterpartVatIdResponse.ts +++ b/src/api/types/ReceivableCounterpartVatIdResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableCounterpartVatIdResponse { id: string; diff --git a/src/api/types/ReceivableCreateBasedOnPayload.ts b/src/api/types/ReceivableCreateBasedOnPayload.ts index 651ea82..965521d 100644 --- a/src/api/types/ReceivableCreateBasedOnPayload.ts +++ b/src/api/types/ReceivableCreateBasedOnPayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableCreateBasedOnPayload { /** The unique ID of a previous document related to the receivable if applicable. */ diff --git a/src/api/types/ReceivableCursorFields.ts b/src/api/types/ReceivableCursorFields.ts index fb60935..10324f2 100644 --- a/src/api/types/ReceivableCursorFields.ts +++ b/src/api/types/ReceivableCursorFields.ts @@ -7,6 +7,7 @@ export type ReceivableCursorFields = | "counterpart_id" | "amount" | "total_amount" + | "discounted_subtotal" | "status" | "due_date" | "issue_date" @@ -18,6 +19,7 @@ export const ReceivableCursorFields = { CounterpartId: "counterpart_id", Amount: "amount", TotalAmount: "total_amount", + DiscountedSubtotal: "discounted_subtotal", Status: "status", DueDate: "due_date", IssueDate: "issue_date", diff --git a/src/api/types/ReceivableCursorFields2.ts b/src/api/types/ReceivableCursorFields2.ts new file mode 100644 index 0000000..0ca01a2 --- /dev/null +++ b/src/api/types/ReceivableCursorFields2.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type ReceivableCursorFields2 = + | "counterpart_name" + | "counterpart_id" + | "amount" + | "total_amount" + | "status" + | "due_date" + | "issue_date" + | "document_id" + | "created_at" + | "project_id"; +export const ReceivableCursorFields2 = { + CounterpartName: "counterpart_name", + CounterpartId: "counterpart_id", + Amount: "amount", + TotalAmount: "total_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/ReceivableEntityAddressSchema.ts b/src/api/types/ReceivableEntityAddressSchema.ts index 605555a..a101cd6 100644 --- a/src/api/types/ReceivableEntityAddressSchema.ts +++ b/src/api/types/ReceivableEntityAddressSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema represents address info of the entity diff --git a/src/api/types/ReceivableEntityVatIdResponse.ts b/src/api/types/ReceivableEntityVatIdResponse.ts index 207b4cc..e2fb030 100644 --- a/src/api/types/ReceivableEntityVatIdResponse.ts +++ b/src/api/types/ReceivableEntityVatIdResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableEntityVatIdResponse { id: string; diff --git a/src/api/types/ReceivableFacadeCreateInvoicePayload.ts b/src/api/types/ReceivableFacadeCreateInvoicePayload.ts index 79cbff9..38079a7 100644 --- a/src/api/types/ReceivableFacadeCreateInvoicePayload.ts +++ b/src/api/types/ReceivableFacadeCreateInvoicePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableFacadeCreateInvoicePayload { commercial_condition_description?: string; @@ -54,6 +54,7 @@ export interface ReceivableFacadeCreateInvoicePayload { /** 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.InlinePaymentTermsRequestPayload; payment_terms_id?: string; /** A project related to current receivable */ project_id?: string; diff --git a/src/api/types/ReceivableFacadeCreatePayload.ts b/src/api/types/ReceivableFacadeCreatePayload.ts index 149c191..a8b1f5e 100644 --- a/src/api/types/ReceivableFacadeCreatePayload.ts +++ b/src/api/types/ReceivableFacadeCreatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type ReceivableFacadeCreatePayload = | Monite.ReceivableFacadeCreateQuotePayload diff --git a/src/api/types/ReceivableFacadeCreateQuotePayload.ts b/src/api/types/ReceivableFacadeCreateQuotePayload.ts index 88633b7..f10024e 100644 --- a/src/api/types/ReceivableFacadeCreateQuotePayload.ts +++ b/src/api/types/ReceivableFacadeCreateQuotePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableFacadeCreateQuotePayload { commercial_condition_description?: string; diff --git a/src/api/types/ReceivableHistoryPaginationResponse.ts b/src/api/types/ReceivableHistoryPaginationResponse.ts index c5261d0..0133254 100644 --- a/src/api/types/ReceivableHistoryPaginationResponse.ts +++ b/src/api/types/ReceivableHistoryPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of change history records. diff --git a/src/api/types/ReceivableHistoryResponse.ts b/src/api/types/ReceivableHistoryResponse.ts index 4aa9dcd..edfb3d4 100644 --- a/src/api/types/ReceivableHistoryResponse.ts +++ b/src/api/types/ReceivableHistoryResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents an entry in the change history of an accounts receivable document. @@ -21,7 +21,7 @@ export interface ReceivableHistoryResponse { /** ID of the entity user who made the change or trigger the event, or `null` if it was done by using a partner access token. */ entity_user_id?: string; /** An object containing additional information about the event or change. The object structure varies based on the `event_type`. In `receivable_created` and `receivable_updated` events, `event_data` is an empty object `{}`. */ - event_data: Monite.ReceivableHistoryResponseEventData; + event_data: ReceivableHistoryResponse.EventData; /** The type of the event or change. See [Event types](https://docs.monite.com/accounts-receivable/document-history#event-types). */ event_type: Monite.ReceivableHistoryEventTypeEnum; /** ID of the receivable document that was changed or triggered an event. */ @@ -29,3 +29,17 @@ export interface ReceivableHistoryResponse { /** UTC date and time when the event or change occurred. */ timestamp: string; } + +export namespace ReceivableHistoryResponse { + /** + * An object containing additional information about the event or change. The object structure varies based on the `event_type`. In `receivable_created` and `receivable_updated` events, `event_data` is an empty object `{}`. + */ + export type EventData = + | Monite.StatusChangedEventData + | Monite.ReceivableUpdatedEventData + | Monite.ReceivableCreatedEventData + | Monite.BasedOnReceivableCreatedEventData + | Monite.PaymentReceivedEventData + | Monite.MailSentEventData + | Monite.ReminderMailSentEventData; +} diff --git a/src/api/types/ReceivableHistoryResponseEventData.ts b/src/api/types/ReceivableHistoryResponseEventData.ts deleted file mode 100644 index fb342ce..0000000 --- a/src/api/types/ReceivableHistoryResponseEventData.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as Monite from "../index"; - -/** - * An object containing additional information about the event or change. The object structure varies based on the `event_type`. In `receivable_created` and `receivable_updated` events, `event_data` is an empty object `{}`. - */ -export type ReceivableHistoryResponseEventData = - | Monite.StatusChangedEventData - | Monite.ReceivableUpdatedEventData - | Monite.ReceivableCreatedEventData - | Monite.BasedOnReceivableCreatedEventData - | Monite.PaymentReceivedEventData - | Monite.MailSentEventData - | Monite.ReminderMailSentEventData; diff --git a/src/api/types/ReceivableMailPaginationResponse.ts b/src/api/types/ReceivableMailPaginationResponse.ts index 6306576..c2e8042 100644 --- a/src/api/types/ReceivableMailPaginationResponse.ts +++ b/src/api/types/ReceivableMailPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableMailPaginationResponse { data: Monite.ReceivableMailResponse[]; diff --git a/src/api/types/ReceivableMailRecipients.ts b/src/api/types/ReceivableMailRecipients.ts index 96d1f0b..b6ffe24 100644 --- a/src/api/types/ReceivableMailRecipients.ts +++ b/src/api/types/ReceivableMailRecipients.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableMailRecipients { bcc?: Monite.ReceivableMailRecipientState[]; diff --git a/src/api/types/ReceivableMailResponse.ts b/src/api/types/ReceivableMailResponse.ts index 971f2ad..8344519 100644 --- a/src/api/types/ReceivableMailResponse.ts +++ b/src/api/types/ReceivableMailResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableMailResponse { id: string; diff --git a/src/api/types/ReceivablePaginationResponse.ts b/src/api/types/ReceivablePaginationResponse.ts index 1bba829..7ce61b8 100644 --- a/src/api/types/ReceivablePaginationResponse.ts +++ b/src/api/types/ReceivablePaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of receivables diff --git a/src/api/types/ReceivableRequiredFields.ts b/src/api/types/ReceivableRequiredFields.ts index a99516b..c10c284 100644 --- a/src/api/types/ReceivableRequiredFields.ts +++ b/src/api/types/ReceivableRequiredFields.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableRequiredFields { /** Object describing the required fields for counterpart */ diff --git a/src/api/types/ReceivableResponse.ts b/src/api/types/ReceivableResponse.ts index 5d9ee85..a903cfa 100644 --- a/src/api/types/ReceivableResponse.ts +++ b/src/api/types/ReceivableResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type ReceivableResponse = | Monite.ReceivableResponse.Quote diff --git a/src/api/types/ReceivableTagCategory.ts b/src/api/types/ReceivableTagCategory.ts deleted file mode 100644 index daad0b7..0000000 --- a/src/api/types/ReceivableTagCategory.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export type ReceivableTagCategory = - | "document_type" - | "department" - | "project" - | "cost_center" - | "vendor_type" - | "payment_method" - | "approval_status"; -export const ReceivableTagCategory = { - 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/ReceivableTemplatesVariablesObject.ts b/src/api/types/ReceivableTemplatesVariablesObject.ts index 9d7a5d3..715b4f0 100644 --- a/src/api/types/ReceivableTemplatesVariablesObject.ts +++ b/src/api/types/ReceivableTemplatesVariablesObject.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableTemplatesVariablesObject { object_subtype: Monite.VariablesType; diff --git a/src/api/types/ReceivableTemplatesVariablesObjectList.ts b/src/api/types/ReceivableTemplatesVariablesObjectList.ts index 420c6b4..a5a0b56 100644 --- a/src/api/types/ReceivableTemplatesVariablesObjectList.ts +++ b/src/api/types/ReceivableTemplatesVariablesObjectList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivableTemplatesVariablesObjectList { data: Monite.ReceivableTemplatesVariablesObject[]; diff --git a/src/api/types/ReceivableUpdatePayload.ts b/src/api/types/ReceivableUpdatePayload.ts index 4e6e53c..684faf9 100644 --- a/src/api/types/ReceivableUpdatePayload.ts +++ b/src/api/types/ReceivableUpdatePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type ReceivableUpdatePayload = | Monite.UpdateQuotePayload diff --git a/src/api/types/ReceivablesAnalyticsResponse.ts b/src/api/types/ReceivablesAnalyticsResponse.ts index 7a68a12..24b6bfd 100644 --- a/src/api/types/ReceivablesAnalyticsResponse.ts +++ b/src/api/types/ReceivablesAnalyticsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivablesAnalyticsResponse { data: Monite.ReceivablesAnalyticsDataPoint[]; diff --git a/src/api/types/ReceivablesCounterpartAddress.ts b/src/api/types/ReceivablesCounterpartAddress.ts index 86a053d..bddb1bf 100644 --- a/src/api/types/ReceivablesCounterpartAddress.ts +++ b/src/api/types/ReceivablesCounterpartAddress.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Address information. diff --git a/src/api/types/ReceivablesRepresentationOfCounterpartAddress.ts b/src/api/types/ReceivablesRepresentationOfCounterpartAddress.ts index bcbd5f4..2235c1d 100644 --- a/src/api/types/ReceivablesRepresentationOfCounterpartAddress.ts +++ b/src/api/types/ReceivablesRepresentationOfCounterpartAddress.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ReceivablesRepresentationOfCounterpartAddress { /** Unique ID of the address in the system */ diff --git a/src/api/types/ReceivablesVerifyResponse.ts b/src/api/types/ReceivablesVerifyResponse.ts index f4de88d..72a8378 100644 --- a/src/api/types/ReceivablesVerifyResponse.ts +++ b/src/api/types/ReceivablesVerifyResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema for returning a response with validation results diff --git a/src/api/types/Recipient.ts b/src/api/types/Recipient.ts index 7439b70..7d36980 100644 --- a/src/api/types/Recipient.ts +++ b/src/api/types/Recipient.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface Recipient { id: string; diff --git a/src/api/types/RecipientAccountResponse.ts b/src/api/types/RecipientAccountResponse.ts index 57bd403..2b836a5 100644 --- a/src/api/types/RecipientAccountResponse.ts +++ b/src/api/types/RecipientAccountResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface RecipientAccountResponse { /** ID of a payment account */ diff --git a/src/api/types/Recurrence.ts b/src/api/types/Recurrence.ts deleted file mode 100644 index 3c74001..0000000 --- a/src/api/types/Recurrence.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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; - /** - * Controls how invoices are processed when generated: - * - "draft": Creates invoices in draft status, requiring manual review, issuing, and sending - * - "issue": Automatically issues invoices but requires manual sending - * - "issue_and_send": Fully automates the process (creates, issues, and sends invoices) - * - * Default: "issue" (or "issue_and_send" if subject_text and body_text are provided) - * - * Note: When using "issue_and_send", both subject_text and body_text must be provided. - */ - automation_level: Monite.AutomationLevel; - body_text?: string; - current_iteration: number; - day_of_month: Monite.DayOfMonth; - end_month: number; - end_year: number; - invoice_id: string; - iterations: Monite.RecurrenceIteration[]; - recipients?: Monite.Recipients; - start_month: number; - start_year: number; - status: Monite.RecurrenceStatus; - subject_text?: string; -} diff --git a/src/api/types/RecurrenceFrequency.ts b/src/api/types/RecurrenceFrequency.ts new file mode 100644 index 0000000..0588105 --- /dev/null +++ b/src/api/types/RecurrenceFrequency.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type RecurrenceFrequency = "day" | "week" | "month" | "quarter" | "year"; +export const RecurrenceFrequency = { + Day: "day", + Week: "week", + Month: "month", + Quarter: "quarter", + Year: "year", +} as const; diff --git a/src/api/types/RecurrenceIteration.ts b/src/api/types/RecurrenceIteration.ts index f5f7eb9..056e9fb 100644 --- a/src/api/types/RecurrenceIteration.ts +++ b/src/api/types/RecurrenceIteration.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface RecurrenceIteration { issue_at: string; diff --git a/src/api/types/RecurrenceResponse.ts b/src/api/types/RecurrenceResponse.ts new file mode 100644 index 0000000..3fec6f4 --- /dev/null +++ b/src/api/types/RecurrenceResponse.ts @@ -0,0 +1,58 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface RecurrenceResponse { + id: string; + /** Time at which the recurrence was created. Timestamps follow the ISO 8601 standard. */ + created_at: string; + /** Time at which the recurrence was last updated. Timestamps follow the ISO 8601 standard. */ + updated_at: string; + /** + * Controls how invoices are processed when generated: + * - "draft": Creates invoices in draft status, requiring manual review, issuing, and sending + * - "issue": Automatically issues invoices but requires manual sending + * - "issue_and_send": Fully automates the process (creates, issues, and sends invoices) + * + * Default: "issue" (or "issue_and_send" if subject_text and body_text are provided) + * + * Note: When using "issue_and_send", both subject_text and body_text must be provided. + */ + automation_level: Monite.AutomationLevel; + /** The body text for the email that will be sent with the recurring invoice. */ + body_text?: string; + /** Current iteration number */ + current_iteration: number; + /** Deprecated, use `start_date` instead */ + day_of_month: Monite.DayOfMonth; + /** The end date of the recurring invoice, in the `yyyy-mm-dd` format. The end date is inclusive, that is, the last invoice will be created on this date if the last occurrence falls on this date. `end_date` is mutually exclusive with `max_occurrences`. Either `end_date` or `max_occurrences` must be specified. */ + end_date?: string; + /** Deprecated, use `end_date` instead */ + end_month?: number; + /** Deprecated, use `end_date` instead */ + end_year?: number; + /** How often the invoice will be created. */ + frequency: Monite.RecurrenceFrequency; + /** The interval between each occurrence of the invoice. For example, when using monthly frequency, an interval of 1 means invoices will be created every month, an interval of 2 means invoices will be created every 2 months. */ + interval: number; + /** ID of the base invoice that will be used as a template for creating recurring invoices. */ + invoice_id: string; + /** List of iterations for the recurrence */ + iterations: Monite.RecurrenceIteration[]; + /** How many times the recurring invoice will be created. The recurrence will stop after this number is reached. `max_occurrences` is mutually exclusive with `end_date`. Either `max_occurrences` or `end_date` must be specified. */ + max_occurrences?: number; + /** An object containing the recipients (To, CC, BCC) of the recurring invoices. Can be omitted if the base invoice has the counterpart contact email specified in the `counterpart_contact.email` field. */ + recipients?: Monite.Recipients; + /** The date when the first invoice will be created, in the `yyyy-mm-dd` format. Cannot be a past date. Subsequent invoice dates will be calculated based on `start_date`, `frequency`, and `interval`. */ + start_date: string; + /** Deprecated, use `start_date` instead */ + start_month: number; + /** Deprecated, use `start_date` instead */ + start_year: number; + /** Status of the recurrence */ + status: Monite.RecurrenceStatus; + /** The subject for the email that will be sent with the recurring invoice. */ + subject_text?: string; +} diff --git a/src/api/types/RecurrenceResponseList.ts b/src/api/types/RecurrenceResponseList.ts new file mode 100644 index 0000000..4933ee6 --- /dev/null +++ b/src/api/types/RecurrenceResponseList.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Monite from "../index.js"; + +export interface RecurrenceResponseList { + data: Monite.RecurrenceResponse[]; +} diff --git a/src/api/types/RecurrenceStatus.ts b/src/api/types/RecurrenceStatus.ts index 2e3f108..4f37816 100644 --- a/src/api/types/RecurrenceStatus.ts +++ b/src/api/types/RecurrenceStatus.ts @@ -2,9 +2,20 @@ * This file was auto-generated by Fern from our API Definition. */ -export type RecurrenceStatus = "active" | "canceled" | "completed"; +/** + * Represents the status of a recurrence + * + * Allowed transitions: + * - active -> paused + * - active -> canceled + * - active -> completed + * - paused -> active + * - paused -> canceled + */ +export type RecurrenceStatus = "active" | "paused" | "canceled" | "completed"; export const RecurrenceStatus = { Active: "active", + Paused: "paused", Canceled: "canceled", Completed: "completed", } as const; diff --git a/src/api/types/ReminderMailSentEventData.ts b/src/api/types/ReminderMailSentEventData.ts index 2d82a64..f9ba011 100644 --- a/src/api/types/ReminderMailSentEventData.ts +++ b/src/api/types/ReminderMailSentEventData.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Contains information about an invoice reminder sent via email. diff --git a/src/api/types/ResponseItem.ts b/src/api/types/ResponseItem.ts index f3214cd..5d7fc9c 100644 --- a/src/api/types/ResponseItem.ts +++ b/src/api/types/ResponseItem.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface ResponseItem { /** The discount for a product. */ diff --git a/src/api/types/RolePaginationResponse.ts b/src/api/types/RolePaginationResponse.ts index 4a8773c..6874687 100644 --- a/src/api/types/RolePaginationResponse.ts +++ b/src/api/types/RolePaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface RolePaginationResponse { /** array of records */ diff --git a/src/api/types/RoleResponse.ts b/src/api/types/RoleResponse.ts index 3c74819..0098f34 100644 --- a/src/api/types/RoleResponse.ts +++ b/src/api/types/RoleResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface RoleResponse { /** UUID role ID */ diff --git a/src/api/types/RootSchemaInput.ts b/src/api/types/RootSchemaInput.ts index 8d1cda4..6ba5aa6 100644 --- a/src/api/types/RootSchemaInput.ts +++ b/src/api/types/RootSchemaInput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type RootSchemaInput = | Monite.RootSchemaInput.ApprovalPolicy diff --git a/src/api/types/RootSchemaOutput.ts b/src/api/types/RootSchemaOutput.ts index cec2fb5..f833ac8 100644 --- a/src/api/types/RootSchemaOutput.ts +++ b/src/api/types/RootSchemaOutput.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type RootSchemaOutput = | Monite.RootSchemaOutput.ApprovalPolicy diff --git a/src/api/types/SettingsResponse.ts b/src/api/types/SettingsResponse.ts index 0addc5f..f494236 100644 --- a/src/api/types/SettingsResponse.ts +++ b/src/api/types/SettingsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SettingsResponse { language?: Monite.LanguageCodeEnum; diff --git a/src/api/types/SingleOnboardingRequirementsResponse.ts b/src/api/types/SingleOnboardingRequirementsResponse.ts index 7b46e4e..3867e07 100644 --- a/src/api/types/SingleOnboardingRequirementsResponse.ts +++ b/src/api/types/SingleOnboardingRequirementsResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SingleOnboardingRequirementsResponse { disabled_reason?: string; diff --git a/src/api/types/SinglePaymentIntent.ts b/src/api/types/SinglePaymentIntent.ts index 8a8a0ff..ef66a5b 100644 --- a/src/api/types/SinglePaymentIntent.ts +++ b/src/api/types/SinglePaymentIntent.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SinglePaymentIntent { object: Monite.PaymentObjectPayable; diff --git a/src/api/types/SinglePaymentIntentResponse.ts b/src/api/types/SinglePaymentIntentResponse.ts index 28975a3..78b26cc 100644 --- a/src/api/types/SinglePaymentIntentResponse.ts +++ b/src/api/types/SinglePaymentIntentResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SinglePaymentIntentResponse { id: string; diff --git a/src/api/types/StatusChangedEventData.ts b/src/api/types/StatusChangedEventData.ts index 1f12b42..85a63d5 100644 --- a/src/api/types/StatusChangedEventData.ts +++ b/src/api/types/StatusChangedEventData.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Contains information about a document's status change. See the applicable diff --git a/src/api/types/SupportedFormatSchema.ts b/src/api/types/SupportedFormatSchema.ts index f52172f..e5d93a8 100644 --- a/src/api/types/SupportedFormatSchema.ts +++ b/src/api/types/SupportedFormatSchema.ts @@ -2,9 +2,17 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SupportedFormatSchema { available_types: Record; - object_type: Monite.SupportedFormatSchemaObjectType; + object_type: SupportedFormatSchema.ObjectType; +} + +export namespace SupportedFormatSchema { + export type ObjectType = "payable" | "receivable"; + export const ObjectType = { + Payable: "payable", + Receivable: "receivable", + } as const; } diff --git a/src/api/types/SupportedFormatSchemaObjectType.ts b/src/api/types/SupportedFormatSchemaObjectType.ts deleted file mode 100644 index 39472d5..0000000 --- a/src/api/types/SupportedFormatSchemaObjectType.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 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/SyncRecordResource.ts b/src/api/types/SyncRecordResource.ts index 3b9cb16..838f5f5 100644 --- a/src/api/types/SyncRecordResource.ts +++ b/src/api/types/SyncRecordResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SyncRecordResource { id: string; diff --git a/src/api/types/SyncRecordResourceList.ts b/src/api/types/SyncRecordResourceList.ts index 2323d54..9780ca5 100644 --- a/src/api/types/SyncRecordResourceList.ts +++ b/src/api/types/SyncRecordResourceList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SyncRecordResourceList { data: Monite.SyncRecordResource[]; diff --git a/src/api/types/SystemTemplateDataSchema.ts b/src/api/types/SystemTemplateDataSchema.ts index e9e71be..5be2a56 100644 --- a/src/api/types/SystemTemplateDataSchema.ts +++ b/src/api/types/SystemTemplateDataSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SystemTemplateDataSchema { /** Array of templates */ diff --git a/src/api/types/SystemTemplates.ts b/src/api/types/SystemTemplates.ts index 68d1e54..4db97b6 100644 --- a/src/api/types/SystemTemplates.ts +++ b/src/api/types/SystemTemplates.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface SystemTemplates { /** All pre-defined email templates */ diff --git a/src/api/types/TagReadSchema.ts b/src/api/types/TagReadSchema.ts index 84b3225..8656771 100644 --- a/src/api/types/TagReadSchema.ts +++ b/src/api/types/TagReadSchema.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Represents a user-defined tag that can be assigned to resources to filter them. @@ -15,7 +15,7 @@ export interface TagReadSchema { /** 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.ReceivableTagCategory; + category?: Monite.TagCategory; /** ID of the user who created the tag. */ created_by_entity_user_id?: string; /** The tag description. */ diff --git a/src/api/types/TagsPaginationResponse.ts b/src/api/types/TagsPaginationResponse.ts index 5c69adb..1ac72d0 100644 --- a/src/api/types/TagsPaginationResponse.ts +++ b/src/api/types/TagsPaginationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A paginated list of tags. diff --git a/src/api/types/TemplateListResponse.ts b/src/api/types/TemplateListResponse.ts index 26793ba..b75a292 100644 --- a/src/api/types/TemplateListResponse.ts +++ b/src/api/types/TemplateListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface TemplateListResponse { data?: Monite.TemplateReceivableResponse[]; diff --git a/src/api/types/TemplateReceivableResponse.ts b/src/api/types/TemplateReceivableResponse.ts index 6130eff..3e25424 100644 --- a/src/api/types/TemplateReceivableResponse.ts +++ b/src/api/types/TemplateReceivableResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface TemplateReceivableResponse { id: string; diff --git a/src/api/types/PaymentTermDiscount.ts b/src/api/types/TermDiscountDays.ts similarity index 87% rename from src/api/types/PaymentTermDiscount.ts rename to src/api/types/TermDiscountDays.ts index 144ac72..9f9be5e 100644 --- a/src/api/types/PaymentTermDiscount.ts +++ b/src/api/types/TermDiscountDays.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface PaymentTermDiscount { +export interface TermDiscountDays { /** 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. */ diff --git a/src/api/types/PaymentTerm.ts b/src/api/types/TermFinalDays.ts similarity index 83% rename from src/api/types/PaymentTerm.ts rename to src/api/types/TermFinalDays.ts index d748266..39403a9 100644 --- a/src/api/types/PaymentTerm.ts +++ b/src/api/types/TermFinalDays.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface PaymentTerm { +export interface TermFinalDays { /** The amount of days after the invoice issue date. */ number_of_days: number; } diff --git a/src/api/types/TextTemplateResponse.ts b/src/api/types/TextTemplateResponse.ts index 90bdb4e..16e97d5 100644 --- a/src/api/types/TextTemplateResponse.ts +++ b/src/api/types/TextTemplateResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface TextTemplateResponse { id: string; diff --git a/src/api/types/TextTemplateResponseList.ts b/src/api/types/TextTemplateResponseList.ts index 0670eeb..1ceaa87 100644 --- a/src/api/types/TextTemplateResponseList.ts +++ b/src/api/types/TextTemplateResponseList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface TextTemplateResponseList { data: Monite.TextTemplateResponse[]; diff --git a/src/api/types/TotalVatAmountItem.ts b/src/api/types/TotalVatAmountItem.ts index eaf4900..01a48d9 100644 --- a/src/api/types/TotalVatAmountItem.ts +++ b/src/api/types/TotalVatAmountItem.ts @@ -2,10 +2,16 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as Monite from "../index.js"; + export interface TotalVatAmountItem { id?: string; /** The total VAT of all line items, in [minor units](https://docs.monite.com/references/currencies#minor-units). */ amount: number; + /** Sub-taxes included in the VAT. */ + components?: Monite.TotalVatAmountItemComponent[]; + /** Display name of the vat rate. */ + name?: string; /** The amount on which this VAT is calculated, in [minor units](https://docs.monite.com/references/currencies#minor-units). */ taxable_amount: number; /** Percent minor units. Example: 12.5% is 1250. */ diff --git a/src/api/types/TotalVatAmountItemComponent.ts b/src/api/types/TotalVatAmountItemComponent.ts new file mode 100644 index 0000000..fc7092c --- /dev/null +++ b/src/api/types/TotalVatAmountItemComponent.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface TotalVatAmountItemComponent { + name: string; + /** Percent minor units. Example: 12.5% is 1250. */ + value: number; + /** The total VAT of all line items, in [minor units](https://docs.monite.com/references/currencies#minor-units). */ + amount: number; +} diff --git a/src/api/types/UnitListResponse.ts b/src/api/types/UnitListResponse.ts index c5be817..c0de371 100644 --- a/src/api/types/UnitListResponse.ts +++ b/src/api/types/UnitListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UnitListResponse { data: Monite.UnitResponse[]; diff --git a/src/api/types/UpdateCreditNote.ts b/src/api/types/UpdateCreditNote.ts index cb9b64a..b4cefdd 100644 --- a/src/api/types/UpdateCreditNote.ts +++ b/src/api/types/UpdateCreditNote.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UpdateCreditNote { /** Address of invoicing, need to state as a separate fields for some countries if it differs from address of a company. */ diff --git a/src/api/types/UpdateCreditNotePayload.ts b/src/api/types/UpdateCreditNotePayload.ts index a5c2666..fcd0c35 100644 --- a/src/api/types/UpdateCreditNotePayload.ts +++ b/src/api/types/UpdateCreditNotePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UpdateCreditNotePayload { credit_note: Monite.UpdateCreditNote; diff --git a/src/api/types/UpdateEinvoicingAddress.ts b/src/api/types/UpdateEinvoicingAddress.ts new file mode 100644 index 0000000..da86614 --- /dev/null +++ b/src/api/types/UpdateEinvoicingAddress.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface UpdateEinvoicingAddress { + /** Street address line 1 */ + address_line1: string; + /** Street address line 2 */ + address_line2?: string; + /** City name */ + city: string; + /** Postal/ZIP code */ + postal_code: string; + /** State/Province/County */ + state?: string; +} diff --git a/src/api/types/UpdateEntityRequest.ts b/src/api/types/UpdateEntityRequest.ts index c302c23..fb7b7bc 100644 --- a/src/api/types/UpdateEntityRequest.ts +++ b/src/api/types/UpdateEntityRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * A schema for a request to update an entity diff --git a/src/api/types/UpdateInvoice.ts b/src/api/types/UpdateInvoice.ts index 3dd952a..07bbac5 100644 --- a/src/api/types/UpdateInvoice.ts +++ b/src/api/types/UpdateInvoice.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UpdateInvoice { /** Unique ID of the counterpart contact. */ @@ -52,6 +52,7 @@ export interface UpdateInvoice { /** Link to your invoice's custom payment rails or external payment link. */ payment_page_url?: string; payment_reminder_id?: string; + payment_terms?: Monite.InlinePaymentTermsRequestPayload; /** Unique ID of the payment terms. */ payment_terms_id?: string; /** A project related to current receivable */ diff --git a/src/api/types/UpdateInvoicePayload.ts b/src/api/types/UpdateInvoicePayload.ts index 8e0431a..a25f9a8 100644 --- a/src/api/types/UpdateInvoicePayload.ts +++ b/src/api/types/UpdateInvoicePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UpdateInvoicePayload { invoice: Monite.UpdateInvoice; diff --git a/src/api/types/UpdateIssuedInvoice.ts b/src/api/types/UpdateIssuedInvoice.ts index 5659415..838e188 100644 --- a/src/api/types/UpdateIssuedInvoice.ts +++ b/src/api/types/UpdateIssuedInvoice.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UpdateIssuedInvoice { /** Unique ID of the counterpart contact. */ @@ -35,6 +35,7 @@ export interface UpdateIssuedInvoice { /** Metadata for partner needs */ partner_metadata?: Record; payment_reminder_id?: string; + payment_terms?: Monite.InlinePaymentTermsRequestPayload; payment_terms_id?: string; /** A project related to current receivable */ project_id?: string; diff --git a/src/api/types/UpdateIssuedInvoiceEntity.ts b/src/api/types/UpdateIssuedInvoiceEntity.ts index e1ff9a9..e39ce15 100644 --- a/src/api/types/UpdateIssuedInvoiceEntity.ts +++ b/src/api/types/UpdateIssuedInvoiceEntity.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export type UpdateIssuedInvoiceEntity = | Monite.UpdateIssuedInvoiceEntity.Organization diff --git a/src/api/types/UpdateIssuedInvoicePayload.ts b/src/api/types/UpdateIssuedInvoicePayload.ts index 74d4533..025e28c 100644 --- a/src/api/types/UpdateIssuedInvoicePayload.ts +++ b/src/api/types/UpdateIssuedInvoicePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UpdateIssuedInvoicePayload { issued_invoice: Monite.UpdateIssuedInvoice; diff --git a/src/api/types/UpdateLineItemForCreditNote.ts b/src/api/types/UpdateLineItemForCreditNote.ts index 242ace7..41c4aef 100644 --- a/src/api/types/UpdateLineItemForCreditNote.ts +++ b/src/api/types/UpdateLineItemForCreditNote.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; /** * Line item with given product id can be changed only once diff --git a/src/api/types/UpdateQuote.ts b/src/api/types/UpdateQuote.ts index 2b6d1fd..02ff85e 100644 --- a/src/api/types/UpdateQuote.ts +++ b/src/api/types/UpdateQuote.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UpdateQuote { /** Unique ID of the counterpart contact. */ @@ -36,6 +36,7 @@ export interface UpdateQuote { memo?: string; /** Metadata for partner needs */ partner_metadata?: Record; + payment_terms?: Monite.InlinePaymentTermsRequestPayload; /** Unique ID of the payment terms. */ payment_terms_id?: string; /** A project related to current receivable */ diff --git a/src/api/types/UpdateQuotePayload.ts b/src/api/types/UpdateQuotePayload.ts index ebf5ccd..127968e 100644 --- a/src/api/types/UpdateQuotePayload.ts +++ b/src/api/types/UpdateQuotePayload.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface UpdateQuotePayload { quote: Monite.UpdateQuote; diff --git a/src/api/types/ValidationError.ts b/src/api/types/ValidationError.ts index 9e72e4d..1c398a1 100644 --- a/src/api/types/ValidationError.ts +++ b/src/api/types/ValidationError.ts @@ -2,10 +2,16 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; - export interface ValidationError { - loc: Monite.ValidationErrorLocItem[]; + loc: ValidationError.Loc.Item[]; msg: string; type: string; } + +export namespace ValidationError { + export type Loc = Loc.Item[]; + + export namespace Loc { + export type Item = string | number; + } +} diff --git a/src/api/types/VariablesObject.ts b/src/api/types/VariablesObject.ts index 7e23ea4..998ed81 100644 --- a/src/api/types/VariablesObject.ts +++ b/src/api/types/VariablesObject.ts @@ -2,10 +2,10 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface VariablesObject { - object_subtype: Monite.OcrDocumentTypeEnum; + object_subtype: Monite.DocumentTypeEnum; object_type: string; variables: Monite.Variable[]; } diff --git a/src/api/types/VariablesObjectList.ts b/src/api/types/VariablesObjectList.ts index bac4133..29e80ef 100644 --- a/src/api/types/VariablesObjectList.ts +++ b/src/api/types/VariablesObjectList.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface VariablesObjectList { data: Monite.VariablesObject[]; diff --git a/src/api/types/VatRateComponent.ts b/src/api/types/VatRateComponent.ts new file mode 100644 index 0000000..fd9493a --- /dev/null +++ b/src/api/types/VatRateComponent.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface VatRateComponent { + /** Display name of the Tax. */ + name: string; + /** Percent multiplied by a 100. Example: 12.125% is 1212.5. Will be rounded to 2 decimal places */ + value: number; +} diff --git a/src/api/types/VatRateListResponse.ts b/src/api/types/VatRateListResponse.ts index f9d0e14..4d4683f 100644 --- a/src/api/types/VatRateListResponse.ts +++ b/src/api/types/VatRateListResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface VatRateListResponse { data: Monite.VatRateResponse[]; diff --git a/src/api/types/VatRateResponse.ts b/src/api/types/VatRateResponse.ts index 920c656..8bcc88c 100644 --- a/src/api/types/VatRateResponse.ts +++ b/src/api/types/VatRateResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface VatRateResponse { /** Unique identifier of the vat rate object. */ @@ -11,6 +11,8 @@ export interface VatRateResponse { created_at: string; /** Date/time when this rate was updated in the table. */ updated_at: string; + /** Sub-taxes included in the VAT. */ + components?: Monite.VatRateComponent[]; /** 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. */ diff --git a/src/api/types/VerificationRequest.ts b/src/api/types/VerificationRequest.ts index 7281029..08d183c 100644 --- a/src/api/types/VerificationRequest.ts +++ b/src/api/types/VerificationRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface VerificationRequest { airwallex_plaid: Monite.VerificationAirwallexPlaidRequest; diff --git a/src/api/types/VerificationResponse.ts b/src/api/types/VerificationResponse.ts index 4f7f7e3..e40c728 100644 --- a/src/api/types/VerificationResponse.ts +++ b/src/api/types/VerificationResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface VerificationResponse { airwallex_plaid: Monite.VerificationAirwallexPlaidResponse; diff --git a/src/api/types/WebhookDeliveryPaginationResource.ts b/src/api/types/WebhookDeliveryPaginationResource.ts index 4f3133b..a9649d7 100644 --- a/src/api/types/WebhookDeliveryPaginationResource.ts +++ b/src/api/types/WebhookDeliveryPaginationResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface WebhookDeliveryPaginationResource { /** A set of webhooks returned per page */ diff --git a/src/api/types/WebhookSubscriptionPaginationResource.ts b/src/api/types/WebhookSubscriptionPaginationResource.ts index c129d98..5f2b02a 100644 --- a/src/api/types/WebhookSubscriptionPaginationResource.ts +++ b/src/api/types/WebhookSubscriptionPaginationResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface WebhookSubscriptionPaginationResource { /** A set of webhook settings of different types returned per page */ diff --git a/src/api/types/WebhookSubscriptionResource.ts b/src/api/types/WebhookSubscriptionResource.ts index 06e1d2d..1e888a8 100644 --- a/src/api/types/WebhookSubscriptionResource.ts +++ b/src/api/types/WebhookSubscriptionResource.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface WebhookSubscriptionResource { id: string; diff --git a/src/api/types/WebhookSubscriptionResourceWithSecret.ts b/src/api/types/WebhookSubscriptionResourceWithSecret.ts index c720c69..c055936 100644 --- a/src/api/types/WebhookSubscriptionResourceWithSecret.ts +++ b/src/api/types/WebhookSubscriptionResourceWithSecret.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Monite from "../index"; +import * as Monite from "../index.js"; export interface WebhookSubscriptionResourceWithSecret { id: string; diff --git a/src/api/types/index.ts b/src/api/types/index.ts index ad49eef..d02ddfe 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -1,612 +1,617 @@ -export * from "./ApiVersion"; -export * from "./AccessTokenResponse"; -export * from "./AccountDisabledReason"; -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 "./AccountingSettings"; -export * from "./AccountingTaxRateListResponse"; -export * from "./AccountingTaxRateResponse"; -export * from "./AccountingVendorRefObject"; -export * from "./ActionEnum"; -export * from "./ActionSchema"; -export * from "./AggregationFunctionEnum"; -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 "./AllowedEinvoicingCountryCodes"; -export * from "./AllowedFileTypes"; -export * from "./AnalyticsDataPoint"; -export * from "./ApprovalPolicyCursorFields"; -export * from "./ApprovalPolicyResourceScriptItem"; -export * from "./ApprovalPolicyResourceStatus"; -export * from "./ApprovalPolicyResourceTrigger"; -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 "./AutomationLevel"; -export * from "./BankAccount"; -export * from "./BankAccountVerificationType"; -export * from "./BankAccountVerifications"; -export * from "./BasedOnReceivableCreatedEventData"; -export * from "./BasedOnTransitionType"; -export * from "./BizObjectsSchemaInput"; -export * from "./BizObjectsSchemaOutput"; -export * from "./BusinessInfoSchema"; -export * from "./BusinessProfileInput"; -export * from "./BusinessProfileOutput"; -export * from "./ButtonTheme"; -export * from "./CardTheme"; -export * from "./CommentCursorFields"; -export * from "./CommentResource"; -export * from "./CommentResourceList"; -export * from "./CommonSchemaInput"; -export * from "./CommonSchemaOutput"; -export * from "./CompleteRefreshVerificationRequest"; -export * from "./CompleteRefreshVerificationResponse"; -export * from "./CompleteVerificationAirwallexPlaidRequest"; -export * from "./CompleteVerificationRequest"; -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 "./CounterpartEinvoicingCredentialResponse"; -export * from "./CounterpartEinvoicingCredentialResponseList"; -export * from "./CounterpartEinvoicingCredentialSchema"; -export * from "./CounterpartFields"; -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 "./CreateCounterpartEinvoicingCredentialCounterpartVatId"; -export * from "./CreateCounterpartEinvoicingCredentialPayload"; -export * from "./CreateExportTaskResponseSchema"; -export * from "./CreateOnboardingLinkRequest"; -export * from "./CreditNoteCursorFields"; -export * from "./CreditNoteDimensionEnum"; -export * from "./CreditNoteFieldsAllowedForValidate"; -export * from "./CreditNoteLineItemCreateRequest"; -export * from "./CreditNoteLineItemCursorFields"; -export * from "./CreditNoteLineItemPaginationResponse"; -export * from "./CreditNoteLineItemResponse"; -export * from "./CreditNoteMetricEnum"; -export * from "./CreditNotePaginationResponse"; -export * from "./CreditNoteRenderingSettings"; -export * from "./CreditNoteResponse"; -export * from "./CreditNoteResponsePayloadEntity"; -export * from "./CreditNoteResponsePayload"; -export * from "./CreditNoteStateEnum"; -export * from "./CreditNoteValidationResponse"; -export * from "./CreditNoteValidationsResource"; -export * from "./CurrencyEnum"; -export * from "./CurrencyExchangeSchema"; -export * from "./CurrencyExchangeSchema2"; -export * from "./CurrencySettingsInput"; -export * from "./CurrencySettingsOutput"; -export * from "./CursorFields"; -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 "./DateDimensionBreakdownEnum"; -export * from "./DayOfMonth"; -export * from "./DefaultAccountingTaxIDs"; -export * from "./DefaultLedgerAccountIDs"; -export * from "./DeliveryNoteCounterpartResource"; -export * from "./DeliveryNoteCreateBasedOnRequest"; -export * from "./DeliveryNoteCreateLineItem"; -export * from "./DeliveryNoteCreateRequest"; -export * from "./DeliveryNoteCursorFields"; -export * from "./DeliveryNoteLineItemProduct"; -export * from "./DeliveryNoteLineItemResource"; -export * from "./DeliveryNoteResourceEntity"; -export * from "./DeliveryNoteResource"; -export * from "./DeliveryNoteResourceList"; -export * from "./DeliveryNoteStatusEnum"; -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 "./DocumentRenderingSettings"; -export * from "./DocumentTypeEnum"; -export * from "./DocumentTypePrefix"; -export * from "./DomainListResponse"; -export * from "./DomainResponseDnsRecords"; -export * from "./DomainResponse"; -export * from "./EInvoicingRetrieveListData"; -export * from "./EinvoiceSchemaTypeEnum"; -export * from "./EinvoicingAddress"; -export * from "./EinvoicingConnectionResponse"; -export * from "./EinvoicingCredentials"; -export * from "./EinvoicingNetworkCredentialsResponse"; -export * from "./EntityAddressResponseSchema"; -export * from "./EntityAddressSchema"; -export * from "./EntityBankAccountPaginationResponse"; -export * from "./EntityBankAccountResponse"; -export * from "./EntityBusinessStructure"; -export * from "./EntityCursorFields"; -export * from "./EntityFields"; -export * from "./EntityIndividualResponse"; -export * from "./EntityOnboardingDataResponse"; -export * from "./EntityOnboardingDocuments"; -export * from "./EntityOrganizationResponse"; -export * from "./EntityPaginationResponse"; -export * from "./EntityResponse"; -export * from "./EntityStatusEnum"; -export * from "./EntityTypeEnum"; -export * from "./EntityUserCursorFields"; -export * from "./EntityUserPaginationResponse"; -export * from "./EntityUserResponse"; -export * from "./EntityVatIdResourceList"; -export * from "./EntityVatIdResponse"; -export * from "./ErrorSchema"; -export * from "./ErrorSchema2"; -export * from "./ErrorSchemaResponse"; -export * from "./ErrorSchemaResponse2"; -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 "./FieldSchema"; -export * from "./FileResponse"; -export * from "./FileSchema"; -export * from "./FileSchema2"; -export * from "./FileSchema3"; -export * from "./FilesResponse"; -export * from "./FinancingInvoice"; -export * from "./FinancingInvoiceCursorFields"; -export * from "./FinancingInvoiceListResponse"; -export * from "./FinancingInvoiceType"; -export * from "./FinancingOffer"; -export * from "./FinancingOffersResponse"; -export * from "./FinancingPushInvoicesRequestInvoice"; -export * from "./FinancingPushInvoicesResponse"; -export * from "./FinancingTokenResponse"; -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 "./InvoiceRenderingSettings"; -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 "./LineItemFields"; -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 "./MailSentEventData"; -export * from "./MailSettings"; -export * from "./MailboxDataResponse"; -export * from "./MailboxObjectTypeEnum"; -export * from "./MailboxResponse"; -export * from "./MessageResponse"; -export * from "./MissingFields"; -export * from "./MissingLineItemFields"; -export * from "./MoniteAllPaymentMethods"; -export * from "./MoniteAllPaymentMethodsTypes"; -export * from "./OcrAddress"; -export * from "./OcrAddressDetails"; -export * from "./OcrBankDetails"; -export * from "./OcrCounterpartDetails"; -export * from "./OcrCreditNote"; -export * from "./OcrDocumentTypeEnum"; -export * from "./OcrInvoice"; -export * from "./OcrLineItem"; -export * from "./OcrReceipt"; -export * from "./OcrReceiptLineItem"; -export * from "./OcrResponseInvoiceReceiptData"; -export * from "./OcrResponseInvoiceReceiptLineItemRaw"; -export * from "./OcrTaskStatus"; -export * from "./OcrTasksPaginationResponse"; -export * from "./ObjectMatchTypes"; -export * from "./ObjectType"; -export * from "./ObjectTypeAvailableComment"; -export * from "./ObjectTypeEnum"; -export * from "./OcrAutoTaggingSettingsRequest"; -export * from "./OcrRecognitionResponse"; -export * from "./OcrStatusEnum"; -export * from "./OcrTaskResponseSchemaRecognizedData"; -export * from "./OcrTaskResponseSchema"; -export * from "./OnboardingLinkPublicResponse"; -export * from "./OnboardingLinkRequest"; -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 "./OrganizationResponseSchema"; -export * from "./OrganizationSchema"; -export * from "./OriginEnum"; -export * from "./OverdueReminderResponse"; -export * from "./OverdueReminderTerm"; -export * from "./OwnershipDeclarationInput"; -export * from "./OwnershipDeclarationOutput"; -export * from "./PageSchema"; -export * from "./PageSchema2"; -export * from "./PageSchema3"; -export * from "./PartnerMetadata"; -export * from "./PartnerMetadataResponse"; -export * from "./PartnerProjectSettingsPayloadOutput"; -export * from "./PayableActionEnum"; -export * from "./PayableActionSchema"; -export * from "./PayableAggregatedDataResponse"; -export * from "./PayableAggregatedItem"; -export * from "./PayableAnalyticsResponse"; -export * from "./PayableCreditNoteData"; -export * from "./PayableCreditNoteStateEnum"; -export * from "./PayableCursorFields"; -export * from "./PayableDimensionEnum"; -export * from "./PayableEntityAddressSchema"; -export * from "./PayableEntityIndividualResponse"; -export * from "./PayableEntityOrganizationResponse"; -export * from "./PayableIndividualSchema"; -export * from "./PayableMetricEnum"; -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 "./PayableSchemaInput"; -export * from "./PayableSchemaOutput"; -export * from "./PayableSettings"; -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 "./PayerAccountResponse"; -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 "./PaymentPageTheme"; -export * from "./PaymentPriorityEnum"; -export * from "./PaymentReceivedEventData"; -export * from "./PaymentRecordCursorFields"; -export * from "./PaymentRecordObjectRequest"; -export * from "./PaymentRecordObjectResponse"; -export * from "./PaymentRecordResponse"; -export * from "./PaymentRecordResponseList"; -export * from "./PaymentRecordStatusEnum"; -export * from "./PaymentRecordStatusUpdateRequest"; -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 "./PaymentsBatchPaymentRequest"; -export * from "./PaymentsBatchPaymentResponse"; -export * from "./PaymentsBatchPaymentStatus"; -export * from "./PaymentsSettingsInput"; -export * from "./PaymentsSettingsOutput"; -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 "./PreviewTemplateResponse"; -export * from "./Price"; -export * from "./PricingPlan"; -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 "./QuoteRenderingSettings"; -export * from "./QuoteResponsePayloadEntity"; -export * from "./QuoteResponsePayload"; -export * from "./QuoteStateEnum"; -export * from "./ReceivableCounterpartContact"; -export * from "./ReceivableCounterpartType"; -export * from "./ReceivableCounterpartVatIdResponse"; -export * from "./ReceivableCreateBasedOnPayload"; -export * from "./ReceivableCreatedEventData"; -export * from "./ReceivableCursorFields"; -export * from "./ReceivableDimensionEnum"; -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 "./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 "./ReceivableMetricEnum"; -export * from "./ReceivablePaginationResponse"; -export * from "./ReceivablePreviewResponse"; -export * from "./ReceivableRequiredFields"; -export * from "./ReceivableResponse"; -export * from "./ReceivableSendResponse"; -export * from "./ReceivableSettings"; -export * from "./ReceivableTagCategory"; -export * from "./ReceivableTemplatesVariable"; -export * from "./ReceivableTemplatesVariablesObject"; -export * from "./ReceivableTemplatesVariablesObjectList"; -export * from "./ReceivableType"; -export * from "./ReceivableUpdatePayload"; -export * from "./ReceivableUpdatedEventData"; -export * from "./ReceivablesAnalyticsDataPoint"; -export * from "./ReceivablesAnalyticsResponse"; -export * from "./ReceivablesCounterpartAddress"; -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 "./ReminderMailSentEventData"; -export * from "./ReminderTypeEnum"; -export * from "./RemindersSettings"; -export * from "./RepaymentSchedule"; -export * from "./RequirementsError"; -export * from "./ResponseItem"; -export * from "./RoleCursorFields"; -export * from "./RolePaginationResponse"; -export * from "./RoleResponse"; -export * from "./RootSchemaInput"; -export * from "./RootSchemaOutput"; -export * from "./ServiceProvidersEnum"; -export * from "./SettingsResponse"; -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 "./TermsOfServiceAcceptanceInput"; -export * from "./TermsOfServiceAcceptanceOutput"; -export * from "./TextTemplateDocumentTypeEnum"; -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 "./WcBusinessStatus"; -export * from "./WcInvoiceStatus"; -export * from "./WcOfferStatus"; -export * from "./WcRepaymentType"; -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"; +export * from "./ApiVersion.js"; +export * from "./AccessTokenResponse.js"; +export * from "./AccountDisabledReason.js"; +export * from "./AccountingConnectionList.js"; +export * from "./AccountingConnectionResponse.js"; +export * from "./AccountingCustomerRefObject.js"; +export * from "./AccountingLineItem.js"; +export * from "./AccountingMessageResponse.js"; +export * from "./AccountingPayable.js"; +export * from "./AccountingPayableList.js"; +export * from "./AccountingPurchaseOrderRef.js"; +export * from "./AccountingReceivable.js"; +export * from "./AccountingReceivableList.js"; +export * from "./AccountingRefObject.js"; +export * from "./AccountingSettings.js"; +export * from "./AccountingTaxRateListResponse.js"; +export * from "./AccountingTaxRateResponse.js"; +export * from "./AccountingVendorRefObject.js"; +export * from "./ActionEnum.js"; +export * from "./ActionSchema.js"; +export * from "./AggregationFunctionEnum.js"; +export * from "./AirwallexMandate.js"; +export * from "./AirwallexMandateType.js"; +export * from "./AirwallexMandateVersion.js"; +export * from "./AirwallexPlaidAccount.js"; +export * from "./AirwallexPlaidBankAccountVerificationStatus.js"; +export * from "./AirwallexPlaidInstitution.js"; +export * from "./AirwallexPlaidVerification.js"; +export * from "./AllDocumentExportResponseSchema.js"; +export * from "./AllOverdueRemindersResponse.js"; +export * from "./AllowedCountries.js"; +export * from "./AllowedEinvoicingCountryCodes.js"; +export * from "./AllowedFileTypes.js"; +export * from "./AnalyticsDataPoint.js"; +export * from "./ApprovalPolicyCursorFields.js"; +export * from "./ApprovalPolicyResource.js"; +export * from "./ApprovalPolicyResourceList.js"; +export * from "./ApprovalPolicyStatus.js"; +export * from "./ApprovalProcessResourceList.js"; +export * from "./ApprovalProcessStepResource.js"; +export * from "./ApprovalProcessStepResourceList.js"; +export * from "./ApprovalProcessStepStatus.js"; +export * from "./ApprovalRequestCreateByRoleRequest.js"; +export * from "./ApprovalRequestCreateByUserRequest.js"; +export * from "./ApprovalRequestCreateRequest.js"; +export * from "./ApprovalRequestCursorFields.js"; +export * from "./ApprovalRequestResourceList.js"; +export * from "./ApprovalRequestResourceWithMetadata.js"; +export * from "./ApprovalRequestStatus.js"; +export * from "./AutomationLevel.js"; +export * from "./BankAccount.js"; +export * from "./BankAccountVerificationType.js"; +export * from "./BankAccountVerifications.js"; +export * from "./BasedOnReceivableCreatedEventData.js"; +export * from "./BasedOnTransitionType.js"; +export * from "./BizObjectsSchemaInput.js"; +export * from "./BizObjectsSchemaOutput.js"; +export * from "./BusinessInfoSchema.js"; +export * from "./BusinessProfileInput.js"; +export * from "./BusinessProfileOutput.js"; +export * from "./ButtonTheme.js"; +export * from "./CardTheme.js"; +export * from "./CommentCursorFields.js"; +export * from "./CommentResource.js"; +export * from "./CommentResourceList.js"; +export * from "./CommonSchemaInput.js"; +export * from "./CommonSchemaOutput.js"; +export * from "./CompleteRefreshVerificationRequest.js"; +export * from "./CompleteRefreshVerificationResponse.js"; +export * from "./CompleteVerificationAirwallexPlaidRequest.js"; +export * from "./CompleteVerificationRequest.js"; +export * from "./CompleteVerificationResponse.js"; +export * from "./ConnectionStatus.js"; +export * from "./CounterpartAddress.js"; +export * from "./CounterpartAddressResourceList.js"; +export * from "./CounterpartAddressResponseWithCounterpartId.js"; +export * from "./CounterpartBankAccountResourceList.js"; +export * from "./CounterpartBankAccountResponse.js"; +export * from "./CounterpartContactResponse.js"; +export * from "./CounterpartContactsResourceList.js"; +export * from "./CounterpartCreatePayload.js"; +export * from "./CounterpartCursorFields.js"; +export * from "./CounterpartEinvoicingCredentialResponse.js"; +export * from "./CounterpartEinvoicingCredentialResponseList.js"; +export * from "./CounterpartEinvoicingCredentialSchema.js"; +export * from "./CounterpartFields.js"; +export * from "./CounterpartIndividualCreatePayload.js"; +export * from "./CounterpartIndividualResponse.js"; +export * from "./CounterpartIndividualRootCreatePayload.js"; +export * from "./CounterpartIndividualRootResponse.js"; +export * from "./CounterpartIndividualRootUpdatePayload.js"; +export * from "./CounterpartIndividualUpdatePayload.js"; +export * from "./CounterpartOrganizationCreatePayload.js"; +export * from "./CounterpartOrganizationResponse.js"; +export * from "./CounterpartOrganizationRootCreatePayload.js"; +export * from "./CounterpartOrganizationRootResponse.js"; +export * from "./CounterpartOrganizationRootUpdatePayload.js"; +export * from "./CounterpartOrganizationUpdatePayload.js"; +export * from "./CounterpartPaginationResponse.js"; +export * from "./CounterpartRawAddress.js"; +export * from "./CounterpartRawAddressUpdateRequest.js"; +export * from "./CounterpartRawBankAccount.js"; +export * from "./CounterpartRawBankAccountUpdateRequest.js"; +export * from "./CounterpartRawData.js"; +export * from "./CounterpartRawDataUpdateRequest.js"; +export * from "./CounterpartRawVatId.js"; +export * from "./CounterpartRawVatIdUpdateRequest.js"; +export * from "./CounterpartResponse.js"; +export * from "./CounterpartTagSchema.js"; +export * from "./CounterpartType.js"; +export * from "./CounterpartUpdatePayload.js"; +export * from "./CounterpartVatIdResourceList.js"; +export * from "./CounterpartVatIdResponse.js"; +export * from "./CreateCounterpartEinvoicingCredentialCounterpartVatId.js"; +export * from "./CreateCounterpartEinvoicingCredentialPayload.js"; +export * from "./CreateExportTaskResponseSchema.js"; +export * from "./CreateOnboardingLinkRequest.js"; +export * from "./CreditNoteCursorFields.js"; +export * from "./CreditNoteDimensionEnum.js"; +export * from "./CreditNoteFieldsAllowedForValidate.js"; +export * from "./CreditNoteLineItemCreateRequest.js"; +export * from "./CreditNoteLineItemCursorFields.js"; +export * from "./CreditNoteLineItemPaginationResponse.js"; +export * from "./CreditNoteLineItemResponse.js"; +export * from "./CreditNoteMetricEnum.js"; +export * from "./CreditNotePaginationResponse.js"; +export * from "./CreditNoteRenderingSettings.js"; +export * from "./CreditNoteResponse.js"; +export * from "./CreditNoteResponsePayloadEntity.js"; +export * from "./CreditNoteResponsePayload.js"; +export * from "./CreditNoteStateEnum.js"; +export * from "./CreditNoteValidationResponse.js"; +export * from "./CreditNoteValidationsResource.js"; +export * from "./CurrencyEnum.js"; +export * from "./CurrencyExchangeSchema.js"; +export * from "./CurrencyExchangeSchema2.js"; +export * from "./CurrencySettingsInput.js"; +export * from "./CurrencySettingsOutput.js"; +export * from "./CursorFields.js"; +export * from "./CustomTemplateDataSchema.js"; +export * from "./CustomTemplatesCursorFields.js"; +export * from "./CustomTemplatesPaginationResponse.js"; +export * from "./CustomVatRateResponse.js"; +export * from "./CustomVatRateResponseList.js"; +export * from "./DnsRecord.js"; +export * from "./DnsRecordPurpose.js"; +export * from "./DnsRecordType.js"; +export * from "./DnsRecords.js"; +export * from "./DataExportCursorFields.js"; +export * from "./DateDimensionBreakdownEnum.js"; +export * from "./DayOfMonth.js"; +export * from "./DefaultAccountingTaxIDs.js"; +export * from "./DefaultLedgerAccountIDs.js"; +export * from "./DeliveryNoteCounterpartResource.js"; +export * from "./DeliveryNoteCreateBasedOnRequest.js"; +export * from "./DeliveryNoteCreateLineItem.js"; +export * from "./DeliveryNoteCreateRequest.js"; +export * from "./DeliveryNoteCursorFields.js"; +export * from "./DeliveryNoteLineItemProduct.js"; +export * from "./DeliveryNoteLineItemResource.js"; +export * from "./DeliveryNoteResourceEntity.js"; +export * from "./DeliveryNoteResource.js"; +export * from "./DeliveryNoteResourceList.js"; +export * from "./DeliveryNoteStatusEnum.js"; +export * from "./Discount.js"; +export * from "./DiscountResponse.js"; +export * from "./DiscountType.js"; +export * from "./DocumentExportResponseSchema.js"; +export * from "./DocumentIdSeparators.js"; +export * from "./DocumentIDsSettings.js"; +export * from "./DocumentIDsSettingsNextNumber.js"; +export * from "./DocumentIDsSettingsRequest.js"; +export * from "./DocumentObjectTypeRequestEnum.js"; +export * from "./DocumentRenderingSettings.js"; +export * from "./DocumentTypeEnum.js"; +export * from "./DocumentTypePrefix.js"; +export * from "./DomainListResponse.js"; +export * from "./DomainResponse.js"; +export * from "./EInvoicingRetrieveListData.js"; +export * from "./EinvoiceSchemaTypeEnum.js"; +export * from "./EinvoicingAddress.js"; +export * from "./EinvoicingConnectionResponse.js"; +export * from "./EinvoicingCredentials.js"; +export * from "./EinvoicingNetworkCredentialsResponse.js"; +export * from "./EntityAddressResponseSchema.js"; +export * from "./EntityAddressSchema.js"; +export * from "./EntityBankAccountPaginationResponse.js"; +export * from "./EntityBankAccountResponse.js"; +export * from "./EntityBusinessStructure.js"; +export * from "./EntityCursorFields.js"; +export * from "./EntityFields.js"; +export * from "./EntityIndividualResponse.js"; +export * from "./EntityOnboardingDataResponse.js"; +export * from "./EntityOnboardingDocuments.js"; +export * from "./EntityOrganizationResponse.js"; +export * from "./EntityPaginationResponse.js"; +export * from "./EntityResponse.js"; +export * from "./EntityStatusEnum.js"; +export * from "./EntityTypeEnum.js"; +export * from "./EntityUserCursorFields.js"; +export * from "./EntityUserPaginationResponse.js"; +export * from "./EntityUserResponse.js"; +export * from "./EntityVatIdResourceList.js"; +export * from "./EntityVatIdResponse.js"; +export * from "./ErrorSchema.js"; +export * from "./ErrorSchema2.js"; +export * from "./ErrorSchemaResponse.js"; +export * from "./ErrorSchemaResponse2.js"; +export * from "./EstimatedMonthlyRevenue.js"; +export * from "./EventCursorFields.js"; +export * from "./EventPaginationResource.js"; +export * from "./EventResource.js"; +export * from "./EventResourceForWebhookClient.js"; +export * from "./ExchangeRate.js"; +export * from "./ExportFormat.js"; +export * from "./ExportObjectSchema.js"; +export * from "./ExportPayableSchema.js"; +export * from "./ExportReceivableSchema.js"; +export * from "./ExportSettingCursorFields.js"; +export * from "./ExtraDataResource.js"; +export * from "./ExtraDataResourceList.js"; +export * from "./FieldSchema.js"; +export * from "./FileAttachedEventData.js"; +export * from "./FileResponse.js"; +export * from "./FileSchema.js"; +export * from "./FileSchema2.js"; +export * from "./FileSchema3.js"; +export * from "./FilesResponse.js"; +export * from "./FinancingInvoice.js"; +export * from "./FinancingInvoiceCursorFields.js"; +export * from "./FinancingInvoiceListResponse.js"; +export * from "./FinancingInvoiceType.js"; +export * from "./FinancingOffer.js"; +export * from "./FinancingOffersResponse.js"; +export * from "./FinancingPushInvoicesRequestInvoice.js"; +export * from "./FinancingPushInvoicesResponse.js"; +export * from "./FinancingTokenResponse.js"; +export * from "./GetAllPaymentReminders.js"; +export * from "./GetOnboardingRequirementsResponse.js"; +export * from "./GrantType.js"; +export * from "./HttpValidationError.js"; +export * from "./IndividualResponseSchema.js"; +export * from "./IndividualSchema.js"; +export * from "./InlinePaymentTermsRequestPayload.js"; +export * from "./InlineTermDiscount.js"; +export * from "./InlineTermFinal.js"; +export * from "./Invoice.js"; +export * from "./InvoiceFile.js"; +export * from "./InvoiceRenderingSettings.js"; +export * from "./InvoiceResponsePayloadEntity.js"; +export * from "./InvoiceResponsePayload.js"; +export * from "./Item.js"; +export * from "./IterationStatus.js"; +export * from "./LabelNValue.js"; +export * from "./LanguageCodeEnum.js"; +export * from "./LedgerAccountCursorFields.js"; +export * from "./LedgerAccountListResponse.js"; +export * from "./LedgerAccountResponse.js"; +export * from "./LineItem.js"; +export * from "./LineItemCursorFields.js"; +export * from "./LineItemFields.js"; +export * from "./LineItemInternalRequest.js"; +export * from "./LineItemPaginationResponse.js"; +export * from "./LineItemProduct.js"; +export * from "./LineItemProductCreate.js"; +export * from "./LineItemProductMeasureUnit.js"; +export * from "./LineItemProductVatRate.js"; +export * from "./LineItemRequest.js"; +export * from "./LineItemResponse.js"; +export * from "./LineItemUpdate.js"; +export * from "./LineItemsReplaceResponse.js"; +export * from "./LineItemsResponse.js"; +export * from "./MailSentEventData.js"; +export * from "./MailSettings.js"; +export * from "./MailboxDataResponse.js"; +export * from "./MailboxObjectTypeEnum.js"; +export * from "./MailboxResponse.js"; +export * from "./MessageResponse.js"; +export * from "./MissingFields.js"; +export * from "./MissingLineItemFields.js"; +export * from "./MoniteAllPaymentMethods.js"; +export * from "./MoniteAllPaymentMethodsTypes.js"; +export * from "./OcrAddress.js"; +export * from "./OcrAddressDetails.js"; +export * from "./OcrBankDetails.js"; +export * from "./OcrCounterpartDetails.js"; +export * from "./OcrCreditNote.js"; +export * from "./OcrDocumentTypeEnum.js"; +export * from "./OcrInvoice.js"; +export * from "./OcrLineItem.js"; +export * from "./OcrReceipt.js"; +export * from "./OcrReceiptLineItem.js"; +export * from "./OcrResponseInvoiceReceiptData.js"; +export * from "./OcrResponseInvoiceReceiptLineItemRaw.js"; +export * from "./OcrTaskStatus.js"; +export * from "./OcrTasksPaginationResponse.js"; +export * from "./ObjectMatchTypes.js"; +export * from "./ObjectType.js"; +export * from "./ObjectTypeAvailableComment.js"; +export * from "./ObjectTypeEnum.js"; +export * from "./OcrAutoTaggingSettingsRequest.js"; +export * from "./OcrRecognitionResponse.js"; +export * from "./OcrStatusEnum.js"; +export * from "./OcrTaskResponseSchemaRecognizedData.js"; +export * from "./OcrTaskResponseSchema.js"; +export * from "./OnboardingLinkPublicResponse.js"; +export * from "./OnboardingLinkRequest.js"; +export * from "./OnboardingLinkResponse.js"; +export * from "./OnboardingPaymentMethodsResponse.js"; +export * from "./OnboardingRequirementsError.js"; +export * from "./OnboardingRequirementsResponse.js"; +export * from "./OnboardingVerificationError.js"; +export * from "./OnboardingVerificationStatusEnum.js"; +export * from "./OptionalIndividualSchema.js"; +export * from "./OptionalOrganizationSchema.js"; +export * from "./OptionalPersonAddressRequest.js"; +export * from "./OptionalPersonRelationship.js"; +export * from "./OrderEnum.js"; +export * from "./OrganizationResponseSchema.js"; +export * from "./OrganizationSchema.js"; +export * from "./OriginEnum.js"; +export * from "./OverdueReminderResponse.js"; +export * from "./OverdueReminderTerm.js"; +export * from "./OwnershipDeclarationInput.js"; +export * from "./OwnershipDeclarationOutput.js"; +export * from "./PageSchema.js"; +export * from "./PageSchema2.js"; +export * from "./PageSchema3.js"; +export * from "./PartnerMetadata.js"; +export * from "./PartnerMetadataResponse.js"; +export * from "./PartnerProjectSettingsPayloadOutput.js"; +export * from "./PayableActionEnum.js"; +export * from "./PayableActionSchema.js"; +export * from "./PayableAggregatedDataResponse.js"; +export * from "./PayableAggregatedItem.js"; +export * from "./PayableAnalyticsResponse.js"; +export * from "./PayableCreatedEventData.js"; +export * from "./PayableCreditNoteData.js"; +export * from "./PayableCreditNoteLinkedEventData.js"; +export * from "./PayableCreditNoteStateEnum.js"; +export * from "./PayableCreditNoteUnlinkedEventData.js"; +export * from "./PayableCursorFields.js"; +export * from "./PayableDimensionEnum.js"; +export * from "./PayableEntityAddressSchema.js"; +export * from "./PayableEntityIndividualResponse.js"; +export * from "./PayableEntityOrganizationResponse.js"; +export * from "./PayableHistoryCursorFields.js"; +export * from "./PayableHistoryEventTypeEnum.js"; +export * from "./PayableHistoryPaginationResponse.js"; +export * from "./PayableHistoryResponse.js"; +export * from "./PayableIndividualSchema.js"; +export * from "./PayableMetricEnum.js"; +export * from "./PayableOrganizationSchema.js"; +export * from "./PayableOriginEnum.js"; +export * from "./PayablePaginationResponse.js"; +export * from "./PayablePaymentTermDiscount.js"; +export * from "./PayablePaymentTermFinal.js"; +export * from "./PayablePaymentTermsCreatePayload.js"; +export * from "./PayableResponseSchema.js"; +export * from "./PayableSchemaInput.js"; +export * from "./PayableSchemaOutput.js"; +export * from "./PayableSettings.js"; +export * from "./PayableStateEnum.js"; +export * from "./PayableStatusChangedEventData.js"; +export * from "./PayableTemplatesVariable.js"; +export * from "./PayableTemplatesVariablesObject.js"; +export * from "./PayableTemplatesVariablesObjectList.js"; +export * from "./PayableUpdatedEventData.js"; +export * from "./PayableValidationResponse.js"; +export * from "./PayableValidationsResource.js"; +export * from "./PayablesFieldsAllowedForValidate.js"; +export * from "./PayablesVariableType.js"; +export * from "./PayerAccountResponse.js"; +export * from "./PaymentAccountObject.js"; +export * from "./PaymentAccountType.js"; +export * from "./PaymentIntent.js"; +export * from "./PaymentIntentCursorFields.js"; +export * from "./PaymentIntentHistory.js"; +export * from "./PaymentIntentHistoryResponse.js"; +export * from "./PaymentIntentPayoutMethod.js"; +export * from "./PaymentIntentResponse.js"; +export * from "./PaymentIntentsListResponse.js"; +export * from "./PaymentIntentsRecipient.js"; +export * from "./PaymentMethod.js"; +export * from "./PaymentMethodDirection.js"; +export * from "./PaymentMethodRequirements.js"; +export * from "./PaymentMethodStatus.js"; +export * from "./PaymentObject.js"; +export * from "./PaymentObjectPayable.js"; +export * from "./PaymentObjectType.js"; +export * from "./PaymentPageTheme.js"; +export * from "./PaymentPriorityEnum.js"; +export * from "./PaymentReceivedEventData.js"; +export * from "./PaymentRecordCursorFields.js"; +export * from "./PaymentRecordHistoryResponse.js"; +export * from "./PaymentRecordObjectRequest.js"; +export * from "./PaymentRecordObjectResponse.js"; +export * from "./PaymentRecordResponse.js"; +export * from "./PaymentRecordResponseList.js"; +export * from "./PaymentRecordStatusEnum.js"; +export * from "./PaymentRecordStatusUpdateRequest.js"; +export * from "./PaymentReminderResponse.js"; +export * from "./PaymentRequirements.js"; +export * from "./PaymentTerms.js"; +export * from "./PaymentTermsListResponse.js"; +export * from "./PaymentTermsResponse.js"; +export * from "./PaymentsBatchPaymentRequest.js"; +export * from "./PaymentsBatchPaymentResponse.js"; +export * from "./PaymentsBatchPaymentStatus.js"; +export * from "./PaymentsSettingsInput.js"; +export * from "./PaymentsSettingsOutput.js"; +export * from "./PermissionEnum.js"; +export * from "./PersonAddressRequest.js"; +export * from "./PersonAddressResponse.js"; +export * from "./PersonOnboardingDocuments.js"; +export * from "./PersonRelationshipRequest.js"; +export * from "./PersonRelationshipResponse.js"; +export * from "./PersonResponse.js"; +export * from "./PersonsResponse.js"; +export * from "./Platform.js"; +export * from "./PreviewSchema.js"; +export * from "./PreviewSchema2.js"; +export * from "./PreviewSchema3.js"; +export * from "./PreviewTemplateResponse.js"; +export * from "./Price.js"; +export * from "./PricingPlan.js"; +export * from "./ProcessResource.js"; +export * from "./ProcessStatusEnum.js"; +export * from "./ProductCursorFields.js"; +export * from "./ProductServicePaginationResponse.js"; +export * from "./ProductServiceResponse.js"; +export * from "./ProductServiceTypeEnum.js"; +export * from "./ProjectCursorFields.js"; +export * from "./ProjectPaginationResponse.js"; +export * from "./ProjectResource.js"; +export * from "./PublicPaymentLinkResponse.js"; +export * from "./PurchaseOrderCounterpartAddressSchema.js"; +export * from "./PurchaseOrderCounterpartIndividualResponse.js"; +export * from "./PurchaseOrderCounterpartIndividualRootResponse.js"; +export * from "./PurchaseOrderCounterpartOrganizationResponse.js"; +export * from "./PurchaseOrderCounterpartOrganizationRootResponse.js"; +export * from "./PurchaseOrderCounterpartSchema.js"; +export * from "./PurchaseOrderCursorFields.js"; +export * from "./PurchaseOrderEmailPreviewResponse.js"; +export * from "./PurchaseOrderEmailSentResponse.js"; +export * from "./PurchaseOrderItem.js"; +export * from "./PurchaseOrderPaginationResponse.js"; +export * from "./PurchaseOrderResponseSchema.js"; +export * from "./PurchaseOrderStatusEnum.js"; +export * from "./PurchaseOrderVatId.js"; +export * from "./QuoteRenderingSettings.js"; +export * from "./QuoteResponsePayloadEntity.js"; +export * from "./QuoteResponsePayload.js"; +export * from "./QuoteStateEnum.js"; +export * from "./ReceivableCounterpartContact.js"; +export * from "./ReceivableCounterpartVatIdResponse.js"; +export * from "./ReceivableCreateBasedOnPayload.js"; +export * from "./ReceivableCreatedEventData.js"; +export * from "./ReceivableCursorFields.js"; +export * from "./ReceivableCursorFields2.js"; +export * from "./ReceivableDimensionEnum.js"; +export * from "./ReceivableEditFlow.js"; +export * from "./ReceivableEntityAddressSchema.js"; +export * from "./ReceivableEntityBase.js"; +export * from "./ReceivableEntityIndividual.js"; +export * from "./ReceivableEntityIndividualRequest.js"; +export * from "./ReceivableEntityOrganization.js"; +export * from "./ReceivableEntityOrganizationRequest.js"; +export * from "./ReceivableEntityVatIdResponse.js"; +export * from "./ReceivableFacadeCreateInvoicePayload.js"; +export * from "./ReceivableFacadeCreatePayload.js"; +export * from "./ReceivableFacadeCreateQuotePayload.js"; +export * from "./ReceivableFileUrl.js"; +export * from "./ReceivableHistoryCursorFields.js"; +export * from "./ReceivableHistoryEventTypeEnum.js"; +export * from "./ReceivableHistoryPaginationResponse.js"; +export * from "./ReceivableHistoryResponse.js"; +export * from "./ReceivableMailCursorFields.js"; +export * from "./ReceivableMailPaginationResponse.js"; +export * from "./ReceivableMailRecipientState.js"; +export * from "./ReceivableMailRecipients.js"; +export * from "./ReceivableMailResponse.js"; +export * from "./ReceivableMailStatusEnum.js"; +export * from "./ReceivableMetricEnum.js"; +export * from "./ReceivablePaginationResponse.js"; +export * from "./ReceivablePreviewResponse.js"; +export * from "./ReceivableRequiredFields.js"; +export * from "./ReceivableResponse.js"; +export * from "./ReceivableSendResponse.js"; +export * from "./ReceivableSettings.js"; +export * from "./ReceivableTemplatesVariable.js"; +export * from "./ReceivableTemplatesVariablesObject.js"; +export * from "./ReceivableTemplatesVariablesObjectList.js"; +export * from "./ReceivableType.js"; +export * from "./ReceivableUpdatePayload.js"; +export * from "./ReceivableUpdatedEventData.js"; +export * from "./ReceivablesAnalyticsDataPoint.js"; +export * from "./ReceivablesAnalyticsResponse.js"; +export * from "./ReceivablesCounterpartAddress.js"; +export * from "./ReceivablesPreviewTypeEnum.js"; +export * from "./ReceivablesRemindersWarningMessage.js"; +export * from "./ReceivablesRepresentationOfCounterpartAddress.js"; +export * from "./ReceivablesRepresentationOfEntityBankAccount.js"; +export * from "./ReceivablesSendResponse.js"; +export * from "./ReceivablesStatusEnum.js"; +export * from "./ReceivablesVerifyResponse.js"; +export * from "./Recipient.js"; +export * from "./RecipientAccountResponse.js"; +export * from "./RecipientType.js"; +export * from "./Recipients.js"; +export * from "./RecurrenceFrequency.js"; +export * from "./RecurrenceIteration.js"; +export * from "./RecurrenceResponse.js"; +export * from "./RecurrenceResponseList.js"; +export * from "./RecurrenceStatus.js"; +export * from "./RelatedDocuments.js"; +export * from "./Reminder.js"; +export * from "./ReminderMailSentEventData.js"; +export * from "./ReminderTypeEnum.js"; +export * from "./RemindersSettings.js"; +export * from "./RepaymentSchedule.js"; +export * from "./RequirementsError.js"; +export * from "./ResponseItem.js"; +export * from "./RoleCursorFields.js"; +export * from "./RolePaginationResponse.js"; +export * from "./RoleResponse.js"; +export * from "./RootSchemaInput.js"; +export * from "./RootSchemaOutput.js"; +export * from "./ServiceProvidersEnum.js"; +export * from "./SettingsResponse.js"; +export * from "./Signature.js"; +export * from "./SingleOnboardingRequirementsResponse.js"; +export * from "./SinglePaymentIntent.js"; +export * from "./SinglePaymentIntentResponse.js"; +export * from "./SourceOfPayableDataEnum.js"; +export * from "./StatusChangedEventData.js"; +export * from "./StatusEnum.js"; +export * from "./SuccessResult.js"; +export * from "./SuggestedPaymentTerm.js"; +export * from "./SupportedFieldNames.js"; +export * from "./SupportedFormatSchema.js"; +export * from "./SyncRecordCursorFields.js"; +export * from "./SyncRecordResource.js"; +export * from "./SyncRecordResourceList.js"; +export * from "./SyncStatus.js"; +export * from "./SystemTemplateDataSchema.js"; +export * from "./SystemTemplates.js"; +export * from "./TagCategory.js"; +export * from "./TagCursorFields.js"; +export * from "./TagReadSchema.js"; +export * from "./TagsPaginationResponse.js"; +export * from "./TaxComponentResponse.js"; +export * from "./TaxRateAccountCursorFields.js"; +export * from "./TemplateDataSchema.js"; +export * from "./TemplateListResponse.js"; +export * from "./TemplateReceivableResponse.js"; +export * from "./TemplateTypeEnum.js"; +export * from "./TermDiscountDays.js"; +export * from "./TermFinalDays.js"; +export * from "./TermsOfServiceAcceptanceInput.js"; +export * from "./TermsOfServiceAcceptanceOutput.js"; +export * from "./TextTemplateDocumentTypeEnum.js"; +export * from "./TextTemplateResponse.js"; +export * from "./TextTemplateResponseList.js"; +export * from "./TextTemplateType.js"; +export * from "./TotalVatAmountItem.js"; +export * from "./TotalVatAmountItemComponent.js"; +export * from "./Unit.js"; +export * from "./UnitListResponse.js"; +export * from "./UnitRequest.js"; +export * from "./UnitResponse.js"; +export * from "./UpdateCreditNote.js"; +export * from "./UpdateCreditNotePayload.js"; +export * from "./UpdateEinvoicingAddress.js"; +export * from "./UpdateEntityAddressSchema.js"; +export * from "./UpdateEntityRequest.js"; +export * from "./UpdateInvoice.js"; +export * from "./UpdateInvoicePayload.js"; +export * from "./UpdateIssuedInvoiceEntity.js"; +export * from "./UpdateIssuedInvoice.js"; +export * from "./UpdateIssuedInvoicePayload.js"; +export * from "./UpdateLineItemForCreditNote.js"; +export * from "./UpdateProductForCreditNote.js"; +export * from "./UpdateQuote.js"; +export * from "./UpdateQuotePayload.js"; +export * from "./ValidationError.js"; +export * from "./Variable.js"; +export * from "./VariablesObject.js"; +export * from "./VariablesObjectList.js"; +export * from "./VariablesType.js"; +export * from "./VatIdTypeEnum.js"; +export * from "./VatModeEnum.js"; +export * from "./VatRateComponent.js"; +export * from "./VatRateCreator.js"; +export * from "./VatRateListResponse.js"; +export * from "./VatRateResponse.js"; +export * from "./VatRateStatusEnum.js"; +export * from "./VerificationAirwallexPlaidRequest.js"; +export * from "./VerificationAirwallexPlaidResponse.js"; +export * from "./VerificationError.js"; +export * from "./VerificationRequest.js"; +export * from "./VerificationResponse.js"; +export * from "./VerificationStatusEnum.js"; +export * from "./VerifyResponse.js"; +export * from "./WcBusinessStatus.js"; +export * from "./WcInvoiceStatus.js"; +export * from "./WcOfferStatus.js"; +export * from "./WcRepaymentType.js"; +export * from "./WebhookDeliveryCursorFields.js"; +export * from "./WebhookDeliveryPaginationResource.js"; +export * from "./WebhookDeliveryResource.js"; +export * from "./WebhookObjectType.js"; +export * from "./WebhookSubscriptionCursorFields.js"; +export * from "./WebhookSubscriptionPaginationResource.js"; +export * from "./WebhookSubscriptionResource.js"; +export * from "./WebhookSubscriptionResourceWithSecret.js"; +export * from "./WebhookSubscriptionStatus.js"; diff --git a/src/core/auth/index.ts b/src/core/auth/index.ts index ee293b3..59c0fe7 100644 --- a/src/core/auth/index.ts +++ b/src/core/auth/index.ts @@ -1,2 +1,2 @@ -export { BasicAuth } from "./BasicAuth"; -export { BearerToken } from "./BearerToken"; +export { BasicAuth } from "./BasicAuth.js"; +export { BearerToken } from "./BearerToken.js"; diff --git a/src/core/fetcher/APIResponse.ts b/src/core/fetcher/APIResponse.ts index 6335291..dd4b946 100644 --- a/src/core/fetcher/APIResponse.ts +++ b/src/core/fetcher/APIResponse.ts @@ -1,4 +1,4 @@ -import { RawResponse } from "./RawResponse"; +import { RawResponse } from "./RawResponse.js"; /** * The response of an API call. diff --git a/src/core/fetcher/BinaryResponse.ts b/src/core/fetcher/BinaryResponse.ts new file mode 100644 index 0000000..8c134bc --- /dev/null +++ b/src/core/fetcher/BinaryResponse.ts @@ -0,0 +1,29 @@ +import { ResponseWithBody } from "./ResponseWithBody.js"; + +export interface BinaryResponse { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */ + bodyUsed: boolean; + /** + * Returns a ReadableStream of the response body. + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) + */ + stream: () => ReadableStream; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */ + arrayBuffer: () => Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */ + blob: () => Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */ + bytes(): Promise; +} + +export function getBinaryResponse(response: ResponseWithBody): BinaryResponse { + return { + get bodyUsed() { + return response.bodyUsed; + }, + stream: () => response.body, + arrayBuffer: response.arrayBuffer.bind(response), + blob: response.blob.bind(response), + bytes: response.bytes.bind(response), + }; +} diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts index 336ee10..5f3ba76 100644 --- a/src/core/fetcher/Fetcher.ts +++ b/src/core/fetcher/Fetcher.ts @@ -1,12 +1,13 @@ -import { toJson } from "../json"; -import { APIResponse } from "./APIResponse"; -import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse"; -import { createRequestUrl } from "./createRequestUrl"; -import { getFetchFn } from "./getFetchFn"; -import { getRequestBody } from "./getRequestBody"; -import { getResponseBody } from "./getResponseBody"; -import { makeRequest } from "./makeRequest"; -import { requestWithRetries } from "./requestWithRetries"; +import { toJson } from "../json.js"; +import { APIResponse } from "./APIResponse.js"; +import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js"; +import { Supplier } from "./Supplier.js"; +import { createRequestUrl } from "./createRequestUrl.js"; +import { getFetchFn } from "./getFetchFn.js"; +import { getRequestBody } from "./getRequestBody.js"; +import { getResponseBody } from "./getResponseBody.js"; +import { makeRequest } from "./makeRequest.js"; +import { requestWithRetries } from "./requestWithRetries.js"; export type FetchFunction = (args: Fetcher.Args) => Promise>; @@ -15,7 +16,7 @@ export declare namespace Fetcher { url: string; method: string; contentType?: string; - headers?: Record; + headers?: Record | undefined>; queryParameters?: Record; body?: unknown; timeoutMs?: number; @@ -23,7 +24,7 @@ export declare namespace Fetcher { withCredentials?: boolean; abortSignal?: AbortSignal; requestType?: "json" | "file" | "bytes"; - responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer"; + responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response"; duplex?: "half"; } @@ -51,20 +52,31 @@ export declare namespace Fetcher { } } -export async function fetcherImpl(args: Fetcher.Args): Promise> { - const headers: Record = {}; +async function getHeaders(args: Fetcher.Args): Promise> { + const newHeaders: Record = {}; if (args.body !== undefined && args.contentType != null) { - headers["Content-Type"] = args.contentType; + newHeaders["Content-Type"] = args.contentType; + } + + if (args.headers == null) { + return newHeaders; } - if (args.headers != null) { - for (const [key, value] of Object.entries(args.headers)) { - if (value != null) { - headers[key] = value; - } + for (const [key, value] of Object.entries(args.headers)) { + const result = await Supplier.get(value); + if (typeof result === "string") { + newHeaders[key] = result; + continue; } + if (result == null) { + continue; + } + newHeaders[key] = `${result}`; } + return newHeaders; +} +export async function fetcherImpl(args: Fetcher.Args): Promise> { const url = createRequestUrl(args.url, args.queryParameters); const requestBody: BodyInit | undefined = await getRequestBody({ body: args.body, @@ -79,7 +91,7 @@ export async function fetcherImpl(args: Fetcher.Args): Promise; +}; + +export function isResponseWithBody(response: Response): response is ResponseWithBody { + return (response as ResponseWithBody).body != null; +} diff --git a/src/core/fetcher/getFetchFn.ts b/src/core/fetcher/getFetchFn.ts index 9fd9bfc..3b27d49 100644 --- a/src/core/fetcher/getFetchFn.ts +++ b/src/core/fetcher/getFetchFn.ts @@ -1,4 +1,4 @@ -import { RUNTIME } from "../runtime"; +import { RUNTIME } from "../runtime/index.js"; /** * Returns a fetch function based on the runtime diff --git a/src/core/fetcher/getRequestBody.ts b/src/core/fetcher/getRequestBody.ts index fce5589..e38457c 100644 --- a/src/core/fetcher/getRequestBody.ts +++ b/src/core/fetcher/getRequestBody.ts @@ -1,4 +1,4 @@ -import { toJson } from "../json"; +import { toJson } from "../json.js"; export declare namespace GetRequestBody { interface Args { diff --git a/src/core/fetcher/getResponseBody.ts b/src/core/fetcher/getResponseBody.ts index d046e6e..c1e2bed 100644 --- a/src/core/fetcher/getResponseBody.ts +++ b/src/core/fetcher/getResponseBody.ts @@ -1,34 +1,44 @@ -import { chooseStreamWrapper } from "./stream-wrappers/chooseStreamWrapper"; +import { getBinaryResponse } from "./BinaryResponse.js"; +import { isResponseWithBody } from "./ResponseWithBody.js"; + +import { chooseStreamWrapper } from "./stream-wrappers/chooseStreamWrapper.js"; 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 === "arrayBuffer") { - return await response.arrayBuffer(); - } 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; + if (!isResponseWithBody(response)) { + return undefined; + } + switch (responseType) { + case "binary-response": + return getBinaryResponse(response); + case "blob": + return await response.blob(); + case "arrayBuffer": + return await response.arrayBuffer(); + case "sse": + return response.body; + case "streaming": + return chooseStreamWrapper(response.body); + + case "text": + return await response.text(); + } + + // if responseType is "json" or not specified, try to parse as JSON + 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, + }, + }; } } + return undefined; } diff --git a/src/core/fetcher/index.ts b/src/core/fetcher/index.ts index 249f517..49e1393 100644 --- a/src/core/fetcher/index.ts +++ b/src/core/fetcher/index.ts @@ -1,8 +1,9 @@ -export type { APIResponse } from "./APIResponse"; -export { fetcher } from "./Fetcher"; -export type { Fetcher, FetchFunction } from "./Fetcher"; -export { getHeader } from "./getHeader"; -export { Supplier } from "./Supplier"; -export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse"; -export type { RawResponse, WithRawResponse } from "./RawResponse"; -export { HttpResponsePromise } from "./HttpResponsePromise"; +export type { APIResponse } from "./APIResponse.js"; +export { fetcher } from "./Fetcher.js"; +export type { Fetcher, FetchFunction } from "./Fetcher.js"; +export { getHeader } from "./getHeader.js"; +export { Supplier } from "./Supplier.js"; +export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js"; +export type { RawResponse, WithRawResponse } from "./RawResponse.js"; +export { HttpResponsePromise } from "./HttpResponsePromise.js"; +export { BinaryResponse } from "./BinaryResponse.js"; diff --git a/src/core/fetcher/makeRequest.ts b/src/core/fetcher/makeRequest.ts index 1af42bb..1a5ffd3 100644 --- a/src/core/fetcher/makeRequest.ts +++ b/src/core/fetcher/makeRequest.ts @@ -1,4 +1,4 @@ -import { anySignal, getTimeoutSignal } from "./signals"; +import { anySignal, getTimeoutSignal } from "./signals.js"; export const makeRequest = async ( fetchFn: (url: string, init: RequestInit) => Promise, diff --git a/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts b/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts index 6f1a82e..289085f 100644 --- a/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +++ b/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts @@ -1,6 +1,6 @@ import type { Writable } from "readable-stream"; -import { EventCallback, StreamWrapper } from "./chooseStreamWrapper"; +import { EventCallback, StreamWrapper } from "./chooseStreamWrapper.js"; export class Node18UniversalStreamWrapper implements diff --git a/src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts b/src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts index 23c01a1..c7b3e4f 100644 --- a/src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts +++ b/src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts @@ -1,6 +1,6 @@ import type { Readable, Writable } from "readable-stream"; -import { EventCallback, StreamWrapper } from "./chooseStreamWrapper"; +import { EventCallback, StreamWrapper } from "./chooseStreamWrapper.js"; export class NodePre18StreamWrapper implements StreamWrapper { private readableStream: Readable; diff --git a/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts b/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts index 091e2a7..951b1d6 100644 --- a/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +++ b/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts @@ -1,4 +1,4 @@ -import { StreamWrapper } from "./chooseStreamWrapper"; +import { StreamWrapper } from "./chooseStreamWrapper.js"; type EventCallback = (data?: any) => void; diff --git a/src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts b/src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts index 8c7492f..c4f370f 100644 --- a/src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts +++ b/src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts @@ -1,6 +1,6 @@ import type { Readable } from "readable-stream"; -import { RUNTIME } from "../../runtime"; +import { RUNTIME } from "../../runtime/index.js"; export type EventCallback = (data?: any) => void; @@ -23,12 +23,12 @@ export interface StreamWrapper { export async function chooseStreamWrapper(responseBody: any): Promise>> { if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) { - return new (await import("./Node18UniversalStreamWrapper")).Node18UniversalStreamWrapper( + return new (await import("./Node18UniversalStreamWrapper.js")).Node18UniversalStreamWrapper( responseBody as ReadableStream, ); } else if (RUNTIME.type !== "node" && typeof fetch === "function") { - return new (await import("./UndiciStreamWrapper")).UndiciStreamWrapper(responseBody as ReadableStream); + return new (await import("./UndiciStreamWrapper.js")).UndiciStreamWrapper(responseBody as ReadableStream); } else { - return new (await import("./NodePre18StreamWrapper")).NodePre18StreamWrapper(responseBody as Readable); + return new (await import("./NodePre18StreamWrapper.js")).NodePre18StreamWrapper(responseBody as Readable); } } diff --git a/src/core/form-data-utils/FormDataWrapper.ts b/src/core/form-data-utils/FormDataWrapper.ts index f7a9830..c2f8cb3 100644 --- a/src/core/form-data-utils/FormDataWrapper.ts +++ b/src/core/form-data-utils/FormDataWrapper.ts @@ -1,4 +1,5 @@ -import { RUNTIME } from "../runtime"; +import { RUNTIME } from "../runtime/index.js"; +import { toReadableStream } from "./toReadableStream.js"; export type MaybePromise = Promise | T; @@ -98,7 +99,7 @@ export class Node18FormData implements CrossPlatformFormData { 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), + body: await toReadableStream(encoder), headers: encoder.headers, duplex: "half", }; diff --git a/src/core/form-data-utils/index.ts b/src/core/form-data-utils/index.ts index 62121d5..1188f80 100644 --- a/src/core/form-data-utils/index.ts +++ b/src/core/form-data-utils/index.ts @@ -1,2 +1,2 @@ -export { encodeAsFormParameter } from "./encodeAsFormParameter"; -export * from "./FormDataWrapper"; +export { encodeAsFormParameter } from "./encodeAsFormParameter.js"; +export * from "./FormDataWrapper.js"; diff --git a/src/core/form-data-utils/toReadableStream.ts b/src/core/form-data-utils/toReadableStream.ts new file mode 100644 index 0000000..955d6ac --- /dev/null +++ b/src/core/form-data-utils/toReadableStream.ts @@ -0,0 +1,3 @@ +export async function toReadableStream(encoder: import("form-data-encoder").FormDataEncoder) { + return (await import("readable-stream")).Readable.from(encoder); +} diff --git a/src/core/headers.ts b/src/core/headers.ts new file mode 100644 index 0000000..561314d --- /dev/null +++ b/src/core/headers.ts @@ -0,0 +1,35 @@ +import * as core from "./index.js"; + +export function mergeHeaders( + ...headersArray: (Record | undefined> | undefined)[] +): Record> { + const result: Record> = {}; + + for (const [key, value] of headersArray + .filter((headers) => headers != null) + .flatMap((headers) => Object.entries(headers))) { + if (value != null) { + result[key] = value; + } else if (key in result) { + delete result[key]; + } + } + + return result; +} + +export function mergeOnlyDefinedHeaders( + ...headersArray: (Record | undefined> | undefined)[] +): Record> { + const result: Record> = {}; + + for (const [key, value] of headersArray + .filter((headers) => headers != null) + .flatMap((headers) => Object.entries(headers))) { + if (value != null) { + result[key] = value; + } + } + + return result; +} diff --git a/src/core/index.ts b/src/core/index.ts index 4f67d9a..0547cb8 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,4 +1,4 @@ -export * from "./fetcher"; -export * from "./runtime"; -export * from "./auth"; -export * from "./form-data-utils"; +export * from "./fetcher/index.js"; +export * from "./runtime/index.js"; +export * from "./auth/index.js"; +export * from "./form-data-utils/index.js"; diff --git a/src/core/runtime/index.ts b/src/core/runtime/index.ts index 5c76dbb..cfab23f 100644 --- a/src/core/runtime/index.ts +++ b/src/core/runtime/index.ts @@ -1 +1 @@ -export { RUNTIME } from "./runtime"; +export { RUNTIME } from "./runtime.js"; diff --git a/src/core/runtime/runtime.ts b/src/core/runtime/runtime.ts index a975017..08fd256 100644 --- a/src/core/runtime/runtime.ts +++ b/src/core/runtime/runtime.ts @@ -11,6 +11,9 @@ interface BunGlobal { declare const Deno: DenoGlobal | undefined; declare const Bun: BunGlobal | undefined; declare const EdgeRuntime: string | undefined; +declare const self: typeof globalThis.self & { + importScripts?: unknown; +}; /** * A constant that indicates which environment and version the SDK is running in. @@ -62,7 +65,6 @@ function evaluateRuntime(): Runtime { */ const isWebWorker = typeof self === "object" && - // @ts-ignore typeof self?.importScripts === "function" && (self.constructor?.name === "DedicatedWorkerGlobalScope" || self.constructor?.name === "ServiceWorkerGlobalScope" || diff --git a/src/errors/MoniteError.ts b/src/errors/MoniteError.ts index 4f44b50..4e22bee 100644 --- a/src/errors/MoniteError.ts +++ b/src/errors/MoniteError.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as core from "../core"; -import { toJson } from "../core/json"; +import * as core from "../core/index.js"; +import { toJson } from "../core/json.js"; export class MoniteError extends Error { public readonly statusCode?: number; diff --git a/src/errors/index.ts b/src/errors/index.ts index 8f63c9a..a104d7e 100644 --- a/src/errors/index.ts +++ b/src/errors/index.ts @@ -1,2 +1,2 @@ -export { MoniteError } from "./MoniteError"; -export { MoniteTimeoutError } from "./MoniteTimeoutError"; +export { MoniteError } from "./MoniteError.js"; +export { MoniteTimeoutError } from "./MoniteTimeoutError.js"; diff --git a/src/index.ts b/src/index.ts index fa21f0c..2db61f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export * as Monite from "./api"; -export { MoniteClient } from "./Client"; -export { MoniteEnvironment } from "./environments"; -export { MoniteError, MoniteTimeoutError } from "./errors"; +export * as Monite from "./api/index.js"; +export { MoniteError, MoniteTimeoutError } from "./errors/index.js"; +export { MoniteClient } from "./Client.js"; +export { MoniteEnvironment } from "./environments.js"; diff --git a/src/version.ts b/src/version.ts index 9b7fc09..659d877 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const SDK_VERSION = "0.3.3"; +export const SDK_VERSION = "0.3.4"; diff --git a/tests/mock-server/MockServer.ts b/tests/mock-server/MockServer.ts new file mode 100644 index 0000000..6e258f1 --- /dev/null +++ b/tests/mock-server/MockServer.ts @@ -0,0 +1,29 @@ +import { RequestHandlerOptions } from "msw"; +import type { SetupServer } from "msw/node"; + +import { mockEndpointBuilder } from "./mockEndpointBuilder"; + +export interface MockServerOptions { + baseUrl: string; + server: SetupServer; +} + +export class MockServer { + private readonly server: SetupServer; + public readonly baseUrl: string; + + constructor({ baseUrl, server }: MockServerOptions) { + this.baseUrl = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl; + this.server = server; + } + + public mockEndpoint(options?: RequestHandlerOptions): ReturnType { + const builder = mockEndpointBuilder({ + once: options?.once, + onBuild: (handler) => { + this.server.use(handler); + }, + }).baseUrl(this.baseUrl); + return builder; + } +} diff --git a/tests/mock-server/MockServerPool.ts b/tests/mock-server/MockServerPool.ts new file mode 100644 index 0000000..8160806 --- /dev/null +++ b/tests/mock-server/MockServerPool.ts @@ -0,0 +1,106 @@ +import { setupServer } from "msw/node"; + +import { fromJson, toJson } from "../../src/core/json"; +import { MockServer } from "./MockServer"; +import { randomBaseUrl } from "./randomBaseUrl"; + +const mswServer = setupServer(); +interface MockServerOptions { + baseUrl?: string; +} + +async function formatHttpRequest(request: Request, id?: string): Promise { + try { + const clone = request.clone(); + const headers = [...clone.headers.entries()].map(([k, v]) => `${k}: ${v}`).join("\n"); + + let body = ""; + try { + const contentType = clone.headers.get("content-type"); + if (contentType?.includes("application/json")) { + body = toJson(fromJson(await clone.text()), undefined, 2); + } else if (clone.body) { + body = await clone.text(); + } + } catch (e) { + body = "(unable to parse body)"; + } + + const title = id ? `### Request ${id} ###\n` : ""; + const firstLine = `${title}${request.method} ${request.url.toString()} HTTP/1.1`; + + return `\n${firstLine}\n${headers}\n\n${body || "(no body)"}\n`; + } catch (e) { + return `Error formatting request: ${e}`; + } +} + +async function formatHttpResponse(response: Response, id?: string): Promise { + try { + const clone = response.clone(); + const headers = [...clone.headers.entries()].map(([k, v]) => `${k}: ${v}`).join("\n"); + + let body = ""; + try { + const contentType = clone.headers.get("content-type"); + if (contentType?.includes("application/json")) { + body = toJson(fromJson(await clone.text()), undefined, 2); + } else if (clone.body) { + body = await clone.text(); + } + } catch (e) { + body = "(unable to parse body)"; + } + + const title = id ? `### Response for ${id} ###\n` : ""; + const firstLine = `${title}HTTP/1.1 ${response.status} ${response.statusText}`; + + return `\n${firstLine}\n${headers}\n\n${body || "(no body)"}\n`; + } catch (e) { + return `Error formatting response: ${e}`; + } +} + +class MockServerPool { + private servers: MockServer[] = []; + + public createServer(options?: Partial): MockServer { + const baseUrl = options?.baseUrl || randomBaseUrl(); + const server = new MockServer({ baseUrl, server: mswServer }); + this.servers.push(server); + return server; + } + + public getServers(): MockServer[] { + return [...this.servers]; + } + + public listen(): void { + const onUnhandledRequest = process.env.LOG_LEVEL === "debug" ? "warn" : "bypass"; + mswServer.listen({ onUnhandledRequest }); + + if (process.env.LOG_LEVEL === "debug") { + mswServer.events.on("request:start", async ({ request, requestId }) => { + const formattedRequest = await formatHttpRequest(request, requestId); + console.debug("request:start\n" + formattedRequest); + }); + + mswServer.events.on("request:unhandled", async ({ request, requestId }) => { + const formattedRequest = await formatHttpRequest(request, requestId); + console.debug("request:unhandled\n" + formattedRequest); + }); + + mswServer.events.on("response:mocked", async ({ request, response, requestId }) => { + const formattedResponse = await formatHttpResponse(response, requestId); + console.debug("response:mocked\n" + formattedResponse); + }); + } + } + + public close(): void { + this.servers = []; + mswServer.close(); + } +} + +export const mockServerPool = new MockServerPool(); diff --git a/tests/mock-server/mockEndpointBuilder.ts b/tests/mock-server/mockEndpointBuilder.ts new file mode 100644 index 0000000..390b225 --- /dev/null +++ b/tests/mock-server/mockEndpointBuilder.ts @@ -0,0 +1,209 @@ +import { DefaultBodyType, HttpHandler, HttpResponse, HttpResponseResolver, http } from "msw"; + +import { toJson } from "../../src/core/json"; +import { withHeaders } from "./withHeaders"; +import { withJson } from "./withJson"; + +type HttpMethod = "all" | "get" | "post" | "put" | "delete" | "patch" | "options" | "head"; + +interface MethodStage { + baseUrl(baseUrl: string): MethodStage; + all(path: string): RequestHeadersStage; + get(path: string): RequestHeadersStage; + post(path: string): RequestHeadersStage; + put(path: string): RequestHeadersStage; + delete(path: string): RequestHeadersStage; + patch(path: string): RequestHeadersStage; + options(path: string): RequestHeadersStage; + head(path: string): RequestHeadersStage; +} + +interface RequestHeadersStage extends RequestBodyStage, ResponseStage { + header(name: string, value: string): RequestHeadersStage; + headers(headers: Record): RequestBodyStage; +} + +interface RequestBodyStage extends ResponseStage { + jsonBody(body: unknown): ResponseStage; +} + +interface ResponseStage { + respondWith(): ResponseStatusStage; +} +interface ResponseStatusStage { + statusCode(statusCode: number): ResponseHeaderStage; +} + +interface ResponseHeaderStage extends ResponseBodyStage, BuildStage { + header(name: string, value: string): ResponseHeaderStage; + headers(headers: Record): ResponseHeaderStage; +} + +interface ResponseBodyStage { + jsonBody(body: unknown): BuildStage; +} + +interface BuildStage { + build(): HttpHandler; +} + +export interface HttpHandlerBuilderOptions { + onBuild?: (handler: HttpHandler) => void; + once?: boolean; +} + +class RequestBuilder implements MethodStage, RequestHeadersStage, RequestBodyStage, ResponseStage { + private method: HttpMethod = "get"; + private _baseUrl: string = ""; + private path: string = "/"; + private readonly predicates: ((resolver: HttpResponseResolver) => HttpResponseResolver)[] = []; + private readonly handlerOptions?: HttpHandlerBuilderOptions; + + constructor(options?: HttpHandlerBuilderOptions) { + this.handlerOptions = options; + } + + baseUrl(baseUrl: string): MethodStage { + this._baseUrl = baseUrl; + return this; + } + + all(path: string): RequestHeadersStage { + this.method = "all"; + this.path = path; + return this; + } + + get(path: string): RequestHeadersStage { + this.method = "get"; + this.path = path; + return this; + } + + post(path: string): RequestHeadersStage { + this.method = "post"; + this.path = path; + return this; + } + + put(path: string): RequestHeadersStage { + this.method = "put"; + this.path = path; + return this; + } + + delete(path: string): RequestHeadersStage { + this.method = "delete"; + this.path = path; + return this; + } + + patch(path: string): RequestHeadersStage { + this.method = "patch"; + this.path = path; + return this; + } + + options(path: string): RequestHeadersStage { + this.method = "options"; + this.path = path; + return this; + } + + head(path: string): RequestHeadersStage { + this.method = "head"; + this.path = path; + return this; + } + + header(name: string, value: string): RequestHeadersStage { + this.predicates.push((resolver) => withHeaders({ [name]: value }, resolver)); + return this; + } + + headers(headers: Record): RequestBodyStage { + this.predicates.push((resolver) => withHeaders(headers, resolver)); + return this; + } + + jsonBody(body: unknown): ResponseStage { + this.predicates.push((resolver) => withJson(body, resolver)); + return this; + } + + respondWith(): ResponseStatusStage { + return new ResponseBuilder(this.method, this.buildPath(), this.predicates, this.handlerOptions); + } + + private buildPath(): string { + if (this._baseUrl.endsWith("/") && this.path.startsWith("/")) { + return this._baseUrl + this.path.slice(1); + } + if (!this._baseUrl.endsWith("/") && !this.path.startsWith("/")) { + return this._baseUrl + "/" + this.path; + } + return this._baseUrl + this.path; + } +} + +class ResponseBuilder implements ResponseStatusStage, ResponseHeaderStage, ResponseBodyStage, BuildStage { + private readonly method: HttpMethod; + private readonly path: string; + private readonly requestPredicates: ((resolver: HttpResponseResolver) => HttpResponseResolver)[]; + private readonly handlerOptions?: HttpHandlerBuilderOptions; + + private responseStatusCode: number = 200; + private responseHeaders: Record = {}; + private responseBody: DefaultBodyType = undefined; + + constructor( + method: HttpMethod, + path: string, + requestPredicates: ((resolver: HttpResponseResolver) => HttpResponseResolver)[], + options?: HttpHandlerBuilderOptions, + ) { + this.method = method; + this.path = path; + this.requestPredicates = requestPredicates; + this.handlerOptions = options; + } + + public statusCode(code: number): ResponseHeaderStage { + this.responseStatusCode = code; + return this; + } + + public header(name: string, value: string): ResponseHeaderStage { + this.responseHeaders[name] = value; + return this; + } + + public headers(headers: Record): ResponseHeaderStage { + this.responseHeaders = { ...this.responseHeaders, ...headers }; + return this; + } + + public jsonBody(body: unknown): BuildStage { + this.responseBody = toJson(body); + return this; + } + + public build(): HttpHandler { + const responseResolver: HttpResponseResolver = () => { + return new HttpResponse(this.responseBody, { + status: this.responseStatusCode, + headers: this.responseHeaders, + }); + }; + + const finalResolver = this.requestPredicates.reduceRight((acc, predicate) => predicate(acc), responseResolver); + + const handler = http[this.method](this.path, finalResolver, this.handlerOptions); + this.handlerOptions?.onBuild?.(handler); + return handler; + } +} + +export function mockEndpointBuilder(options?: HttpHandlerBuilderOptions): MethodStage { + return new RequestBuilder(options); +} diff --git a/tests/mock-server/randomBaseUrl.ts b/tests/mock-server/randomBaseUrl.ts new file mode 100644 index 0000000..031aa64 --- /dev/null +++ b/tests/mock-server/randomBaseUrl.ts @@ -0,0 +1,4 @@ +export function randomBaseUrl(): string { + const randomString = Math.random().toString(36).substring(2, 15); + return `http://${randomString}.localhost`; +} diff --git a/tests/mock-server/setup.ts b/tests/mock-server/setup.ts new file mode 100644 index 0000000..c216d60 --- /dev/null +++ b/tests/mock-server/setup.ts @@ -0,0 +1,10 @@ +import { afterAll, beforeAll } from "@jest/globals"; + +import { mockServerPool } from "./MockServerPool"; + +beforeAll(() => { + mockServerPool.listen(); +}); +afterAll(() => { + mockServerPool.close(); +}); diff --git a/tests/mock-server/withHeaders.ts b/tests/mock-server/withHeaders.ts new file mode 100644 index 0000000..e77c837 --- /dev/null +++ b/tests/mock-server/withHeaders.ts @@ -0,0 +1,70 @@ +import { HttpResponseResolver, passthrough } from "msw"; + +/** + * Creates a request matcher that validates if request headers match specified criteria + * @param expectedHeaders - Headers to match against + * @param resolver - Response resolver to execute if headers match + */ +export function withHeaders( + expectedHeaders: Record boolean)>, + resolver: HttpResponseResolver, +): HttpResponseResolver { + return (args) => { + const { request } = args; + const { headers } = request; + + const mismatches: Record< + string, + { actual: string | null; expected: string | RegExp | ((value: string) => boolean) } + > = {}; + + for (const [key, expectedValue] of Object.entries(expectedHeaders)) { + const actualValue = headers.get(key); + + if (actualValue === null) { + mismatches[key] = { actual: null, expected: expectedValue }; + continue; + } + + if (typeof expectedValue === "function") { + if (!expectedValue(actualValue)) { + mismatches[key] = { actual: actualValue, expected: expectedValue }; + } + } else if (expectedValue instanceof RegExp) { + if (!expectedValue.test(actualValue)) { + mismatches[key] = { actual: actualValue, expected: expectedValue }; + } + } else if (expectedValue !== actualValue) { + mismatches[key] = { actual: actualValue, expected: expectedValue }; + } + } + + if (Object.keys(mismatches).length > 0) { + const formattedMismatches = formatHeaderMismatches(mismatches); + console.error("Header mismatch:", formattedMismatches); + return passthrough(); + } + + return resolver(args); + }; +} + +function formatHeaderMismatches( + mismatches: Record boolean) }>, +): Record { + const formatted: Record = {}; + + for (const [key, { actual, expected }] of Object.entries(mismatches)) { + formatted[key] = { + actual, + expected: + expected instanceof RegExp + ? expected.toString() + : typeof expected === "function" + ? "[Function]" + : expected, + }; + } + + return formatted; +} diff --git a/tests/mock-server/withJson.ts b/tests/mock-server/withJson.ts new file mode 100644 index 0000000..4b4820c --- /dev/null +++ b/tests/mock-server/withJson.ts @@ -0,0 +1,146 @@ +import { HttpResponseResolver, passthrough } from "msw"; + +import { fromJson, toJson } from "../../src/core/json"; + +/** + * Creates a request matcher that validates if the request JSON body exactly matches the expected object + * @param expectedBody - The exact body object to match against + * @param resolver - Response resolver to execute if body matches + */ +export function withJson(expectedBody: unknown, resolver: HttpResponseResolver): HttpResponseResolver { + return async (args) => { + const { request } = args; + + let clonedRequest: Request; + let actualBody: unknown; + try { + clonedRequest = request.clone(); + actualBody = fromJson(await clonedRequest.text()); + } catch (error) { + console.error("Error processing request body:", error); + return passthrough(); + } + + const mismatches = findMismatches(actualBody, expectedBody); + if (Object.keys(mismatches).length > 0) { + console.error("JSON body mismatch:", toJson(mismatches, undefined, 2)); + return passthrough(); + } + + return resolver(args); + }; +} + +function findMismatches(actual: any, expected: any): Record { + const mismatches: Record = {}; + + if (typeof actual !== typeof expected) { + if (areEquivalent(actual, expected)) { + return {}; + } + return { value: { actual, expected } }; + } + + if (typeof actual !== "object" || actual === null || expected === null) { + if (actual !== expected) { + if (areEquivalent(actual, expected)) { + return {}; + } + return { value: { actual, expected } }; + } + return {}; + } + + if (Array.isArray(actual) && Array.isArray(expected)) { + if (actual.length !== expected.length) { + return { length: { actual: actual.length, expected: expected.length } }; + } + + const arrayMismatches: Record = {}; + for (let i = 0; i < actual.length; i++) { + const itemMismatches = findMismatches(actual[i], expected[i]); + if (Object.keys(itemMismatches).length > 0) { + for (const [mismatchKey, mismatchValue] of Object.entries(itemMismatches)) { + arrayMismatches[`[${i}]${mismatchKey === "value" ? "" : "." + mismatchKey}`] = mismatchValue; + } + } + } + return arrayMismatches; + } + + const actualKeys = Object.keys(actual); + const expectedKeys = Object.keys(expected); + + const allKeys = new Set([...actualKeys, ...expectedKeys]); + + for (const key of allKeys) { + if (!expectedKeys.includes(key)) { + mismatches[key] = { actual: actual[key], expected: undefined }; + } else if (!actualKeys.includes(key)) { + mismatches[key] = { actual: undefined, expected: expected[key] }; + } else if ( + typeof actual[key] === "object" && + actual[key] !== null && + typeof expected[key] === "object" && + expected[key] !== null + ) { + const nestedMismatches = findMismatches(actual[key], expected[key]); + if (Object.keys(nestedMismatches).length > 0) { + for (const [nestedKey, nestedValue] of Object.entries(nestedMismatches)) { + mismatches[`${key}${nestedKey === "value" ? "" : "." + nestedKey}`] = nestedValue; + } + } + } else if (actual[key] !== expected[key]) { + if (areEquivalent(actual[key], expected[key])) { + continue; + } + mismatches[key] = { actual: actual[key], expected: expected[key] }; + } + } + + return mismatches; +} + +function areEquivalent(actual: unknown, expected: unknown): boolean { + if (actual === expected) { + return true; + } + if (isEquivalentBigInt(actual, expected)) { + return true; + } + if (isEquivalentDatetime(actual, expected)) { + return true; + } + return false; +} + +function isEquivalentBigInt(actual: unknown, expected: unknown) { + if (typeof actual === "number") { + actual = BigInt(actual); + } + if (typeof expected === "number") { + expected = BigInt(expected); + } + if (typeof actual === "bigint" && typeof expected === "bigint") { + return actual === expected; + } + return false; +} + +function isEquivalentDatetime(str1: unknown, str2: unknown): boolean { + if (typeof str1 !== "string" || typeof str2 !== "string") { + return false; + } + const isoDatePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/; + if (!isoDatePattern.test(str1) || !isoDatePattern.test(str2)) { + return false; + } + + try { + const date1 = new Date(str1).getTime(); + const date2 = new Date(str2).getTime(); + return date1 === date2; + } catch { + return false; + } +} diff --git a/tests/tsconfig.json b/tests/tsconfig.json new file mode 100644 index 0000000..10185ed --- /dev/null +++ b/tests/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": null, + "rootDir": "..", + "baseUrl": ".." + }, + "include": ["../src", "../tests"], + "exclude": [] +} diff --git a/tests/unit/fetcher/Fetcher.test.ts b/tests/unit/fetcher/Fetcher.test.ts index a32945e..847c018 100644 --- a/tests/unit/fetcher/Fetcher.test.ts +++ b/tests/unit/fetcher/Fetcher.test.ts @@ -1,7 +1,9 @@ import fs from "fs"; +import stream from "stream"; import { join } from "path"; import { Fetcher, fetcherImpl } from "../../../src/core/fetcher/Fetcher"; +import { BinaryResponse } from "../../../src/core"; describe("Test fetcherImpl", () => { it("should handle successful request", async () => { @@ -12,14 +14,15 @@ describe("Test fetcherImpl", () => { body: { data: "test" }, contentType: "application/json", requestType: "json", + responseType: "json", }; - global.fetch = jest.fn().mockResolvedValue({ - ok: true, - status: 200, - text: () => Promise.resolve(JSON.stringify({ data: "test" })), - json: () => ({ data: "test" }), - }); + global.fetch = jest.fn().mockResolvedValue( + new Response(JSON.stringify({ data: "test" }), { + status: 200, + statusText: "OK", + }), + ); const result = await fetcherImpl(mockArgs); expect(result.ok).toBe(true); @@ -45,16 +48,16 @@ describe("Test fetcherImpl", () => { headers: { "X-Test": "x-test-header" }, contentType: "application/octet-stream", requestType: "bytes", - duplex: "half", + responseType: "json", body: fs.createReadStream(join(__dirname, "test-file.txt")), }; - global.fetch = jest.fn().mockResolvedValue({ - ok: true, - status: 200, - text: () => Promise.resolve(JSON.stringify({ data: "test" })), - json: () => Promise.resolve({ data: "test" }), - }); + global.fetch = jest.fn().mockResolvedValue( + new Response(JSON.stringify({ data: "test" }), { + status: 200, + statusText: "OK", + }), + ); const result = await fetcherImpl(mockArgs); diff --git a/tests/unit/fetcher/getFetchFn.test.ts b/tests/unit/fetcher/getFetchFn.test.ts index 9b315ad..b55dbbc 100644 --- a/tests/unit/fetcher/getFetchFn.test.ts +++ b/tests/unit/fetcher/getFetchFn.test.ts @@ -1,5 +1,5 @@ -import { RUNTIME } from "../../../src/core/runtime"; import { getFetchFn } from "../../../src/core/fetcher/getFetchFn"; +import { RUNTIME } from "../../../src/core/runtime"; describe("Test for getFetchFn", () => { it("should get node-fetch function", async () => { diff --git a/tests/unit/fetcher/getRequestBody.test.ts b/tests/unit/fetcher/getRequestBody.test.ts index 919604c..1e4a3d6 100644 --- a/tests/unit/fetcher/getRequestBody.test.ts +++ b/tests/unit/fetcher/getRequestBody.test.ts @@ -1,5 +1,5 @@ -import { RUNTIME } from "../../../src/core/runtime"; import { getRequestBody } from "../../../src/core/fetcher/getRequestBody"; +import { RUNTIME } from "../../../src/core/runtime"; describe("Test getRequestBody", () => { it("should return FormData as is in Node environment", async () => { diff --git a/tests/unit/fetcher/getResponseBody.test.ts b/tests/unit/fetcher/getResponseBody.test.ts index 1030c51..17ef223 100644 --- a/tests/unit/fetcher/getResponseBody.test.ts +++ b/tests/unit/fetcher/getResponseBody.test.ts @@ -1,5 +1,6 @@ import { RUNTIME } from "../../../src/core/runtime"; import { getResponseBody } from "../../../src/core/fetcher/getResponseBody"; + import { chooseStreamWrapper } from "../../../src/core/fetcher/stream-wrappers/chooseStreamWrapper"; describe("Test getResponseBody", () => { diff --git a/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts b/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts index 8004e9a..5752c8a 100644 --- a/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts +++ b/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts @@ -1,8 +1,8 @@ -import { RUNTIME } from "../../../../src/core/runtime"; 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"; import { chooseStreamWrapper } from "../../../../src/core/fetcher/stream-wrappers/chooseStreamWrapper"; +import { RUNTIME } from "../../../../src/core/runtime"; describe("chooseStreamWrapper", () => { beforeEach(() => { diff --git a/tests/unit/form-data-utils/formDataWrapper.test.ts b/tests/unit/form-data-utils/formDataWrapper.test.ts deleted file mode 100644 index aa96262..0000000 --- a/tests/unit/form-data-utils/formDataWrapper.test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import fs from "fs"; - -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"; - 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"; - 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"); - }); - - it("should append stream with path", async () => { - const expectedFileName = "testfile.txt"; - const filePath = "/test/testfile.txt"; - const stream = (await import("readable-stream")).Readable.from(["file content"]); - (stream as any).path = filePath; - await formData.appendFile("file", stream); - - 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(`Content-Disposition: form-data; name="file"; filename="${expectedFileName}"`); - }); - }); - - 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"; - 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"; - 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/tests/wire/accessTokens.test.ts b/tests/wire/accessTokens.test.ts new file mode 100644 index 0000000..d0b683e --- /dev/null +++ b/tests/wire/accessTokens.test.ts @@ -0,0 +1,76 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("AccessTokens", () => { + test("revoke", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { client_id: "client_id", client_secret: "client_secret", token: "token" }; + const rawResponseBody = { message: "message" }; + server + .mockEndpoint() + .post("/auth/revoke") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accessTokens.revoke({ + client_id: "client_id", + client_secret: "client_secret", + token: "token", + }); + expect(response).toEqual({ + message: "message", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + client_id: "client_id", + client_secret: "client_secret", + grant_type: "client_credentials", + }; + const rawResponseBody = { + access_token: "L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg", + expires_in: 86400, + token_type: "Bearer", + }; + server + .mockEndpoint() + .post("/auth/token") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accessTokens.create({ + client_id: "client_id", + client_secret: "client_secret", + grant_type: "client_credentials", + }); + expect(response).toEqual({ + access_token: "L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg", + expires_in: 86400, + token_type: "Bearer", + }); + }); +}); diff --git a/tests/wire/accounting/connections.test.ts b/tests/wire/accounting/connections.test.ts new file mode 100644 index 0000000..8bde71e --- /dev/null +++ b/tests/wire/accounting/connections.test.ts @@ -0,0 +1,258 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("Connections", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + connection_url: "connection_url", + errors: [{ message: "message" }], + last_pull: "2024-01-15T09:30:00Z", + platform: "platform", + status: "connected", + }, + ], + }; + server + .mockEndpoint() + .get("/accounting_connections") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.connections.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + connection_url: "connection_url", + errors: [ + { + message: "message", + }, + ], + last_pull: "2024-01-15T09:30:00Z", + platform: "platform", + status: "connected", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + business_info: { + base_currency: "base_currency", + email: "email", + legal_name: "legal_name", + name: "name", + type: "type", + }, + connection_url: "connection_url", + errors: [{ message: "message" }], + last_pull: "2024-01-15T09:30:00Z", + platform: "platform", + status: "connected", + }; + server + .mockEndpoint() + .post("/accounting_connections") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.connections.create(); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + business_info: { + base_currency: "base_currency", + email: "email", + legal_name: "legal_name", + name: "name", + type: "type", + }, + connection_url: "connection_url", + errors: [ + { + message: "message", + }, + ], + last_pull: "2024-01-15T09:30:00Z", + platform: "platform", + status: "connected", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + business_info: { + base_currency: "base_currency", + email: "email", + legal_name: "legal_name", + name: "name", + type: "type", + }, + connection_url: "connection_url", + errors: [{ message: "message" }], + last_pull: "2024-01-15T09:30:00Z", + platform: "platform", + status: "connected", + }; + server + .mockEndpoint() + .get("/accounting_connections/connection_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.connections.getById("connection_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + business_info: { + base_currency: "base_currency", + email: "email", + legal_name: "legal_name", + name: "name", + type: "type", + }, + connection_url: "connection_url", + errors: [ + { + message: "message", + }, + ], + last_pull: "2024-01-15T09:30:00Z", + platform: "platform", + status: "connected", + }); + }); + + test("disconnect_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + business_info: { + base_currency: "base_currency", + email: "email", + legal_name: "legal_name", + name: "name", + type: "type", + }, + connection_url: "connection_url", + errors: [{ message: "message" }], + last_pull: "2024-01-15T09:30:00Z", + platform: "platform", + status: "connected", + }; + server + .mockEndpoint() + .post("/accounting_connections/connection_id/disconnect") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.connections.disconnectById("connection_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + business_info: { + base_currency: "base_currency", + email: "email", + legal_name: "legal_name", + name: "name", + type: "type", + }, + connection_url: "connection_url", + errors: [ + { + message: "message", + }, + ], + last_pull: "2024-01-15T09:30:00Z", + platform: "platform", + status: "connected", + }); + }); + + test("sync_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { message: "message" }; + server + .mockEndpoint() + .post("/accounting_connections/connection_id/sync") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.connections.syncById("connection_id"); + expect(response).toEqual({ + message: "message", + }); + }); +}); diff --git a/tests/wire/accounting/ledgerAccounts.test.ts b/tests/wire/accounting/ledgerAccounts.test.ts new file mode 100644 index 0000000..cff61e2 --- /dev/null +++ b/tests/wire/accounting/ledgerAccounts.test.ts @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("LedgerAccounts", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + currency: "AED", + current_balance: 1, + description: "description", + is_bank_account: true, + name: "Accounts Receivable", + nominal_code: "610", + status: "Active", + subtype: "Current", + type: "Asset", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/ledger_accounts").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.accounting.ledgerAccounts.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + currency: "AED", + current_balance: 1, + description: "description", + is_bank_account: true, + name: "Accounts Receivable", + nominal_code: "610", + status: "Active", + subtype: "Current", + type: "Asset", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + currency: "AED", + current_balance: 1, + description: "description", + is_bank_account: true, + name: "Accounts Receivable", + nominal_code: "610", + status: "Active", + subtype: "Current", + type: "Asset", + }; + server + .mockEndpoint() + .get("/ledger_accounts/ledger_account_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.ledgerAccounts.getById("ledger_account_id"); + expect(response).toEqual({ + id: "id", + currency: "AED", + current_balance: 1, + description: "description", + is_bank_account: true, + name: "Accounts Receivable", + nominal_code: "610", + status: "Active", + subtype: "Current", + type: "Asset", + }); + }); +}); diff --git a/tests/wire/accounting/payables.test.ts b/tests/wire/accounting/payables.test.ts new file mode 100644 index 0000000..edf649d --- /dev/null +++ b/tests/wire/accounting/payables.test.ts @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("Payables", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + amount_due: 1.1, + currency: "EUR", + currency_rate: 1.1, + due_date: "2024-01-15T09:30:00Z", + invoice_number: "invoice_number", + lines: [{ description: "Logo design" }], + memo: "memo", + posted_date: "posted_date", + purchase_order_refs: [{ id: "10", name: "PO-1234" }], + status: "paid", + subtotal: 1.1, + tax_amount: 1.1, + total_amount: 1.1, + vendor_ref: { id: "120", name: "Acme Inc." }, + }, + ], + }; + server + .mockEndpoint() + .get("/accounting/payables") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.payables.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + amount_due: 1.1, + currency: "EUR", + currency_rate: 1.1, + due_date: "2024-01-15T09:30:00Z", + invoice_number: "invoice_number", + lines: [ + { + description: "Logo design", + }, + ], + memo: "memo", + posted_date: "posted_date", + purchase_order_refs: [ + { + id: "10", + name: "PO-1234", + }, + ], + status: "paid", + subtotal: 1.1, + tax_amount: 1.1, + total_amount: 1.1, + vendor_ref: { + id: "120", + name: "Acme Inc.", + }, + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + amount_due: 1.1, + currency: "EUR", + currency_rate: 1.1, + due_date: "2024-01-15T09:30:00Z", + invoice_number: "invoice_number", + lines: [ + { + description: "Logo design", + discount_amount: 1.1, + discount_percentage: 1.1, + ledger_account_id: "ledger_account_id", + quantity: 1.1, + unit_amount: 1.1, + }, + ], + memo: "memo", + posted_date: "posted_date", + purchase_order_refs: [{ id: "10", name: "PO-1234" }], + status: "paid", + subtotal: 1.1, + tax_amount: 1.1, + total_amount: 1.1, + vendor_ref: { id: "120", name: "Acme Inc." }, + }; + server + .mockEndpoint() + .get("/accounting/payables/payable_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.payables.getById("payable_id"); + expect(response).toEqual({ + id: "id", + amount_due: 1.1, + currency: "EUR", + currency_rate: 1.1, + due_date: "2024-01-15T09:30:00Z", + invoice_number: "invoice_number", + lines: [ + { + description: "Logo design", + discount_amount: 1.1, + discount_percentage: 1.1, + ledger_account_id: "ledger_account_id", + quantity: 1.1, + unit_amount: 1.1, + }, + ], + memo: "memo", + posted_date: "posted_date", + purchase_order_refs: [ + { + id: "10", + name: "PO-1234", + }, + ], + status: "paid", + subtotal: 1.1, + tax_amount: 1.1, + total_amount: 1.1, + vendor_ref: { + id: "120", + name: "Acme Inc.", + }, + }); + }); +}); diff --git a/tests/wire/accounting/receivables.test.ts b/tests/wire/accounting/receivables.test.ts new file mode 100644 index 0000000..3673400 --- /dev/null +++ b/tests/wire/accounting/receivables.test.ts @@ -0,0 +1,136 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("Receivables", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + currency: "EUR", + currency_rate: 1.1, + customer_ref: { id: "120", company_name: "Acme Inc." }, + due_date: "2024-01-15T09:30:00Z", + invoice_number: "invoice_number", + lines: [{ description: "Logo design" }], + memo: "memo", + pass_through: { key: "value" }, + posted_date: "posted_date", + }, + ], + }; + server + .mockEndpoint() + .get("/accounting/receivables") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.receivables.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + currency: "EUR", + currency_rate: 1.1, + customer_ref: { + id: "120", + company_name: "Acme Inc.", + }, + due_date: "2024-01-15T09:30:00Z", + invoice_number: "invoice_number", + lines: [ + { + description: "Logo design", + }, + ], + memo: "memo", + pass_through: { + key: "value", + }, + posted_date: "posted_date", + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + currency: "EUR", + currency_rate: 1.1, + customer_ref: { id: "120", company_name: "Acme Inc." }, + due_date: "2024-01-15T09:30:00Z", + invoice_number: "invoice_number", + lines: [ + { + description: "Logo design", + discount_amount: 1.1, + discount_percentage: 1.1, + ledger_account_id: "ledger_account_id", + quantity: 1.1, + unit_amount: 1.1, + }, + ], + memo: "memo", + pass_through: { key: "value" }, + posted_date: "posted_date", + }; + server + .mockEndpoint() + .get("/accounting/receivables/invoice_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.receivables.getById("invoice_id"); + expect(response).toEqual({ + id: "id", + currency: "EUR", + currency_rate: 1.1, + customer_ref: { + id: "120", + company_name: "Acme Inc.", + }, + due_date: "2024-01-15T09:30:00Z", + invoice_number: "invoice_number", + lines: [ + { + description: "Logo design", + discount_amount: 1.1, + discount_percentage: 1.1, + ledger_account_id: "ledger_account_id", + quantity: 1.1, + unit_amount: 1.1, + }, + ], + memo: "memo", + pass_through: { + key: "value", + }, + posted_date: "posted_date", + }); + }); +}); diff --git a/tests/wire/accounting/syncedRecords.test.ts b/tests/wire/accounting/syncedRecords.test.ts new file mode 100644 index 0000000..15d2242 --- /dev/null +++ b/tests/wire/accounting/syncedRecords.test.ts @@ -0,0 +1,194 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("SyncedRecords", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + errors: { key: "value" }, + last_pulled_at: "2024-01-15T09:30:00Z", + object_updated_at: "2024-01-15T09:30:00Z", + object_id: "object_id", + platform: "xero", + platform_updated_at: "2024-01-15T09:30:00Z", + platform_object_id: "platform_object_id", + provider: "codat", + provider_updated_at: "2024-01-15T09:30:00Z", + provider_object_id: "provider_object_id", + sync_status: "pending", + object_type: "product", + }, + ], + next_pagination_token: + "eyJvcmRlciI6ImFzYyIsImxpbWl0IjoyLCJwYWdpbmF0aW9uX2ZpbHRlcnMiOnsiZW50aXR5X2lkIjoiOWQyYjRjOGYtMjA4Ny00NzM4LWJhOTEtNzM1OTY4M2M0OWE0In0sInBhZ2luYXRpb25fdG9rZW5fdHlwZSI6Im5leHQiLCJjdXJzb3JfZmllbGQiOm51bGwsImN1cnNvcl9maWVsZF92YWx1ZSI6bnVsbCwiY3VycmVudF9vaWQiOjR9", + prev_pagination_token: + "eyJvcmRlciI6ImFzYyIsImxpbWl0IjoyLCJwYWdpbmF0aW9uX2ZpbHRlcnMiOnsiZW50aXR5X2lkIjoiOWQyYjRjOGYtMjA4Ny00NzM4LWJhOTEtNzM1OTY4M2M0OWE0In0sInBhZ2luYXRpb25fdG9rZW5fdHlwZSI6Im5leHQiLCJjdXJzb3JfZmllbGQiOm51bGwsImN1cnNvcl9maWVsZF92YWx1ZSI6bnVsbCwiY3VycmVudF9vaWQiOjR9", + }; + server + .mockEndpoint() + .get("/accounting_synced_records") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.syncedRecords.get({ + object_type: "product", + }); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + errors: { + key: "value", + }, + last_pulled_at: "2024-01-15T09:30:00Z", + object_updated_at: "2024-01-15T09:30:00Z", + object_id: "object_id", + platform: "xero", + platform_updated_at: "2024-01-15T09:30:00Z", + platform_object_id: "platform_object_id", + provider: "codat", + provider_updated_at: "2024-01-15T09:30:00Z", + provider_object_id: "provider_object_id", + sync_status: "pending", + object_type: "product", + }, + ], + next_pagination_token: + "eyJvcmRlciI6ImFzYyIsImxpbWl0IjoyLCJwYWdpbmF0aW9uX2ZpbHRlcnMiOnsiZW50aXR5X2lkIjoiOWQyYjRjOGYtMjA4Ny00NzM4LWJhOTEtNzM1OTY4M2M0OWE0In0sInBhZ2luYXRpb25fdG9rZW5fdHlwZSI6Im5leHQiLCJjdXJzb3JfZmllbGQiOm51bGwsImN1cnNvcl9maWVsZF92YWx1ZSI6bnVsbCwiY3VycmVudF9vaWQiOjR9", + prev_pagination_token: + "eyJvcmRlciI6ImFzYyIsImxpbWl0IjoyLCJwYWdpbmF0aW9uX2ZpbHRlcnMiOnsiZW50aXR5X2lkIjoiOWQyYjRjOGYtMjA4Ny00NzM4LWJhOTEtNzM1OTY4M2M0OWE0In0sInBhZ2luYXRpb25fdG9rZW5fdHlwZSI6Im5leHQiLCJjdXJzb3JfZmllbGQiOm51bGwsImN1cnNvcl9maWVsZF92YWx1ZSI6bnVsbCwiY3VycmVudF9vaWQiOjR9", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + errors: { key: "value" }, + last_pulled_at: "2024-01-15T09:30:00Z", + object_updated_at: "2024-01-15T09:30:00Z", + object_id: "object_id", + platform: "xero", + platform_updated_at: "2024-01-15T09:30:00Z", + platform_object_id: "platform_object_id", + provider: "codat", + provider_updated_at: "2024-01-15T09:30:00Z", + provider_object_id: "provider_object_id", + sync_status: "pending", + object_type: "product", + }; + server + .mockEndpoint() + .get("/accounting_synced_records/synced_record_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.syncedRecords.getById("synced_record_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + errors: { + key: "value", + }, + last_pulled_at: "2024-01-15T09:30:00Z", + object_updated_at: "2024-01-15T09:30:00Z", + object_id: "object_id", + platform: "xero", + platform_updated_at: "2024-01-15T09:30:00Z", + platform_object_id: "platform_object_id", + provider: "codat", + provider_updated_at: "2024-01-15T09:30:00Z", + provider_object_id: "provider_object_id", + sync_status: "pending", + object_type: "product", + }); + }); + + test("push_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + errors: { key: "value" }, + last_pulled_at: "2024-01-15T09:30:00Z", + object_updated_at: "2024-01-15T09:30:00Z", + object_id: "object_id", + platform: "xero", + platform_updated_at: "2024-01-15T09:30:00Z", + platform_object_id: "platform_object_id", + provider: "codat", + provider_updated_at: "2024-01-15T09:30:00Z", + provider_object_id: "provider_object_id", + sync_status: "pending", + object_type: "product", + }; + server + .mockEndpoint() + .post("/accounting_synced_records/synced_record_id/push") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.syncedRecords.pushById("synced_record_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + errors: { + key: "value", + }, + last_pulled_at: "2024-01-15T09:30:00Z", + object_updated_at: "2024-01-15T09:30:00Z", + object_id: "object_id", + platform: "xero", + platform_updated_at: "2024-01-15T09:30:00Z", + platform_object_id: "platform_object_id", + provider: "codat", + provider_updated_at: "2024-01-15T09:30:00Z", + provider_object_id: "provider_object_id", + sync_status: "pending", + object_type: "product", + }); + }); +}); diff --git a/tests/wire/accounting/taxRates.test.ts b/tests/wire/accounting/taxRates.test.ts new file mode 100644 index 0000000..37b6cee --- /dev/null +++ b/tests/wire/accounting/taxRates.test.ts @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("TaxRates", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + code: "code", + components: [{}], + effective_tax_rate: 1, + name: "name", + status: "status", + total_tax_rate: 1, + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/accounting_tax_rates") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.taxRates.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + code: "code", + components: [{}], + effective_tax_rate: 1, + name: "name", + status: "status", + total_tax_rate: 1, + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + code: "code", + components: [{ is_compound: true, name: "name", rate: 1 }], + effective_tax_rate: 1, + name: "name", + status: "status", + total_tax_rate: 1, + }; + server + .mockEndpoint() + .get("/accounting_tax_rates/tax_rate_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.accounting.taxRates.getById("tax_rate_id"); + expect(response).toEqual({ + id: "id", + code: "code", + components: [ + { + is_compound: true, + name: "name", + rate: 1, + }, + ], + effective_tax_rate: 1, + name: "name", + status: "status", + total_tax_rate: 1, + }); + }); +}); diff --git a/tests/wire/analytics.test.ts b/tests/wire/analytics.test.ts new file mode 100644 index 0000000..d7bd5b6 --- /dev/null +++ b/tests/wire/analytics.test.ts @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Analytics", () => { + test("get_analytics_credit_notes", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { data: [{ dimension_value: "dimension_value", metric_value: 1.1 }] }; + server + .mockEndpoint() + .get("/analytics/credit_notes") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.analytics.getAnalyticsCreditNotes({ + metric: "id", + aggregation_function: "count", + }); + expect(response).toEqual({ + data: [ + { + dimension_value: "dimension_value", + metric_value: 1.1, + }, + ], + }); + }); + + test("get_analytics_payables", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { data: [{ dimension_value: "dimension_value", metric_value: 1.1 }] }; + server + .mockEndpoint() + .get("/analytics/payables") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.analytics.getAnalyticsPayables({ + metric: "id", + aggregation_function: "count", + }); + expect(response).toEqual({ + data: [ + { + dimension_value: "dimension_value", + metric_value: 1.1, + }, + ], + }); + }); + + test("get_analytics_receivables", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { data: [{ dimension_value: "dimension_value", metric_value: 1 }] }; + server + .mockEndpoint() + .get("/analytics/receivables") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.analytics.getAnalyticsReceivables({ + metric: "id", + aggregation_function: "count", + }); + expect(response).toEqual({ + data: [ + { + dimension_value: "dimension_value", + metric_value: 1, + }, + ], + }); + }); +}); diff --git a/tests/wire/approvalPolicies.test.ts b/tests/wire/approvalPolicies.test.ts new file mode 100644 index 0000000..d8f121c --- /dev/null +++ b/tests/wire/approvalPolicies.test.ts @@ -0,0 +1,226 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("ApprovalPolicies", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + description: "description", + ends_at: "2024-01-15T09:30:00Z", + name: "name", + script: [true], + starts_at: "2024-01-15T09:30:00Z", + status: "active", + trigger: true, + updated_by: "updated_by", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/approval_policies").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.approvalPolicies.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + description: "description", + ends_at: "2024-01-15T09:30:00Z", + name: "name", + script: [true], + starts_at: "2024-01-15T09:30:00Z", + status: "active", + trigger: true, + updated_by: "updated_by", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name", script: [true] }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + description: "description", + ends_at: "2024-01-15T09:30:00Z", + name: "name", + script: [true], + starts_at: "2024-01-15T09:30:00Z", + status: "active", + trigger: true, + updated_by: "updated_by", + }; + server + .mockEndpoint() + .post("/approval_policies") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalPolicies.create({ + name: "name", + script: [true], + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + description: "description", + ends_at: "2024-01-15T09:30:00Z", + name: "name", + script: [true], + starts_at: "2024-01-15T09:30:00Z", + status: "active", + trigger: true, + updated_by: "updated_by", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + description: "description", + ends_at: "2024-01-15T09:30:00Z", + name: "name", + script: [true], + starts_at: "2024-01-15T09:30:00Z", + status: "active", + trigger: true, + updated_by: "updated_by", + }; + server + .mockEndpoint() + .get("/approval_policies/approval_policy_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalPolicies.getById("approval_policy_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + description: "description", + ends_at: "2024-01-15T09:30:00Z", + name: "name", + script: [true], + starts_at: "2024-01-15T09:30:00Z", + status: "active", + trigger: true, + updated_by: "updated_by", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/approval_policies/approval_policy_id").respondWith().statusCode(200).build(); + + const response = await client.approvalPolicies.deleteById("approval_policy_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + description: "description", + ends_at: "2024-01-15T09:30:00Z", + name: "name", + script: [true], + starts_at: "2024-01-15T09:30:00Z", + status: "active", + trigger: true, + updated_by: "updated_by", + }; + server + .mockEndpoint() + .patch("/approval_policies/approval_policy_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalPolicies.updateById("approval_policy_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + description: "description", + ends_at: "2024-01-15T09:30:00Z", + name: "name", + script: [true], + starts_at: "2024-01-15T09:30:00Z", + status: "active", + trigger: true, + updated_by: "updated_by", + }); + }); +}); diff --git a/tests/wire/approvalPolicies/processes.test.ts b/tests/wire/approvalPolicies/processes.test.ts new file mode 100644 index 0000000..6c0b950 --- /dev/null +++ b/tests/wire/approvalPolicies/processes.test.ts @@ -0,0 +1,212 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("Processes", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + error: { key: "value" }, + input: { key: "value" }, + metadata: { key: "value" }, + script_snapshot: true, + status: "succeeded", + updated_by: "updated_by", + }, + ], + }; + server + .mockEndpoint() + .get("/approval_policies/approval_policy_id/processes") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalPolicies.processes.get("approval_policy_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + error: { + key: "value", + }, + input: { + key: "value", + }, + metadata: { + key: "value", + }, + script_snapshot: true, + status: "succeeded", + updated_by: "updated_by", + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + error: { key: "value" }, + input: { key: "value" }, + metadata: { key: "value" }, + script_snapshot: true, + status: "succeeded", + updated_by: "updated_by", + }; + server + .mockEndpoint() + .get("/approval_policies/approval_policy_id/processes/process_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalPolicies.processes.getById("approval_policy_id", "process_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + error: { + key: "value", + }, + input: { + key: "value", + }, + metadata: { + key: "value", + }, + script_snapshot: true, + status: "succeeded", + updated_by: "updated_by", + }); + }); + + test("cancel_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + error: { key: "value" }, + input: { key: "value" }, + metadata: { key: "value" }, + script_snapshot: true, + status: "succeeded", + updated_by: "updated_by", + }; + server + .mockEndpoint() + .post("/approval_policies/approval_policy_id/processes/process_id/cancel") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalPolicies.processes.cancelById("approval_policy_id", "process_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + error: { + key: "value", + }, + input: { + key: "value", + }, + metadata: { + key: "value", + }, + script_snapshot: true, + status: "succeeded", + updated_by: "updated_by", + }); + }); + + test("get_steps", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + approved_by: ["approved_by"], + object_id: "object_id", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }, + ], + }; + server + .mockEndpoint() + .get("/approval_policies/approval_policy_id/processes/process_id/steps") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalPolicies.processes.getSteps("approval_policy_id", "process_id"); + expect(response).toEqual({ + data: [ + { + approved_by: ["approved_by"], + object_id: "object_id", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }, + ], + }); + }); +}); diff --git a/tests/wire/approvalRequests.test.ts b/tests/wire/approvalRequests.test.ts new file mode 100644 index 0000000..a5bfbb5 --- /dev/null +++ b/tests/wire/approvalRequests.test.ts @@ -0,0 +1,313 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("ApprovalRequests", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/approval_requests").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.approvalRequests.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + object_id: "object_id", + object_type: "account", + required_approval_count: 1, + role_ids: ["role_ids"], + }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }; + server + .mockEndpoint() + .post("/approval_requests") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalRequests.create({ + object_id: "object_id", + object_type: "account", + required_approval_count: 1, + role_ids: ["role_ids"], + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }; + server + .mockEndpoint() + .get("/approval_requests/approval_request_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalRequests.getById("approval_request_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }); + }); + + test("approve_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }; + server + .mockEndpoint() + .post("/approval_requests/approval_request_id/approve") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalRequests.approveById("approval_request_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }); + }); + + test("cancel_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }; + server + .mockEndpoint() + .post("/approval_requests/approval_request_id/cancel") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalRequests.cancelById("approval_request_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }); + }); + + test("reject_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }; + server + .mockEndpoint() + .post("/approval_requests/approval_request_id/reject") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.approvalRequests.rejectById("approval_request_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + approved_by: ["approved_by"], + created_by: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + object_id: "object_id", + object_type: "account", + rejected_by: "rejected_by", + required_approval_count: 1, + role_ids: ["role_ids"], + status: "waiting", + user_ids: ["user_ids"], + }); + }); +}); diff --git a/tests/wire/comments.test.ts b/tests/wire/comments.test.ts new file mode 100644 index 0000000..06985ce --- /dev/null +++ b/tests/wire/comments.test.ts @@ -0,0 +1,214 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Comments", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by_entity_user_id: "created_by_entity_user_id", + entity_id: "entity_id", + object_id: "object_id", + object_type: "object_type", + reply_to_entity_user_id: "reply_to_entity_user_id", + status: "active", + text: "text", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/comments").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.comments.get({ + object_type: "payable", + object_id: "object_id", + }); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by_entity_user_id: "created_by_entity_user_id", + entity_id: "entity_id", + object_id: "object_id", + object_type: "object_type", + reply_to_entity_user_id: "reply_to_entity_user_id", + status: "active", + text: "text", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { object_id: "object_id", object_type: "object_type", text: "text" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by_entity_user_id: "created_by_entity_user_id", + entity_id: "entity_id", + object_id: "object_id", + object_type: "object_type", + reply_to_entity_user_id: "reply_to_entity_user_id", + status: "active", + text: "text", + }; + server + .mockEndpoint() + .post("/comments") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.comments.create({ + object_id: "object_id", + object_type: "object_type", + text: "text", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by_entity_user_id: "created_by_entity_user_id", + entity_id: "entity_id", + object_id: "object_id", + object_type: "object_type", + reply_to_entity_user_id: "reply_to_entity_user_id", + status: "active", + text: "text", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by_entity_user_id: "created_by_entity_user_id", + entity_id: "entity_id", + object_id: "object_id", + object_type: "object_type", + reply_to_entity_user_id: "reply_to_entity_user_id", + status: "active", + text: "text", + }; + server + .mockEndpoint() + .get("/comments/comment_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.comments.getById("comment_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by_entity_user_id: "created_by_entity_user_id", + entity_id: "entity_id", + object_id: "object_id", + object_type: "object_type", + reply_to_entity_user_id: "reply_to_entity_user_id", + status: "active", + text: "text", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/comments/comment_id").respondWith().statusCode(200).build(); + + const response = await client.comments.deleteById("comment_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by_entity_user_id: "created_by_entity_user_id", + entity_id: "entity_id", + object_id: "object_id", + object_type: "object_type", + reply_to_entity_user_id: "reply_to_entity_user_id", + status: "active", + text: "text", + }; + server + .mockEndpoint() + .patch("/comments/comment_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.comments.updateById("comment_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by_entity_user_id: "created_by_entity_user_id", + entity_id: "entity_id", + object_id: "object_id", + object_type: "object_type", + reply_to_entity_user_id: "reply_to_entity_user_id", + status: "active", + text: "text", + }); + }); +}); diff --git a/tests/wire/counterpartEInvoicingCredentials.test.ts b/tests/wire/counterpartEInvoicingCredentials.test.ts new file mode 100644 index 0000000..31aa9b6 --- /dev/null +++ b/tests/wire/counterpartEInvoicingCredentials.test.ts @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("CounterpartEInvoicingCredentials", () => { + test("get_counterparts_id_einvoicing_credentials", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [{ id: "id", network_identifier: "network_identifier", network_schema: "DE:VAT" }], + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/einvoicing_credentials") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = + await client.counterpartEInvoicingCredentials.getCounterpartsIdEinvoicingCredentials("counterpart_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + network_identifier: "network_identifier", + network_schema: "DE:VAT", + }, + ], + }); + }); + + test("post_counterparts_id_einvoicing_credentials", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { counterpart_vat_id_id: "counterpart_vat_id_id" }; + const rawResponseBody = { id: "id", network_identifier: "network_identifier", network_schema: "DE:VAT" }; + server + .mockEndpoint() + .post("/counterparts/counterpart_id/einvoicing_credentials") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterpartEInvoicingCredentials.postCounterpartsIdEinvoicingCredentials( + "counterpart_id", + { + counterpart_vat_id_id: "counterpart_vat_id_id", + }, + ); + expect(response).toEqual({ + id: "id", + network_identifier: "network_identifier", + network_schema: "DE:VAT", + }); + }); + + test("get_counterparts_id_einvoicing_credentials_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "id", network_identifier: "network_identifier", network_schema: "DE:VAT" }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/einvoicing_credentials/credential_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterpartEInvoicingCredentials.getCounterpartsIdEinvoicingCredentialsId( + "credential_id", + "counterpart_id", + ); + expect(response).toEqual({ + id: "id", + network_identifier: "network_identifier", + network_schema: "DE:VAT", + }); + }); + + test("delete_counterparts_id_einvoicing_credentials_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/counterparts/counterpart_id/einvoicing_credentials/credential_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.counterpartEInvoicingCredentials.deleteCounterpartsIdEinvoicingCredentialsId( + "credential_id", + "counterpart_id", + ); + expect(response).toEqual(undefined); + }); + + test("patch_counterparts_id_einvoicing_credentials_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { id: "id", network_identifier: "network_identifier", network_schema: "DE:VAT" }; + server + .mockEndpoint() + .patch("/counterparts/counterpart_id/einvoicing_credentials/credential_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterpartEInvoicingCredentials.patchCounterpartsIdEinvoicingCredentialsId( + "credential_id", + "counterpart_id", + ); + expect(response).toEqual({ + id: "id", + network_identifier: "network_identifier", + network_schema: "DE:VAT", + }); + }); +}); diff --git a/tests/wire/counterparts.test.ts b/tests/wire/counterparts.test.ts new file mode 100644 index 0000000..9376898 --- /dev/null +++ b/tests/wire/counterparts.test.ts @@ -0,0 +1,457 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Counterparts", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + external_reference: "123456789", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/counterparts").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.counterparts.get({ + sort_code: "123456", + }); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + external_reference: "123456789", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + organization: { + address: { city: "Berlin", country: "AF", line1: "Flughafenstrasse 52", postal_code: "10115" }, + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + }, + type: "organization", + }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + external_reference: "123456789", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }; + server + .mockEndpoint() + .post("/counterparts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.create({ + type: "organization", + organization: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + }, + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + external_reference: "123456789", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + external_reference: "123456789", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.getById("counterpart_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + external_reference: "123456789", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/counterparts/counterpart_id").respondWith().statusCode(200).build(); + + const response = await client.counterparts.deleteById("counterpart_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { individual: {} }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + external_reference: "123456789", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }; + server + .mockEndpoint() + .patch("/counterparts/counterpart_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.updateById("counterpart_id", { + individual: {}, + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + external_reference: "123456789", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }); + }); + + test("get_partner_metadata_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { metadata: { key: "value" } }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/partner_metadata") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.getPartnerMetadataById("counterpart_id"); + expect(response).toEqual({ + metadata: { + key: "value", + }, + }); + }); + + test("update_partner_metadata_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { metadata: { key: "value" } }; + const rawResponseBody = { metadata: { key: "value" } }; + server + .mockEndpoint() + .put("/counterparts/counterpart_id/partner_metadata") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.updatePartnerMetadataById("counterpart_id", { + metadata: { + key: "value", + }, + }); + expect(response).toEqual({ + metadata: { + key: "value", + }, + }); + }); +}); diff --git a/tests/wire/counterparts/addresses.test.ts b/tests/wire/counterparts/addresses.test.ts new file mode 100644 index 0000000..b38ec70 --- /dev/null +++ b/tests/wire/counterparts/addresses.test.ts @@ -0,0 +1,203 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("Addresses", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + city: "Berlin", + counterpart_id: "counterpart_id", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + ], + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/addresses") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.addresses.get("counterpart_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + city: "Berlin", + counterpart_id: "counterpart_id", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { city: "Berlin", country: "AF", line1: "Flughafenstrasse 52", postal_code: "10115" }; + const rawResponseBody = { + id: "id", + city: "Berlin", + counterpart_id: "counterpart_id", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }; + server + .mockEndpoint() + .post("/counterparts/counterpart_id/addresses") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.addresses.create("counterpart_id", { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }); + expect(response).toEqual({ + id: "id", + city: "Berlin", + counterpart_id: "counterpart_id", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + city: "Berlin", + counterpart_id: "counterpart_id", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/addresses/address_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.addresses.getById("address_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + city: "Berlin", + counterpart_id: "counterpart_id", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/counterparts/counterpart_id/addresses/address_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.counterparts.addresses.deleteById("address_id", "counterpart_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + city: "Berlin", + counterpart_id: "counterpart_id", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }; + server + .mockEndpoint() + .patch("/counterparts/counterpart_id/addresses/address_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.addresses.updateById("address_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + city: "Berlin", + counterpart_id: "counterpart_id", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }); + }); +}); diff --git a/tests/wire/counterparts/bankAccounts.test.ts b/tests/wire/counterparts/bankAccounts.test.ts new file mode 100644 index 0000000..d79f014 --- /dev/null +++ b/tests/wire/counterparts/bankAccounts.test.ts @@ -0,0 +1,273 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("BankAccounts", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + counterpart_id: "counterpart_id", + country: "AF", + currency: "AED", + iban: "DE74500700100100000900", + is_default_for_currency: true, + name: "name", + partner_metadata: { key: "value" }, + routing_number: "routing_number", + sort_code: "123456", + }, + ], + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/bank_accounts") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.bankAccounts.get("counterpart_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + counterpart_id: "counterpart_id", + country: "AF", + currency: "AED", + iban: "DE74500700100100000900", + is_default_for_currency: true, + name: "name", + partner_metadata: { + key: "value", + }, + routing_number: "routing_number", + sort_code: "123456", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { country: "AF", currency: "AED" }; + const rawResponseBody = { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + counterpart_id: "counterpart_id", + country: "AF", + currency: "AED", + iban: "DE74500700100100000900", + is_default_for_currency: true, + name: "name", + partner_metadata: { key: "value" }, + routing_number: "routing_number", + sort_code: "123456", + }; + server + .mockEndpoint() + .post("/counterparts/counterpart_id/bank_accounts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.bankAccounts.create("counterpart_id", { + country: "AF", + currency: "AED", + }); + expect(response).toEqual({ + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + counterpart_id: "counterpart_id", + country: "AF", + currency: "AED", + iban: "DE74500700100100000900", + is_default_for_currency: true, + name: "name", + partner_metadata: { + key: "value", + }, + routing_number: "routing_number", + sort_code: "123456", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + counterpart_id: "counterpart_id", + country: "AF", + currency: "AED", + iban: "DE74500700100100000900", + is_default_for_currency: true, + name: "name", + partner_metadata: { key: "value" }, + routing_number: "routing_number", + sort_code: "123456", + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/bank_accounts/bank_account_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.bankAccounts.getById("bank_account_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + counterpart_id: "counterpart_id", + country: "AF", + currency: "AED", + iban: "DE74500700100100000900", + is_default_for_currency: true, + name: "name", + partner_metadata: { + key: "value", + }, + routing_number: "routing_number", + sort_code: "123456", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/counterparts/counterpart_id/bank_accounts/bank_account_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.counterparts.bankAccounts.deleteById("bank_account_id", "counterpart_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + counterpart_id: "counterpart_id", + country: "AF", + currency: "AED", + iban: "DE74500700100100000900", + is_default_for_currency: true, + name: "name", + partner_metadata: { key: "value" }, + routing_number: "routing_number", + sort_code: "123456", + }; + server + .mockEndpoint() + .patch("/counterparts/counterpart_id/bank_accounts/bank_account_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.bankAccounts.updateById("bank_account_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + counterpart_id: "counterpart_id", + country: "AF", + currency: "AED", + iban: "DE74500700100100000900", + is_default_for_currency: true, + name: "name", + partner_metadata: { + key: "value", + }, + routing_number: "routing_number", + sort_code: "123456", + }); + }); + + test("make_default_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/counterparts/counterpart_id/bank_accounts/bank_account_id/make_default") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.bankAccounts.makeDefaultById("bank_account_id", "counterpart_id"); + expect(response).toEqual({ + key: "value", + }); + }); +}); diff --git a/tests/wire/counterparts/contacts.test.ts b/tests/wire/counterparts/contacts.test.ts new file mode 100644 index 0000000..48d4c53 --- /dev/null +++ b/tests/wire/counterparts/contacts.test.ts @@ -0,0 +1,322 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("Contacts", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + address: { city: "Berlin", country: "AF", line1: "Flughafenstrasse 52", postal_code: "10115" }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }, + ], + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/contacts") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.contacts.get("counterpart_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + address: { city: "Berlin", country: "AF", line1: "Flughafenstrasse 52", postal_code: "10115" }, + first_name: "Mary", + last_name: "O'Brien", + }; + const rawResponseBody = { + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }; + server + .mockEndpoint() + .post("/counterparts/counterpart_id/contacts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = 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", + }); + expect(response).toEqual({ + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/contacts/contact_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.contacts.getById("contact_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/counterparts/counterpart_id/contacts/contact_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.counterparts.contacts.deleteById("contact_id", "counterpart_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }; + server + .mockEndpoint() + .patch("/counterparts/counterpart_id/contacts/contact_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.contacts.updateById("contact_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }); + }); + + test("make_default_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }; + server + .mockEndpoint() + .post("/counterparts/counterpart_id/contacts/contact_id/make_default") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.contacts.makeDefaultById("contact_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_id: "counterpart_id", + email: "contact@example.org", + first_name: "Mary", + is_default: true, + last_name: "O'Brien", + phone: "5551235476", + title: "Ms.", + }); + }); +}); diff --git a/tests/wire/counterparts/vatIds.test.ts b/tests/wire/counterparts/vatIds.test.ts new file mode 100644 index 0000000..ba6dc60 --- /dev/null +++ b/tests/wire/counterparts/vatIds.test.ts @@ -0,0 +1,168 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("VatIds", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [{ id: "id", counterpart_id: "counterpart_id", country: "AF", type: "ae_trn", value: "123456789" }], + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/vat_ids") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.vatIds.get("counterpart_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { value: "123456789" }; + const rawResponseBody = { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }; + server + .mockEndpoint() + .post("/counterparts/counterpart_id/vat_ids") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.vatIds.create("counterpart_id", { + value: "123456789", + }); + expect(response).toEqual({ + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }; + server + .mockEndpoint() + .get("/counterparts/counterpart_id/vat_ids/vat_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.vatIds.getById("vat_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/counterparts/counterpart_id/vat_ids/vat_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.counterparts.vatIds.deleteById("vat_id", "counterpart_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }; + server + .mockEndpoint() + .patch("/counterparts/counterpart_id/vat_ids/vat_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.counterparts.vatIds.updateById("vat_id", "counterpart_id"); + expect(response).toEqual({ + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }); + }); +}); diff --git a/tests/wire/creditNotes.test.ts b/tests/wire/creditNotes.test.ts new file mode 100644 index 0000000..25fbf93 --- /dev/null +++ b/tests/wire/creditNotes.test.ts @@ -0,0 +1,2304 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; +import * as Monite from "../../src/api/index"; + +describe("CreditNotes", () => { + test("get_payable_credit_notes", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }, + ], + next_pagination_token: "eyJwYWdlIjoyfQ==", + prev_pagination_token: "eyJwYWdlIjoxfQ==", + }; + server + .mockEndpoint() + .get("/payable_credit_notes") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.getPayableCreditNotes(); + expect(response).toEqual({ + data: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }, + ], + next_pagination_token: "eyJwYWdlIjoyfQ==", + prev_pagination_token: "eyJwYWdlIjoxfQ==", + }); + }); + + test("post_payable_credit_notes", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { document_id: "CN-2287", issued_at: "2024-01-15" }; + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }; + server + .mockEndpoint() + .post("/payable_credit_notes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.postPayableCreditNotes({ + document_id: "CN-2287", + issued_at: "2024-01-15", + }); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }); + }); + + test("get_payable_credit_notes_validations", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { required_fields: ["currency"] }; + server + .mockEndpoint() + .get("/payable_credit_notes/validations") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.getPayableCreditNotesValidations(); + expect(response).toEqual({ + required_fields: ["currency"], + }); + }); + + test("put_payable_credit_notes_validations", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { required_fields: ["currency"] }; + const rawResponseBody = { required_fields: ["currency"] }; + server + .mockEndpoint() + .put("/payable_credit_notes/validations") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.putPayableCreditNotesValidations({ + required_fields: ["currency"], + }); + expect(response).toEqual({ + required_fields: ["currency"], + }); + }); + + test("post_payable_credit_notes_validations_reset", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { required_fields: ["currency"] }; + server + .mockEndpoint() + .post("/payable_credit_notes/validations/reset") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.postPayableCreditNotesValidationsReset(); + expect(response).toEqual({ + required_fields: ["currency"], + }); + }); + + test("get_payable_credit_notes_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }; + server + .mockEndpoint() + .get("/payable_credit_notes/credit_note_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.getPayableCreditNotesId("credit_note_id"); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }); + }); + + test("delete_payable_credit_notes_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/payable_credit_notes/credit_note_id").respondWith().statusCode(200).build(); + + const response = await client.creditNotes.deletePayableCreditNotesId("credit_note_id"); + expect(response).toEqual(undefined); + }); + + test("patch_payable_credit_notes_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }; + server + .mockEndpoint() + .patch("/payable_credit_notes/credit_note_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.patchPayableCreditNotesId("credit_note_id"); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }); + }); + + test("post_payable_credit_notes_id_approve", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }; + server + .mockEndpoint() + .post("/payable_credit_notes/credit_note_id/approve") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.postPayableCreditNotesIdApprove("credit_note_id"); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }); + }); + + test("post_payable_credit_notes_id_cancel", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }; + server + .mockEndpoint() + .post("/payable_credit_notes/credit_note_id/cancel") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.postPayableCreditNotesIdCancel("credit_note_id"); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }); + }); + + test("post_payable_credit_notes_id_cancel_ocr", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }; + server + .mockEndpoint() + .post("/payable_credit_notes/credit_note_id/cancel_ocr") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.postPayableCreditNotesIdCancelOcr("credit_note_id"); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }); + }); + + test("get_payable_credit_notes_id_line_items", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }, + ], + next_pagination_token: "eyJwYWdlIjoyfQ==", + prev_pagination_token: "eyJwYWdlIjoxfQ==", + }; + server + .mockEndpoint() + .get("/payable_credit_notes/credit_note_id/line_items") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.getPayableCreditNotesIdLineItems("credit_note_id"); + expect(response).toEqual({ + data: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }, + ], + next_pagination_token: "eyJwYWdlIjoyfQ==", + prev_pagination_token: "eyJwYWdlIjoxfQ==", + }); + }); + + test("post_payable_credit_notes_id_line_items", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }; + server + .mockEndpoint() + .post("/payable_credit_notes/credit_note_id/line_items") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.postPayableCreditNotesIdLineItems("credit_note_id", {}); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }); + }); + + test("put_payable_credit_notes_id_line_items", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { data: [{}] }; + const rawResponseBody = { + data: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }, + ], + next_pagination_token: "eyJwYWdlIjoyfQ==", + prev_pagination_token: "eyJwYWdlIjoxfQ==", + }; + server + .mockEndpoint() + .put("/payable_credit_notes/credit_note_id/line_items") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.putPayableCreditNotesIdLineItems("credit_note_id", { + data: [{}], + }); + expect(response).toEqual({ + data: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }, + ], + next_pagination_token: "eyJwYWdlIjoyfQ==", + prev_pagination_token: "eyJwYWdlIjoxfQ==", + }); + }); + + test("get_payable_credit_notes_id_line_items_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }; + server + .mockEndpoint() + .get("/payable_credit_notes/credit_note_id/line_items/line_item_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.getPayableCreditNotesIdLineItemsId("credit_note_id", "line_item_id"); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }); + }); + + test("delete_payable_credit_notes_id_line_items_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }, + ], + next_pagination_token: "eyJwYWdlIjoyfQ==", + prev_pagination_token: "eyJwYWdlIjoxfQ==", + }; + server + .mockEndpoint() + .delete("/payable_credit_notes/credit_note_id/line_items/line_item_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.deletePayableCreditNotesIdLineItemsId( + "credit_note_id", + "line_item_id", + ); + expect(response).toEqual({ + data: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }, + ], + next_pagination_token: "eyJwYWdlIjoyfQ==", + prev_pagination_token: "eyJwYWdlIjoxfQ==", + }); + }); + + test("patch_payable_credit_notes_id_line_items_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }; + server + .mockEndpoint() + .patch("/payable_credit_notes/credit_note_id/line_items/line_item_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.patchPayableCreditNotesIdLineItemsId( + "credit_note_id", + "line_item_id", + ); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + credit_note_id: "123e4567-e89b-12d3-a456-426614174000", + description: "Premium version of Product XYZ with extended warranty", + name: "Product XYZ", + quantity: 2, + subtotal: 10000, + tax: 20, + tax_amount: 2000, + total: 12000, + unit: "pieces", + unit_price: 5000, + }); + }); + + test("post_payable_credit_notes_id_reject", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }; + server + .mockEndpoint() + .post("/payable_credit_notes/credit_note_id/reject") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.postPayableCreditNotesIdReject("credit_note_id"); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }); + }); + + test("post_payable_credit_notes_id_submit_for_approval", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }; + server + .mockEndpoint() + .post("/payable_credit_notes/credit_note_id/submit_for_approval") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.postPayableCreditNotesIdSubmitForApproval("credit_note_id"); + expect(response).toEqual({ + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2024-01-15T14:30:00Z", + updated_at: "2024-01-15T14:30:00Z", + based_on: "123e4567-e89b-12d3-a456-426614174000", + based_on_document_id: "INV-2287", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_bank_account_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_id: "123e4567-e89b-12d3-a456-426614174000", + counterpart_raw: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "123e4567-e89b-12d3-a456-426614174000", + created_by_external_user_id: "ext_user_123", + created_by_external_user_name: "John Doe", + created_by_user_id: "123e4567-e89b-12d3-a456-426614174000", + currency: "EUR", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "Credit note for returned items from invoice INV-2287", + document_id: "CN-2287", + entity_id: "123e4567-e89b-12d3-a456-426614174000", + file_id: "123e4567-e89b-12d3-a456-426614174000", + file_url: "file_url", + issued_at: "2024-01-15", + ocr_request_id: "123e4567-e89b-12d3-a456-426614174000", + ocr_status: "completed", + origin: "SAP", + project_id: "123e4567-e89b-12d3-a456-426614174000", + sender: "supplier@example.com", + source_of_data: "user_specified", + status: "submitted_for_approval", + subtotal: 1000, + tags: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "department", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Department A", + }, + ], + tax: 20, + tax_amount: 200, + total_amount: 1200, + }); + }); + + test("get_payable_credit_notes_id_validate", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "id", validation_errors: [{ key: "value" }] }; + server + .mockEndpoint() + .get("/payable_credit_notes/credit_note_id/validate") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.creditNotes.getPayableCreditNotesIdValidate("credit_note_id"); + expect(response).toEqual({ + id: "id", + validation_errors: [ + { + key: "value", + }, + ], + }); + }); +}); diff --git a/tests/wire/customVatRates.test.ts b/tests/wire/customVatRates.test.ts new file mode 100644 index 0000000..8ac241d --- /dev/null +++ b/tests/wire/customVatRates.test.ts @@ -0,0 +1,207 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("CustomVatRates", () => { + test("get_custom_vat_rates", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [{ name: "name", value: 1.1 }], + created_by_entity_user_id: "created_by_entity_user_id", + name: "name", + value: 1.1, + }, + ], + }; + server.mockEndpoint().get("/custom_vat_rates").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.customVatRates.getCustomVatRates(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [ + { + name: "name", + value: 1.1, + }, + ], + created_by_entity_user_id: "created_by_entity_user_id", + name: "name", + value: 1.1, + }, + ], + }); + }); + + test("post_custom_vat_rates", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { components: [{ name: "name", value: 1.1 }], name: "name" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [{ name: "name", value: 1.1 }], + created_by_entity_user_id: "created_by_entity_user_id", + name: "name", + value: 1.1, + }; + server + .mockEndpoint() + .post("/custom_vat_rates") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.customVatRates.postCustomVatRates({ + components: [ + { + name: "name", + value: 1.1, + }, + ], + name: "name", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [ + { + name: "name", + value: 1.1, + }, + ], + created_by_entity_user_id: "created_by_entity_user_id", + name: "name", + value: 1.1, + }); + }); + + test("get_custom_vat_rates_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [{ name: "name", value: 1.1 }], + created_by_entity_user_id: "created_by_entity_user_id", + name: "name", + value: 1.1, + }; + server + .mockEndpoint() + .get("/custom_vat_rates/custom_vat_rate_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.customVatRates.getCustomVatRatesId("custom_vat_rate_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [ + { + name: "name", + value: 1.1, + }, + ], + created_by_entity_user_id: "created_by_entity_user_id", + name: "name", + value: 1.1, + }); + }); + + test("delete_custom_vat_rates_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/custom_vat_rates/custom_vat_rate_id").respondWith().statusCode(200).build(); + + const response = await client.customVatRates.deleteCustomVatRatesId("custom_vat_rate_id"); + expect(response).toEqual(undefined); + }); + + test("patch_custom_vat_rates_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [{ name: "name", value: 1.1 }], + created_by_entity_user_id: "created_by_entity_user_id", + name: "name", + value: 1.1, + }; + server + .mockEndpoint() + .patch("/custom_vat_rates/custom_vat_rate_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.customVatRates.patchCustomVatRatesId("custom_vat_rate_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [ + { + name: "name", + value: 1.1, + }, + ], + created_by_entity_user_id: "created_by_entity_user_id", + name: "name", + value: 1.1, + }); + }); +}); diff --git a/tests/wire/dataExports.test.ts b/tests/wire/dataExports.test.ts new file mode 100644 index 0000000..b04fbc0 --- /dev/null +++ b/tests/wire/dataExports.test.ts @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("DataExports", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + count: 1, + created_by_entity_user_id: "created_by_entity_user_id", + end_datetime: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + format: "format", + language: "language", + source_url: "source_url", + start_datetime: "2024-01-15T09:30:00Z", + status: "status", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/data_exports").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.dataExports.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + count: 1, + created_by_entity_user_id: "created_by_entity_user_id", + end_datetime: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + format: "format", + language: "language", + source_url: "source_url", + start_datetime: "2024-01-15T09:30:00Z", + status: "status", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + date_from: "date_from", + date_to: "date_to", + format: "csv", + objects: [{ statuses: ["draft"], name: "payable" }], + }; + const rawResponseBody = { id: "id" }; + server + .mockEndpoint() + .post("/data_exports") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.dataExports.create({ + date_from: "date_from", + date_to: "date_to", + format: "csv", + objects: [ + { + name: "payable", + statuses: ["draft"], + }, + ], + }); + expect(response).toEqual({ + id: "id", + }); + }); + + test("get_supported_formats", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = [{ available_types: { key: ["csv"] }, object_type: "payable" }]; + server + .mockEndpoint() + .get("/data_exports/supported_formats") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.dataExports.getSupportedFormats(); + expect(response).toEqual([ + { + available_types: { + key: ["csv"], + }, + object_type: "payable", + }, + ]); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + count: 1, + created_by_entity_user_id: "created_by_entity_user_id", + end_datetime: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + format: "format", + language: "language", + source_url: "source_url", + start_datetime: "2024-01-15T09:30:00Z", + status: "status", + }; + server + .mockEndpoint() + .get("/data_exports/document_export_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.dataExports.getById("document_export_id"); + expect(response).toEqual({ + id: "id", + count: 1, + created_by_entity_user_id: "created_by_entity_user_id", + end_datetime: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + format: "format", + language: "language", + source_url: "source_url", + start_datetime: "2024-01-15T09:30:00Z", + status: "status", + }); + }); +}); diff --git a/tests/wire/dataExports/extraData.test.ts b/tests/wire/dataExports/extraData.test.ts new file mode 100644 index 0000000..01c09f3 --- /dev/null +++ b/tests/wire/dataExports/extraData.test.ts @@ -0,0 +1,231 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("ExtraData", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/data_exports/extra_data") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.dataExports.extraData.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }; + server + .mockEndpoint() + .post("/data_exports/extra_data") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.dataExports.extraData.create({ + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }; + server + .mockEndpoint() + .get("/data_exports/extra_data/extra_data_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.dataExports.extraData.getById("extra_data_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }; + server + .mockEndpoint() + .delete("/data_exports/extra_data/extra_data_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.dataExports.extraData.deleteById("extra_data_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }; + server + .mockEndpoint() + .patch("/data_exports/extra_data/extra_data_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.dataExports.extraData.updateById("extra_data_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_by: "created_by", + field_name: "default_account_code", + field_value: "field_value", + object_id: "object_id", + object_type: "counterpart", + }); + }); +}); diff --git a/tests/wire/deliveryNotes.test.ts b/tests/wire/deliveryNotes.test.ts new file mode 100644 index 0000000..79a4e2c --- /dev/null +++ b/tests/wire/deliveryNotes.test.ts @@ -0,0 +1,1358 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("DeliveryNotes", () => { + test("get_delivery_notes", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + postal_code: "123009", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { name: "name", type: "organization" }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + postal_code: "123009", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { description: "Pieces", name: "pcs" }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/delivery_notes").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.deliveryNotes.getDeliveryNotes(); + expect(response).toEqual({ + data: [ + { + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + postal_code: "123009", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + type: "organization", + name: "name", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + postal_code: "123009", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { + description: "Pieces", + name: "pcs", + }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("post_delivery_notes", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + counterpart_address_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2025-01-01", + delivery_number: "102-2025-0987", + display_signature_placeholder: true, + line_items: [ + { product_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", quantity: 10 }, + { + product: { + description: "Description of product 2", + measure_unit: { description: "pieces", name: "pcs" }, + name: "Product 2", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + }; + const rawResponseBody = { + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { description: "Pieces", name: "pcs" }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }; + server + .mockEndpoint() + .post("/delivery_notes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.deliveryNotes.postDeliveryNotes({ + counterpart_address_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2025-01-01", + delivery_number: "102-2025-0987", + display_signature_placeholder: true, + line_items: [ + { + product_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + quantity: 10, + }, + { + product: { + description: "Description of product 2", + measure_unit: { + description: "pieces", + name: "pcs", + }, + name: "Product 2", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + }); + expect(response).toEqual({ + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { + description: "Pieces", + name: "pcs", + }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }); + }); + + test("get_delivery_notes_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { description: "Pieces", name: "pcs" }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }; + server + .mockEndpoint() + .get("/delivery_notes/delivery_note_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.deliveryNotes.getDeliveryNotesId("delivery_note_id"); + expect(response).toEqual({ + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { + description: "Pieces", + name: "pcs", + }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }); + }); + + test("delete_delivery_notes_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/delivery_notes/delivery_note_id").respondWith().statusCode(200).build(); + + const response = await client.deliveryNotes.deleteDeliveryNotesId("delivery_note_id"); + expect(response).toEqual(undefined); + }); + + test("patch_delivery_notes_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { description: "Pieces", name: "pcs" }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }; + server + .mockEndpoint() + .patch("/delivery_notes/delivery_note_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.deliveryNotes.patchDeliveryNotesId("delivery_note_id"); + expect(response).toEqual({ + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { + description: "Pieces", + name: "pcs", + }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }); + }); + + test("post_delivery_notes_id_cancel", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { description: "Pieces", name: "pcs" }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }; + server + .mockEndpoint() + .post("/delivery_notes/delivery_note_id/cancel") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.deliveryNotes.postDeliveryNotesIdCancel("delivery_note_id"); + expect(response).toEqual({ + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { + description: "Pieces", + name: "pcs", + }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }); + }); + + test("post_delivery_notes_id_mark_as_delivered", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { description: "Pieces", name: "pcs" }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }; + server + .mockEndpoint() + .post("/delivery_notes/delivery_note_id/mark_as_delivered") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.deliveryNotes.postDeliveryNotesIdMarkAsDelivered("delivery_note_id"); + expect(response).toEqual({ + id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_at: "2022-01-01T00:00:00Z", + updated_at: "2022-01-01T00:00:00Z", + based_on: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + based_on_document_id: "IN-2022-01-01-0001", + counterpart: { + id: "id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + title: "Mr.", + }, + language: "ab", + organization: { + email: "acme@example.com", + is_customer: true, + is_vendor: true, + legal_name: "Acme Inc.", + phone: "5551231234", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + }, + counterpart_address: { + city: "Counterpart City", + country: "DE", + line1: "Counterpart Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + counterpart_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + created_by_entity_user_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + delivery_date: "2022-01-01", + delivery_number: "102-2022-0987", + display_signature_placeholder: true, + document_id: "DN-2022-01-01-0001", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "Entity City", + country: "DE", + line1: "Entity Street", + line2: "line2", + postal_code: "123009", + state: "state", + }, + entity_id: "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", + file_language: "en", + file_url: "https://example.com/delivery_note.pdf", + line_items: [ + { + product: { + description: "Description of product", + measure_unit: { + description: "Pieces", + name: "pcs", + }, + name: "Product Name", + }, + quantity: 20, + }, + ], + memo: "This is a memo", + original_file_language: "de", + original_file_url: "https://example.com/delivery_note_original.pdf", + status: "created", + }); + }); +}); diff --git a/tests/wire/eInvoicingConnections.test.ts b/tests/wire/eInvoicingConnections.test.ts new file mode 100644 index 0000000..1ca27bb --- /dev/null +++ b/tests/wire/eInvoicingConnections.test.ts @@ -0,0 +1,398 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("EInvoicingConnections", () => { + test("get_einvoicing_connections", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + address_line1: "address_line1", + city: "city", + country: "DE", + postal_code: "postal_code", + }, + credentials: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ], + entity_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + is_receiver: true, + is_sender: true, + legal_name: "legal_name", + provider_id: "12345", + status: "active", + }, + ], + }; + server + .mockEndpoint() + .get("/einvoicing_connections") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.eInvoicingConnections.getEinvoicingConnections(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + address_line1: "address_line1", + city: "city", + country: "DE", + postal_code: "postal_code", + }, + credentials: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ], + entity_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + is_receiver: true, + is_sender: true, + legal_name: "legal_name", + provider_id: "12345", + status: "active", + }, + ], + }); + }); + + test("post_einvoicing_connections", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + address: { address_line1: "address_line1", city: "city", country: "DE", postal_code: "postal_code" }, + }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + address_line1: "address_line1", + address_line2: "address_line2", + city: "city", + country: "DE", + postal_code: "postal_code", + state: "state", + }, + credentials: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ], + entity_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + is_receiver: true, + is_sender: true, + legal_name: "legal_name", + provider_id: "12345", + status: "active", + }; + server + .mockEndpoint() + .post("/einvoicing_connections") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.eInvoicingConnections.postEinvoicingConnections({ + address: { + address_line1: "address_line1", + city: "city", + country: "DE", + postal_code: "postal_code", + }, + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + address_line1: "address_line1", + address_line2: "address_line2", + city: "city", + country: "DE", + postal_code: "postal_code", + state: "state", + }, + credentials: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ], + entity_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + is_receiver: true, + is_sender: true, + legal_name: "legal_name", + provider_id: "12345", + status: "active", + }); + }); + + test("get_einvoicing_connections_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + address_line1: "address_line1", + address_line2: "address_line2", + city: "city", + country: "DE", + postal_code: "postal_code", + state: "state", + }, + credentials: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ], + entity_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + is_receiver: true, + is_sender: true, + legal_name: "legal_name", + provider_id: "12345", + status: "active", + }; + server + .mockEndpoint() + .get("/einvoicing_connections/einvoicing_connection_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.eInvoicingConnections.getEinvoicingConnectionsId("einvoicing_connection_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + address_line1: "address_line1", + address_line2: "address_line2", + city: "city", + country: "DE", + postal_code: "postal_code", + state: "state", + }, + credentials: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ], + entity_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + is_receiver: true, + is_sender: true, + legal_name: "legal_name", + provider_id: "12345", + status: "active", + }); + }); + + test("delete_einvoicing_connections_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/einvoicing_connections/einvoicing_connection_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.eInvoicingConnections.deleteEinvoicingConnectionsId("einvoicing_connection_id"); + expect(response).toEqual(undefined); + }); + + test("patch_einvoicing_connections_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + address_line1: "address_line1", + address_line2: "address_line2", + city: "city", + country: "DE", + postal_code: "postal_code", + state: "state", + }, + credentials: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ], + entity_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + is_receiver: true, + is_sender: true, + legal_name: "legal_name", + provider_id: "12345", + status: "active", + }; + server + .mockEndpoint() + .patch("/einvoicing_connections/einvoicing_connection_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.eInvoicingConnections.patchEinvoicingConnectionsId("einvoicing_connection_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + address_line1: "address_line1", + address_line2: "address_line2", + city: "city", + country: "DE", + postal_code: "postal_code", + state: "state", + }, + credentials: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ], + entity_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + is_receiver: true, + is_sender: true, + legal_name: "legal_name", + provider_id: "12345", + status: "active", + }); + }); + + test("post_einvoicing_connections_id_network_credentials", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { network_credentials_identifier: "12345678", network_credentials_schema: "DE:VAT" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }; + server + .mockEndpoint() + .post("/einvoicing_connections/einvoicing_connection_id/network_credentials") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.eInvoicingConnections.postEinvoicingConnectionsIdNetworkCredentials( + "einvoicing_connection_id", + { + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }, + ); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + einvoicing_connection_id: "einvoicing_connection_id", + network_credentials_identifier: "12345678", + network_credentials_schema: "DE:VAT", + }); + }); +}); diff --git a/tests/wire/entities.test.ts b/tests/wire/entities.test.ts new file mode 100644 index 0000000..bb38dae --- /dev/null +++ b/tests/wire/entities.test.ts @@ -0,0 +1,1394 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; +import * as Monite from "../../src/api/index"; + +describe("Entities", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { city: "city", country: "AF", line1: "line1", postal_code: "postal_code" }, + email: "email", + individual: { first_name: "first_name", last_name: "last_name" }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/entities").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.entities.get(); + expect(response).toEqual({ + data: [ + { + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + postal_code: "postal_code", + }, + email: "email", + individual: { + first_name: "first_name", + last_name: "last_name", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + address: { city: "city", country: "AF", line1: "line1", postal_code: "postal_code" }, + email: "email", + type: "individual", + }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server + .mockEndpoint() + .post("/entities") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.create({ + address: { + city: "city", + country: "AF", + line1: "line1", + postal_code: "postal_code", + }, + email: "email", + type: "individual", + }); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("get_entities_me", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server.mockEndpoint().get("/entities/me").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.entities.getEntitiesMe(); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("patch_entities_me", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server + .mockEndpoint() + .patch("/entities/me") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.patchEntitiesMe({}); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server + .mockEndpoint() + .get("/entities/ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.getById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server + .mockEndpoint() + .patch("/entities/ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.updateById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5", {}); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("post_entities_id_activate", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server + .mockEndpoint() + .post("/entities/ea837e28-509b-4b6a-a600-d54b6aa0b1f5/activate") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.postEntitiesIdActivate("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("post_entities_id_deactivate", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server + .mockEndpoint() + .post("/entities/ea837e28-509b-4b6a-a600-d54b6aa0b1f5/deactivate") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.postEntitiesIdDeactivate("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("delete_logo_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/entities/ea837e28-509b-4b6a-a600-d54b6aa0b1f5/logo") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.entities.deleteLogoById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); + expect(response).toEqual(undefined); + }); + + test("get_partner_metadata_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { metadata: { key: "value" } }; + server + .mockEndpoint() + .get("/entities/entity_id/partner_metadata") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.getPartnerMetadataById("entity_id"); + expect(response).toEqual({ + metadata: { + key: "value", + }, + }); + }); + + test("update_partner_metadata_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { metadata: { key: "value" } }; + const rawResponseBody = { metadata: { key: "value" } }; + server + .mockEndpoint() + .put("/entities/entity_id/partner_metadata") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.updatePartnerMetadataById("entity_id", { + metadata: { + key: "value", + }, + }); + expect(response).toEqual({ + metadata: { + key: "value", + }, + }); + }); + + test("get_settings_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + language: "ab", + currency: { default: "AED", exchange_rates: [{ base: "AED", to: "AED", rate: 0.98 }] }, + reminder: { enabled: true }, + vat_mode: "exclusive", + vat_inclusive_discount_mode: "exclusive", + payment_priority: "working_capital", + allow_purchase_order_autolinking: true, + receivable_edit_flow: "compliant", + document_ids: { + document_type_prefix: { + credit_note: "credit_note", + delivery_note: "delivery_note", + invoice: "invoice", + purchase_order: "purchase_order", + quote: "quote", + }, + include_date: true, + min_digits: 1, + prefix: "prefix", + separator: "/", + }, + payables_ocr_auto_tagging: [{ enabled: true, keywords: ["keywords"], tag_id: "tag_id" }], + quote_signature_required: true, + generate_paid_invoice_pdf: true, + accounting: { + ledger_account_ids: { payments: "payments", products: "products" }, + tax_ids: { deductions: "deductions" }, + }, + payables_skip_approval_flow: true, + document_rendering: { + credit_note: { display_entity_bank_account: true }, + invoice: { display_entity_bank_account: true }, + quote: { display_entity_bank_account: true, display_signature: true }, + }, + }; + server + .mockEndpoint() + .get("/entities/ea837e28-509b-4b6a-a600-d54b6aa0b1f5/settings") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.getSettingsById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); + expect(response).toEqual({ + language: "ab", + currency: { + default: "AED", + exchange_rates: [ + { + base: "AED", + to: "AED", + rate: 0.98, + }, + ], + }, + reminder: { + enabled: true, + }, + vat_mode: "exclusive", + vat_inclusive_discount_mode: "exclusive", + payment_priority: "working_capital", + allow_purchase_order_autolinking: true, + receivable_edit_flow: "compliant", + document_ids: { + document_type_prefix: { + credit_note: "credit_note", + delivery_note: "delivery_note", + invoice: "invoice", + purchase_order: "purchase_order", + quote: "quote", + }, + include_date: true, + min_digits: 1, + prefix: "prefix", + separator: "/", + }, + payables_ocr_auto_tagging: [ + { + enabled: true, + keywords: ["keywords"], + tag_id: "tag_id", + }, + ], + quote_signature_required: true, + generate_paid_invoice_pdf: true, + accounting: { + ledger_account_ids: { + payments: "payments", + products: "products", + }, + tax_ids: { + deductions: "deductions", + }, + }, + payables_skip_approval_flow: true, + document_rendering: { + credit_note: { + display_entity_bank_account: true, + }, + invoice: { + display_entity_bank_account: true, + }, + quote: { + display_entity_bank_account: true, + display_signature: true, + }, + }, + }); + }); + + test("update_settings_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + language: "ab", + currency: { default: "AED", exchange_rates: [{ base: "AED", to: "AED", rate: 0.98 }] }, + reminder: { enabled: true }, + vat_mode: "exclusive", + vat_inclusive_discount_mode: "exclusive", + payment_priority: "working_capital", + allow_purchase_order_autolinking: true, + receivable_edit_flow: "compliant", + document_ids: { + document_type_prefix: { + credit_note: "credit_note", + delivery_note: "delivery_note", + invoice: "invoice", + purchase_order: "purchase_order", + quote: "quote", + }, + include_date: true, + min_digits: 1, + prefix: "prefix", + separator: "/", + }, + payables_ocr_auto_tagging: [{ enabled: true, keywords: ["keywords"], tag_id: "tag_id" }], + quote_signature_required: true, + generate_paid_invoice_pdf: true, + accounting: { + ledger_account_ids: { payments: "payments", products: "products" }, + tax_ids: { deductions: "deductions" }, + }, + payables_skip_approval_flow: true, + document_rendering: { + credit_note: { display_entity_bank_account: true }, + invoice: { display_entity_bank_account: true }, + quote: { display_entity_bank_account: true, display_signature: true }, + }, + }; + server + .mockEndpoint() + .patch("/entities/ea837e28-509b-4b6a-a600-d54b6aa0b1f5/settings") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.updateSettingsById("ea837e28-509b-4b6a-a600-d54b6aa0b1f5"); + expect(response).toEqual({ + language: "ab", + currency: { + default: "AED", + exchange_rates: [ + { + base: "AED", + to: "AED", + rate: 0.98, + }, + ], + }, + reminder: { + enabled: true, + }, + vat_mode: "exclusive", + vat_inclusive_discount_mode: "exclusive", + payment_priority: "working_capital", + allow_purchase_order_autolinking: true, + receivable_edit_flow: "compliant", + document_ids: { + document_type_prefix: { + credit_note: "credit_note", + delivery_note: "delivery_note", + invoice: "invoice", + purchase_order: "purchase_order", + quote: "quote", + }, + include_date: true, + min_digits: 1, + prefix: "prefix", + separator: "/", + }, + payables_ocr_auto_tagging: [ + { + enabled: true, + keywords: ["keywords"], + tag_id: "tag_id", + }, + ], + quote_signature_required: true, + generate_paid_invoice_pdf: true, + accounting: { + ledger_account_ids: { + payments: "payments", + products: "products", + }, + tax_ids: { + deductions: "deductions", + }, + }, + payables_skip_approval_flow: true, + document_rendering: { + credit_note: { + display_entity_bank_account: true, + }, + invoice: { + display_entity_bank_account: true, + }, + quote: { + display_entity_bank_account: true, + display_signature: true, + }, + }, + }); + }); + + test("upload_onboarding_documents", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + + server + .mockEndpoint() + .post("/onboarding_documents") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .build(); + + const response = await client.entities.uploadOnboardingDocuments(); + expect(response).toEqual(undefined); + }); + + test("get_onboarding_requirements", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + disabled_reason: "disabled_reason", + payment_method: "payment_method", + requirements: { + currently_due: ["currently_due"], + eventually_due: ["eventually_due"], + past_due: ["past_due"], + pending_verification: ["pending_verification"], + }, + requirements_errors: [{ code: "code", reason: "reason", requirement: "requirement" }], + verification_errors: [{ code: "code", details: "details" }], + verification_status: "enabled", + }, + ], + }; + server + .mockEndpoint() + .get("/onboarding_requirements") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.getOnboardingRequirements(); + expect(response).toEqual({ + data: [ + { + disabled_reason: "disabled_reason", + payment_method: "payment_method", + requirements: { + currently_due: ["currently_due"], + eventually_due: ["eventually_due"], + past_due: ["past_due"], + pending_verification: ["pending_verification"], + }, + requirements_errors: [ + { + code: "code", + reason: "reason", + requirement: "requirement", + }, + ], + verification_errors: [ + { + code: "code", + details: "details", + }, + ], + verification_status: "enabled", + }, + ], + }); + }); +}); diff --git a/tests/wire/entities/bankAccounts.test.ts b/tests/wire/entities/bankAccounts.test.ts new file mode 100644 index 0000000..53ce438 --- /dev/null +++ b/tests/wire/entities/bankAccounts.test.ts @@ -0,0 +1,284 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("BankAccounts", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/bank_accounts").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.entities.bankAccounts.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { country: "AF", currency: "AED" }; + const rawResponseBody = { + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/bank_accounts") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.bankAccounts.create({ + country: "AF", + currency: "AED", + }); + expect(response).toEqual({ + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .get("/bank_accounts/bank_account_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.bankAccounts.getById("bank_account_id"); + expect(response).toEqual({ + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/bank_accounts/bank_account_id").respondWith().statusCode(200).build(); + + const response = await client.entities.bankAccounts.deleteById("bank_account_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .patch("/bank_accounts/bank_account_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.bankAccounts.updateById("bank_account_id"); + expect(response).toEqual({ + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("make_default_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/bank_accounts/bank_account_id/make_default") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.bankAccounts.makeDefaultById("bank_account_id"); + expect(response).toEqual({ + id: "id", + account_holder_name: "Cayla Lloyd", + account_number: "12345678", + bank_name: "Deutsche Bank", + bic: "DEUTDEFFXXX", + country: "AF", + currency: "AED", + display_name: "Primary account", + iban: "DE74500700100100000900", + is_default_for_currency: true, + routing_number: "routing_number", + sort_code: "123456", + was_created_by_user_id: "was_created_by_user_id", + }); + }); +}); diff --git a/tests/wire/entities/onboardingData.test.ts b/tests/wire/entities/onboardingData.test.ts new file mode 100644 index 0000000..750db0b --- /dev/null +++ b/tests/wire/entities/onboardingData.test.ts @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("OnboardingData", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + business_profile: { + description_of_goods_or_services: "description_of_goods_or_services", + estimated_monthly_revenue: { amount: 1, currency: "AED" }, + mcc: "mcc", + operating_countries: ["AF"], + url: "url", + }, + ownership_declaration: { date: "2024-01-15T09:30:00Z", ip: "ip" }, + tos_acceptance: { date: "2024-01-15T09:30:00Z", ip: "ip" }, + }; + server + .mockEndpoint() + .get("/entities/entity_id/onboarding_data") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.onboardingData.get("entity_id"); + expect(response).toEqual({ + business_profile: { + description_of_goods_or_services: "description_of_goods_or_services", + estimated_monthly_revenue: { + amount: 1, + currency: "AED", + }, + mcc: "mcc", + operating_countries: ["AF"], + url: "url", + }, + ownership_declaration: { + date: "2024-01-15T09:30:00Z", + ip: "ip", + }, + tos_acceptance: { + date: "2024-01-15T09:30:00Z", + ip: "ip", + }, + }); + }); + + test("update", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + business_profile: { + description_of_goods_or_services: "description_of_goods_or_services", + estimated_monthly_revenue: { amount: 1, currency: "AED" }, + mcc: "mcc", + operating_countries: ["AF"], + url: "url", + }, + ownership_declaration: { date: "2024-01-15T09:30:00Z", ip: "ip" }, + tos_acceptance: { date: "2024-01-15T09:30:00Z", ip: "ip" }, + }; + server + .mockEndpoint() + .patch("/entities/entity_id/onboarding_data") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.onboardingData.update("entity_id"); + expect(response).toEqual({ + business_profile: { + description_of_goods_or_services: "description_of_goods_or_services", + estimated_monthly_revenue: { + amount: 1, + currency: "AED", + }, + mcc: "mcc", + operating_countries: ["AF"], + url: "url", + }, + ownership_declaration: { + date: "2024-01-15T09:30:00Z", + ip: "ip", + }, + tos_acceptance: { + date: "2024-01-15T09:30:00Z", + ip: "ip", + }, + }); + }); +}); diff --git a/tests/wire/entities/paymentMethods.test.ts b/tests/wire/entities/paymentMethods.test.ts new file mode 100644 index 0000000..fd8f798 --- /dev/null +++ b/tests/wire/entities/paymentMethods.test.ts @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("PaymentMethods", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [{ direction: "receive", name: "SEPA Payments", status: "active", type: "sepa_credit" }], + }; + server + .mockEndpoint() + .get("/entities/entity_id/payment_methods") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.paymentMethods.get("entity_id"); + expect(response).toEqual({ + data: [ + { + direction: "receive", + name: "SEPA Payments", + status: "active", + type: "sepa_credit", + }, + ], + }); + }); + + test("set", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + data: [{ direction: "receive", name: "SEPA Payments", status: "active", type: "sepa_credit" }], + }; + server + .mockEndpoint() + .put("/entities/entity_id/payment_methods") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.paymentMethods.set("entity_id"); + expect(response).toEqual({ + data: [ + { + direction: "receive", + name: "SEPA Payments", + status: "active", + type: "sepa_credit", + }, + ], + }); + }); +}); diff --git a/tests/wire/entities/persons.test.ts b/tests/wire/entities/persons.test.ts new file mode 100644 index 0000000..b15d4db --- /dev/null +++ b/tests/wire/entities/persons.test.ts @@ -0,0 +1,353 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("Persons", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { city: "city", country: "country", line1: "line1", postal_code: "postal_code" }, + citizenship: "AF", + created_by_entity_user_id: "created_by_entity_user_id", + date_of_birth: "date_of_birth", + email: "email", + entity_id: "entity_id", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + phone: "phone", + relationship: {}, + ssn_last_4: "ssn_last_4", + }, + ], + }; + server.mockEndpoint().get("/persons").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.entities.persons.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "country", + line1: "line1", + postal_code: "postal_code", + }, + citizenship: "AF", + created_by_entity_user_id: "created_by_entity_user_id", + date_of_birth: "date_of_birth", + email: "email", + entity_id: "entity_id", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + phone: "phone", + relationship: {}, + ssn_last_4: "ssn_last_4", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { email: "email", first_name: "first_name", last_name: "last_name", relationship: {} }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "country", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + citizenship: "AF", + created_by_entity_user_id: "created_by_entity_user_id", + date_of_birth: "date_of_birth", + email: "email", + entity_id: "entity_id", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + phone: "phone", + relationship: { + director: true, + executive: true, + owner: true, + percent_ownership: 1.1, + representative: true, + title: "title", + }, + ssn_last_4: "ssn_last_4", + }; + server + .mockEndpoint() + .post("/persons") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.persons.create({ + email: "email", + first_name: "first_name", + last_name: "last_name", + relationship: {}, + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "country", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + citizenship: "AF", + created_by_entity_user_id: "created_by_entity_user_id", + date_of_birth: "date_of_birth", + email: "email", + entity_id: "entity_id", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + phone: "phone", + relationship: { + director: true, + executive: true, + owner: true, + percent_ownership: 1.1, + representative: true, + title: "title", + }, + ssn_last_4: "ssn_last_4", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "country", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + citizenship: "AF", + created_by_entity_user_id: "created_by_entity_user_id", + date_of_birth: "date_of_birth", + email: "email", + entity_id: "entity_id", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + phone: "phone", + relationship: { + director: true, + executive: true, + owner: true, + percent_ownership: 1.1, + representative: true, + title: "title", + }, + ssn_last_4: "ssn_last_4", + }; + server.mockEndpoint().get("/persons/person_id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.entities.persons.getById("person_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "country", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + citizenship: "AF", + created_by_entity_user_id: "created_by_entity_user_id", + date_of_birth: "date_of_birth", + email: "email", + entity_id: "entity_id", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + phone: "phone", + relationship: { + director: true, + executive: true, + owner: true, + percent_ownership: 1.1, + representative: true, + title: "title", + }, + ssn_last_4: "ssn_last_4", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/persons/person_id").respondWith().statusCode(200).build(); + + const response = await client.entities.persons.deleteById("person_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "country", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + citizenship: "AF", + created_by_entity_user_id: "created_by_entity_user_id", + date_of_birth: "date_of_birth", + email: "email", + entity_id: "entity_id", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + phone: "phone", + relationship: { + director: true, + executive: true, + owner: true, + percent_ownership: 1.1, + representative: true, + title: "title", + }, + ssn_last_4: "ssn_last_4", + }; + server + .mockEndpoint() + .patch("/persons/person_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.persons.updateById("person_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "country", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + citizenship: "AF", + created_by_entity_user_id: "created_by_entity_user_id", + date_of_birth: "date_of_birth", + email: "email", + entity_id: "entity_id", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + phone: "phone", + relationship: { + director: true, + executive: true, + owner: true, + percent_ownership: 1.1, + representative: true, + title: "title", + }, + ssn_last_4: "ssn_last_4", + }); + }); + + test("upload_onboarding_documents", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + + server + .mockEndpoint() + .post("/persons/person_id/onboarding_documents") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .build(); + + const response = await client.entities.persons.uploadOnboardingDocuments("person_id"); + expect(response).toEqual(undefined); + }); +}); diff --git a/tests/wire/entities/vatIds.test.ts b/tests/wire/entities/vatIds.test.ts new file mode 100644 index 0000000..6266353 --- /dev/null +++ b/tests/wire/entities/vatIds.test.ts @@ -0,0 +1,146 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; + +describe("VatIds", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [{ id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }], + }; + server + .mockEndpoint() + .get("/entities/entity_id/vat_ids") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.vatIds.get("entity_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { country: "AF", value: "123456789" }; + const rawResponseBody = { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }; + server + .mockEndpoint() + .post("/entities/entity_id/vat_ids") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.vatIds.create("entity_id", { + country: "AF", + value: "123456789", + }); + expect(response).toEqual({ + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }; + server + .mockEndpoint() + .get("/entities/entity_id/vat_ids/id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.vatIds.getById("id", "entity_id"); + expect(response).toEqual({ + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/entities/entity_id/vat_ids/id").respondWith().statusCode(200).build(); + + const response = await client.entities.vatIds.deleteById("id", "entity_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }; + server + .mockEndpoint() + .patch("/entities/entity_id/vat_ids/id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entities.vatIds.updateById("id", "entity_id"); + expect(response).toEqual({ + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }); + }); +}); diff --git a/tests/wire/entityUsers.test.ts b/tests/wire/entityUsers.test.ts new file mode 100644 index 0000000..99db01d --- /dev/null +++ b/tests/wire/entityUsers.test.ts @@ -0,0 +1,601 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; +import * as Monite from "../../src/api/index"; + +describe("EntityUsers", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/entity_users").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.entityUsers.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { first_name: "Casey", login: "login" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }; + server + .mockEndpoint() + .post("/entity_users") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entityUsers.create({ + first_name: "Casey", + login: "login", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }); + }); + + test("get_current", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }; + server.mockEndpoint().get("/entity_users/me").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.entityUsers.getCurrent(); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }); + }); + + test("update_current", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }; + server + .mockEndpoint() + .patch("/entity_users/me") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entityUsers.updateCurrent(); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }); + }); + + test("get_current_entity", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server + .mockEndpoint() + .get("/entity_users/my_entity") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entityUsers.getCurrentEntity(); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("update_current_entity", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + type: "individual", + }; + server + .mockEndpoint() + .patch("/entity_users/my_entity") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entityUsers.updateCurrentEntity({}); + expect(response).toEqual({ + type: "individual", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + status: "active", + tax_id: "tax_id", + website: "website", + }); + }); + + test("get_current_role", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + name: "name", + permissions: { objects: [{ object_type: "approval_policy" }] }, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .get("/entity_users/my_role") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entityUsers.getCurrentRole(); + expect(response).toEqual({ + id: "id", + name: "name", + permissions: { + objects: [ + { + object_type: "approval_policy", + }, + ], + }, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }; + server + .mockEndpoint() + .get("/entity_users/entity_user_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entityUsers.getById("entity_user_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/entity_users/entity_user_id").respondWith().statusCode(200).build(); + + const response = await client.entityUsers.deleteById("entity_user_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }; + server + .mockEndpoint() + .patch("/entity_users/entity_user_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.entityUsers.updateById("entity_user_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + email: "email", + first_name: "first_name", + last_name: "last_name", + login: "caseyp", + phone: "phone", + role_id: "role_id", + status: "active", + userpic_file_id: "userpic_file_id", + }); + }); +}); diff --git a/tests/wire/events.test.ts b/tests/wire/events.test.ts new file mode 100644 index 0000000..ca8456e --- /dev/null +++ b/tests/wire/events.test.ts @@ -0,0 +1,92 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Events", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + action: "action", + api_version: "api_version", + description: "description", + entity_id: "entity_id", + object: { key: "value" }, + object_type: "account", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/events").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.events.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + action: "action", + api_version: "api_version", + description: "description", + entity_id: "entity_id", + object: { + key: "value", + }, + object_type: "account", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + action: "action", + api_version: "api_version", + description: "description", + entity_id: "entity_id", + object: { key: "value" }, + object_type: "account", + }; + server.mockEndpoint().get("/events/event_id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.events.getById("event_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + action: "action", + api_version: "api_version", + description: "description", + entity_id: "entity_id", + object: { + key: "value", + }, + object_type: "account", + }); + }); +}); diff --git a/tests/wire/files.test.ts b/tests/wire/files.test.ts new file mode 100644 index 0000000..c4b7a45 --- /dev/null +++ b/tests/wire/files.test.ts @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Files", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + ], + }; + server.mockEndpoint().get("/files").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.files.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }; + server.mockEndpoint().get("/files/file_id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.files.getById("file_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }); + }); + + test("delete", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/files/file_id").respondWith().statusCode(200).build(); + + const response = await client.files.delete("file_id"); + expect(response).toEqual(undefined); + }); +}); diff --git a/tests/wire/financing.test.ts b/tests/wire/financing.test.ts new file mode 100644 index 0000000..328c0b9 --- /dev/null +++ b/tests/wire/financing.test.ts @@ -0,0 +1,193 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Financing", () => { + test("get_financing_invoices", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + type: "payable", + status: "DRAFT", + invoice_id: "invoice_id", + document_id: "document_id", + due_date: "due_date", + issue_date: "issue_date", + total_amount: 1, + currency: "AED", + description: "description", + payer_type: "payer_type", + payer_business_name: "payer_business_name", + payer_first_name: "payer_first_name", + payer_last_name: "payer_last_name", + requested_amount: 1, + principal_amount: 1, + repayment_amount: 1, + advance_amount: 1, + advance_rate_percentage: 1, + fee_amount: 1, + fee_percentage: 1, + repayment_schedule: { + repayment_date: "repayment_date", + repayment_amount: 1, + repayment_fee_amount: 1, + repayment_principal_amount: 1, + }, + }, + ], + prev_pagination_token: "prev_pagination_token", + next_pagination_token: "next_pagination_token", + }; + server + .mockEndpoint() + .get("/financing_invoices") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.financing.getFinancingInvoices(); + expect(response).toEqual({ + data: [ + { + type: "payable", + status: "DRAFT", + invoice_id: "invoice_id", + document_id: "document_id", + due_date: "due_date", + issue_date: "issue_date", + total_amount: 1, + currency: "AED", + description: "description", + payer_type: "payer_type", + payer_business_name: "payer_business_name", + payer_first_name: "payer_first_name", + payer_last_name: "payer_last_name", + requested_amount: 1, + principal_amount: 1, + repayment_amount: 1, + advance_amount: 1, + advance_rate_percentage: 1, + fee_amount: 1, + fee_percentage: 1, + repayment_schedule: { + repayment_date: "repayment_date", + repayment_amount: 1, + repayment_fee_amount: 1, + repayment_principal_amount: 1, + }, + }, + ], + prev_pagination_token: "prev_pagination_token", + next_pagination_token: "next_pagination_token", + }); + }); + + test("post_financing_invoices", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { invoices: [{ id: "id", type: "payable" }] }; + const rawResponseBody = { connect_token: "connect_token", session_token: "session_token" }; + server + .mockEndpoint() + .post("/financing_invoices") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.financing.postFinancingInvoices({ + invoices: [ + { + id: "id", + type: "payable", + }, + ], + }); + expect(response).toEqual({ + connect_token: "connect_token", + session_token: "session_token", + }); + }); + + test("get_financing_offers", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + offers: [ + { + status: "NEW", + total_amount: 1000000, + available_amount: 500000, + currency: "AED", + pricing_plans: [ + { advance_rate_percentage: 1, fee_percentage: 1, repayment_type: "MULTIPLE_DURATION" }, + ], + }, + ], + business_status: "NEW", + }; + server.mockEndpoint().get("/financing_offers").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.financing.getFinancingOffers(); + expect(response).toEqual({ + offers: [ + { + status: "NEW", + total_amount: 1000000, + available_amount: 500000, + currency: "AED", + pricing_plans: [ + { + advance_rate_percentage: 1, + fee_percentage: 1, + repayment_type: "MULTIPLE_DURATION", + }, + ], + }, + ], + business_status: "NEW", + }); + }); + + test("post_financing_tokens", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { connect_token: "connect_token" }; + server.mockEndpoint().post("/financing_tokens").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.financing.postFinancingTokens(); + expect(response).toEqual({ + connect_token: "connect_token", + }); + }); +}); diff --git a/tests/wire/mailTemplates.test.ts b/tests/wire/mailTemplates.test.ts new file mode 100644 index 0000000..a265603 --- /dev/null +++ b/tests/wire/mailTemplates.test.ts @@ -0,0 +1,331 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("MailTemplates", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/mail_templates").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.mailTemplates.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + body_template: "body_template", + name: "name", + subject_template: "subject_template", + type: "receivables_quote", + }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }; + server + .mockEndpoint() + .post("/mail_templates") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailTemplates.create({ + body_template: "body_template", + name: "name", + subject_template: "subject_template", + type: "receivables_quote", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }); + }); + + test("preview", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + body: "body", + document_type: "receivables_quote", + language_code: "ab", + subject: "subject", + }; + const rawResponseBody = { body_preview: "body_preview", subject_preview: "subject_preview" }; + server + .mockEndpoint() + .post("/mail_templates/preview") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailTemplates.preview({ + body: "body", + document_type: "receivables_quote", + language_code: "ab", + subject: "subject", + }); + expect(response).toEqual({ + body_preview: "body_preview", + subject_preview: "subject_preview", + }); + }); + + test("get_system", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + available_templates: [ + { body_template: "body_template", language: "language", subject_template: "subject_template" }, + ], + template_name: "template_name", + }, + ], + }; + server + .mockEndpoint() + .get("/mail_templates/system") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailTemplates.getSystem(); + expect(response).toEqual({ + data: [ + { + available_templates: [ + { + body_template: "body_template", + language: "language", + subject_template: "subject_template", + }, + ], + template_name: "template_name", + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }; + server + .mockEndpoint() + .get("/mail_templates/template_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailTemplates.getById("template_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/mail_templates/template_id").respondWith().statusCode(200).build(); + + const response = await client.mailTemplates.deleteById("template_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }; + server + .mockEndpoint() + .patch("/mail_templates/template_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailTemplates.updateById("template_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }); + }); + + test("make_default_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }; + server + .mockEndpoint() + .post("/mail_templates/template_id/make_default") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailTemplates.makeDefaultById("template_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + body_template: "body_template", + is_default: true, + language: "language", + name: "name", + subject_template: "subject_template", + type: "type", + }); + }); +}); diff --git a/tests/wire/mailboxDomains.test.ts b/tests/wire/mailboxDomains.test.ts new file mode 100644 index 0000000..963a551 --- /dev/null +++ b/tests/wire/mailboxDomains.test.ts @@ -0,0 +1,168 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("MailboxDomains", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + dedicated_ip: "dedicated_ip", + dns_records: { + receiving_dns_records: [ + { is_active: true, record_type: "TXT", valid: "valid", value: "value" }, + ], + sending_dns_records: [{ is_active: true, record_type: "TXT", valid: "valid", value: "value" }], + }, + domain: "domain", + last_updated_at: "2024-01-15T09:30:00Z", + status: "status", + }, + ], + }; + server.mockEndpoint().get("/mailbox_domains").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.mailboxDomains.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + dedicated_ip: "dedicated_ip", + dns_records: { + receiving_dns_records: [ + { + is_active: true, + record_type: "TXT", + valid: "valid", + value: "value", + }, + ], + sending_dns_records: [ + { + is_active: true, + record_type: "TXT", + valid: "valid", + value: "value", + }, + ], + }, + domain: "domain", + last_updated_at: "2024-01-15T09:30:00Z", + status: "status", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { domain: "domain" }; + const rawResponseBody = { + id: "id", + dedicated_ip: "dedicated_ip", + dns_records: { + receiving_dns_records: [{ is_active: true, record_type: "TXT", valid: "valid", value: "value" }], + sending_dns_records: [{ is_active: true, record_type: "TXT", valid: "valid", value: "value" }], + }, + domain: "domain", + last_updated_at: "2024-01-15T09:30:00Z", + status: "status", + }; + server + .mockEndpoint() + .post("/mailbox_domains") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailboxDomains.create({ + domain: "domain", + }); + expect(response).toEqual({ + id: "id", + dedicated_ip: "dedicated_ip", + dns_records: { + receiving_dns_records: [ + { + is_active: true, + record_type: "TXT", + valid: "valid", + value: "value", + }, + ], + sending_dns_records: [ + { + is_active: true, + record_type: "TXT", + valid: "valid", + value: "value", + }, + ], + }, + domain: "domain", + last_updated_at: "2024-01-15T09:30:00Z", + status: "status", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/mailbox_domains/domain_id").respondWith().statusCode(200).build(); + + const response = await client.mailboxDomains.deleteById("domain_id"); + expect(response).toEqual(undefined); + }); + + test("verify_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "id", domain: "domain", status: "status" }; + server + .mockEndpoint() + .post("/mailbox_domains/domain_id/verify") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailboxDomains.verifyById("domain_id"); + expect(response).toEqual({ + id: "id", + domain: "domain", + status: "status", + }); + }); +}); diff --git a/tests/wire/mailboxes.test.ts b/tests/wire/mailboxes.test.ts new file mode 100644 index 0000000..3446c7f --- /dev/null +++ b/tests/wire/mailboxes.test.ts @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Mailboxes", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + mailbox_domain_id: "mailbox_domain_id", + mailbox_full_address: "mailbox_full_address", + mailbox_name: "mailbox_name", + related_object_type: "related_object_type", + status: "status", + }, + ], + }; + server.mockEndpoint().get("/mailboxes").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.mailboxes.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + mailbox_domain_id: "mailbox_domain_id", + mailbox_full_address: "mailbox_full_address", + mailbox_name: "mailbox_name", + related_object_type: "related_object_type", + status: "status", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + mailbox_domain_id: "mailbox_domain_id", + mailbox_name: "mailbox_name", + related_object_type: "payable", + }; + const rawResponseBody = { + id: "id", + mailbox_domain_id: "mailbox_domain_id", + mailbox_full_address: "mailbox_full_address", + mailbox_name: "mailbox_name", + related_object_type: "related_object_type", + status: "status", + }; + server + .mockEndpoint() + .post("/mailboxes") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailboxes.create({ + mailbox_domain_id: "mailbox_domain_id", + mailbox_name: "mailbox_name", + }); + expect(response).toEqual({ + id: "id", + mailbox_domain_id: "mailbox_domain_id", + mailbox_full_address: "mailbox_full_address", + mailbox_name: "mailbox_name", + related_object_type: "related_object_type", + status: "status", + }); + }); + + test("search", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { entity_ids: ["entity_ids"] }; + const rawResponseBody = { + data: [ + { + id: "id", + mailbox_domain_id: "mailbox_domain_id", + mailbox_full_address: "mailbox_full_address", + mailbox_name: "mailbox_name", + related_object_type: "related_object_type", + status: "status", + }, + ], + }; + server + .mockEndpoint() + .post("/mailboxes/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.mailboxes.search({ + entity_ids: ["entity_ids"], + }); + expect(response).toEqual({ + data: [ + { + id: "id", + mailbox_domain_id: "mailbox_domain_id", + mailbox_full_address: "mailbox_full_address", + mailbox_name: "mailbox_name", + related_object_type: "related_object_type", + status: "status", + }, + ], + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/mailboxes/mailbox_id").respondWith().statusCode(200).build(); + + const response = await client.mailboxes.deleteById("mailbox_id"); + expect(response).toEqual(undefined); + }); +}); diff --git a/tests/wire/measureUnits.test.ts b/tests/wire/measureUnits.test.ts new file mode 100644 index 0000000..acc3979 --- /dev/null +++ b/tests/wire/measureUnits.test.ts @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("MeasureUnits", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + name: "name", + }, + ], + }; + server.mockEndpoint().get("/measure_units").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.measureUnits.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + name: "name", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + name: "name", + }; + server + .mockEndpoint() + .post("/measure_units") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.measureUnits.create({ + name: "name", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + name: "name", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + name: "name", + }; + server + .mockEndpoint() + .get("/measure_units/unit_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.measureUnits.getById("unit_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + name: "name", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/measure_units/unit_id").respondWith().statusCode(200).build(); + + const response = await client.measureUnits.deleteById("unit_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + name: "name", + }; + server + .mockEndpoint() + .patch("/measure_units/unit_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.measureUnits.updateById("unit_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + name: "name", + }); + }); +}); diff --git a/tests/wire/ocr.test.ts b/tests/wire/ocr.test.ts new file mode 100644 index 0000000..5278e87 --- /dev/null +++ b/tests/wire/ocr.test.ts @@ -0,0 +1,249 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Ocr", () => { + test("get_ocr_tasks", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + status: "processing", + document_type: "invoice", + recognized_data: { + sender: { address: {}, bank_account: {} }, + recipient: { address: {}, bank_account: {} }, + type: "invoice", + }, + }, + ], + prev_pagination_token: "prev_pagination_token", + next_pagination_token: "next_pagination_token", + }; + server.mockEndpoint().get("/ocr_tasks").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.ocr.getOcrTasks(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + status: "processing", + document_type: "invoice", + recognized_data: { + type: "invoice", + sender: { + address: {}, + bank_account: {}, + }, + recipient: { + address: {}, + bank_account: {}, + }, + }, + }, + ], + prev_pagination_token: "prev_pagination_token", + next_pagination_token: "next_pagination_token", + }); + }); + + test("post_ocr_tasks", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { file_url: "file_url" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + status: "processing", + document_type: "invoice", + recognized_data: { + currency: "AED", + due_date: "due_date", + issue_date: "issue_date", + document_number: "document_number", + sender: { + vat_number: "vat_number", + tax_number: "tax_number", + email: "email", + name: "name", + address: {}, + bank_account: {}, + }, + recipient: { + vat_number: "vat_number", + tax_number: "tax_number", + email: "email", + name: "name", + address: {}, + bank_account: {}, + }, + subtotal: 1.1, + total_amount: 1.1, + tax_amount: 1.1, + tax_rate: 1.1, + amount_paid: 1.1, + payment_terms: "payment_terms", + line_items: [{}], + type: "invoice", + }, + }; + server + .mockEndpoint() + .post("/ocr_tasks") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.ocr.postOcrTasks({ + file_url: "file_url", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + status: "processing", + document_type: "invoice", + recognized_data: { + type: "invoice", + currency: "AED", + due_date: "due_date", + issue_date: "issue_date", + document_number: "document_number", + sender: { + vat_number: "vat_number", + tax_number: "tax_number", + email: "email", + name: "name", + address: {}, + bank_account: {}, + }, + recipient: { + vat_number: "vat_number", + tax_number: "tax_number", + email: "email", + name: "name", + address: {}, + bank_account: {}, + }, + subtotal: 1.1, + total_amount: 1.1, + tax_amount: 1.1, + tax_rate: 1.1, + amount_paid: 1.1, + payment_terms: "payment_terms", + line_items: [{}], + }, + }); + }); + + test("get_ocr_tasks_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + status: "processing", + document_type: "invoice", + recognized_data: { + currency: "AED", + due_date: "due_date", + issue_date: "issue_date", + document_number: "document_number", + sender: { + vat_number: "vat_number", + tax_number: "tax_number", + email: "email", + name: "name", + address: {}, + bank_account: {}, + }, + recipient: { + vat_number: "vat_number", + tax_number: "tax_number", + email: "email", + name: "name", + address: {}, + bank_account: {}, + }, + subtotal: 1.1, + total_amount: 1.1, + tax_amount: 1.1, + tax_rate: 1.1, + amount_paid: 1.1, + payment_terms: "payment_terms", + line_items: [{}], + type: "invoice", + }, + }; + server.mockEndpoint().get("/ocr_tasks/task_id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.ocr.getOcrTasksId("task_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + status: "processing", + document_type: "invoice", + recognized_data: { + type: "invoice", + currency: "AED", + due_date: "due_date", + issue_date: "issue_date", + document_number: "document_number", + sender: { + vat_number: "vat_number", + tax_number: "tax_number", + email: "email", + name: "name", + address: {}, + bank_account: {}, + }, + recipient: { + vat_number: "vat_number", + tax_number: "tax_number", + email: "email", + name: "name", + address: {}, + bank_account: {}, + }, + subtotal: 1.1, + total_amount: 1.1, + tax_amount: 1.1, + tax_rate: 1.1, + amount_paid: 1.1, + payment_terms: "payment_terms", + line_items: [{}], + }, + }); + }); +}); diff --git a/tests/wire/overdueReminders.test.ts b/tests/wire/overdueReminders.test.ts new file mode 100644 index 0000000..aa4eb4b --- /dev/null +++ b/tests/wire/overdueReminders.test.ts @@ -0,0 +1,207 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("OverdueReminders", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + name: "name", + terms: [{ body: "body", days_after: 1, subject: "subject" }], + }, + ], + }; + server.mockEndpoint().get("/overdue_reminders").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.overdueReminders.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + name: "name", + terms: [ + { + body: "body", + days_after: 1, + subject: "subject", + }, + ], + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + name: "name", + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + terms: [{ body: "body", days_after: 1, subject: "subject" }], + }; + server + .mockEndpoint() + .post("/overdue_reminders") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.overdueReminders.create({ + name: "name", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + name: "name", + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + terms: [ + { + body: "body", + days_after: 1, + subject: "subject", + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + name: "name", + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + terms: [{ body: "body", days_after: 1, subject: "subject" }], + }; + server + .mockEndpoint() + .get("/overdue_reminders/overdue_reminder_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.overdueReminders.getById("overdue_reminder_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + name: "name", + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + terms: [ + { + body: "body", + days_after: 1, + subject: "subject", + }, + ], + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/overdue_reminders/overdue_reminder_id").respondWith().statusCode(200).build(); + + const response = await client.overdueReminders.deleteById("overdue_reminder_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + name: "name", + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + terms: [{ body: "body", days_after: 1, subject: "subject" }], + }; + server + .mockEndpoint() + .patch("/overdue_reminders/overdue_reminder_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.overdueReminders.updateById("overdue_reminder_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + name: "name", + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + terms: [ + { + body: "body", + days_after: 1, + subject: "subject", + }, + ], + }); + }); +}); diff --git a/tests/wire/partnerSettings.test.ts b/tests/wire/partnerSettings.test.ts new file mode 100644 index 0000000..fa41b25 --- /dev/null +++ b/tests/wire/partnerSettings.test.ts @@ -0,0 +1,213 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("PartnerSettings", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + currency: { default: "AED", exchange_rates: [{ base: "AED", to: "AED", rate: 0.98 }] }, + payable: { + allow_cancel_duplicates_automatically: true, + allow_counterpart_autocreation: true, + allow_counterpart_autolinking: true, + allow_credit_note_autolinking: true, + approve_page_url: "https://monite.com", + default_state: "default_state", + skip_approval_for_paid_invoice: true, + }, + receivable: { create_without_personal_info: true, deduction_title: "deduction_title" }, + mail: { attach_documents_as_pdf: true, from_email_username: "from_email_username", from_name: "from_name" }, + commercial_conditions: ["commercial_conditions"], + units: [{ designation: "kg", name: "Kilogram" }], + website: "website", + default_role: { key: "value" }, + payments: { + payment_page_domain: "payment_page_domain", + payment_page_theme: { + background_color: "background_color", + border_radius: "border_radius", + font_color: "font_color", + font_family: "font_family", + font_link_href: "font_link_href", + logo_src: "logo_src", + }, + support_email: "support_email", + }, + api_version: "2024-05-25", + }; + server.mockEndpoint().get("/settings").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.partnerSettings.get(); + expect(response).toEqual({ + currency: { + default: "AED", + exchange_rates: [ + { + base: "AED", + to: "AED", + rate: 0.98, + }, + ], + }, + payable: { + allow_cancel_duplicates_automatically: true, + allow_counterpart_autocreation: true, + allow_counterpart_autolinking: true, + allow_credit_note_autolinking: true, + approve_page_url: "https://monite.com", + default_state: "default_state", + skip_approval_for_paid_invoice: true, + }, + receivable: { + create_without_personal_info: true, + deduction_title: "deduction_title", + }, + mail: { + attach_documents_as_pdf: true, + from_email_username: "from_email_username", + from_name: "from_name", + }, + commercial_conditions: ["commercial_conditions"], + units: [ + { + designation: "kg", + name: "Kilogram", + }, + ], + website: "website", + default_role: { + key: "value", + }, + payments: { + payment_page_domain: "payment_page_domain", + payment_page_theme: { + background_color: "background_color", + border_radius: "border_radius", + font_color: "font_color", + font_family: "font_family", + font_link_href: "font_link_href", + logo_src: "logo_src", + }, + support_email: "support_email", + }, + api_version: "2024-05-25", + }); + }); + + test("update", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + currency: { default: "AED", exchange_rates: [{ base: "AED", to: "AED", rate: 0.98 }] }, + payable: { + allow_cancel_duplicates_automatically: true, + allow_counterpart_autocreation: true, + allow_counterpart_autolinking: true, + allow_credit_note_autolinking: true, + approve_page_url: "https://monite.com", + default_state: "default_state", + skip_approval_for_paid_invoice: true, + }, + receivable: { create_without_personal_info: true, deduction_title: "deduction_title" }, + mail: { attach_documents_as_pdf: true, from_email_username: "from_email_username", from_name: "from_name" }, + commercial_conditions: ["commercial_conditions"], + units: [{ designation: "kg", name: "Kilogram" }], + website: "website", + default_role: { key: "value" }, + payments: { + payment_page_domain: "payment_page_domain", + payment_page_theme: { + background_color: "background_color", + border_radius: "border_radius", + font_color: "font_color", + font_family: "font_family", + font_link_href: "font_link_href", + logo_src: "logo_src", + }, + support_email: "support_email", + }, + api_version: "2024-05-25", + }; + server + .mockEndpoint() + .patch("/settings") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.partnerSettings.update(); + expect(response).toEqual({ + currency: { + default: "AED", + exchange_rates: [ + { + base: "AED", + to: "AED", + rate: 0.98, + }, + ], + }, + payable: { + allow_cancel_duplicates_automatically: true, + allow_counterpart_autocreation: true, + allow_counterpart_autolinking: true, + allow_credit_note_autolinking: true, + approve_page_url: "https://monite.com", + default_state: "default_state", + skip_approval_for_paid_invoice: true, + }, + receivable: { + create_without_personal_info: true, + deduction_title: "deduction_title", + }, + mail: { + attach_documents_as_pdf: true, + from_email_username: "from_email_username", + from_name: "from_name", + }, + commercial_conditions: ["commercial_conditions"], + units: [ + { + designation: "kg", + name: "Kilogram", + }, + ], + website: "website", + default_role: { + key: "value", + }, + payments: { + payment_page_domain: "payment_page_domain", + payment_page_theme: { + background_color: "background_color", + border_radius: "border_radius", + font_color: "font_color", + font_family: "font_family", + font_link_href: "font_link_href", + logo_src: "logo_src", + }, + support_email: "support_email", + }, + api_version: "2024-05-25", + }); + }); +}); diff --git a/tests/wire/payables.test.ts b/tests/wire/payables.test.ts new file mode 100644 index 0000000..cfeecf5 --- /dev/null +++ b/tests/wire/payables.test.ts @@ -0,0 +1,5003 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Payables", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { name: "name", term_final: { number_of_days: 1 } }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date" }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/payables").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.payables.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + name: "name", + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.create(); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("get_analytics", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + count: 1, + data: [{ count: 1, status: "draft", sum_total_amount: 1 }], + sum_total_amount: 1, + }; + server + .mockEndpoint() + .get("/payables/analytics") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.getAnalytics(); + expect(response).toEqual({ + count: 1, + data: [ + { + count: 1, + status: "draft", + sum_total_amount: 1, + }, + ], + sum_total_amount: 1, + }); + }); + + test("get_validations", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { required_fields: ["currency"] }; + server + .mockEndpoint() + .get("/payables/validations") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.getValidations(); + expect(response).toEqual({ + required_fields: ["currency"], + }); + }); + + test("update_validations", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { required_fields: ["currency"] }; + const rawResponseBody = { required_fields: ["currency"] }; + server + .mockEndpoint() + .put("/payables/validations") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.updateValidations({ + required_fields: ["currency"], + }); + expect(response).toEqual({ + required_fields: ["currency"], + }); + }); + + test("reset_validations", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { required_fields: ["currency"] }; + server + .mockEndpoint() + .post("/payables/validations/reset") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.resetValidations(); + expect(response).toEqual({ + required_fields: ["currency"], + }); + }); + + test("get_variables", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + object_subtype: "payables_purchase_order", + object_type: "account", + variables: [{ description: "description", name: "name" }], + }, + ], + }; + server + .mockEndpoint() + .get("/payables/variables") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.getVariables(); + expect(response).toEqual({ + data: [ + { + object_subtype: "payables_purchase_order", + object_type: "account", + variables: [ + { + description: "description", + name: "name", + }, + ], + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .get("/payables/payable_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.getById("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/payables/payable_id").respondWith().statusCode(200).build(); + + const response = await client.payables.deleteById("payable_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .patch("/payables/payable_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.updateById("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("approve_payment_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables/payable_id/approve_payment_operation") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.approvePaymentById("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("cancel_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables/payable_id/cancel") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.cancelById("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("post_payables_id_cancel_ocr", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables/payable_id/cancel_ocr") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.postPayablesIdCancelOcr("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("get_payables_id_history", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "cd58435b-1c79-4b17-9f79-f898c93e5f97", + entity_user_id: "d5a577b0-01c0-4566-ac5c-44f41935e8c4", + event_data: { new_status: "draft", old_status: "draft" }, + event_type: "status_changed", + payable_id: "f669a8a4-0563-4ab9-b54f-e9d700d282c5", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/payables/payable_id/history") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.getPayablesIdHistory("payable_id"); + expect(response).toEqual({ + data: [ + { + id: "cd58435b-1c79-4b17-9f79-f898c93e5f97", + entity_user_id: "d5a577b0-01c0-4566-ac5c-44f41935e8c4", + event_data: { + new_status: "draft", + old_status: "draft", + }, + event_type: "status_changed", + payable_id: "f669a8a4-0563-4ab9-b54f-e9d700d282c5", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("mark_as_paid_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables/payable_id/mark_as_paid") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.markAsPaidById("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("mark_as_partially_paid_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { amount_paid: 1 }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables/payable_id/mark_as_partially_paid") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.markAsPartiallyPaidById("payable_id", { + amount_paid: 1, + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("reject_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables/payable_id/reject") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.rejectById("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("reopen_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables/payable_id/reopen") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.reopenById("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("submit_for_approval_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { country: "AF", type: "type", value: "value" }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { default_currency_code: "default_currency_code", rate: 1.1, total: 1.1 }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [{ url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200, height: 400 }], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { key: "value" }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { date: "date", discount: 1 }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }; + server + .mockEndpoint() + .post("/payables/payable_id/submit_for_approval") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.submitForApprovalById("payable_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + amount_due: 1000, + amount_paid: 1000, + amount_to_pay: 1000, + approval_policy_id: "approval_policy_id", + counterpart: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_address_id: "counterpart_address_id", + counterpart_bank_account_id: "counterpart_bank_account_id", + counterpart_id: "counterpart_id", + counterpart_raw_data: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + bank_account: { + account_holder_name: "account_holder_name", + account_number: "123456789012", + bic: "DEUTDE2HXXX", + iban: "iban", + sort_code: "sort_code", + }, + email: "acme@example.com", + name: "Acme Inc.", + phone: "5551231234", + tax_id: "DE12345678", + vat_id: { + country: "AF", + type: "type", + value: "value", + }, + }, + counterpart_vat_id_id: "counterpart_vat_id_id", + created_by_role_id: "created_by_role_id", + credit_notes: [ + { + id: "123e4567-e89b-12d3-a456-426614174000", + document_id: "CN-123456", + issued_at: "2024-01-15", + status: "submitted_for_approval", + total_amount: 1000, + }, + ], + currency: "AED", + currency_exchange: { + default_currency_code: "default_currency_code", + rate: 1.1, + total: 1.1, + }, + description: "description", + discount: 500, + document_id: "DE2287", + due_date: "due_date", + entity_id: "entity_id", + file: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + name: "invoice.pdf", + region: "eu-central-1", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + size: 24381, + previews: [ + { + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + height: 400, + }, + ], + pages: [ + { + id: "id", + mimetype: "image/png", + size: 21972, + number: 0, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + }, + file_id: "file_id", + issued_at: "issued_at", + marked_as_paid_by_entity_user_id: "71e8875a-43b3-434f-b12a-54c84c176ef3", + marked_as_paid_with_comment: "Was paid partly in the end of the month.", + ocr_request_id: "ocr_request_id", + ocr_status: "processing", + other_extracted_data: { + type: "invoice", + discount_raw: 1.1, + total_paid_amount_raw: 50, + total_raw: 70, + total_excl_vat_raw: 77, + total_vat_amount_raw: 7, + total_vat_rate_raw: 12.5, + currency: "EUR", + purchase_order_number: "1234", + counterpart_name: "Monite GMbH", + counterpart_email: "counterpart_email", + counterpart_address: "counterpart_address", + counterpart_account_id: "DEUTDEFF", + document_id: "CST-13341", + payment_terms_raw: ["payment_terms_raw"], + tax_payer_id: "12345678901", + counterpart_vat_id: "DE88939004", + document_issued_at_date: "document_issued_at_date", + document_due_date: "document_due_date", + counterpart_address_object: { + city: "Berlin", + country: "DE", + line1: "Flughafenstrasse 52", + line2: "line2", + original_country_name: "Berlin", + postal_code: "10115", + state: "state", + }, + counterpart_account_number: "counterpart_account_number", + counterpart_routing_number: "counterpart_routing_number", + line_items_raw: [ + { + description: "Impact Players : How to Take the Lead , Play Bigger , and Multiply Your", + quantity: 1.2, + unit_price: 100, + unit: "meters", + vat_percentage: 12.5, + vat_amount: 15, + total_excl_vat: 120, + total_incl_vat: 135, + }, + ], + }, + paid_at: "2024-01-15T09:30:00Z", + partner_metadata: { + key: "value", + }, + payable_origin: "upload", + payment_terms: { + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + project_id: "project_id", + purchase_order_id: "purchase_order_id", + sender: "hello@example.com", + source_of_payable_data: "ocr", + status: "draft", + subtotal: 1250, + suggested_payment_term: { + date: "date", + discount: 1, + }, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + tax: 2000, + tax_amount: 250, + total_amount: 1500, + total_amount_with_credit_notes: 1, + was_created_by_user_id: "was_created_by_user_id", + }); + }); + + test("validate_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { id: "id", validation_errors: [{ key: "value" }] }; + server + .mockEndpoint() + .post("/payables/payable_id/validate") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.validateById("payable_id"); + expect(response).toEqual({ + id: "id", + validation_errors: [ + { + key: "value", + }, + ], + }); + }); +}); diff --git a/tests/wire/payables/lineItems.test.ts b/tests/wire/payables/lineItems.test.ts new file mode 100644 index 0000000..847cadc --- /dev/null +++ b/tests/wire/payables/lineItems.test.ts @@ -0,0 +1,324 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../../src/Client"; +import * as Monite from "../../../src/api/index"; + +describe("LineItems", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/payables/payable_id/line_items") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.lineItems.get("payable_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }; + server + .mockEndpoint() + .post("/payables/payable_id/line_items") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.lineItems.create("payable_id", {}); + expect(response).toEqual({ + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }); + }); + + test("replace", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { data: [{}] }; + const rawResponseBody = { + data: [ + { + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }, + ], + }; + server + .mockEndpoint() + .put("/payables/payable_id/line_items") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.lineItems.replace("payable_id", { + data: [{}], + }); + expect(response).toEqual({ + data: [ + { + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }; + server + .mockEndpoint() + .get("/payables/payable_id/line_items/line_item_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.lineItems.getById("line_item_id", "payable_id"); + expect(response).toEqual({ + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/payables/payable_id/line_items/line_item_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.payables.lineItems.deleteById("line_item_id", "payable_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }; + server + .mockEndpoint() + .patch("/payables/payable_id/line_items/line_item_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.payables.lineItems.updateById("line_item_id", "payable_id", {}); + expect(response).toEqual({ + id: "id", + accounting_tax_rate_id: "dd13735f-ef3a-4312-8c37-835d70341375", + description: "description", + ledger_account_id: "7df884fd-8be8-4eba-b6ff-417b66efe033", + name: "name", + ocr_set_quantity_to_one: false, + payable_id: "payable_id", + quantity: 1.22, + subtotal: 1250, + tax: 2000, + tax_amount: 250, + total: 1200, + unit: "meter", + unit_price: 1500, + was_created_by_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + }); + }); +}); diff --git a/tests/wire/paymentIntents.test.ts b/tests/wire/paymentIntents.test.ts new file mode 100644 index 0000000..74f5961 --- /dev/null +++ b/tests/wire/paymentIntents.test.ts @@ -0,0 +1,392 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("PaymentIntents", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + amount: 1, + application_fee_amount: 1, + batch_payment_id: "batch_payment_id", + currency: "currency", + object: { id: "id", type: "payable" }, + payer: { id: "id", type: "entity" }, + payment_link_id: "payment_link_id", + payment_methods: ["sepa_credit"], + payment_reference: "payment_reference", + provider: "provider", + recipient: { id: "id", type: "entity" }, + selected_payment_method: "sepa_credit", + status: "status", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/payment_intents").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.paymentIntents.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + amount: 1, + application_fee_amount: 1, + batch_payment_id: "batch_payment_id", + currency: "currency", + object: { + id: "id", + type: "payable", + }, + payer: { + id: "id", + type: "entity", + }, + payment_link_id: "payment_link_id", + payment_methods: ["sepa_credit"], + payment_reference: "payment_reference", + provider: "provider", + recipient: { + id: "id", + type: "entity", + }, + selected_payment_method: "sepa_credit", + status: "status", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + amount: 1, + application_fee_amount: 1, + batch_payment_id: "batch_payment_id", + currency: "currency", + invoice: { + due_date: "due_date", + file: { mimetype: "mimetype", name: "name", url: "url" }, + issue_date: "issue_date", + }, + object: { id: "id", type: "payable" }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_link_id: "payment_link_id", + payment_methods: ["sepa_credit"], + payment_reference: "payment_reference", + provider: "provider", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + selected_payment_method: "sepa_credit", + status: "status", + }; + server + .mockEndpoint() + .get("/payment_intents/payment_intent_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentIntents.getById("payment_intent_id"); + expect(response).toEqual({ + id: "id", + updated_at: "2024-01-15T09:30:00Z", + amount: 1, + application_fee_amount: 1, + batch_payment_id: "batch_payment_id", + currency: "currency", + invoice: { + due_date: "due_date", + file: { + mimetype: "mimetype", + name: "name", + url: "url", + }, + issue_date: "issue_date", + }, + object: { + id: "id", + type: "payable", + }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_link_id: "payment_link_id", + payment_methods: ["sepa_credit"], + payment_reference: "payment_reference", + provider: "provider", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + selected_payment_method: "sepa_credit", + status: "status", + }); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { amount: 1 }; + const rawResponseBody = { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + amount: 1, + application_fee_amount: 1, + batch_payment_id: "batch_payment_id", + currency: "currency", + invoice: { + due_date: "due_date", + file: { mimetype: "mimetype", name: "name", url: "url" }, + issue_date: "issue_date", + }, + object: { id: "id", type: "payable" }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_link_id: "payment_link_id", + payment_methods: ["sepa_credit"], + payment_reference: "payment_reference", + provider: "provider", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + selected_payment_method: "sepa_credit", + status: "status", + }; + server + .mockEndpoint() + .patch("/payment_intents/payment_intent_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentIntents.updateById("payment_intent_id", { + amount: 1, + }); + expect(response).toEqual({ + id: "id", + updated_at: "2024-01-15T09:30:00Z", + amount: 1, + application_fee_amount: 1, + batch_payment_id: "batch_payment_id", + currency: "currency", + invoice: { + due_date: "due_date", + file: { + mimetype: "mimetype", + name: "name", + url: "url", + }, + issue_date: "issue_date", + }, + object: { + id: "id", + type: "payable", + }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_link_id: "payment_link_id", + payment_methods: ["sepa_credit"], + payment_reference: "payment_reference", + provider: "provider", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + selected_payment_method: "sepa_credit", + status: "status", + }); + }); + + test("get_history_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + status: "status", + }, + ], + }; + server + .mockEndpoint() + .get("/payment_intents/payment_intent_id/history") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentIntents.getHistoryById("payment_intent_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + status: "status", + }, + ], + }); + }); +}); diff --git a/tests/wire/paymentLinks.test.ts b/tests/wire/paymentLinks.test.ts new file mode 100644 index 0000000..4f3285e --- /dev/null +++ b/tests/wire/paymentLinks.test.ts @@ -0,0 +1,456 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("PaymentLinks", () => { + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { payment_methods: ["sepa_credit"], recipient: { id: "id", type: "entity" } }; + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + expires_at: "2024-01-15T09:30:00Z", + invoice: { + due_date: "due_date", + file: { mimetype: "mimetype", name: "name", url: "url" }, + issue_date: "issue_date", + }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_intent: { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + application_fee_amount: 1, + object: { id: "id", type: "payable" }, + provider: "provider", + selected_payment_method: "selected_payment_method", + status: "status", + }, + payment_intent_id: "payment_intent_id", + payment_methods: ["payment_methods"], + payment_page_url: "payment_page_url", + payment_reference: "payment_reference", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + return_url: "https://pay.example.com/complete", + status: "status", + }; + server + .mockEndpoint() + .post("/payment_links") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentLinks.create({ + payment_methods: ["sepa_credit"], + recipient: { + id: "id", + type: "entity", + }, + }); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + expires_at: "2024-01-15T09:30:00Z", + invoice: { + due_date: "due_date", + file: { + mimetype: "mimetype", + name: "name", + url: "url", + }, + issue_date: "issue_date", + }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_intent: { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + application_fee_amount: 1, + object: { + id: "id", + type: "payable", + }, + provider: "provider", + selected_payment_method: "selected_payment_method", + status: "status", + }, + payment_intent_id: "payment_intent_id", + payment_methods: ["payment_methods"], + payment_page_url: "payment_page_url", + payment_reference: "payment_reference", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + return_url: "https://pay.example.com/complete", + status: "status", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + expires_at: "2024-01-15T09:30:00Z", + invoice: { + due_date: "due_date", + file: { mimetype: "mimetype", name: "name", url: "url" }, + issue_date: "issue_date", + }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_intent: { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + application_fee_amount: 1, + object: { id: "id", type: "payable" }, + provider: "provider", + selected_payment_method: "selected_payment_method", + status: "status", + }, + payment_intent_id: "payment_intent_id", + payment_methods: ["payment_methods"], + payment_page_url: "payment_page_url", + payment_reference: "payment_reference", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + return_url: "https://pay.example.com/complete", + status: "status", + }; + server + .mockEndpoint() + .get("/payment_links/payment_link_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentLinks.getById("payment_link_id"); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + expires_at: "2024-01-15T09:30:00Z", + invoice: { + due_date: "due_date", + file: { + mimetype: "mimetype", + name: "name", + url: "url", + }, + issue_date: "issue_date", + }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_intent: { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + application_fee_amount: 1, + object: { + id: "id", + type: "payable", + }, + provider: "provider", + selected_payment_method: "selected_payment_method", + status: "status", + }, + payment_intent_id: "payment_intent_id", + payment_methods: ["payment_methods"], + payment_page_url: "payment_page_url", + payment_reference: "payment_reference", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + return_url: "https://pay.example.com/complete", + status: "status", + }); + }); + + test("expire_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + expires_at: "2024-01-15T09:30:00Z", + invoice: { + due_date: "due_date", + file: { mimetype: "mimetype", name: "name", url: "url" }, + issue_date: "issue_date", + }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_intent: { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + application_fee_amount: 1, + object: { id: "id", type: "payable" }, + provider: "provider", + selected_payment_method: "selected_payment_method", + status: "status", + }, + payment_intent_id: "payment_intent_id", + payment_methods: ["payment_methods"], + payment_page_url: "payment_page_url", + payment_reference: "payment_reference", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + return_url: "https://pay.example.com/complete", + status: "status", + }; + server + .mockEndpoint() + .post("/payment_links/payment_link_id/expire") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentLinks.expireById("payment_link_id"); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + expires_at: "2024-01-15T09:30:00Z", + invoice: { + due_date: "due_date", + file: { + mimetype: "mimetype", + name: "name", + url: "url", + }, + issue_date: "issue_date", + }, + payer: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + payment_intent: { + id: "id", + updated_at: "2024-01-15T09:30:00Z", + application_fee_amount: 1, + object: { + id: "id", + type: "payable", + }, + provider: "provider", + selected_payment_method: "selected_payment_method", + status: "status", + }, + payment_intent_id: "payment_intent_id", + payment_methods: ["payment_methods"], + payment_page_url: "payment_page_url", + payment_reference: "payment_reference", + recipient: { + id: "id", + bank_accounts: [ + { + id: "id", + account_holder_name: "Bob Jones", + account_number: "12345678", + bic: "DEUTDEFFXXX", + display_name: "Primary account", + iban: "DE74500700100100000900", + name: "Primary account", + sort_code: "123456", + }, + ], + name: "name", + type: "entity", + }, + return_url: "https://pay.example.com/complete", + status: "status", + }); + }); +}); diff --git a/tests/wire/paymentRecords.test.ts b/tests/wire/paymentRecords.test.ts new file mode 100644 index 0000000..c549a61 --- /dev/null +++ b/tests/wire/paymentRecords.test.ts @@ -0,0 +1,475 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; +import * as Monite from "../../src/api/index"; + +describe("PaymentRecords", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [{ status: "created", timestamp: "2024-01-15T09:30:00Z" }], + is_external: true, + object: { id: "id", new_status: "new_status", old_status: "old_status", type: "receivable" }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/payment_records").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.paymentRecords.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [ + { + status: "created", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + is_external: true, + object: { + id: "id", + new_status: "new_status", + old_status: "old_status", + type: "receivable", + }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + amount: 1, + currency: "AED", + object: { id: "id", type: "receivable" }, + payment_intent_id: "payment_intent_id", + }; + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [{ entity_user_id: "entity_user_id", status: "created", timestamp: "2024-01-15T09:30:00Z" }], + is_external: true, + object: { id: "id", new_status: "new_status", old_status: "old_status", type: "receivable" }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }; + server + .mockEndpoint() + .post("/payment_records") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentRecords.create({ + amount: 1, + currency: "AED", + object: { + id: "id", + type: "receivable", + }, + payment_intent_id: "payment_intent_id", + }); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [ + { + entity_user_id: "entity_user_id", + status: "created", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + is_external: true, + object: { + id: "id", + new_status: "new_status", + old_status: "old_status", + type: "receivable", + }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [{ entity_user_id: "entity_user_id", status: "created", timestamp: "2024-01-15T09:30:00Z" }], + is_external: true, + object: { id: "id", new_status: "new_status", old_status: "old_status", type: "receivable" }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }; + server + .mockEndpoint() + .get("/payment_records/payment_record_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentRecords.getById("payment_record_id"); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [ + { + entity_user_id: "entity_user_id", + status: "created", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + is_external: true, + object: { + id: "id", + new_status: "new_status", + old_status: "old_status", + type: "receivable", + }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }); + }); + + test("patch_payment_records_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [{ entity_user_id: "entity_user_id", status: "created", timestamp: "2024-01-15T09:30:00Z" }], + is_external: true, + object: { id: "id", new_status: "new_status", old_status: "old_status", type: "receivable" }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }; + server + .mockEndpoint() + .patch("/payment_records/payment_record_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentRecords.patchPaymentRecordsId("payment_record_id"); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [ + { + entity_user_id: "entity_user_id", + status: "created", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + is_external: true, + object: { + id: "id", + new_status: "new_status", + old_status: "old_status", + type: "receivable", + }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }); + }); + + test("post_payment_records_id_cancel", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [{ entity_user_id: "entity_user_id", status: "created", timestamp: "2024-01-15T09:30:00Z" }], + is_external: true, + object: { id: "id", new_status: "new_status", old_status: "old_status", type: "receivable" }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }; + server + .mockEndpoint() + .post("/payment_records/payment_record_id/cancel") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentRecords.postPaymentRecordsIdCancel("payment_record_id", {}); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [ + { + entity_user_id: "entity_user_id", + status: "created", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + is_external: true, + object: { + id: "id", + new_status: "new_status", + old_status: "old_status", + type: "receivable", + }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }); + }); + + test("post_payment_records_id_mark_as_succeeded", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { paid_at: "2024-01-15T09:30:00Z" }; + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [{ entity_user_id: "entity_user_id", status: "created", timestamp: "2024-01-15T09:30:00Z" }], + is_external: true, + object: { id: "id", new_status: "new_status", old_status: "old_status", type: "receivable" }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }; + server + .mockEndpoint() + .post("/payment_records/payment_record_id/mark_as_succeeded") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentRecords.postPaymentRecordsIdMarkAsSucceeded("payment_record_id", { + paid_at: "2024-01-15T09:30:00Z", + }); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [ + { + entity_user_id: "entity_user_id", + status: "created", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + is_external: true, + object: { + id: "id", + new_status: "new_status", + old_status: "old_status", + type: "receivable", + }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }); + }); + + test("post_payment_records_id_start_processing", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [{ entity_user_id: "entity_user_id", status: "created", timestamp: "2024-01-15T09:30:00Z" }], + is_external: true, + object: { id: "id", new_status: "new_status", old_status: "old_status", type: "receivable" }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }; + server + .mockEndpoint() + .post("/payment_records/payment_record_id/start_processing") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentRecords.postPaymentRecordsIdStartProcessing("payment_record_id", {}); + expect(response).toEqual({ + id: "id", + amount: 1, + currency: "AED", + entity_user_id: "entity_user_id", + history: [ + { + entity_user_id: "entity_user_id", + status: "created", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + is_external: true, + object: { + id: "id", + new_status: "new_status", + old_status: "old_status", + type: "receivable", + }, + overpaid_amount: 1, + paid_at: "2024-01-15T09:30:00Z", + payment_intent_id: "payment_intent_id", + payment_intent_status: "payment_intent_status", + payment_method: "payment_method", + planned_payment_date: "planned_payment_date", + status: "status", + }); + }); +}); diff --git a/tests/wire/paymentReminders.test.ts b/tests/wire/paymentReminders.test.ts new file mode 100644 index 0000000..75b887a --- /dev/null +++ b/tests/wire/paymentReminders.test.ts @@ -0,0 +1,263 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("PaymentReminders", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + name: "name", + status: "active", + term_1_reminder: { body: "body", days_before: 1, subject: "subject" }, + term_2_reminder: { body: "body", days_before: 1, subject: "subject" }, + term_final_reminder: { body: "body", days_before: 1, subject: "subject" }, + }, + ], + }; + server.mockEndpoint().get("/payment_reminders").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.paymentReminders.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + name: "name", + status: "active", + term_1_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + term_2_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + term_final_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + name: "name", + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + status: "active", + term_1_reminder: { body: "body", days_before: 1, subject: "subject" }, + term_2_reminder: { body: "body", days_before: 1, subject: "subject" }, + term_final_reminder: { body: "body", days_before: 1, subject: "subject" }, + }; + server + .mockEndpoint() + .post("/payment_reminders") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentReminders.create({ + name: "name", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + name: "name", + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + status: "active", + term_1_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + term_2_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + term_final_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + name: "name", + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + status: "active", + term_1_reminder: { body: "body", days_before: 1, subject: "subject" }, + term_2_reminder: { body: "body", days_before: 1, subject: "subject" }, + term_final_reminder: { body: "body", days_before: 1, subject: "subject" }, + }; + server + .mockEndpoint() + .get("/payment_reminders/payment_reminder_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentReminders.getById("payment_reminder_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + name: "name", + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + status: "active", + term_1_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + term_2_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + term_final_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/payment_reminders/payment_reminder_id").respondWith().statusCode(200).build(); + + const response = await client.paymentReminders.deleteById("payment_reminder_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + name: "name", + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + status: "active", + term_1_reminder: { body: "body", days_before: 1, subject: "subject" }, + term_2_reminder: { body: "body", days_before: 1, subject: "subject" }, + term_final_reminder: { body: "body", days_before: 1, subject: "subject" }, + }; + server + .mockEndpoint() + .patch("/payment_reminders/payment_reminder_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentReminders.updateById("payment_reminder_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + entity_id: "entity_id", + name: "name", + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + status: "active", + term_1_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + term_2_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + term_final_reminder: { + body: "body", + days_before: 1, + subject: "subject", + }, + }); + }); +}); diff --git a/tests/wire/paymentTerms.test.ts b/tests/wire/paymentTerms.test.ts new file mode 100644 index 0000000..2233c0d --- /dev/null +++ b/tests/wire/paymentTerms.test.ts @@ -0,0 +1,208 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("PaymentTerms", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }, + ], + }; + server.mockEndpoint().get("/payment_terms").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.paymentTerms.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name", term_final: { number_of_days: 1 } }; + const rawResponseBody = { + id: "id", + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }; + server + .mockEndpoint() + .post("/payment_terms") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentTerms.create({ + name: "name", + term_final: { + number_of_days: 1, + }, + }); + expect(response).toEqual({ + id: "id", + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }; + server + .mockEndpoint() + .get("/payment_terms/payment_terms_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentTerms.getById("payment_terms_id"); + expect(response).toEqual({ + id: "id", + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/payment_terms/payment_terms_id").respondWith().statusCode(200).build(); + + const response = await client.paymentTerms.deleteById("payment_terms_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + description: "description", + name: "name", + term_1: { discount: 1, number_of_days: 1 }, + term_2: { discount: 1, number_of_days: 1 }, + term_final: { number_of_days: 1 }, + }; + server + .mockEndpoint() + .patch("/payment_terms/payment_terms_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.paymentTerms.updateById("payment_terms_id"); + expect(response).toEqual({ + id: "id", + description: "description", + name: "name", + term_1: { + discount: 1, + number_of_days: 1, + }, + term_2: { + discount: 1, + number_of_days: 1, + }, + term_final: { + number_of_days: 1, + }, + }); + }); +}); diff --git a/tests/wire/pdfTemplates.test.ts b/tests/wire/pdfTemplates.test.ts new file mode 100644 index 0000000..8f24730 --- /dev/null +++ b/tests/wire/pdfTemplates.test.ts @@ -0,0 +1,312 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("PdfTemplates", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + blocks: ["blocks"], + document_type: "receivable", + is_default: true, + language: "language", + name: "name", + preview: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + template: "template", + template_type: "block", + }, + ], + }; + server + .mockEndpoint() + .get("/document_templates") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.pdfTemplates.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + blocks: ["blocks"], + document_type: "receivable", + is_default: true, + language: "language", + name: "name", + preview: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + template: "template", + template_type: "block", + }, + ], + }); + }); + + test("get_system", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + blocks: ["blocks"], + document_type: "receivable", + is_default: true, + language: "language", + name: "name", + preview: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + template: "template", + template_type: "block", + }, + ], + }; + server + .mockEndpoint() + .get("/document_templates/system") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.pdfTemplates.getSystem(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + blocks: ["blocks"], + document_type: "receivable", + is_default: true, + language: "language", + name: "name", + preview: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + template: "template", + template_type: "block", + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + blocks: ["blocks"], + document_type: "receivable", + is_default: true, + language: "language", + name: "name", + preview: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + template: "template", + template_type: "block", + }; + server + .mockEndpoint() + .get("/document_templates/document_template_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.pdfTemplates.getById("document_template_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + blocks: ["blocks"], + document_type: "receivable", + is_default: true, + language: "language", + name: "name", + preview: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + template: "template", + template_type: "block", + }); + }); + + test("make_default_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + blocks: ["blocks"], + document_type: "receivable", + is_default: true, + language: "language", + name: "name", + preview: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + template: "template", + template_type: "block", + }; + server + .mockEndpoint() + .post("/document_templates/document_template_id/make_default") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.pdfTemplates.makeDefaultById("document_template_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + blocks: ["blocks"], + document_type: "receivable", + is_default: true, + language: "language", + name: "name", + preview: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + file_type: "file_type", + md5: "md5", + mimetype: "mimetype", + name: "name", + region: "region", + s3_bucket: "s3_bucket", + s3_file_path: "s3_file_path", + size: 1, + url: "url", + }, + template: "template", + template_type: "block", + }); + }); +}); diff --git a/tests/wire/products.test.ts b/tests/wire/products.test.ts new file mode 100644 index 0000000..7128147 --- /dev/null +++ b/tests/wire/products.test.ts @@ -0,0 +1,245 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Products", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + entity_id: "entity_id", + entity_user_id: "entity_user_id", + external_reference: "HT-1234-S-BL", + ledger_account_id: "ledger_account_id", + measure_unit_id: "measure_unit_id", + name: "name", + price: { currency: "AED", value: 1 }, + smallest_amount: 1.1, + type: "product", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/products").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.products.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + entity_id: "entity_id", + entity_user_id: "entity_user_id", + external_reference: "HT-1234-S-BL", + ledger_account_id: "ledger_account_id", + measure_unit_id: "measure_unit_id", + name: "name", + price: { + currency: "AED", + value: 1, + }, + smallest_amount: 1.1, + type: "product", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + entity_id: "entity_id", + entity_user_id: "entity_user_id", + external_reference: "HT-1234-S-BL", + ledger_account_id: "ledger_account_id", + measure_unit_id: "measure_unit_id", + name: "name", + price: { currency: "AED", value: 1 }, + smallest_amount: 1.1, + type: "product", + }; + server + .mockEndpoint() + .post("/products") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.products.create({ + name: "name", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + entity_id: "entity_id", + entity_user_id: "entity_user_id", + external_reference: "HT-1234-S-BL", + ledger_account_id: "ledger_account_id", + measure_unit_id: "measure_unit_id", + name: "name", + price: { + currency: "AED", + value: 1, + }, + smallest_amount: 1.1, + type: "product", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + entity_id: "entity_id", + entity_user_id: "entity_user_id", + external_reference: "HT-1234-S-BL", + ledger_account_id: "ledger_account_id", + measure_unit_id: "measure_unit_id", + name: "name", + price: { currency: "AED", value: 1 }, + smallest_amount: 1.1, + type: "product", + }; + server + .mockEndpoint() + .get("/products/product_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.products.getById("product_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + entity_id: "entity_id", + entity_user_id: "entity_user_id", + external_reference: "HT-1234-S-BL", + ledger_account_id: "ledger_account_id", + measure_unit_id: "measure_unit_id", + name: "name", + price: { + currency: "AED", + value: 1, + }, + smallest_amount: 1.1, + type: "product", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/products/product_id").respondWith().statusCode(200).build(); + + const response = await client.products.deleteById("product_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + entity_id: "entity_id", + entity_user_id: "entity_user_id", + external_reference: "HT-1234-S-BL", + ledger_account_id: "ledger_account_id", + measure_unit_id: "measure_unit_id", + name: "name", + price: { currency: "AED", value: 1 }, + smallest_amount: 1.1, + type: "product", + }; + server + .mockEndpoint() + .patch("/products/product_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.products.updateById("product_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + description: "description", + entity_id: "entity_id", + entity_user_id: "entity_user_id", + external_reference: "HT-1234-S-BL", + ledger_account_id: "ledger_account_id", + measure_unit_id: "measure_unit_id", + name: "name", + price: { + currency: "AED", + value: 1, + }, + smallest_amount: 1.1, + type: "product", + }); + }); +}); diff --git a/tests/wire/projects.test.ts b/tests/wire/projects.test.ts new file mode 100644 index 0000000..cc8d504 --- /dev/null +++ b/tests/wire/projects.test.ts @@ -0,0 +1,327 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Projects", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + code: "code", + color: "color", + created_by_entity_user_id: "created_by_entity_user_id", + description: "description", + end_date: "end_date", + entity_id: "entity_id", + name: "Marketing", + parent_id: "parent_id", + partner_metadata: { key: "value" }, + start_date: "start_date", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/projects").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.projects.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + code: "code", + color: "color", + created_by_entity_user_id: "created_by_entity_user_id", + description: "description", + end_date: "end_date", + entity_id: "entity_id", + name: "Marketing", + parent_id: "parent_id", + partner_metadata: { + key: "value", + }, + start_date: "start_date", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "Marketing" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + code: "code", + color: "color", + created_by_entity_user_id: "created_by_entity_user_id", + description: "description", + end_date: "end_date", + entity_id: "entity_id", + name: "Marketing", + parent_id: "parent_id", + partner_metadata: { key: "value" }, + start_date: "start_date", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }; + server + .mockEndpoint() + .post("/projects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.projects.create({ + name: "Marketing", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + code: "code", + color: "color", + created_by_entity_user_id: "created_by_entity_user_id", + description: "description", + end_date: "end_date", + entity_id: "entity_id", + name: "Marketing", + parent_id: "parent_id", + partner_metadata: { + key: "value", + }, + start_date: "start_date", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + code: "code", + color: "color", + created_by_entity_user_id: "created_by_entity_user_id", + description: "description", + end_date: "end_date", + entity_id: "entity_id", + name: "Marketing", + parent_id: "parent_id", + partner_metadata: { key: "value" }, + start_date: "start_date", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }; + server + .mockEndpoint() + .get("/projects/project_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.projects.getById("project_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + code: "code", + color: "color", + created_by_entity_user_id: "created_by_entity_user_id", + description: "description", + end_date: "end_date", + entity_id: "entity_id", + name: "Marketing", + parent_id: "parent_id", + partner_metadata: { + key: "value", + }, + start_date: "start_date", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/projects/project_id").respondWith().statusCode(200).build(); + + const response = await client.projects.deleteById("project_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + code: "code", + color: "color", + created_by_entity_user_id: "created_by_entity_user_id", + description: "description", + end_date: "end_date", + entity_id: "entity_id", + name: "Marketing", + parent_id: "parent_id", + partner_metadata: { key: "value" }, + start_date: "start_date", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }; + server + .mockEndpoint() + .patch("/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.projects.updateById("project_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + code: "code", + color: "color", + created_by_entity_user_id: "created_by_entity_user_id", + description: "description", + end_date: "end_date", + entity_id: "entity_id", + name: "Marketing", + parent_id: "parent_id", + partner_metadata: { + key: "value", + }, + start_date: "start_date", + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + }); + }); +}); diff --git a/tests/wire/purchaseOrders.test.ts b/tests/wire/purchaseOrders.test.ts new file mode 100644 index 0000000..53b7e20 --- /dev/null +++ b/tests/wire/purchaseOrders.test.ts @@ -0,0 +1,1064 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("PurchaseOrders", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + counterpart: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + title: "Mr.", + }, + type: "individual", + }, + counterpart_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_id: "counterpart_id", + created_by_user_id: "created_by_user_id", + currency: "AED", + document_id: "document_id", + entity: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { city: "city", line1: "line1", postal_code: "postal_code" }, + individual: { first_name: "first_name", last_name: "last_name" }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + status: "active", + }, + entity_id: "entity_id", + entity_vat_id: { + id: "id", + country: "country", + entity_id: "entity_id", + type: "type", + value: "value", + }, + file_id: "file_id", + file_url: "file_url", + issued_at: "issued_at", + items: [{ currency: "AED", name: "name", price: 1, quantity: 1, unit: "unit", vat_rate: 1 }], + message: "message", + project_id: "project_id", + status: "status", + valid_for_days: 1, + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/payable_purchase_orders") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.purchaseOrders.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + counterpart: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + title: "Mr.", + }, + type: "individual", + }, + counterpart_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_id: "counterpart_id", + created_by_user_id: "created_by_user_id", + currency: "AED", + document_id: "document_id", + entity: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + line1: "line1", + postal_code: "postal_code", + }, + individual: { + first_name: "first_name", + last_name: "last_name", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + status: "active", + }, + entity_id: "entity_id", + entity_vat_id: { + id: "id", + country: "country", + entity_id: "entity_id", + type: "type", + value: "value", + }, + file_id: "file_id", + file_url: "file_url", + issued_at: "issued_at", + items: [ + { + currency: "AED", + name: "name", + price: 1, + quantity: 1, + unit: "unit", + vat_rate: 1, + }, + ], + message: "message", + project_id: "project_id", + status: "status", + valid_for_days: 1, + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + 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, + }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + counterpart: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }, + counterpart_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_id: "counterpart_id", + created_by_user_id: "created_by_user_id", + currency: "AED", + document_id: "document_id", + entity: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + status: "active", + tax_id: "tax_id", + website: "website", + }, + entity_id: "entity_id", + entity_vat_id: { id: "id", country: "country", entity_id: "entity_id", type: "type", value: "value" }, + file_id: "file_id", + file_url: "file_url", + issued_at: "issued_at", + items: [{ currency: "AED", name: "name", price: 1, quantity: 1, unit: "unit", vat_rate: 1 }], + message: "message", + project_id: "project_id", + status: "status", + valid_for_days: 1, + }; + server + .mockEndpoint() + .post("/payable_purchase_orders") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = 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, + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + counterpart: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }, + counterpart_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_id: "counterpart_id", + created_by_user_id: "created_by_user_id", + currency: "AED", + document_id: "document_id", + entity: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + status: "active", + tax_id: "tax_id", + website: "website", + }, + entity_id: "entity_id", + entity_vat_id: { + id: "id", + country: "country", + entity_id: "entity_id", + type: "type", + value: "value", + }, + file_id: "file_id", + file_url: "file_url", + issued_at: "issued_at", + items: [ + { + currency: "AED", + name: "name", + price: 1, + quantity: 1, + unit: "unit", + vat_rate: 1, + }, + ], + message: "message", + project_id: "project_id", + status: "status", + valid_for_days: 1, + }); + }); + + test("get_variables", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + object_subtype: "receivable", + object_type: "object_type", + variables: [{ description: "description", name: "name" }], + }, + ], + }; + server + .mockEndpoint() + .get("/payable_purchase_orders/variables") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.purchaseOrders.getVariables(); + expect(response).toEqual({ + data: [ + { + object_subtype: "receivable", + object_type: "object_type", + variables: [ + { + description: "description", + name: "name", + }, + ], + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + counterpart: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }, + counterpart_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_id: "counterpart_id", + created_by_user_id: "created_by_user_id", + currency: "AED", + document_id: "document_id", + entity: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + status: "active", + tax_id: "tax_id", + website: "website", + }, + entity_id: "entity_id", + entity_vat_id: { id: "id", country: "country", entity_id: "entity_id", type: "type", value: "value" }, + file_id: "file_id", + file_url: "file_url", + issued_at: "issued_at", + items: [{ currency: "AED", name: "name", price: 1, quantity: 1, unit: "unit", vat_rate: 1 }], + message: "message", + project_id: "project_id", + status: "status", + valid_for_days: 1, + }; + server + .mockEndpoint() + .get("/payable_purchase_orders/purchase_order_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.purchaseOrders.getById("purchase_order_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + counterpart: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }, + counterpart_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_id: "counterpart_id", + created_by_user_id: "created_by_user_id", + currency: "AED", + document_id: "document_id", + entity: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + status: "active", + tax_id: "tax_id", + website: "website", + }, + entity_id: "entity_id", + entity_vat_id: { + id: "id", + country: "country", + entity_id: "entity_id", + type: "type", + value: "value", + }, + file_id: "file_id", + file_url: "file_url", + issued_at: "issued_at", + items: [ + { + currency: "AED", + name: "name", + price: 1, + quantity: 1, + unit: "unit", + vat_rate: 1, + }, + ], + message: "message", + project_id: "project_id", + status: "status", + valid_for_days: 1, + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/payable_purchase_orders/purchase_order_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.purchaseOrders.deleteById("purchase_order_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + counterpart: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }, + counterpart_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_id: "counterpart_id", + created_by_user_id: "created_by_user_id", + currency: "AED", + document_id: "document_id", + entity: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [{ height: 400, url: "https://bucketname.s3.amazonaws.com/1/2/3.png", width: 200 }], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + status: "active", + tax_id: "tax_id", + website: "website", + }, + entity_id: "entity_id", + entity_vat_id: { id: "id", country: "country", entity_id: "entity_id", type: "type", value: "value" }, + file_id: "file_id", + file_url: "file_url", + issued_at: "issued_at", + items: [{ currency: "AED", name: "name", price: 1, quantity: 1, unit: "unit", vat_rate: 1 }], + message: "message", + project_id: "project_id", + status: "status", + valid_for_days: 1, + }; + server + .mockEndpoint() + .patch("/payable_purchase_orders/purchase_order_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.purchaseOrders.updateById("purchase_order_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + counterpart: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + created_automatically: true, + default_billing_address_id: "default_billing_address_id", + default_shipping_address_id: "default_shipping_address_id", + created_by_entity_user_id: "created_by_entity_user_id", + individual: { + email: "asingh@example.net", + first_name: "Adnan", + is_customer: true, + is_vendor: true, + last_name: "Singh", + phone: "5553211234", + title: "Mr.", + }, + language: "ab", + reminders_enabled: true, + tax_id: "tax_id", + type: "individual", + }, + counterpart_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_address_id: "counterpart_address_id", + counterpart_id: "counterpart_id", + created_by_user_id: "created_by_user_id", + currency: "AED", + document_id: "document_id", + entity: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + email: "email", + individual: { + date_of_birth: "date_of_birth", + first_name: "first_name", + id_number: "id_number", + last_name: "last_name", + ssn_last_4: "ssn_last_4", + title: "title", + }, + logo: { + id: "id", + created_at: "2024-01-15T09:30:00Z", + file_type: "payables", + md5: "31d1a2dd1ad3dfc39be849d70a68dac0", + mimetype: "application/pdf", + name: "invoice.pdf", + pages: [ + { + id: "id", + mimetype: "image/png", + number: 0, + size: 21972, + url: "https://bucket.s3.amazonaws.com/123/456.png", + }, + ], + previews: [ + { + height: 400, + url: "https://bucketname.s3.amazonaws.com/1/2/3.png", + width: 200, + }, + ], + region: "eu-central-1", + size: 24381, + url: "https://bucketname.s3.amazonaws.com/12345/67890.pdf", + }, + phone: "phone", + status: "active", + tax_id: "tax_id", + website: "website", + }, + entity_id: "entity_id", + entity_vat_id: { + id: "id", + country: "country", + entity_id: "entity_id", + type: "type", + value: "value", + }, + file_id: "file_id", + file_url: "file_url", + issued_at: "issued_at", + items: [ + { + currency: "AED", + name: "name", + price: 1, + quantity: 1, + unit: "unit", + vat_rate: 1, + }, + ], + message: "message", + project_id: "project_id", + status: "status", + valid_for_days: 1, + }); + }); + + test("preview_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { body_text: "body_text", subject_text: "subject_text" }; + const rawResponseBody = { body_preview: "body_preview", subject_preview: "subject_preview" }; + server + .mockEndpoint() + .post("/payable_purchase_orders/purchase_order_id/preview") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.purchaseOrders.previewById("purchase_order_id", { + body_text: "body_text", + subject_text: "subject_text", + }); + expect(response).toEqual({ + body_preview: "body_preview", + subject_preview: "subject_preview", + }); + }); + + test("send_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { body_text: "body_text", subject_text: "subject_text" }; + const rawResponseBody = { mail_id: "mail_id" }; + server + .mockEndpoint() + .post("/payable_purchase_orders/purchase_order_id/send") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.purchaseOrders.sendById("purchase_order_id", { + body_text: "body_text", + subject_text: "subject_text", + }); + expect(response).toEqual({ + mail_id: "mail_id", + }); + }); +}); diff --git a/tests/wire/receivables.test.ts b/tests/wire/receivables.test.ts new file mode 100644 index 0000000..39fe758 --- /dev/null +++ b/tests/wire/receivables.test.ts @@ -0,0 +1,4146 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Receivables", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { city: "Berlin", country: "AF", line1: "Flughafenstrasse 52", postal_code: "10115" }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { id: "id", counterpart_id: "counterpart_id", value: "123456789" }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount" }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { name: "name", type: "organization" }, + entity_address: { city: "city", line1: "line1", postal_code: "postal_code" }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [{ amount: 1, taxable_amount: 1, value: 1 }], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/receivables").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.receivables.get(); + expect(response).toEqual({ + data: [ + { + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + name: "name", + }, + entity_address: { + city: "city", + line1: "line1", + postal_code: "postal_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + amount: 1, + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { + counterpart_billing_address_id: "counterpart_billing_address_id", + counterpart_id: "counterpart_id", + currency: "AED", + line_items: [{ quantity: 1.1 }], + type: "quote", + }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount", value: 1 }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [{ name: "name", value: 1.1, amount: 1 }], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }; + server + .mockEndpoint() + .post("/receivables") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = 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", + }); + expect(response).toEqual({ + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + value: 1, + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [ + { + name: "name", + value: 1.1, + amount: 1, + }, + ], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }); + }); + + test("get_receivables_required_fields", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + counterpart: { + tax_id: { + description: + "The counterpart's taxpayer identification number or tax ID. For identification purposes, this field may be required for counterparts that are not VAT-registered.", + required: false, + }, + vat_id: { + description: + "The counterpart's VAT (Value Added Tax) identification number. This field is required for counterparts that are VAT-registered.", + required: true, + }, + }, + entity: { + tax_id: { + description: + "The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered.", + required: false, + }, + vat_id: { + description: + "The entity's VAT (Value Added Tax) identification number. This field is required for entities that are VAT-registered.", + required: true, + }, + }, + line_item: { + measure_unit: { + description: "Unit used to measure the quantity of the product (e.g. items, meters, kilograms)", + required: true, + }, + tax_rate_value: { + description: + "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.", + required: false, + }, + vat_rate_id: { + description: + "Unique identifier of the vat rate object. This field is required for all entities in supported countries except the US and Pakistan.", + required: true, + }, + }, + }; + server + .mockEndpoint() + .get("/receivables/required_fields") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.getReceivablesRequiredFields(); + expect(response).toEqual({ + counterpart: { + tax_id: { + description: + "The counterpart's taxpayer identification number or tax ID. For identification purposes, this field may be required for counterparts that are not VAT-registered.", + required: false, + }, + vat_id: { + description: + "The counterpart's VAT (Value Added Tax) identification number. This field is required for counterparts that are VAT-registered.", + required: true, + }, + }, + entity: { + tax_id: { + description: + "The entity's taxpayer identification number or tax ID. This field is required for entities that are non-VAT registered.", + required: false, + }, + vat_id: { + description: + "The entity's VAT (Value Added Tax) identification number. This field is required for entities that are VAT-registered.", + required: true, + }, + }, + line_item: { + measure_unit: { + description: "Unit used to measure the quantity of the product (e.g. items, meters, kilograms)", + required: true, + }, + tax_rate_value: { + description: + "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.", + required: false, + }, + vat_rate_id: { + description: + "Unique identifier of the vat rate object. This field is required for all entities in supported countries except the US and Pakistan.", + required: true, + }, + }, + }); + }); + + test("post_receivables_search", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { city: "Berlin", country: "AF", line1: "Flughafenstrasse 52", postal_code: "10115" }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { id: "id", counterpart_id: "counterpart_id", value: "123456789" }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount" }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { name: "name", type: "organization" }, + entity_address: { city: "city", line1: "line1", postal_code: "postal_code" }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [{ amount: 1, taxable_amount: 1, value: 1 }], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .post("/receivables/search") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.postReceivablesSearch(); + expect(response).toEqual({ + data: [ + { + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + postal_code: "10115", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + name: "name", + }, + entity_address: { + city: "city", + line1: "line1", + postal_code: "postal_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + amount: 1, + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("get_variables", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + object_subtype: "quote", + object_type: "object_type", + variables: [{ description: "description", name: "name" }], + }, + ], + }; + server + .mockEndpoint() + .get("/receivables/variables") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.getVariables(); + expect(response).toEqual({ + data: [ + { + object_subtype: "quote", + object_type: "object_type", + variables: [ + { + description: "description", + name: "name", + }, + ], + }, + ], + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount", value: 1 }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [{ name: "name", value: 1.1, amount: 1 }], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }; + server + .mockEndpoint() + .get("/receivables/receivable_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.getById("receivable_id"); + expect(response).toEqual({ + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + value: 1, + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [ + { + name: "name", + value: 1.1, + amount: 1, + }, + ], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/receivables/receivable_id").respondWith().statusCode(200).build(); + + const response = await client.receivables.deleteById("receivable_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { quote: {} }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount", value: 1 }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [{ name: "name", value: 1.1, amount: 1 }], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }; + server + .mockEndpoint() + .patch("/receivables/receivable_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.updateById("receivable_id", { + quote: {}, + }); + expect(response).toEqual({ + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + value: 1, + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [ + { + name: "name", + value: 1.1, + amount: 1, + }, + ], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }); + }); + + test("accept_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { success: true }; + server + .mockEndpoint() + .post("/receivables/receivable_id/accept") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.acceptById("receivable_id"); + expect(response).toEqual({ + success: true, + }); + }); + + test("cancel_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().post("/receivables/receivable_id/cancel").respondWith().statusCode(200).build(); + + const response = await client.receivables.cancelById("receivable_id"); + expect(response).toEqual(undefined); + }); + + test("clone_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount", value: 1 }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [{ name: "name", value: 1.1, amount: 1 }], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }; + server + .mockEndpoint() + .post("/receivables/receivable_id/clone") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.cloneById("receivable_id"); + expect(response).toEqual({ + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + value: 1, + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [ + { + name: "name", + value: 1.1, + amount: 1, + }, + ], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }); + }); + + test("decline_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { success: true }; + server + .mockEndpoint() + .post("/receivables/receivable_id/decline") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.declineById("receivable_id"); + expect(response).toEqual({ + success: true, + }); + }); + + test("get_history", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "cd58435b-1c79-4b17-9f79-f898c93e5f97", + current_pdf_url: "https://monite-file-saver.example.com/12345/67890.pdf", + entity_user_id: "d5a577b0-01c0-4566-ac5c-44f41935e8c4", + event_data: { new_status: "draft", old_status: "draft" }, + event_type: "status_changed", + receivable_id: "f669a8a4-0563-4ab9-b54f-e9d700d282c5", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/receivables/receivable_id/history") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.getHistory("receivable_id"); + expect(response).toEqual({ + data: [ + { + id: "cd58435b-1c79-4b17-9f79-f898c93e5f97", + current_pdf_url: "https://monite-file-saver.example.com/12345/67890.pdf", + entity_user_id: "d5a577b0-01c0-4566-ac5c-44f41935e8c4", + event_data: { + new_status: "draft", + old_status: "draft", + }, + event_type: "status_changed", + receivable_id: "f669a8a4-0563-4ab9-b54f-e9d700d282c5", + timestamp: "2024-01-15T09:30:00Z", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("get_history_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "cd58435b-1c79-4b17-9f79-f898c93e5f97", + current_pdf_url: "https://monite-file-saver.example.com/12345/67890.pdf", + entity_user_id: "d5a577b0-01c0-4566-ac5c-44f41935e8c4", + event_data: { new_status: "draft", old_status: "draft" }, + event_type: "status_changed", + receivable_id: "f669a8a4-0563-4ab9-b54f-e9d700d282c5", + timestamp: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .get("/receivables/receivable_id/history/receivable_history_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.getHistoryById("receivable_history_id", "receivable_id"); + expect(response).toEqual({ + id: "cd58435b-1c79-4b17-9f79-f898c93e5f97", + current_pdf_url: "https://monite-file-saver.example.com/12345/67890.pdf", + entity_user_id: "d5a577b0-01c0-4566-ac5c-44f41935e8c4", + event_data: { + new_status: "draft", + old_status: "draft", + }, + event_type: "status_changed", + receivable_id: "f669a8a4-0563-4ab9-b54f-e9d700d282c5", + timestamp: "2024-01-15T09:30:00Z", + }); + }); + + test("issue_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount", value: 1 }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [{ name: "name", value: 1.1, amount: 1 }], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }; + server + .mockEndpoint() + .post("/receivables/receivable_id/issue") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.issueById("receivable_id"); + expect(response).toEqual({ + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + value: 1, + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [ + { + name: "name", + value: 1.1, + amount: 1, + }, + ], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }); + }); + + test("update_line_items_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { data: [{ quantity: 1.1 }] }; + const rawResponseBody = { + data: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + }; + server + .mockEndpoint() + .put("/receivables/receivable_id/line_items") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.updateLineItemsById("receivable_id", { + data: [ + { + quantity: 1.1, + }, + ], + }); + expect(response).toEqual({ + data: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + }); + }); + + test("get_mails", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { id: "id", created_at: "2024-01-15T09:30:00Z", updated_at: "2024-01-15T09:30:00Z", status: "pending" }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/receivables/receivable_id/mails") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.getMails("receivable_id"); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + status: "pending", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("get_mail_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + recipients: { + bcc: [{ email: "email", is_success: true }], + cc: [{ email: "email", is_success: true }], + to: [{ email: "email", is_success: true }], + }, + status: "pending", + }; + server + .mockEndpoint() + .get("/receivables/receivable_id/mails/mail_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.getMailById("receivable_id", "mail_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + recipients: { + bcc: [ + { + email: "email", + is_success: true, + }, + ], + cc: [ + { + email: "email", + is_success: true, + }, + ], + to: [ + { + email: "email", + is_success: true, + }, + ], + }, + status: "pending", + }); + }); + + test("mark_as_paid_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount", value: 1 }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [{ name: "name", value: 1.1, amount: 1 }], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }; + server + .mockEndpoint() + .post("/receivables/receivable_id/mark_as_paid") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.markAsPaidById("receivable_id"); + expect(response).toEqual({ + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + value: 1, + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [ + { + name: "name", + value: 1.1, + amount: 1, + }, + ], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }); + }); + + test("mark_as_partially_paid_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { amount_paid: 1 }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount", value: 1 }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [{ name: "name", value: 1.1, amount: 1 }], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }; + server + .mockEndpoint() + .post("/receivables/receivable_id/mark_as_partially_paid") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.markAsPartiallyPaidById("receivable_id", { + amount_paid: 1, + }); + expect(response).toEqual({ + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + value: 1, + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [ + { + name: "name", + value: 1.1, + amount: 1, + }, + ], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }); + }); + + test("mark_as_uncollectible_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { amount: 1, type: "amount", value: 1 }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + type: "organization", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { id: "id", country: "AF", entity_id: "entity_id", type: "ae_trn", value: "123456789" }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { amount: 1, type: "amount" }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { currency: "AED", value: 1 }, + price_after_vat: { currency: "AED", value: 1 }, + vat_rate: { country: "AF", value: 1 }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { key: "value" }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [{ name: "name", value: 1.1, amount: 1 }], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + type: "quote", + }; + server + .mockEndpoint() + .post("/receivables/receivable_id/mark_as_uncollectible") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.markAsUncollectibleById("receivable_id"); + expect(response).toEqual({ + type: "quote", + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + based_on: "based_on", + based_on_document_id: "based_on_document_id", + comment: "comment", + commercial_condition_description: "commercial_condition_description", + counterpart_billing_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_business_type: "counterpart_business_type", + counterpart_contact: { + address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + email: "marge@example.org", + first_name: "Marge", + last_name: "Smith", + phone: "55512378654", + title: "Dr.", + }, + counterpart_external_reference: "counterpart_external_reference", + counterpart_id: "counterpart_id", + counterpart_name: "counterpart_name", + counterpart_shipping_address: { + id: "id", + city: "Berlin", + country: "AF", + line1: "Flughafenstrasse 52", + line2: "line2", + postal_code: "10115", + state: "state", + }, + counterpart_tax_id: "counterpart_tax_id", + counterpart_type: "individual", + counterpart_vat_id: { + id: "id", + counterpart_id: "counterpart_id", + country: "AF", + type: "ae_trn", + value: "123456789", + }, + currency: "AED", + deduction_amount: 1, + deduction_memo: "deduction_memo", + discount: { + amount: 1, + type: "amount", + value: 1, + }, + discounted_subtotal: 1, + document_id: "document_id", + due_date: "due_date", + einvoice_file_url: "einvoice_file_url", + entity: { + type: "organization", + email: "email", + logo: "logo", + name: "name", + phone: "phone", + registration_authority: "registration_authority", + registration_number: "registration_number", + tax_id: "tax_id", + vat_id: "vat_id", + website: "website", + }, + entity_address: { + city: "city", + country: "AF", + line1: "line1", + line2: "line2", + postal_code: "postal_code", + state: "state", + }, + entity_bank_account: { + id: "id", + account_holder_name: "account_holder_name", + account_number: "account_number", + bank_name: "bank_name", + bic: "bic", + iban: "iban", + routing_number: "routing_number", + sort_code: "sort_code", + }, + entity_user_id: "entity_user_id", + entity_vat_id: { + id: "id", + country: "AF", + entity_id: "entity_id", + type: "ae_trn", + value: "123456789", + }, + expiry_date: "expiry_date", + file_language: "ab", + file_url: "file_url", + footer: "footer", + issue_date: "2024-01-15T09:30:00Z", + line_items: [ + { + discount: { + amount: 1, + type: "amount", + }, + product: { + id: "id", + external_reference: "HT-1234-S-BL", + name: "name", + price: { + currency: "AED", + value: 1, + }, + price_after_vat: { + currency: "AED", + value: 1, + }, + vat_rate: { + country: "AF", + value: 1, + }, + }, + quantity: 1.1, + total_after_vat: 1, + total_before_vat: 1, + }, + ], + memo: "memo", + original_file_language: "ab", + original_file_url: "original_file_url", + partner_metadata: { + key: "value", + }, + project_id: "project_id", + quote_accept_page_url: "quote_accept_page_url", + signature_required: true, + status: "draft", + subtotal: 1, + subtotal_after_vat: 1, + tags: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + total_amount: 1, + total_vat_amount: 1, + total_vat_amounts: [ + { + id: "id", + amount: 1, + components: [ + { + name: "name", + value: 1.1, + amount: 1, + }, + ], + name: "name", + taxable_amount: 1, + value: 1, + }, + ], + total_withholding_tax: 1, + trade_name: "trade_name", + vat_exempt: true, + vat_exemption_rationale: "vat_exemption_rationale", + vat_inclusive_discount_mode: "exclusive", + vat_mode: "exclusive", + withholding_tax_rate: 1, + }); + }); + + test("get_pdf_link_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { file_url: "file_url", original_file_url: "original_file_url" }; + server + .mockEndpoint() + .get("/receivables/receivable_id/pdf_link") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.getPdfLinkById("receivable_id"); + expect(response).toEqual({ + file_url: "file_url", + original_file_url: "original_file_url", + }); + }); + + test("preview_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { body_text: "body_text", subject_text: "subject_text" }; + const rawResponseBody = { body_preview: "body_preview", subject_preview: "subject_preview" }; + server + .mockEndpoint() + .post("/receivables/receivable_id/preview") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.previewById("receivable_id", { + body_text: "body_text", + subject_text: "subject_text", + }); + expect(response).toEqual({ + body_preview: "body_preview", + subject_preview: "subject_preview", + }); + }); + + test("send_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { body_text: "body_text", subject_text: "subject_text" }; + const rawResponseBody = { mail_id: "mail_id" }; + server + .mockEndpoint() + .post("/receivables/receivable_id/send") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.sendById("receivable_id", { + body_text: "body_text", + subject_text: "subject_text", + }); + expect(response).toEqual({ + mail_id: "mail_id", + }); + }); + + test("send_test_reminder_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { reminder_type: "term_1" }; + const rawResponseBody = { mail_ids: ["mail_ids"] }; + server + .mockEndpoint() + .post("/receivables/receivable_id/send_test_reminder") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.sendTestReminderById("receivable_id", { + reminder_type: "term_1", + }); + expect(response).toEqual({ + mail_ids: ["mail_ids"], + }); + }); + + test("verify_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + errors: { + counterpart: ["counterpart"], + entity: ["entity"], + products: [{ line_item_number: 1, missing_fields: ["missing_fields"] }], + receivable: ["receivable"], + vat_rates: ["vat_rates"], + }, + warnings: { payment_reminders: "payment_reminders" }, + }; + server + .mockEndpoint() + .post("/receivables/receivable_id/verify") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.receivables.verifyById("receivable_id"); + expect(response).toEqual({ + errors: { + counterpart: ["counterpart"], + entity: ["entity"], + products: [ + { + line_item_number: 1, + missing_fields: ["missing_fields"], + }, + ], + receivable: ["receivable"], + vat_rates: ["vat_rates"], + }, + warnings: { + payment_reminders: "payment_reminders", + }, + }); + }); +}); diff --git a/tests/wire/recurrences.test.ts b/tests/wire/recurrences.test.ts new file mode 100644 index 0000000..8aac9a9 --- /dev/null +++ b/tests/wire/recurrences.test.ts @@ -0,0 +1,367 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Recurrences", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + automation_level: "draft", + body_text: "body_text", + current_iteration: 1, + day_of_month: "first_day", + end_date: "end_date", + frequency: "day", + interval: 1, + invoice_id: "invoice_id", + iterations: [{ issue_at: "issue_at", status: "pending" }], + max_occurrences: 1, + start_date: "start_date", + start_month: 1, + start_year: 1, + status: "active", + subject_text: "subject_text", + }, + ], + }; + server.mockEndpoint().get("/recurrences").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.recurrences.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + automation_level: "draft", + body_text: "body_text", + current_iteration: 1, + day_of_month: "first_day", + end_date: "end_date", + frequency: "day", + interval: 1, + invoice_id: "invoice_id", + iterations: [ + { + issue_at: "issue_at", + status: "pending", + }, + ], + max_occurrences: 1, + start_date: "start_date", + start_month: 1, + start_year: 1, + status: "active", + subject_text: "subject_text", + }, + ], + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { invoice_id: "invoice_id" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + automation_level: "draft", + body_text: "body_text", + current_iteration: 1, + day_of_month: "first_day", + end_date: "end_date", + frequency: "day", + interval: 1, + invoice_id: "invoice_id", + iterations: [ + { issue_at: "issue_at", issued_invoice_id: "issued_invoice_id", iteration: 1, status: "pending" }, + ], + max_occurrences: 1, + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + start_date: "start_date", + start_month: 1, + start_year: 1, + status: "active", + subject_text: "subject_text", + }; + server + .mockEndpoint() + .post("/recurrences") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.recurrences.create({ + invoice_id: "invoice_id", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + automation_level: "draft", + body_text: "body_text", + current_iteration: 1, + day_of_month: "first_day", + end_date: "end_date", + frequency: "day", + interval: 1, + invoice_id: "invoice_id", + iterations: [ + { + issue_at: "issue_at", + issued_invoice_id: "issued_invoice_id", + iteration: 1, + status: "pending", + }, + ], + max_occurrences: 1, + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + start_date: "start_date", + start_month: 1, + start_year: 1, + status: "active", + subject_text: "subject_text", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + automation_level: "draft", + body_text: "body_text", + current_iteration: 1, + day_of_month: "first_day", + end_date: "end_date", + frequency: "day", + interval: 1, + invoice_id: "invoice_id", + iterations: [ + { issue_at: "issue_at", issued_invoice_id: "issued_invoice_id", iteration: 1, status: "pending" }, + ], + max_occurrences: 1, + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + start_date: "start_date", + start_month: 1, + start_year: 1, + status: "active", + subject_text: "subject_text", + }; + server + .mockEndpoint() + .get("/recurrences/recurrence_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.recurrences.getById("recurrence_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + automation_level: "draft", + body_text: "body_text", + current_iteration: 1, + day_of_month: "first_day", + end_date: "end_date", + frequency: "day", + interval: 1, + invoice_id: "invoice_id", + iterations: [ + { + issue_at: "issue_at", + issued_invoice_id: "issued_invoice_id", + iteration: 1, + status: "pending", + }, + ], + max_occurrences: 1, + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + start_date: "start_date", + start_month: 1, + start_year: 1, + status: "active", + subject_text: "subject_text", + }); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + automation_level: "draft", + body_text: "body_text", + current_iteration: 1, + day_of_month: "first_day", + end_date: "end_date", + frequency: "day", + interval: 1, + invoice_id: "invoice_id", + iterations: [ + { issue_at: "issue_at", issued_invoice_id: "issued_invoice_id", iteration: 1, status: "pending" }, + ], + max_occurrences: 1, + recipients: { bcc: ["bcc"], cc: ["cc"], to: ["to"] }, + start_date: "start_date", + start_month: 1, + start_year: 1, + status: "active", + subject_text: "subject_text", + }; + server + .mockEndpoint() + .patch("/recurrences/recurrence_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.recurrences.updateById("recurrence_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + automation_level: "draft", + body_text: "body_text", + current_iteration: 1, + day_of_month: "first_day", + end_date: "end_date", + frequency: "day", + interval: 1, + invoice_id: "invoice_id", + iterations: [ + { + issue_at: "issue_at", + issued_invoice_id: "issued_invoice_id", + iteration: 1, + status: "pending", + }, + ], + max_occurrences: 1, + recipients: { + bcc: ["bcc"], + cc: ["cc"], + to: ["to"], + }, + start_date: "start_date", + start_month: 1, + start_year: 1, + status: "active", + subject_text: "subject_text", + }); + }); + + test("cancel_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().post("/recurrences/recurrence_id/cancel").respondWith().statusCode(200).build(); + + const response = await client.recurrences.cancelById("recurrence_id"); + expect(response).toEqual(undefined); + }); + + test("post_recurrences_id_pause", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/recurrences/recurrence_id/pause") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.recurrences.postRecurrencesIdPause("recurrence_id"); + expect(response).toEqual({ + key: "value", + }); + }); + + test("post_recurrences_id_resume", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/recurrences/recurrence_id/resume") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.recurrences.postRecurrencesIdResume("recurrence_id"); + expect(response).toEqual({ + key: "value", + }); + }); +}); diff --git a/tests/wire/roles.test.ts b/tests/wire/roles.test.ts new file mode 100644 index 0000000..ac0a005 --- /dev/null +++ b/tests/wire/roles.test.ts @@ -0,0 +1,190 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Roles", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + name: "name", + permissions: {}, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }, + ], + prev_pagination_token: "prev_pagination_token", + next_pagination_token: "next_pagination_token", + }; + server.mockEndpoint().get("/roles").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.roles.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + name: "name", + permissions: {}, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }, + ], + prev_pagination_token: "prev_pagination_token", + next_pagination_token: "next_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "name", permissions: {} }; + const rawResponseBody = { + id: "id", + name: "name", + permissions: { objects: [{ object_type: "approval_policy" }] }, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .post("/roles") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.roles.create({ + name: "name", + permissions: {}, + }); + expect(response).toEqual({ + id: "id", + name: "name", + permissions: { + objects: [ + { + object_type: "approval_policy", + }, + ], + }, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + name: "name", + permissions: { objects: [{ object_type: "approval_policy" }] }, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server.mockEndpoint().get("/roles/role_id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.roles.getById("role_id"); + expect(response).toEqual({ + id: "id", + name: "name", + permissions: { + objects: [ + { + object_type: "approval_policy", + }, + ], + }, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); + + test("delete_roles_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/roles/role_id").respondWith().statusCode(200).build(); + + const response = await client.roles.deleteRolesId("role_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + name: "name", + permissions: { objects: [{ object_type: "approval_policy" }] }, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .patch("/roles/role_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.roles.updateById("role_id"); + expect(response).toEqual({ + id: "id", + name: "name", + permissions: { + objects: [ + { + object_type: "approval_policy", + }, + ], + }, + status: "active", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); +}); diff --git a/tests/wire/tags.test.ts b/tests/wire/tags.test.ts new file mode 100644 index 0000000..b67d49f --- /dev/null +++ b/tests/wire/tags.test.ts @@ -0,0 +1,183 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("Tags", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + next_pagination_token: + "eyJvcmRlciI6ImFzYyIsImxpbWl0IjoyLCJwYWdpbmF0aW9uX2ZpbHRlcnMiOnsiZW50aXR5X2lkIjoiOWQyYjRjOGYtMjA4Ny00NzM4LWJhOTEtNzM1OTY4M2M0OWE0In0sInBhZ2luYXRpb25fdG9rZW5fdHlwZSI6Im5leHQiLCJjdXJzb3JfZmllbGQiOm51bGwsImN1cnNvcl9maWVsZF92YWx1ZSI6bnVsbCwiY3VycmVudF9vaWQiOjR9", + prev_pagination_token: + "eyJvcmRlciI6ImFzYyIsImxpbWl0IjoyLCJwYWdpbmF0aW9uX2ZpbHRlcnMiOnsiZW50aXR5X2lkIjoiOWQyYjRjOGYtMjA4Ny00NzM4LWJhOTEtNzM1OTY4M2M0OWE0In0sInBhZ2luYXRpb25fdG9rZW5fdHlwZSI6Im5leHQiLCJjdXJzb3JfZmllbGQiOm51bGwsImN1cnNvcl9maWVsZF92YWx1ZSI6bnVsbCwiY3VycmVudF9vaWQiOjR9", + }; + server.mockEndpoint().get("/tags").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.tags.get(); + expect(response).toEqual({ + data: [ + { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }, + ], + next_pagination_token: + "eyJvcmRlciI6ImFzYyIsImxpbWl0IjoyLCJwYWdpbmF0aW9uX2ZpbHRlcnMiOnsiZW50aXR5X2lkIjoiOWQyYjRjOGYtMjA4Ny00NzM4LWJhOTEtNzM1OTY4M2M0OWE0In0sInBhZ2luYXRpb25fdG9rZW5fdHlwZSI6Im5leHQiLCJjdXJzb3JfZmllbGQiOm51bGwsImN1cnNvcl9maWVsZF92YWx1ZSI6bnVsbCwiY3VycmVudF9vaWQiOjR9", + prev_pagination_token: + "eyJvcmRlciI6ImFzYyIsImxpbWl0IjoyLCJwYWdpbmF0aW9uX2ZpbHRlcnMiOnsiZW50aXR5X2lkIjoiOWQyYjRjOGYtMjA4Ny00NzM4LWJhOTEtNzM1OTY4M2M0OWE0In0sInBhZ2luYXRpb25fdG9rZW5fdHlwZSI6Im5leHQiLCJjdXJzb3JfZmllbGQiOm51bGwsImN1cnNvcl9maWVsZF92YWx1ZSI6bnVsbCwiY3VycmVudF9vaWQiOjR9", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { name: "Marketing" }; + const rawResponseBody = { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }; + server + .mockEndpoint() + .post("/tags") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.tags.create({ + name: "Marketing", + }); + expect(response).toEqual({ + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }; + server.mockEndpoint().get("/tags/tag_id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.tags.getById("tag_id"); + expect(response).toEqual({ + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/tags/tag_id").respondWith().statusCode(200).build(); + + const response = await client.tags.deleteById("tag_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }; + server + .mockEndpoint() + .patch("/tags/tag_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.tags.updateById("tag_id"); + expect(response).toEqual({ + id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + created_at: "2022-09-07T16:35:18Z", + updated_at: "2022-09-07T16:35:18Z", + category: "document_type", + created_by_entity_user_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", + description: "Tag for the Marketing Department", + name: "Marketing", + }); + }); +}); diff --git a/tests/wire/textTemplates.test.ts b/tests/wire/textTemplates.test.ts new file mode 100644 index 0000000..6c63603 --- /dev/null +++ b/tests/wire/textTemplates.test.ts @@ -0,0 +1,236 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("TextTemplates", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server.mockEndpoint().get("/text_templates").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.textTemplates.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { document_type: "quote", name: "name", template: "template", type: "email_header" }; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }; + server + .mockEndpoint() + .post("/text_templates") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.textTemplates.create({ + document_type: "quote", + name: "name", + template: "template", + type: "email_header", + }); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }; + server + .mockEndpoint() + .get("/text_templates/text_template_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.textTemplates.getById("text_template_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server.mockEndpoint().delete("/text_templates/text_template_id").respondWith().statusCode(200).build(); + + const response = await client.textTemplates.deleteById("text_template_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }; + server + .mockEndpoint() + .patch("/text_templates/text_template_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.textTemplates.updateById("text_template_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }); + }); + + test("make_default_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }; + server + .mockEndpoint() + .post("/text_templates/text_template_id/make_default") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.textTemplates.makeDefaultById("text_template_id"); + expect(response).toEqual({ + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + document_type: "quote", + is_default: true, + name: "name", + template: "template", + type: "email_header", + }); + }); +}); diff --git a/tests/wire/vatRates.test.ts b/tests/wire/vatRates.test.ts new file mode 100644 index 0000000..f244911 --- /dev/null +++ b/tests/wire/vatRates.test.ts @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("VatRates", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [{ name: "name", value: 1.1 }], + country: "AF", + status: "active", + valid_from: "valid_from", + valid_until: "valid_until", + value: 1, + }, + ], + }; + server.mockEndpoint().get("/vat_rates").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.vatRates.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + components: [ + { + name: "name", + value: 1.1, + }, + ], + country: "AF", + status: "active", + valid_from: "valid_from", + valid_until: "valid_until", + value: 1, + }, + ], + }); + }); +}); diff --git a/tests/wire/webhookDeliveries.test.ts b/tests/wire/webhookDeliveries.test.ts new file mode 100644 index 0000000..2f0ac18 --- /dev/null +++ b/tests/wire/webhookDeliveries.test.ts @@ -0,0 +1,58 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("WebhookDeliveries", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [ + { + id: "id", + event_id: "event_id", + requests_made_count: 1, + response: "response", + response_status_code: 1, + url: "url", + was_successful: true, + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/webhook_deliveries") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhookDeliveries.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + event_id: "event_id", + requests_made_count: 1, + response: "response", + response_status_code: 1, + url: "url", + was_successful: true, + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); +}); diff --git a/tests/wire/webhookSubscriptions.test.ts b/tests/wire/webhookSubscriptions.test.ts new file mode 100644 index 0000000..0a462f5 --- /dev/null +++ b/tests/wire/webhookSubscriptions.test.ts @@ -0,0 +1,279 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { mockServerPool } from "../mock-server/MockServerPool.js"; +import { MoniteClient } from "../../src/Client"; + +describe("WebhookSubscriptions", () => { + test("get", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + data: [{ id: "id", event_types: ["event_types"], object_type: "account", status: "enabled", url: "url" }], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }; + server + .mockEndpoint() + .get("/webhook_subscriptions") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhookSubscriptions.get(); + expect(response).toEqual({ + data: [ + { + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }, + ], + next_pagination_token: "next_pagination_token", + prev_pagination_token: "prev_pagination_token", + }); + }); + + test("create", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = { object_type: "account", url: "url" }; + const rawResponseBody = { + id: "id", + event_types: ["event_types"], + object_type: "account", + secret: "secret", + status: "enabled", + url: "url", + }; + server + .mockEndpoint() + .post("/webhook_subscriptions") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhookSubscriptions.create({ + object_type: "account", + url: "url", + }); + expect(response).toEqual({ + id: "id", + event_types: ["event_types"], + object_type: "account", + secret: "secret", + status: "enabled", + url: "url", + }); + }); + + test("get_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }; + server + .mockEndpoint() + .get("/webhook_subscriptions/webhook_subscription_id") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhookSubscriptions.getById("webhook_subscription_id"); + expect(response).toEqual({ + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }); + }); + + test("delete_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + server + .mockEndpoint() + .delete("/webhook_subscriptions/webhook_subscription_id") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.webhookSubscriptions.deleteById("webhook_subscription_id"); + expect(response).toEqual(undefined); + }); + + test("update_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }; + server + .mockEndpoint() + .patch("/webhook_subscriptions/webhook_subscription_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhookSubscriptions.updateById("webhook_subscription_id"); + expect(response).toEqual({ + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }); + }); + + test("disable_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }; + server + .mockEndpoint() + .post("/webhook_subscriptions/webhook_subscription_id/disable") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhookSubscriptions.disableById("webhook_subscription_id"); + expect(response).toEqual({ + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }); + }); + + test("enable_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }; + server + .mockEndpoint() + .post("/webhook_subscriptions/webhook_subscription_id/enable") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhookSubscriptions.enableById("webhook_subscription_id"); + expect(response).toEqual({ + id: "id", + event_types: ["event_types"], + object_type: "account", + status: "enabled", + url: "url", + }); + }); + + test("regenerate_secret_by_id", async () => { + const server = mockServerPool.createServer(); + const client = new MoniteClient({ + token: "test", + moniteVersion: "test", + moniteEntityId: "test", + environment: server.baseUrl, + }); + + const rawResponseBody = { + id: "id", + event_types: ["event_types"], + object_type: "account", + secret: "secret", + status: "enabled", + url: "url", + }; + server + .mockEndpoint() + .post("/webhook_subscriptions/webhook_subscription_id/regenerate_secret") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhookSubscriptions.regenerateSecretById("webhook_subscription_id"); + expect(response).toEqual({ + id: "id", + event_types: ["event_types"], + object_type: "account", + secret: "secret", + status: "enabled", + url: "url", + }); + }); +}); diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..c75083d --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "extendedDiagnostics": true, + "strict": true, + "target": "ES6", + "moduleResolution": "node", + "esModuleInterop": true, + "skipLibCheck": true, + "declaration": true, + "outDir": "dist", + "rootDir": "src", + "baseUrl": "src" + }, + "include": ["src"], + "exclude": [] +} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..5c11446 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist/cjs" + }, + "include": ["src"], + "exclude": [] +} diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..95a5eb7 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "esnext", + "outDir": "dist/esm" + }, + "include": ["src"], + "exclude": [] +} diff --git a/tsconfig.json b/tsconfig.json index 1ec87dd..d77fdf0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,3 @@ { - "compilerOptions": { - "extendedDiagnostics": true, - "strict": true, - "target": "ES6", - "moduleResolution": "node", - "esModuleInterop": true, - "skipLibCheck": true, - "declaration": true, - "outDir": "dist", - "rootDir": "src", - "baseUrl": "src", - "module": "CommonJS" - }, - "include": ["src"], - "exclude": [] + "extends": "./tsconfig.cjs.json" } diff --git a/yarn.lock b/yarn.lock index df80c55..207c59a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20,43 +20,43 @@ picocolors "^1.1.1" "@babel/compat-data@^7.27.2": - version "7.27.2" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.27.2.tgz#4183f9e642fd84e74e3eea7ffa93a412e3b102c9" - integrity sha512-TUtMJYRPyUb/9aU8f3K0mjmjf6M9N5Woshn2CS6nqJSeJtTtQcpLUXjGt9vbF8ZGff0El99sWkLgzwW3VXnxZQ== + version "7.27.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.27.5.tgz#7d0658ec1a8420fc866d1df1b03bea0e79934c82" + integrity sha512-KiRAp/VoJaWkkte84TvUd9qjdbZAdiqyvMxrGl1N6vzFogKmaLgoM3L1kgtLicp2HP5fBJS8JrZKLVIZGVJAVg== "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.23.9": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.27.1.tgz#89de51e86bd12246003e3524704c49541b16c3e6" - integrity sha512-IaaGWsQqfsQWVLqMn9OB92MNN7zukfVA4s7KKAI0KfrrDsZ0yhi5uV4baBuLuN7n3vsZpwP8asPPcVwApxvjBQ== + version "7.27.4" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.27.4.tgz#cc1fc55d0ce140a1828d1dd2a2eba285adbfb3ce" + integrity sha512-bXYxrXFubeYdvB0NhD/NBB3Qi6aZeV20GOWVI47t2dkecCEoneR4NPVcb7abpXDEvejgrUfFtG6vG/zxAKmg+g== dependencies: "@ampproject/remapping" "^2.2.0" "@babel/code-frame" "^7.27.1" - "@babel/generator" "^7.27.1" - "@babel/helper-compilation-targets" "^7.27.1" - "@babel/helper-module-transforms" "^7.27.1" - "@babel/helpers" "^7.27.1" - "@babel/parser" "^7.27.1" - "@babel/template" "^7.27.1" - "@babel/traverse" "^7.27.1" - "@babel/types" "^7.27.1" + "@babel/generator" "^7.27.3" + "@babel/helper-compilation-targets" "^7.27.2" + "@babel/helper-module-transforms" "^7.27.3" + "@babel/helpers" "^7.27.4" + "@babel/parser" "^7.27.4" + "@babel/template" "^7.27.2" + "@babel/traverse" "^7.27.4" + "@babel/types" "^7.27.3" 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.27.1", "@babel/generator@^7.7.2": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.27.1.tgz#862d4fad858f7208edd487c28b58144036b76230" - integrity sha512-UnJfnIpc/+JO0/+KRVQNGU+y5taA5vCbwN8+azkX6beii/ZF+enZJSOKo11ZSzGJjlNfJHfQtmQT8H+9TXPG2w== +"@babel/generator@^7.27.3", "@babel/generator@^7.7.2": + version "7.27.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.27.5.tgz#3eb01866b345ba261b04911020cbe22dd4be8c8c" + integrity sha512-ZGhA37l0e/g2s1Cnzdix0O3aLYm66eF8aufiVteOgnwxgnRP8GoyMj7VWsgWnQbVKXyge7hqrFh2K2TQM6t1Hw== dependencies: - "@babel/parser" "^7.27.1" - "@babel/types" "^7.27.1" + "@babel/parser" "^7.27.5" + "@babel/types" "^7.27.3" "@jridgewell/gen-mapping" "^0.3.5" "@jridgewell/trace-mapping" "^0.3.25" jsesc "^3.0.2" -"@babel/helper-compilation-targets@^7.27.1": +"@babel/helper-compilation-targets@^7.27.2": version "7.27.2" resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz#46a0f6efab808d51d29ce96858dd10ce8732733d" integrity sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ== @@ -75,14 +75,14 @@ "@babel/traverse" "^7.27.1" "@babel/types" "^7.27.1" -"@babel/helper-module-transforms@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.27.1.tgz#e1663b8b71d2de948da5c4fb2a20ca4f3ec27a6f" - integrity sha512-9yHn519/8KvTU5BjTVEEeIM3w9/2yXNKoD82JifINImhpKkARMJKPP59kLo+BafpdN5zgNeIcS4jsGDmd3l58g== +"@babel/helper-module-transforms@^7.27.3": + version "7.27.3" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz#db0bbcfba5802f9ef7870705a7ef8788508ede02" + integrity sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg== dependencies: "@babel/helper-module-imports" "^7.27.1" "@babel/helper-validator-identifier" "^7.27.1" - "@babel/traverse" "^7.27.1" + "@babel/traverse" "^7.27.3" "@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.27.1", "@babel/helper-plugin-utils@^7.8.0": version "7.27.1" @@ -104,20 +104,20 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz#fa52f5b1e7db1ab049445b421c4471303897702f" integrity sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg== -"@babel/helpers@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.27.1.tgz#ffc27013038607cdba3288e692c3611c06a18aa4" - integrity sha512-FCvFTm0sWV8Fxhpp2McP5/W53GPllQ9QeQ7SiqGWjMf/LVG07lFa5+pgK05IRhVwtvafT22KF+ZSnM9I545CvQ== +"@babel/helpers@^7.27.4": + version "7.27.6" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.27.6.tgz#6456fed15b2cb669d2d1fabe84b66b34991d812c" + integrity sha512-muE8Tt8M22638HU31A3CgfSUciwz1fhATfoVai05aPXGor//CdWDCbnlY1yvBPo07njuVOCNGCSp/GTt12lIug== dependencies: - "@babel/template" "^7.27.1" - "@babel/types" "^7.27.1" + "@babel/template" "^7.27.2" + "@babel/types" "^7.27.6" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.27.1", "@babel/parser@^7.27.2": - version "7.27.2" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.27.2.tgz#577518bedb17a2ce4212afd052e01f7df0941127" - integrity sha512-QYLs8299NA7WM/bZAdp+CviYYkVoYXlDW2rzliy3chxd1PQjej7JORuMJDJXJUb9g0TT+B99EwaVLKmX+sPXWw== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.27.2", "@babel/parser@^7.27.4", "@babel/parser@^7.27.5": + version "7.27.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.27.5.tgz#ed22f871f110aa285a6fd934a0efed621d118826" + integrity sha512-OsQd175SxWkGlzbny8J3K8TnnDD0N3lrIUtB92xwyRpzaenGZhxDvxN/JgU00U3CDZNj9tPuDJ5H0WS4Nt3vKg== dependencies: - "@babel/types" "^7.27.1" + "@babel/types" "^7.27.3" "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -238,7 +238,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.27.1" -"@babel/template@^7.27.1", "@babel/template@^7.3.3": +"@babel/template@^7.27.2", "@babel/template@^7.3.3": version "7.27.2" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.27.2.tgz#fa78ceed3c4e7b63ebf6cb39e5852fca45f6809d" integrity sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw== @@ -247,23 +247,23 @@ "@babel/parser" "^7.27.2" "@babel/types" "^7.27.1" -"@babel/traverse@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.27.1.tgz#4db772902b133bbddd1c4f7a7ee47761c1b9f291" - integrity sha512-ZCYtZciz1IWJB4U61UPu4KEaqyfj+r5T1Q5mqPo+IBpcG9kHv30Z0aD8LXPgC1trYa6rK0orRyAhqUgk4MjmEg== +"@babel/traverse@^7.27.1", "@babel/traverse@^7.27.3", "@babel/traverse@^7.27.4": + version "7.27.4" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.27.4.tgz#b0045ac7023c8472c3d35effd7cc9ebd638da6ea" + integrity sha512-oNcu2QbHqts9BtOWJosOVJapWjBDSxGCpFvikNR5TGDYDQf3JwpIoMzIKrvfoti93cLfPJEG4tH9SPVeyCGgdA== dependencies: "@babel/code-frame" "^7.27.1" - "@babel/generator" "^7.27.1" - "@babel/parser" "^7.27.1" - "@babel/template" "^7.27.1" - "@babel/types" "^7.27.1" + "@babel/generator" "^7.27.3" + "@babel/parser" "^7.27.4" + "@babel/template" "^7.27.2" + "@babel/types" "^7.27.3" debug "^4.3.1" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.27.1", "@babel/types@^7.3.3": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.27.1.tgz#9defc53c16fc899e46941fc6901a9eea1c9d8560" - integrity sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q== +"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.27.1", "@babel/types@^7.27.3", "@babel/types@^7.27.6", "@babel/types@^7.3.3": + version "7.27.6" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.27.6.tgz#a434ca7add514d4e646c80f7375c0aa2befc5535" + integrity sha512-ETyHEk2VHHvl9b9jZP5IHPavHYk57EhanlRRuae9XCpb/j5bDCbPPMOBfCWhnl/7EDJz0jEMCi/RhccCE8r1+Q== dependencies: "@babel/helper-string-parser" "^7.27.1" "@babel/helper-validator-identifier" "^7.27.1" @@ -273,6 +273,60 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@bundled-es-modules/cookie@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@bundled-es-modules/cookie/-/cookie-2.0.1.tgz#b41376af6a06b3e32a15241d927b840a9b4de507" + integrity sha512-8o+5fRPLNbjbdGRRmJj3h6Hh1AQJf2dk3qQ/5ZFb+PXkRNiSoMGGUKlsgLfrxneb72axVJyIYji64E2+nNfYyw== + dependencies: + cookie "^0.7.2" + +"@bundled-es-modules/statuses@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@bundled-es-modules/statuses/-/statuses-1.0.1.tgz#761d10f44e51a94902c4da48675b71a76cc98872" + integrity sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg== + dependencies: + statuses "^2.0.1" + +"@bundled-es-modules/tough-cookie@^0.1.6": + version "0.1.6" + resolved "https://registry.yarnpkg.com/@bundled-es-modules/tough-cookie/-/tough-cookie-0.1.6.tgz#fa9cd3cedfeecd6783e8b0d378b4a99e52bde5d3" + integrity sha512-dvMHbL464C0zI+Yqxbz6kZ5TOEp7GLW+pry/RWndAR8MJQAXZ2rPmIs8tziTZjeIyhSNZgZbCePtfSbdWqStJw== + dependencies: + "@types/tough-cookie" "^4.0.5" + tough-cookie "^4.1.4" + +"@inquirer/confirm@^5.0.0": + version "5.1.12" + resolved "https://registry.yarnpkg.com/@inquirer/confirm/-/confirm-5.1.12.tgz#387037889a5a558ceefe52e978228630aa6e7d0e" + integrity sha512-dpq+ielV9/bqgXRUbNH//KsY6WEw9DrGPmipkpmgC1Y46cwuBTNx7PXFWTjc3MQ+urcc0QxoVHcMI0FW4Ok0hg== + dependencies: + "@inquirer/core" "^10.1.13" + "@inquirer/type" "^3.0.7" + +"@inquirer/core@^10.1.13": + version "10.1.13" + resolved "https://registry.yarnpkg.com/@inquirer/core/-/core-10.1.13.tgz#8f1ecfaba288fd2d705c7ac0690371464cf687b0" + integrity sha512-1viSxebkYN2nJULlzCxES6G9/stgHSepZ9LqqfdIGPHj5OHhiBUXVS0a6R0bEC2A+VL4D9w6QB66ebCr6HGllA== + dependencies: + "@inquirer/figures" "^1.0.12" + "@inquirer/type" "^3.0.7" + ansi-escapes "^4.3.2" + cli-width "^4.1.0" + mute-stream "^2.0.0" + signal-exit "^4.1.0" + wrap-ansi "^6.2.0" + yoctocolors-cjs "^2.1.2" + +"@inquirer/figures@^1.0.12": + version "1.0.12" + resolved "https://registry.yarnpkg.com/@inquirer/figures/-/figures-1.0.12.tgz#667d6254cc7ba3b0c010a323d78024a1d30c6053" + integrity sha512-MJttijd8rMFcKJC8NYmprWr6hD3r9Gd9qUC0XwPNwoEPWSMVJwA2MlXxF+nhZZNMY+HXsWa+o7KY2emWYIn0jQ== + +"@inquirer/type@^3.0.7": + version "3.0.7" + resolved "https://registry.yarnpkg.com/@inquirer/type/-/type-3.0.7.tgz#b46bcf377b3172dbc768fdbd053e6492ad801a09" + integrity sha512-PfunHQcjwnju84L+ycmcMKB/pTPIngjUJvfnRhKY6FKPuYXlM4aQCb/nIdTFR6BEhMjFvngzvng/vBAJMZpLSA== + "@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" @@ -521,6 +575,36 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@mswjs/interceptors@^0.39.1": + version "0.39.2" + resolved "https://registry.yarnpkg.com/@mswjs/interceptors/-/interceptors-0.39.2.tgz#de9de0ab23f99d387c7904df7219a92157d1d666" + integrity sha512-RuzCup9Ct91Y7V79xwCb146RaBRHZ7NBbrIUySumd1rpKqHL5OonaqrGIbug5hNwP/fRyxFMA6ISgw4FTtYFYg== + dependencies: + "@open-draft/deferred-promise" "^2.2.0" + "@open-draft/logger" "^0.3.0" + "@open-draft/until" "^2.0.0" + is-node-process "^1.2.0" + outvariant "^1.4.3" + strict-event-emitter "^0.5.1" + +"@open-draft/deferred-promise@^2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz#4a822d10f6f0e316be4d67b4d4f8c9a124b073bd" + integrity sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA== + +"@open-draft/logger@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@open-draft/logger/-/logger-0.3.0.tgz#2b3ab1242b360aa0adb28b85f5d7da1c133a0954" + integrity sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ== + dependencies: + is-node-process "^1.2.0" + outvariant "^1.4.0" + +"@open-draft/until@^2.0.0", "@open-draft/until@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-2.1.0.tgz#0acf32f470af2ceaf47f095cdecd40d68666efda" + integrity sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg== + "@sinclair/typebox@^0.27.8": version "0.27.8" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" @@ -578,6 +662,11 @@ dependencies: "@babel/types" "^7.20.7" +"@types/cookie@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5" + integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA== + "@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" @@ -595,9 +684,9 @@ "@types/json-schema" "*" "@types/estree@*", "@types/estree@^1.0.6": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.7.tgz#4158d3105276773d5b7695cd4834b1722e4f37a8" - integrity sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ== + version "1.0.8" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e" + integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w== "@types/graceful-fs@^4.1.3": version "4.1.9" @@ -656,38 +745,42 @@ form-data "^4.0.0" "@types/node@*": - version "22.15.17" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.15.17.tgz#355ccec95f705b664e4332bb64a7f07db30b7055" - integrity sha512-wIX2aSZL5FE+MR0JlvF87BNVrtFWf6AE6rxSE9X7OwnVvoyCQjpzSRJ+M87se/4QCkCiebQAqrJ0y6fwIyi7nw== + version "24.0.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-24.0.4.tgz#dbae889912bda33a7f57669fb8587c1a56bc0c1f" + integrity sha512-ulyqAkrhnuNq9pB76DRBTkcS6YsmDALy6Ua63V8OhrOBgbcYt6IOdzpw5P1+dyRIyMerzLkeYWBeOXPpA9GMAA== dependencies: - undici-types "~6.21.0" + undici-types "~7.8.0" "@types/node@^18.19.70": - version "18.19.100" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.100.tgz#7f3aefbb6911099ab7e0902a1f373b1a4d2c1947" - integrity sha512-ojmMP8SZBKprc3qGrGk8Ujpo80AXkrP7G2tOT4VWr5jlr5DHjsJF+emXJz+Wm0glmy4Js62oKMdZZ6B9Y+tEcA== + version "18.19.112" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.112.tgz#cd2aee9c075402e0e1942a44101428881dbeb110" + integrity sha512-i+Vukt9POdS/MBI7YrrkkI5fMfwFtOjphSmt4WXYLfwqsfr6z/HdCx7LqT9M7JktGob8WNgj8nFB4TbGNE4Cog== dependencies: undici-types "~5.26.4" "@types/qs@^6.9.17": - version "6.9.18" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.18.tgz#877292caa91f7c1b213032b34626505b746624c2" - integrity sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA== + version "6.14.0" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.14.0.tgz#d8b60cecf62f2db0fb68e5e006077b9178b85de5" + integrity sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ== "@types/readable-stream@^4.0.18": - 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== + version "4.0.21" + resolved "https://registry.yarnpkg.com/@types/readable-stream/-/readable-stream-4.0.21.tgz#716558454a5e0c3c0651520f8154efc3288f59cb" + integrity sha512-19eKVv9tugr03IgfXlA9UVUVRbW6IuqRO5B92Dl4a6pT7K8uaGrNS0GkxiZD0BOk6PLuXl5FhWl//eX/pzYdTQ== 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@*": +"@types/statuses@^2.0.4": + version "2.0.6" + resolved "https://registry.yarnpkg.com/@types/statuses/-/statuses-2.0.6.tgz#66748315cc9a96d63403baa8671b2c124f8633aa" + integrity sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA== + +"@types/tough-cookie@*", "@types/tough-cookie@^4.0.5": 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== @@ -867,10 +960,10 @@ acorn-walk@^8.0.2: 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.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" - integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== +acorn@^8.1.0, acorn@^8.11.0, acorn@^8.14.0, acorn@^8.8.1: + version "8.15.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.15.0.tgz#a360898bc415edaac46c8241f6383975b930b816" + integrity sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg== agent-base@6: version "6.0.2" @@ -903,7 +996,7 @@ ajv@^8.0.0, ajv@^8.9.0: json-schema-traverse "^1.0.0" require-from-string "^2.0.2" -ansi-escapes@^4.2.1: +ansi-escapes@^4.2.1, ansi-escapes@^4.3.2: 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== @@ -1026,17 +1119,17 @@ base64-js@^1.3.1: 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== + version "1.1.12" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.12.tgz#ab9b454466e5a8cc3a187beaad580412a9c5b843" + integrity sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg== dependencies: balanced-match "^1.0.0" concat-map "0.0.1" brace-expansion@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" - integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + version "2.0.2" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.2.tgz#54fc53237a613d854c7bd37463aad17df87214e7" + integrity sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ== dependencies: balanced-match "^1.0.0" @@ -1048,12 +1141,12 @@ braces@^3.0.3: fill-range "^7.1.1" browserslist@^4.24.0: - version "4.24.5" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.5.tgz#aa0f5b8560fe81fde84c6dcb38f759bafba0e11b" - integrity sha512-FDToo4Wo82hIdgc1CQ+NQD0hEhmpPjrZ3hiUgwgOG6IuTdlpr8jdjyG24P6cNP1yJpTLzS5OcGgSw0xmDU1/Tw== + version "4.25.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.25.1.tgz#ba9e8e6f298a1d86f829c9b975e07948967bb111" + integrity sha512-KGj0KoOMXLpSNkkEI6Z6mShmQy0bc1I+T7K9N81k4WWMrfz+6fQ6es80B/YLAeRoKvjYE1YSHHOW1qe9xIVzHw== dependencies: - caniuse-lite "^1.0.30001716" - electron-to-chromium "^1.5.149" + caniuse-lite "^1.0.30001726" + electron-to-chromium "^1.5.173" node-releases "^2.0.19" update-browserslist-db "^1.1.3" @@ -1115,10 +1208,10 @@ camelcase@^6.2.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -caniuse-lite@^1.0.30001716: - version "1.0.30001717" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001717.tgz#5d9fec5ce09796a1893013825510678928aca129" - integrity sha512-auPpttCq6BDEG8ZAuHJIplGw6GODhjw+/11e7IjpnYCxZcW/ONgPs0KVBJ0d1bY3e2+7PRe5RCLyP+PfwVgkYw== +caniuse-lite@^1.0.30001726: + version "1.0.30001726" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001726.tgz#a15bd87d5a4bf01f6b6f70ae7c97fdfd28b5ae47" + integrity sha512-VQAUIUzBiZ/UnlM28fSp2CRF3ivUn1BWEvxMcVTNwpw91Py1pGbPIyIKtd+tzct9C3ouceCVdGAXxZOpZAsgdw== chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0: version "4.1.2" @@ -1148,6 +1241,11 @@ cjs-module-lexer@^1.0.0: resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.4.3.tgz#0f79731eb8cfe1ec72acd4066efac9d61991b00d" integrity sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q== +cli-width@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-4.1.0.tgz#42daac41d3c254ef38ad8ac037672130173691c5" + integrity sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ== + cliui@^8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" @@ -1201,6 +1299,11 @@ convert-source-map@^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== +cookie@^0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.7.2.tgz#556369c472a2ba910f2979891b526b3436237ed7" + integrity sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w== + create-jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320" @@ -1250,9 +1353,9 @@ data-urls@^3.0.2: whatwg-url "^11.0.0" debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: - version "4.4.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" - integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== + version "4.4.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b" + integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ== dependencies: ms "^2.1.3" @@ -1309,10 +1412,10 @@ ejs@^3.1.10: dependencies: jake "^10.8.5" -electron-to-chromium@^1.5.149: - version "1.5.151" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.151.tgz#5edd6c17e1b2f14b4662c41b9379f96cc8c2bb7c" - integrity sha512-Rl6uugut2l9sLojjS4H4SAr3A4IgACMLgpuEMPYCVcKydzfyPrn5absNRju38IhQOf/NwjJY8OGWjlteqYeBCA== +electron-to-chromium@^1.5.173: + version "1.5.176" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.176.tgz#f4bbbd2c0a9a6a2a527c884eacc18244fa79dd88" + integrity sha512-2nDK9orkm7M9ZZkjO3PjbEd3VUulQLyg5T9O3enJdFvUg46Hzd4DUvTvAuEgbdHYXyFsiG4A5sO9IzToMH1cDg== emittery@^0.13.1: version "0.13.1" @@ -1325,17 +1428,17 @@ emoji-regex@^8.0.0: integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== enhanced-resolve@^5.0.0, enhanced-resolve@^5.17.1: - version "5.18.1" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.18.1.tgz#728ab082f8b7b6836de51f1637aab5d3b9568faf" - integrity sha512-ZSW3ma5GkcQBIpwZTSRAI8N71Uuwgs93IezB7mf7R60tC8ZbJideoDNKjHn2O9KIlx6rkGTTEk1xUCK2E1Y2Yg== + version "5.18.2" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.18.2.tgz#7903c5b32ffd4b2143eeb4b92472bd68effd5464" + integrity sha512-6Jw4sE1maoRJo3q8MsSIn2onJFbLTOjY9hlx4DZXmOKvLRd1Ok2kXmAGXaafL2+ijsJZ1ClYbl/pmqr9+k4iUQ== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" entities@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-6.0.0.tgz#09c9e29cb79b0a6459a9b9db9efb418ac5bb8e51" - integrity sha512-aKstq2TDOndCn4diEyp9Uq/Flu2i1GlLkc6XIDQSDMuaFE3OPW5OphLCyQ5SpSJZTb4reN+kTcYru5yIfXoRPw== + version "6.0.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-6.0.1.tgz#c28c34a43379ca7f61d074130b2f5f7020a30694" + integrity sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g== error-ex@^1.3.1: version "1.3.2" @@ -1518,18 +1621,19 @@ find-up@^4.0.0, find-up@^4.1.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== + version "4.1.0" + resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-4.1.0.tgz#497cedc94810bd5d53b99b5d4f6c152d5cbc9db2" + integrity sha512-G6NsmEW15s0Uw9XnCg+33H3ViYRyiM0hMrMhhqQOR8NFc5GhYrI+6I3u7OTw7b91J2g8rtvMBZJDbcGb2YUniw== form-data@^4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.2.tgz#35cabbdd30c3ce73deb2c42d3c8d3ed9ca51794c" - integrity sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w== + version "4.0.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.3.tgz#608b1b3f3e28be0fccf5901fc85fb3641e5cf0ae" + integrity sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA== dependencies: asynckit "^0.4.0" combined-stream "^1.0.8" es-set-tostringtag "^2.1.0" + hasown "^2.0.2" mime-types "^2.1.12" formdata-node@^6.0.3: @@ -1628,6 +1732,11 @@ graceful-fs@^4.1.2, graceful-fs@^4.2.11, graceful-fs@^4.2.4, graceful-fs@^4.2.9: 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== +graphql@^16.8.1: + version "16.11.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.11.0.tgz#96d17f66370678027fdf59b2d4c20b4efaa8a633" + integrity sha512-mS1lbMsxgQj6hge1XZ6p7GPhbrtFwUFYi3wRzXAC/FmYnyXMTvvI3td3rjmQ2u8ewXueaSvRPWaEcgVVOT9Jnw== + has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" @@ -1652,6 +1761,11 @@ hasown@^2.0.2: dependencies: function-bind "^1.1.2" +headers-polyfill@^4.0.2: + version "4.0.3" + resolved "https://registry.yarnpkg.com/headers-polyfill/-/headers-polyfill-4.0.3.tgz#922a0155de30ecc1f785bcf04be77844ca95ad07" + integrity sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ== + 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" @@ -1746,6 +1860,11 @@ is-generator-fn@^2.0.0: resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== +is-node-process@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-node-process/-/is-node-process-1.2.0.tgz#ea02a1b90ddb3934a19aea414e88edef7e11d134" + integrity sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw== + is-number@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" @@ -2143,7 +2262,7 @@ jest-snapshot@^29.7.0: pretty-format "^29.7.0" semver "^7.5.3" -jest-util@^29.0.0, jest-util@^29.7.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== @@ -2392,6 +2511,35 @@ ms@^2.1.3: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +msw@^2.8.4: + version "2.10.2" + resolved "https://registry.yarnpkg.com/msw/-/msw-2.10.2.tgz#e7a56ed0b6865b00a30b4c4a5b59e5388fd48315" + integrity sha512-RCKM6IZseZQCWcSWlutdf590M8nVfRHG1ImwzOtwz8IYxgT4zhUO0rfTcTvDGiaFE0Rhcc+h43lcF3Jc9gFtwQ== + dependencies: + "@bundled-es-modules/cookie" "^2.0.1" + "@bundled-es-modules/statuses" "^1.0.1" + "@bundled-es-modules/tough-cookie" "^0.1.6" + "@inquirer/confirm" "^5.0.0" + "@mswjs/interceptors" "^0.39.1" + "@open-draft/deferred-promise" "^2.2.0" + "@open-draft/until" "^2.1.0" + "@types/cookie" "^0.6.0" + "@types/statuses" "^2.0.4" + graphql "^16.8.1" + headers-polyfill "^4.0.2" + is-node-process "^1.2.0" + outvariant "^1.4.3" + path-to-regexp "^6.3.0" + picocolors "^1.1.1" + strict-event-emitter "^0.5.1" + type-fest "^4.26.1" + yargs "^17.7.2" + +mute-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-2.0.0.tgz#a5446fc0c512b71c83c44d908d5c7b7b4c493b2b" + integrity sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -2455,6 +2603,11 @@ onetime@^5.1.2: dependencies: mimic-fn "^2.1.0" +outvariant@^1.4.0, outvariant@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/outvariant/-/outvariant-1.4.3.tgz#221c1bfc093e8fec7075497e7799fdbf43d14873" + integrity sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA== + p-limit@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" @@ -2518,6 +2671,11 @@ path-parse@^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@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.3.0.tgz#2b6a26a337737a8e1416f9272ed0766b1c0389f4" + integrity sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ== + picocolors@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" @@ -2541,9 +2699,9 @@ pkg-dir@^4.2.0: find-up "^4.0.0" prettier@^3.4.2: - version "3.5.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.5.3.tgz#4fc2ce0d657e7a02e602549f053b239cb7dfe1b5" - integrity sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw== + version "3.6.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.6.1.tgz#cc3bce21c09a477b1e987b76ce9663925d86ae44" + integrity sha512-5xGWRa90Sp2+x1dQtNpIpeOQpTDBs9cZDmA/qs2vDNN2i18PdapqY7CmBeyLlMuGqXJRIOPaCaVZTLNQRWUH/A== pretty-format@^29.0.0, pretty-format@^29.7.0: version "29.7.0" @@ -2665,11 +2823,6 @@ safe-buffer@^5.1.0, safe-buffer@~5.2.0: 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" @@ -2697,10 +2850,10 @@ semver@^6.3.0, semver@^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, semver@^7.7.1: - version "7.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.1.tgz#abd5098d82b18c6c81f6074ff2647fd3e7220c9f" - integrity sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA== +semver@^7.3.4, semver@^7.5.3, semver@^7.5.4, semver@^7.7.2: + version "7.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.2.tgz#67d99fdcd35cec21e6f8b87a7fd515a33f982b58" + integrity sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA== serialize-javascript@^6.0.2: version "6.0.2" @@ -2766,6 +2919,11 @@ signal-exit@^3.0.3, signal-exit@^3.0.7: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +signal-exit@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" @@ -2814,6 +2972,16 @@ stack-utils@^2.0.3: dependencies: escape-string-regexp "^2.0.0" +statuses@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.2.tgz#8f75eecef765b5e1cfcdc080da59409ed424e382" + integrity sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw== + +strict-event-emitter@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz#1602ece81c51574ca39c6815e09f1a3e8550bd93" + integrity sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ== + string-length@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a" @@ -2885,9 +3053,9 @@ symbol-tree@^3.2.4: 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== + version "2.2.2" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.2.tgz#ab4984340d30cb9989a490032f086dbb8b56d872" + integrity sha512-Re10+NauLTMCudc7T5WLFLAwDhQ0JWdrMK+9B2M8zR5hRExKmsRDCBA7/aV/pNJFltmBFO5BAMlQFi/vq3nKOg== terser-webpack-plugin@^5.3.11: version "5.3.14" @@ -2901,12 +3069,12 @@ terser-webpack-plugin@^5.3.11: terser "^5.31.1" terser@^5.31.1: - version "5.39.0" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.39.0.tgz#0e82033ed57b3ddf1f96708d123cca717d86ca3a" - integrity sha512-LBAhFyLho16harJoWMg/nZsQYgTrg5jXOn2nCYjRUcZZEdE3qa2zb8QEDRUGVZBW4rlazf2fxkg8tztybTaqWw== + version "5.43.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.43.1.tgz#88387f4f9794ff1a29e7ad61fb2932e25b4fdb6d" + integrity sha512-+6erLbBm0+LROX2sPXlUYx/ux5PyE9K/a92Wrt6oA+WDAoFTdpHE5tCYCI5PNzq2y8df4rA+QgHLJuR4jNymsg== dependencies: "@jridgewell/source-map" "^0.3.3" - acorn "^8.8.2" + acorn "^8.14.0" commander "^2.20.0" source-map-support "~0.5.20" @@ -2931,7 +3099,7 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -tough-cookie@^4.1.2: +tough-cookie@^4.1.2, tough-cookie@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.4.tgz#945f1461b45b5a8c76821c33ea49c3ac192c1b36" integrity sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag== @@ -2953,20 +3121,19 @@ tr46@~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.3.2" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.3.2.tgz#0576cdf0a507f811fe73dcd16d135ce89f8156cb" - integrity sha512-bJJkrWc6PjFVz5g2DGCNUo8z7oFEYaz1xP1NpeDU7KNLMWPpEyV8Chbpkn8xjzgRDpQhnGMyvyldoL7h8JXyug== +ts-jest@^29.3.4: + version "29.4.0" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.4.0.tgz#bef0ee98d94c83670af7462a1617bf2367a83740" + integrity sha512-d423TJMnJGu80/eSgfQ5w/R+0zFJvdtTxwtF9KzFFunOpSeD+79lHJQIiAhluJoyGRbvj9NZJsl9WjCUo0ND7Q== dependencies: bs-logger "^0.2.6" ejs "^3.1.10" fast-json-stable-stringify "^2.1.0" - jest-util "^29.0.0" json5 "^2.2.3" lodash.memoize "^4.1.2" make-error "^1.3.6" - semver "^7.7.1" - type-fest "^4.39.1" + semver "^7.7.2" + type-fest "^4.41.0" yargs-parser "^21.1.1" ts-loader@^9.5.1: @@ -2990,7 +3157,7 @@ type-fest@^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== -type-fest@^4.39.1: +type-fest@^4.26.1, type-fest@^4.41.0: version "4.41.0" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.41.0.tgz#6ae1c8e5731273c2bf1f58ad39cbae2c91a46c58" integrity sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA== @@ -3005,10 +3172,10 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici-types@~6.21.0: - version "6.21.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" - integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== +undici-types@~7.8.0: + version "7.8.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.8.0.tgz#de00b85b710c54122e44fbfd911f8d70174cd294" + integrity sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw== universalify@^0.2.0: version "0.2.0" @@ -3060,9 +3227,9 @@ walker@^1.0.8: 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== + version "2.4.4" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.4.tgz#473bda72f0850453da6425081ea46fc0d7602947" + integrity sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA== dependencies: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2" @@ -3078,14 +3245,14 @@ webidl-conversions@^7.0.0: 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== + version "3.3.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.3.3.tgz#d4bf7f9909675d7a070ff14d0ef2a4f3c982c723" + integrity sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg== webpack@^5.97.1: - version "5.99.8" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.99.8.tgz#dd31a020b7c092d30c4c6d9a4edb95809e7f5946" - integrity sha512-lQ3CPiSTpfOnrEGeXDwoq5hIGzSjmwD72GdfVzF7CQAI7t47rJG9eDWvcEkEn3CUQymAElVvDg3YNTlCYj+qUQ== + version "5.99.9" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.99.9.tgz#d7de799ec17d0cce3c83b70744b4aedb537d8247" + integrity sha512-brOPwM3JnmOa+7kd3NsmOUOwbDAj8FT9xDsG3IW0MgbN9yZV7Oi/s/+MNQ/EcSMqw7qfoRyXPoeEWT8zLVdVGg== dependencies: "@types/eslint-scope" "^3.7.7" "@types/estree" "^1.0.6" @@ -3147,6 +3314,15 @@ which@^2.0.1: dependencies: isexe "^2.0.0" +wrap-ansi@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" + integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.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" @@ -3199,7 +3375,7 @@ yargs-parser@^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: +yargs@^17.3.1, yargs@^17.7.2: version "17.7.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== @@ -3216,3 +3392,8 @@ 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== + +yoctocolors-cjs@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz#f4b905a840a37506813a7acaa28febe97767a242" + integrity sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==