From ddd0434d9e362e10bfadccf9d68c9a615a823d28 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Thu, 12 Sep 2024 00:16:16 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.396.2 --- .speakeasy/workflow.lock | 10 +- RELEASES.md | 10 +- accounting/{.eslintrc.js => .eslintrc.cjs} | 0 accounting/.gitignore | 7 + accounting/.npmignore | 3 + accounting/.speakeasy/gen.lock | 895 ++++++++++++++++-- accounting/CONTRIBUTING.md | 26 + accounting/FUNCTIONS.md | 104 ++ accounting/README.md | 326 +++++-- accounting/RUNTIMES.md | 2 +- accounting/USAGE.md | 16 +- .../models/operations/createaccountrequest.md | 24 + .../operations/createaccountresponse.md | 31 + .../models/operations/getaccountrequest.md | 10 + .../models/operations/getaccountresponse.md | 30 + .../getaccounttransactionrequest.md | 11 + .../getaccounttransactionresponse.md | 27 + .../getcreatechartofaccountsmodelrequest.md | 10 + .../getcreatechartofaccountsmodelresponse.md | 13 + .../models/operations/listaccountsrequest.md | 13 + .../models/operations/listaccountsresponse.md | 45 + .../listaccounttransactionsrequest.md | 14 + .../listaccounttransactionsresponse.md | 42 + accounting/docs/sdk/models/shared/account.md | 22 + .../sdk/models/shared/accountingaccount.md | 22 + .../sdk/models/shared/accountprototype.md | 19 + accounting/docs/sdk/models/shared/accounts.md | 37 + .../docs/sdk/models/shared/accountstatus.md | 7 + .../sdk/models/shared/accounttransaction.md | 19 + .../models/shared/accounttransactionline.md | 11 + .../shared/accounttransactionlinerecordref.md | 9 + ...accounttransactionlinerecordrefdatatype.md | 8 + .../sdk/models/shared/accounttransactions.md | 34 + .../docs/sdk/models/shared/accounttype.md | 7 + .../docs/sdk/models/shared/bankaccountref.md | 7 + .../models/shared/createaccountresponse.md | 23 + accounting/docs/sdk/models/shared/datatype.md | 7 + .../docs/sdk/models/shared/errormessage.md | 7 + .../docs/sdk/models/shared/errorvalidation.md | 7 + .../sdk/models/shared/errorvalidationitem.md | 7 + accounting/docs/sdk/models/shared/halref.md | 7 + accounting/docs/sdk/models/shared/links.md | 14 + accounting/docs/sdk/models/shared/metadata.md | 7 + .../docs/sdk/models/shared/pushchangetype.md | 7 + .../sdk/models/shared/pushfieldvalidation.md | 9 + .../sdk/models/shared/pushoperationchange.md | 11 + .../sdk/models/shared/pushoperationref.md | 9 + .../sdk/models/shared/pushoperationstatus.md | 7 + .../docs/sdk/models/shared/pushoption.md | 11 + .../sdk/models/shared/pushoptionchoice.md | 7 + .../sdk/models/shared/pushoptionproperty.md | 12 + .../docs/sdk/models/shared/pushoptiontype.md | 7 + .../sdk/models/shared/pushvalidationinfo.md | 7 + accounting/docs/sdk/models/shared/security.md | 9 + accounting/docs/sdk/models/shared/status.md | 7 + .../sdk/models/shared/supplementaldata.md | 7 + .../docs/sdk/models/shared/validation.md | 7 + .../docs/sdk/models/shared/validationitem.md | 7 + .../sdk/models/shared/validdatatypelinks.md | 7 + accounting/docs/sdks/accounting/README.md | 6 +- accounting/docs/sdks/accounts/README.md | 151 ++- .../docs/sdks/accounttransactions/README.md | 72 +- accounting/gen.yaml | 4 +- accounting/jsr.json | 2 +- accounting/package-lock.json | 27 +- accounting/package.json | 6 +- accounting/src/core.ts | 13 + .../src/funcs/accountTransactionsGet.ts | 172 ++++ .../src/funcs/accountTransactionsList.ts | 170 ++++ accounting/src/funcs/accountsCreate.ts | 183 ++++ accounting/src/funcs/accountsGet.ts | 164 ++++ .../src/funcs/accountsGetCreateModel.ts | 171 ++++ accounting/src/funcs/accountsList.ts | 163 ++++ accounting/src/hooks/hooks.ts | 177 ++-- accounting/src/hooks/index.ts | 6 +- accounting/src/hooks/types.ts | 111 ++- accounting/src/index.ts | 7 +- accounting/src/lib/base64.ts | 2 +- accounting/src/lib/config.ts | 80 +- accounting/src/lib/dlv.ts | 53 ++ accounting/src/lib/encodings.ts | 82 +- accounting/src/lib/files.ts | 40 + accounting/src/lib/http.ts | 694 +++++--------- accounting/src/lib/is-plain-object.ts | 2 +- accounting/src/lib/logger.ts | 9 + accounting/src/lib/matchers.ts | 319 +++++++ accounting/src/lib/primitives.ts | 40 + accounting/src/lib/retries.ts | 45 +- accounting/src/lib/schemas.ts | 86 +- accounting/src/lib/sdks.ts | 449 ++++++--- accounting/src/lib/security.ts | 301 +++--- accounting/src/lib/url.ts | 2 +- accounting/src/sdk/accounts.ts | 628 +++--------- accounting/src/sdk/accounttransactions.ts | 335 ++----- accounting/src/sdk/index.ts | 4 +- .../src/sdk/models/errors/httpclienterrors.ts | 62 ++ accounting/src/sdk/models/errors/index.ts | 7 +- accounting/src/sdk/models/errors/sdkerror.ts | 34 +- .../sdk/models/errors/sdkvalidationerror.ts | 16 +- .../sdk/models/operations/createaccount.ts | 265 +++--- .../src/sdk/models/operations/getaccount.ts | 227 +++-- .../operations/getaccounttransaction.ts | 252 ++--- .../getcreatechartofaccountsmodel.ts | 247 ++--- accounting/src/sdk/models/operations/index.ts | 14 +- .../src/sdk/models/operations/listaccounts.ts | 275 +++--- .../operations/listaccounttransactions.ts | 301 +++--- accounting/src/sdk/models/shared/account.ts | 392 ++++---- .../src/sdk/models/shared/accountprototype.ts | 338 ++++--- accounting/src/sdk/models/shared/accounts.ts | 138 +-- .../src/sdk/models/shared/accountstatus.ts | 29 +- .../sdk/models/shared/accounttransaction.ts | 427 ++++----- .../models/shared/accounttransactionline.ts | 115 +-- .../shared/accounttransactionlinerecordref.ts | 127 +-- .../sdk/models/shared/accounttransactions.ts | 138 +-- .../src/sdk/models/shared/accounttype.ts | 31 +- .../src/sdk/models/shared/bankaccountref.ts | 79 +- .../models/shared/createaccountresponse.ts | 772 ++++++++------- accounting/src/sdk/models/shared/datatype.ts | 105 +- .../src/sdk/models/shared/errormessage.ts | 170 ++-- .../src/sdk/models/shared/errorvalidation.ts | 74 +- .../sdk/models/shared/errorvalidationitem.ts | 95 +- accounting/src/sdk/models/shared/halref.ts | 60 +- accounting/src/sdk/models/shared/index.ts | 68 +- accounting/src/sdk/models/shared/links.ts | 91 +- accounting/src/sdk/models/shared/metadata.ts | 63 +- .../src/sdk/models/shared/pushchangetype.ts | 31 +- .../sdk/models/shared/pushfieldvalidation.ts | 95 +- .../sdk/models/shared/pushoperationchange.ts | 102 +- .../src/sdk/models/shared/pushoperationref.ts | 85 +- .../sdk/models/shared/pushoperationstatus.ts | 29 +- .../src/sdk/models/shared/pushoption.ts | 169 ++-- .../src/sdk/models/shared/pushoptionchoice.ts | 133 +-- .../sdk/models/shared/pushoptionproperty.ts | 169 ++-- .../src/sdk/models/shared/pushoptiontype.ts | 37 +- .../sdk/models/shared/pushvalidationinfo.ts | 76 +- accounting/src/sdk/models/shared/security.ts | 66 +- .../src/sdk/models/shared/supplementaldata.ts | 57 +- .../src/sdk/models/shared/validation.ts | 74 +- .../src/sdk/models/shared/validationitem.ts | 95 +- .../sdk/models/shared/validdatatypelinks.ts | 81 +- accounting/src/sdk/sdk.ts | 55 +- accounting/src/sdk/types/blobs.ts | 2 +- accounting/src/sdk/types/constdatetime.ts | 15 + accounting/src/sdk/types/decimal.ts | 2 +- accounting/src/sdk/types/enums.ts | 2 +- accounting/src/sdk/types/fp.ts | 50 + accounting/src/sdk/types/index.ts | 17 +- accounting/src/sdk/types/operations.ts | 90 +- accounting/src/sdk/types/rfcdate.ts | 2 +- accounting/src/sdk/types/streams.ts | 21 + lending/{.eslintrc.js => .eslintrc.cjs} | 0 lending/.gitignore | 7 + lending/.npmignore | 3 + lending/.speakeasy/gen.lock | 285 ++++-- lending/CONTRIBUTING.md | 26 + lending/FUNCTIONS.md | 104 ++ lending/README.md | 333 ++++--- lending/RUNTIMES.md | 2 +- lending/USAGE.md | 18 +- lending/docs/models/components/companies.md | 57 ++ lending/docs/models/components/company.md | 42 + .../models/components/companyrequestbody.md | 15 + lending/docs/models/components/connection.md | 24 + .../models/components/dataconnectionerror.md | 9 + .../models/components/dataconnectionstatus.md | 7 + .../docs/models/components/errorvalidation.md | 7 + .../models/components/errorvalidationitem.md | 7 + .../docs/models/components/groupreference.md | 9 + lending/docs/models/components/halref.md | 7 + .../docs/models/components/httpmetadata.md | 12 + lending/docs/models/components/items.md | 9 + lending/docs/models/components/links.md | 14 + lending/docs/models/components/security.md | 9 + lending/docs/models/components/sourcetype.md | 7 + lending/docs/models/errors/errormessage.md | 7 + .../operations/createcompanyresponse.md | 51 + .../models/operations/deletecompanyrequest.md | 9 + .../operations/deletecompanyresponse.md | 14 + .../models/operations/getcompanyrequest.md | 9 + .../models/operations/getcompanyresponse.md | 51 + .../models/operations/listcompaniesrequest.md | 12 + .../operations/listcompaniesresponse.md | 66 ++ .../models/operations/updatecompanyrequest.md | 18 + .../operations/updatecompanyresponse.md | 51 + lending/docs/sdks/companies/README.md | 180 +++- lending/docs/sdks/lendingts/README.md | 6 +- lending/gen.yaml | 4 +- lending/jsr.json | 2 +- lending/package-lock.json | 27 +- lending/package.json | 6 +- lending/src/core.ts | 13 + lending/src/funcs/companiesCreate.ts | 150 +++ lending/src/funcs/companiesDelete.ts | 150 +++ lending/src/funcs/companiesGet.ts | 152 +++ lending/src/funcs/companiesList.ts | 170 ++++ lending/src/funcs/companiesUpdate.ts | 162 ++++ lending/src/hooks/hooks.ts | 177 ++-- lending/src/hooks/index.ts | 6 +- lending/src/hooks/types.ts | 111 ++- lending/src/index.ts | 7 +- lending/src/lib/base64.ts | 2 +- lending/src/lib/config.ts | 80 +- lending/src/lib/dlv.ts | 53 ++ lending/src/lib/encodings.ts | 82 +- lending/src/lib/files.ts | 40 + lending/src/lib/http.ts | 691 +++++--------- lending/src/lib/is-plain-object.ts | 2 +- lending/src/lib/logger.ts | 9 + lending/src/lib/matchers.ts | 316 +++++++ lending/src/lib/primitives.ts | 40 + lending/src/lib/retries.ts | 45 +- lending/src/lib/schemas.ts | 86 +- lending/src/lib/sdks.ts | 449 ++++++--- lending/src/lib/security.ts | 301 +++--- lending/src/lib/url.ts | 2 +- lending/src/models/components/companies.ts | 138 +-- lending/src/models/components/company.ts | 354 ++++--- .../models/components/companyrequestbody.ts | 102 +- lending/src/models/components/connection.ts | 365 ++++--- .../models/components/dataconnectionerror.ts | 149 +-- .../models/components/dataconnectionstatus.ts | 29 +- .../src/models/components/errorvalidation.ts | 74 +- .../models/components/errorvalidationitem.ts | 95 +- lending/src/models/components/halref.ts | 60 +- lending/src/models/components/httpmetadata.ts | 98 +- lending/src/models/components/index.ts | 28 +- lending/src/models/components/items.ts | 60 +- lending/src/models/components/links.ts | 91 +- lending/src/models/components/security.ts | 66 +- lending/src/models/errors/errormessage.ts | 286 +++--- lending/src/models/errors/httpclienterrors.ts | 62 ++ lending/src/models/errors/index.ts | 9 +- lending/src/models/errors/sdkerror.ts | 30 +- .../src/models/errors/sdkvalidationerror.ts | 16 +- .../src/models/operations/createcompany.ts | 86 +- .../src/models/operations/deletecompany.ts | 129 ++- lending/src/models/operations/getcompany.ts | 147 +-- lending/src/models/operations/index.ts | 12 +- .../src/models/operations/listcompanies.ts | 195 ++-- .../src/models/operations/updatecompany.ts | 169 ++-- lending/src/sdk/companies.ts | 681 +++---------- lending/src/sdk/index.ts | 4 +- lending/src/sdk/sdk.ts | 43 +- lending/src/types/blobs.ts | 2 +- lending/src/types/constdatetime.ts | 15 + lending/src/types/enums.ts | 2 +- lending/src/types/fp.ts | 50 + lending/src/types/index.ts | 15 +- lending/src/types/operations.ts | 90 +- lending/src/types/rfcdate.ts | 2 +- lending/src/types/streams.ts | 21 + 251 files changed, 14017 insertions(+), 8004 deletions(-) rename accounting/{.eslintrc.js => .eslintrc.cjs} (100%) create mode 100644 accounting/CONTRIBUTING.md create mode 100644 accounting/FUNCTIONS.md create mode 100644 accounting/src/core.ts create mode 100644 accounting/src/funcs/accountTransactionsGet.ts create mode 100644 accounting/src/funcs/accountTransactionsList.ts create mode 100644 accounting/src/funcs/accountsCreate.ts create mode 100644 accounting/src/funcs/accountsGet.ts create mode 100644 accounting/src/funcs/accountsGetCreateModel.ts create mode 100644 accounting/src/funcs/accountsList.ts create mode 100644 accounting/src/lib/dlv.ts create mode 100644 accounting/src/lib/files.ts create mode 100644 accounting/src/lib/logger.ts create mode 100644 accounting/src/lib/matchers.ts create mode 100644 accounting/src/lib/primitives.ts create mode 100644 accounting/src/sdk/models/errors/httpclienterrors.ts create mode 100644 accounting/src/sdk/types/constdatetime.ts create mode 100644 accounting/src/sdk/types/fp.ts create mode 100644 accounting/src/sdk/types/streams.ts rename lending/{.eslintrc.js => .eslintrc.cjs} (100%) create mode 100644 lending/CONTRIBUTING.md create mode 100644 lending/FUNCTIONS.md create mode 100644 lending/src/core.ts create mode 100644 lending/src/funcs/companiesCreate.ts create mode 100644 lending/src/funcs/companiesDelete.ts create mode 100644 lending/src/funcs/companiesGet.ts create mode 100644 lending/src/funcs/companiesList.ts create mode 100644 lending/src/funcs/companiesUpdate.ts create mode 100644 lending/src/lib/dlv.ts create mode 100644 lending/src/lib/files.ts create mode 100644 lending/src/lib/logger.ts create mode 100644 lending/src/lib/matchers.ts create mode 100644 lending/src/lib/primitives.ts create mode 100644 lending/src/models/errors/httpclienterrors.ts create mode 100644 lending/src/types/constdatetime.ts create mode 100644 lending/src/types/fp.ts create mode 100644 lending/src/types/streams.ts diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 45786b53..85cebd06 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,15 +1,15 @@ -speakeasyVersion: 1.296.1 +speakeasyVersion: 1.396.2 sources: accounting: sourceNamespace: accounting - sourceRevisionDigest: sha256:5e282bee33d1b8996c9d4d9bd50724a57ba308514bcc7c0b69ee1c39f44cd39f + sourceRevisionDigest: sha256:430a64de9ff4076a9a5a65bc6528cf4105eb847dc12d69ea0214f4959846771d sourceBlobDigest: sha256:5f1cc761dc56e7ca4021510061eebb912db4ba7736e61c5a9ccd633a416c2611 tags: - latest - main lending: sourceNamespace: lending - sourceRevisionDigest: sha256:1f09cd1cbff0424a1970a73e4829a80f7ba7a339f3d720a793e9e2b65ad17fe1 + sourceRevisionDigest: sha256:178885971cf1c04155e742359cad4b10d0eba3a8d7de8e7a64d2e33a0678995d sourceBlobDigest: sha256:fa9d95b78d45713a72c0e0606cd94aab70c76d28d8edb2c33545d078dc15d36b tags: - latest @@ -18,13 +18,13 @@ targets: accounting-ts: source: accounting sourceNamespace: accounting - sourceRevisionDigest: sha256:5e282bee33d1b8996c9d4d9bd50724a57ba308514bcc7c0b69ee1c39f44cd39f + sourceRevisionDigest: sha256:430a64de9ff4076a9a5a65bc6528cf4105eb847dc12d69ea0214f4959846771d sourceBlobDigest: sha256:5f1cc761dc56e7ca4021510061eebb912db4ba7736e61c5a9ccd633a416c2611 outLocation: ./accounting lending-ts: source: lending sourceNamespace: lending - sourceRevisionDigest: sha256:1f09cd1cbff0424a1970a73e4829a80f7ba7a339f3d720a793e9e2b65ad17fe1 + sourceRevisionDigest: sha256:178885971cf1c04155e742359cad4b10d0eba3a8d7de8e7a64d2e33a0678995d sourceBlobDigest: sha256:fa9d95b78d45713a72c0e0606cd94aab70c76d28d8edb2c33545d078dc15d36b outLocation: ./lending workflow: diff --git a/RELEASES.md b/RELEASES.md index 48ffcd62..b5309a6a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6,4 +6,12 @@ Based on: - OpenAPI Doc - Speakeasy CLI 1.296.1 (2.338.1) https://github.com/speakeasy-api/speakeasy ### Generated -- [typescript v0.6.0] ./accounting \ No newline at end of file +- [typescript v0.6.0] ./accounting + +## 2024-09-12 00:14:53 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.396.2 (2.415.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.3.0] lending \ No newline at end of file diff --git a/accounting/.eslintrc.js b/accounting/.eslintrc.cjs similarity index 100% rename from accounting/.eslintrc.js rename to accounting/.eslintrc.cjs diff --git a/accounting/.gitignore b/accounting/.gitignore index 8a540c2d..a5ea559b 100755 --- a/accounting/.gitignore +++ b/accounting/.gitignore @@ -1,3 +1,10 @@ +/funcs +/core.* +/esm +/dist +/.tshy +/.tshy-* +/__tests__ /models /sdk/models/errors /sdk/types diff --git a/accounting/.npmignore b/accounting/.npmignore index 709e6847..06cd8abf 100644 --- a/accounting/.npmignore +++ b/accounting/.npmignore @@ -5,3 +5,6 @@ /.eslintrc.js /cjs +/.tshy +/.tshy-* +/__tests__ diff --git a/accounting/.speakeasy/gen.lock b/accounting/.speakeasy/gen.lock index 89cb6c2b..39a695ec 100755 --- a/accounting/.speakeasy/gen.lock +++ b/accounting/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: ef897581-6141-4d3b-8020-231752f2daa4 management: docChecksum: dffee27feb3ffdf16d0b73e130a6aa81 docVersion: 3.0.0 - speakeasyVersion: 1.296.1 - generationVersion: 2.338.1 - releaseVersion: 0.6.0 - configChecksum: 570d101049edb659aba0d294fd2011b8 + speakeasyVersion: 1.396.2 + generationVersion: 2.415.0 + releaseVersion: 0.7.0 + configChecksum: abf289594536ee1928a228fa07f22a78 repoURL: https://github.com/speakeasy-sdks/template-sdk-monorepo.git repoSubDirectory: accounting installationURL: https://gitpkg.now.sh/speakeasy-sdks/template-sdk-monorepo/accounting @@ -14,13 +14,15 @@ management: features: typescript: additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.5 - core: 3.9.9 + constsAndDefaults: 0.1.11 + core: 3.17.0 decimal: 0.1.2 + defaultEnabledRetries: 0.1.0 deprecations: 2.81.1 + envVarSecurityUsage: 0.1.1 examples: 2.81.4 flattening: 2.81.1 - globalSecurity: 2.82.9 + globalSecurity: 2.82.11 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 globalServerURLs: 2.82.4 @@ -30,132 +32,821 @@ features: responseFormat: 0.2.3 retries: 2.83.0 sdkHooks: 0.1.0 + serverEventsSentinels: 0.1.0 generatedFiles: - - src/sdk/accounttransactions.ts - - src/sdk/accounts.ts - - src/sdk/sdk.ts - - .eslintrc.js + - .eslintrc.cjs + - .gitattributes - .npmignore + - CONTRIBUTING.md + - FUNCTIONS.md - RUNTIMES.md + - USAGE.md + - docs/lib/utils/retryconfig.md + - docs/sdk/models/operations/createaccountrequest.md + - docs/sdk/models/operations/createaccountresponse.md + - docs/sdk/models/operations/getaccountrequest.md + - docs/sdk/models/operations/getaccountresponse.md + - docs/sdk/models/operations/getaccounttransactionrequest.md + - docs/sdk/models/operations/getaccounttransactionresponse.md + - docs/sdk/models/operations/getcreatechartofaccountsmodelrequest.md + - docs/sdk/models/operations/getcreatechartofaccountsmodelresponse.md + - docs/sdk/models/operations/listaccountsrequest.md + - docs/sdk/models/operations/listaccountsresponse.md + - docs/sdk/models/operations/listaccounttransactionsrequest.md + - docs/sdk/models/operations/listaccounttransactionsresponse.md + - docs/sdk/models/shared/account.md + - docs/sdk/models/shared/accountingaccount.md + - docs/sdk/models/shared/accountprototype.md + - docs/sdk/models/shared/accounts.md + - docs/sdk/models/shared/accountstatus.md + - docs/sdk/models/shared/accounttransaction.md + - docs/sdk/models/shared/accounttransactionline.md + - docs/sdk/models/shared/accounttransactionlinerecordref.md + - docs/sdk/models/shared/accounttransactionlinerecordrefdatatype.md + - docs/sdk/models/shared/accounttransactions.md + - docs/sdk/models/shared/accounttype.md + - docs/sdk/models/shared/bankaccountref.md + - docs/sdk/models/shared/createaccountresponse.md + - docs/sdk/models/shared/datatype.md + - docs/sdk/models/shared/errormessage.md + - docs/sdk/models/shared/errorvalidation.md + - docs/sdk/models/shared/errorvalidationitem.md + - docs/sdk/models/shared/halref.md + - docs/sdk/models/shared/links.md + - docs/sdk/models/shared/metadata.md + - docs/sdk/models/shared/pushchangetype.md + - docs/sdk/models/shared/pushfieldvalidation.md + - docs/sdk/models/shared/pushoperationchange.md + - docs/sdk/models/shared/pushoperationref.md + - docs/sdk/models/shared/pushoperationstatus.md + - docs/sdk/models/shared/pushoption.md + - docs/sdk/models/shared/pushoptionchoice.md + - docs/sdk/models/shared/pushoptionproperty.md + - docs/sdk/models/shared/pushoptiontype.md + - docs/sdk/models/shared/pushvalidationinfo.md + - docs/sdk/models/shared/security.md + - docs/sdk/models/shared/status.md + - docs/sdk/models/shared/supplementaldata.md + - docs/sdk/models/shared/validation.md + - docs/sdk/models/shared/validationitem.md + - docs/sdk/models/shared/validdatatypelinks.md + - docs/sdks/accounting/README.md + - docs/sdks/accounts/README.md + - docs/sdks/accounttransactions/README.md - jsr.json - package.json + - src/core.ts + - src/funcs/accountTransactionsGet.ts + - src/funcs/accountTransactionsList.ts + - src/funcs/accountsCreate.ts + - src/funcs/accountsGet.ts + - src/funcs/accountsGetCreateModel.ts + - src/funcs/accountsList.ts + - src/hooks/hooks.ts + - src/hooks/index.ts + - src/hooks/types.ts - src/index.ts - src/lib/base64.ts - src/lib/config.ts + - src/lib/dlv.ts - src/lib/encodings.ts + - src/lib/files.ts - src/lib/http.ts - src/lib/is-plain-object.ts + - src/lib/logger.ts + - src/lib/matchers.ts + - src/lib/primitives.ts - src/lib/retries.ts - src/lib/schemas.ts - src/lib/sdks.ts - src/lib/security.ts - src/lib/url.ts + - src/sdk/accounts.ts + - src/sdk/accounttransactions.ts - src/sdk/index.ts + - src/sdk/models/errors/httpclienterrors.ts + - src/sdk/models/errors/index.ts - src/sdk/models/errors/sdkerror.ts - src/sdk/models/errors/sdkvalidationerror.ts - - src/sdk/types/blobs.ts - - src/sdk/types/decimal.ts - - src/sdk/types/enums.ts - - src/sdk/types/index.ts - - src/sdk/types/operations.ts - - src/sdk/types/rfcdate.ts - - tsconfig.json - - src/sdk/models/operations/getaccounttransaction.ts - - src/sdk/models/operations/listaccounttransactions.ts - src/sdk/models/operations/createaccount.ts - src/sdk/models/operations/getaccount.ts + - src/sdk/models/operations/getaccounttransaction.ts - src/sdk/models/operations/getcreatechartofaccountsmodel.ts + - src/sdk/models/operations/index.ts - src/sdk/models/operations/listaccounts.ts - - src/sdk/models/shared/errormessage.ts - - src/sdk/models/shared/errorvalidation.ts - - src/sdk/models/shared/errorvalidationitem.ts + - src/sdk/models/operations/listaccounttransactions.ts + - src/sdk/models/shared/account.ts + - src/sdk/models/shared/accountprototype.ts + - src/sdk/models/shared/accounts.ts + - src/sdk/models/shared/accountstatus.ts - src/sdk/models/shared/accounttransaction.ts - - src/sdk/models/shared/metadata.ts - src/sdk/models/shared/accounttransactionline.ts - src/sdk/models/shared/accounttransactionlinerecordref.ts - - src/sdk/models/shared/bankaccountref.ts - src/sdk/models/shared/accounttransactions.ts - - src/sdk/models/shared/links.ts - - src/sdk/models/shared/halref.ts + - src/sdk/models/shared/accounttype.ts + - src/sdk/models/shared/bankaccountref.ts - src/sdk/models/shared/createaccountresponse.ts - - src/sdk/models/shared/validation.ts - - src/sdk/models/shared/validationitem.ts - - src/sdk/models/shared/pushoperationstatus.ts - src/sdk/models/shared/datatype.ts - - src/sdk/models/shared/validdatatypelinks.ts - - src/sdk/models/shared/accounttype.ts - - src/sdk/models/shared/supplementaldata.ts - - src/sdk/models/shared/accountstatus.ts - - src/sdk/models/shared/pushoperationchange.ts + - src/sdk/models/shared/errormessage.ts + - src/sdk/models/shared/errorvalidation.ts + - src/sdk/models/shared/errorvalidationitem.ts + - src/sdk/models/shared/halref.ts + - src/sdk/models/shared/index.ts + - src/sdk/models/shared/links.ts + - src/sdk/models/shared/metadata.ts - src/sdk/models/shared/pushchangetype.ts + - src/sdk/models/shared/pushfieldvalidation.ts + - src/sdk/models/shared/pushoperationchange.ts - src/sdk/models/shared/pushoperationref.ts - - src/sdk/models/shared/accountprototype.ts - - src/sdk/models/shared/account.ts + - src/sdk/models/shared/pushoperationstatus.ts - src/sdk/models/shared/pushoption.ts - - src/sdk/models/shared/pushvalidationinfo.ts - - src/sdk/models/shared/pushfieldvalidation.ts - - src/sdk/models/shared/pushoptiontype.ts - - src/sdk/models/shared/pushoptionproperty.ts - src/sdk/models/shared/pushoptionchoice.ts - - src/sdk/models/shared/accounts.ts + - src/sdk/models/shared/pushoptionproperty.ts + - src/sdk/models/shared/pushoptiontype.ts + - src/sdk/models/shared/pushvalidationinfo.ts - src/sdk/models/shared/security.ts - - src/sdk/models/errors/index.ts - - src/sdk/models/operations/index.ts - - src/sdk/models/shared/index.ts - - docs/sdk/models/operations/getaccounttransactionrequest.md - - docs/sdk/models/operations/getaccounttransactionresponse.md - - docs/sdk/models/operations/listaccounttransactionsrequest.md - - docs/sdk/models/operations/listaccounttransactionsresponse.md - - docs/sdk/models/operations/createaccountrequest.md - - docs/sdk/models/operations/createaccountresponse.md - - docs/sdk/models/operations/getaccountrequest.md - - docs/sdk/models/operations/getaccountresponse.md - - docs/sdk/models/operations/getcreatechartofaccountsmodelrequest.md - - docs/sdk/models/operations/getcreatechartofaccountsmodelresponse.md - - docs/sdk/models/operations/listaccountsrequest.md - - docs/sdk/models/operations/listaccountsresponse.md - - docs/sdk/models/shared/errormessage.md - - docs/sdk/models/shared/errorvalidation.md - - docs/sdk/models/shared/errorvalidationitem.md - - docs/sdk/models/shared/status.md - - docs/sdk/models/shared/accounttransaction.md - - docs/sdk/models/shared/metadata.md - - docs/sdk/models/shared/accounttransactionline.md - - docs/sdk/models/shared/accounttransactionlinerecordrefdatatype.md - - docs/sdk/models/shared/accounttransactionlinerecordref.md - - docs/sdk/models/shared/bankaccountref.md - - docs/sdk/models/shared/accounttransactions.md - - docs/sdk/models/shared/links.md - - docs/sdk/models/shared/halref.md - - docs/sdk/models/shared/accountingaccount.md - - docs/sdk/models/shared/createaccountresponse.md - - docs/sdk/models/shared/validation.md - - docs/sdk/models/shared/validationitem.md - - docs/sdk/models/shared/pushoperationstatus.md - - docs/sdk/models/shared/datatype.md - - docs/sdk/models/shared/validdatatypelinks.md - - docs/sdk/models/shared/accounttype.md - - docs/sdk/models/shared/supplementaldata.md - - docs/sdk/models/shared/accountstatus.md - - docs/sdk/models/shared/pushoperationchange.md - - docs/sdk/models/shared/pushchangetype.md - - docs/sdk/models/shared/pushoperationref.md - - docs/sdk/models/shared/accountprototype.md - - docs/sdk/models/shared/account.md - - docs/sdk/models/shared/pushoption.md - - docs/sdk/models/shared/pushvalidationinfo.md - - docs/sdk/models/shared/pushfieldvalidation.md - - docs/sdk/models/shared/pushoptiontype.md - - docs/sdk/models/shared/pushoptionproperty.md - - docs/sdk/models/shared/pushoptionchoice.md - - docs/sdk/models/shared/accounts.md - - docs/sdk/models/shared/security.md - - docs/sdks/accounting/README.md - - docs/lib/utils/retryconfig.md - - docs/sdks/accounttransactions/README.md - - docs/sdks/accounts/README.md - - USAGE.md - - .gitattributes - - src/hooks/hooks.ts - - src/hooks/types.ts - - src/hooks/index.ts + - src/sdk/models/shared/supplementaldata.ts + - src/sdk/models/shared/validation.ts + - src/sdk/models/shared/validationitem.ts + - src/sdk/models/shared/validdatatypelinks.ts + - src/sdk/sdk.ts + - src/sdk/types/blobs.ts + - src/sdk/types/constdatetime.ts + - src/sdk/types/decimal.ts + - src/sdk/types/enums.ts + - src/sdk/types/fp.ts + - src/sdk/types/index.ts + - src/sdk/types/operations.ts + - src/sdk/types/rfcdate.ts + - src/sdk/types/streams.ts + - tsconfig.json +examples: + get-account-transaction: + Clear Books: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + accountTransactionId: "" + responses: + "200": + application/json: {"bankAccountRef": {"id": "ff8fdc4c-2aad-4ec1-9430-6bd201832eb3", "name": "Undeposited Funds"}, "currency": "GBP", "currencyRate": 1, "date": "2022-04-19T00:00:00", "id": "062b3a9b-b04f-4d9c-9ebc-81dcb5bbf285", "lines": [{"amount": 188.33, "description": "Payment for direct income $38e8c917-0afc-4583-8ffe-1b53ad601197", "recordRef": {"dataType": "directIncomes", "id": "38e8c917-0afc-4583-8ffe-1b53ad601197"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T12:38:18", "note": "Direct income 38e8c917-0afc-4583-8ffe-1b53ad601197", "sourceModifiedDate": "2022-05-13T01:06:00", "status": "Unreconciled", "totalAmount": 188.33, "transactionId": "356deb9f-98e6-4d6f-8db3-b378241895a1"} + QuickBooks Desktop: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + accountTransactionId: "" + responses: + "200": + application/json: {"bankAccountRef": {"id": "20000-933270541", "name": "Checking"}, "currency": "GBP", "currencyRate": 1, "date": "2022-12-01T00:00:00", "id": "D7B-933784104", "lines": [{"amount": -1200, "recordRef": {"dataType": "directCosts", "id": "D7B-933784104"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:13:23", "sourceModifiedDate": "2023-12-16T05:04:10", "status": "Unknown", "totalAmount": -1200, "transactionId": "D7B-933784104"} + QuickBooks Online Sandbox: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + accountTransactionId: "" + responses: + "200": + application/json: {"bankAccountRef": {"id": "57", "name": "Visa Credit Card"}, "currency": "GBP", "currencyRate": 1, "date": "2015-08-12T00:00:00", "id": "85", "lines": [{"amount": -3831.8, "description": "Opening Balance from Bank", "recordRef": {"dataType": "directCosts", "id": "PUR-85"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:37:16", "note": "Opening Balance from Bank", "sourceModifiedDate": "2016-09-12T18:13:07Z", "status": "Unknown", "totalAmount": -3831.8, "transactionId": "85"} + QuickBooks Online: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + accountTransactionId: "" + responses: + "200": + application/json: {"bankAccountRef": {"id": "61", "name": "Dave PP Current"}, "currency": "GBP", "currencyRate": 1, "date": "2018-09-21T00:00:00", "id": "1", "lines": [{"amount": 170.23, "recordRef": {"dataType": "directIncomes", "id": "1"}}], "modifiedDate": "2023-01-18T11:03:12", "note": "Opening Balance from Bank", "sourceModifiedDate": "2018-12-17T14:56:20Z", "status": "Unknown", "totalAmount": 170.23, "transactionId": "1"} + Xero: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + accountTransactionId: "" + responses: + "200": + application/json: {"bankAccountRef": {"id": "bd9e85e0-0478-433d-ae9f-0b3c4f04bfe4", "name": "Business Bank Account"}, "currency": "GBP", "currencyRate": 1, "date": "2021-12-20T00:00:00", "id": "74004690-82a1-4810-aaca-6ce575af94b4", "lines": [{"amount": -7267.2, "recordRef": {"dataType": "billPayments", "id": "74004690-82a1-4810-aaca-6ce575af94b4"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-15T20:37:10", "sourceModifiedDate": "2021-01-02T22:51:40", "status": "Reconciled", "totalAmount": -7267.2, "transactionId": "74004690-82a1-4810-aaca-6ce575af94b4"} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + accountTransactionId: "" + responses: + "401": + application/json: {"canBeRetried": "Unknown", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "detailedErrorCode": 0, "error": "Unauthorized", "service": "PublicApi", "statusCode": 401} + list-account-transactions: + "": + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/{id}/data/{dataType}?page=1&pageSize=10"}, "self": {"href": "/companies/{id}/data/{dataType}"}}, "pageNumber": 1, "pageSize": 10, "results": [], "totalResults": 1} + "400": {} + Clear Books: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/354a121b-855f-4d25-90ad-0905b498c1c0/connections/57b731ba-1d45-4386-ba58-2a1ca0234624/data/accountTransactions?page=1&pageSize=2"}, "next": {"href": "/companies/354a121b-855f-4d25-90ad-0905b498c1c0/connections/57b731ba-1d45-4386-ba58-2a1ca0234624/data/accountTransactions?page=2&pageSize=2"}, "self": {"href": "/companies/354a121b-855f-4d25-90ad-0905b498c1c0/connections/57b731ba-1d45-4386-ba58-2a1ca0234624/data/accountTransactions"}}, "pageNumber": 1, "pageSize": 2, "results": [{"bankAccountRef": {"id": "ff8fdc4c-2aad-4ec1-9430-6bd201832eb3", "name": "Undeposited Funds"}, "currency": "GBP", "currencyRate": 1, "date": "2022-04-19T00:00:00", "id": "062b3a9b-b04f-4d9c-9ebc-81dcb5bbf285", "lines": [{"amount": 188.33, "description": "Payment for direct income $38e8c917-0afc-4583-8ffe-1b53ad601197", "recordRef": {"dataType": "directIncomes", "id": "38e8c917-0afc-4583-8ffe-1b53ad601197"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T12:38:18", "note": "Direct income 38e8c917-0afc-4583-8ffe-1b53ad601197", "sourceModifiedDate": "2022-05-13T01:06:00", "status": "Unreconciled", "totalAmount": 188.33, "transactionId": "356deb9f-98e6-4d6f-8db3-b378241895a1"}, {"bankAccountRef": {"id": "ff8fdc4c-2aad-4ec1-9430-6bd201832eb3", "name": "Undeposited Funds"}, "currency": "GBP", "currencyRate": 1, "date": "2022-04-19T00:00:00", "id": "f2656119-9521-4d51-a24d-003b44c1410b", "lines": [{"amount": 32095.91, "description": "Payment for direct income $c31a3778-e3ea-4d01-9281-dd2f291c8cb8", "recordRef": {"dataType": "directIncomes", "id": "c31a3778-e3ea-4d01-9281-dd2f291c8cb8"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T12:38:18", "note": "Direct income c31a3778-e3ea-4d01-9281-dd2f291c8cb8", "sourceModifiedDate": "2023-02-13T00:34:00", "status": "Void", "totalAmount": 32095.91, "transactionId": "1fde4f8f-68ca-48fc-8fe7-79ac467d2946"}], "totalResults": 1745} + QuickBooks Desktop: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/fc72ba08-af13-4474-b28a-01dcfa6cfb51/connections/2c26b4da-97d4-4ba9-baad-1e18b49b96ac/data/accountTransactions?page=1&pageSize=2"}, "next": {"href": "/companies/fc72ba08-af13-4474-b28a-01dcfa6cfb51/connections/2c26b4da-97d4-4ba9-baad-1e18b49b96ac/data/accountTransactions?page=2&pageSize=2"}, "self": {"href": "/companies/fc72ba08-af13-4474-b28a-01dcfa6cfb51/connections/2c26b4da-97d4-4ba9-baad-1e18b49b96ac/data/accountTransactions"}}, "pageNumber": 1, "pageSize": 2, "results": [{"bankAccountRef": {"id": "20000-933270541", "name": "Checking"}, "currency": "GBP", "currencyRate": 1, "date": "2022-12-01T00:00:00", "id": "D7B-933784104", "lines": [{"amount": -1200, "recordRef": {"dataType": "directCosts", "id": "D7B-933784104"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:13:23", "sourceModifiedDate": "2023-12-16T05:04:10", "status": "Unknown", "totalAmount": -1200, "transactionId": "D7B-933784104"}, {"bankAccountRef": {"id": "20000-933270541", "name": "Checking"}, "currency": "GBP", "currencyRate": 1, "date": "2022-12-05T00:00:00", "id": "DFA-933785132", "lines": [{"amount": -35, "recordRef": {"dataType": "directCosts", "id": "DFA-933785132"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:13:23", "sourceModifiedDate": "2023-12-16T05:04:11", "status": "Unknown", "totalAmount": -35, "transactionId": "DFA-933785132"}], "totalResults": 652} + QuickBooks Online Sandbox: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/5a7f3597-36e1-4216-86fe-289ad36088a6/connections/1f9f6013-f8a5-4278-8a47-3ab7fdb6c24c/data/accountTransactions?page=1&pageSize=2"}, "next": {"href": "/companies/5a7f3597-36e1-4216-86fe-289ad36088a6/connections/1f9f6013-f8a5-4278-8a47-3ab7fdb6c24c/data/accountTransactions?page=2&pageSize=2"}, "self": {"href": "/companies/5a7f3597-36e1-4216-86fe-289ad36088a6/connections/1f9f6013-f8a5-4278-8a47-3ab7fdb6c24c/data/accountTransactions"}}, "pageNumber": 1, "pageSize": 2, "results": [{"bankAccountRef": {"id": "57", "name": "Visa Credit Card"}, "currency": "GBP", "currencyRate": 1, "date": "2015-08-12T00:00:00", "id": "85", "lines": [{"amount": -3831.8, "description": "Opening Balance from Bank", "recordRef": {"dataType": "directCosts", "id": "PUR-85"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:37:16", "note": "Opening Balance from Bank", "sourceModifiedDate": "2016-09-12T18:13:07Z", "status": "Unknown", "totalAmount": -3831.8, "transactionId": "85"}, {"bankAccountRef": {"id": "81", "name": "Current"}, "currency": "GBP", "currencyRate": 1, "date": "2015-11-24T00:00:00", "id": "5", "lines": [{"amount": 10000, "description": "contribution to start business", "recordRef": {"dataType": "directIncomes", "id": "5-1"}}, {"amount": 25000, "description": "funds borrowed to start business", "recordRef": {"dataType": "directIncomes", "id": "5-2"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:37:17", "sourceModifiedDate": "2016-09-12T15:26:26Z", "status": "Unknown", "totalAmount": 35000, "transactionId": "5"}], "totalResults": 9141} + QuickBooks Online: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/10818b5e-6e6a-4ed4-a1c5-3e3efe626e87/connections/9e28a776-f4be-425b-8a3d-ad49956de2c9/data/accountTransactions?page=1&pageSize=2"}, "next": {"href": "/companies/10818b5e-6e6a-4ed4-a1c5-3e3efe626e87/connections/9e28a776-f4be-425b-8a3d-ad49956de2c9/data/accountTransactions?page=2&pageSize=2"}, "self": {"href": "/companies/10818b5e-6e6a-4ed4-a1c5-3e3efe626e87/connections/9e28a776-f4be-425b-8a3d-ad49956de2c9/data/accountTransactions"}}, "pageNumber": 1, "pageSize": 2, "results": [{"bankAccountRef": {"id": "61", "name": "Dave PP Current"}, "currency": "GBP", "currencyRate": 1, "date": "2018-09-21T00:00:00", "id": "1", "lines": [{"amount": 170.23, "recordRef": {"dataType": "directIncomes", "id": "1"}}], "modifiedDate": "2023-01-18T11:03:12", "note": "Opening Balance from Bank", "sourceModifiedDate": "2018-12-17T14:56:20Z", "status": "Unknown", "totalAmount": 170.23, "transactionId": "1"}, {"bankAccountRef": {"id": "61", "name": "Dave PP Current"}, "currency": "GBP", "currencyRate": 1, "date": "2018-09-21T00:00:00", "id": "15", "lines": [{"amount": -1.59, "description": "Payment to Google", "recordRef": {"dataType": "directCosts", "id": "PUR-15"}}], "modifiedDate": "2023-01-18T11:03:11", "note": "Payment to Google", "sourceModifiedDate": "2018-12-17T14:56:44Z", "status": "Unknown", "totalAmount": -1.59, "transactionId": "15"}], "totalResults": 5984} + Xero: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/5ced9667-a310-443a-a711-958d36377141/connections/6a4bcf97-e46a-465c-abf6-c42cec8e48c0/data/accountTransactions?page=1&pageSize=2"}, "next": {"href": "/companies/5ced9667-a310-443a-a711-958d36377141/connections/6a4bcf97-e46a-465c-abf6-c42cec8e48c0/data/accountTransactions?page=2&pageSize=2"}, "self": {"href": "/companies/5ced9667-a310-443a-a711-958d36377141/connections/6a4bcf97-e46a-465c-abf6-c42cec8e48c0/data/accountTransactions"}}, "pageNumber": 1, "pageSize": 2, "results": [{"bankAccountRef": {"id": "bd9e85e0-0478-433d-ae9f-0b3c4f04bfe4", "name": "Business Bank Account"}, "currency": "GBP", "currencyRate": 1, "date": "2021-12-20T00:00:00", "id": "74004690-82a1-4810-aaca-6ce575af94b4", "lines": [{"amount": -7267.2, "recordRef": {"dataType": "billPayments", "id": "74004690-82a1-4810-aaca-6ce575af94b4"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-15T20:37:10", "sourceModifiedDate": "2021-01-02T22:51:40", "status": "Reconciled", "totalAmount": -7267.2, "transactionId": "74004690-82a1-4810-aaca-6ce575af94b4"}, {"bankAccountRef": {"id": "bd9e85e0-0478-433d-ae9f-0b3c4f04bfe4", "name": "Business Bank Account"}, "currency": "GBP", "currencyRate": 1, "date": "2022-02-17T00:00:00", "id": "65b746c8-9a5d-4a95-8096-d2316fcff592", "lines": [{"amount": 4200, "recordRef": {"dataType": "payments", "id": "65b746c8-9a5d-4a95-8096-d2316fcff592"}}], "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-15T20:37:10", "sourceModifiedDate": "2021-01-02T22:50:58", "status": "Reconciled", "totalAmount": 4200, "transactionId": "65b746c8-9a5d-4a95-8096-d2316fcff592"}], "totalResults": 70} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"canBeRetried": "Unknown", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "detailedErrorCode": 0, "error": "Error parsing query - Malformed query.", "service": "ClientsApi", "statusCode": 400} + Unresolved property: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"canBeRetried": "Unknown", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "detailedErrorCode": 0, "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "service": "PullApi", "statusCode": 400} + create-account: + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + query: {} + requestBody: + application/json: {"currency": "USD", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Current", "fullyQualifiedName": "Cash On Hand", "name": "Accounts Receivable", "nominalCode": "610", "status": "Active", "type": "Asset"} + responses: + "400": + application/json: {"canBeRetried": "Unknown", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "detailedErrorCode": 0, "error": "Error processing request - not valid.", "service": "PublicApi", "statusCode": 400} + get-account: + Clear Books: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Current", "fullyQualifiedName": "Asset.Current.Accounts Receivable", "id": "1b6266d1-1e44-46c5-8eb5-a8f98e03124e", "isBankAccount": false, "modifiedDate": "2023-04-26T12:38:15Z", "name": "Accounts Receivable", "nominalCode": "610", "sourceModifiedDate": "2022-12-10T16:39:00", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + Dynamics 365 Business Central: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": " .", "fullyQualifiedName": "..", "id": "8eaed16d-c69f-ec11-80f1-0022481b4546", "isBankAccount": false, "modifiedDate": "2023-03-27T14:21:18Z", "name": "", "nominalCode": "45422026-68CA-4EF2-9", "sourceModifiedDate": "2022-03-09T16:31:54Z", "status": "Active", "type": "Unknown", "validDatatypeLinks": [{"links": ["DirectCost.LineItems.AccountRef.Id"], "property": "Id"}]} + Exact (Netherlands): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "EUR", "currentBalance": 864435.44, "description": "Debiteuren", "fullyQualifiedCategory": "Asset.Assets.AccountsReceivable", "fullyQualifiedName": "Asset.Assets.AccountsReceivable.Debiteuren.PaymentsEnabled", "id": "ef2fde36-4416-4bc5-b239-315b2929348c", "isBankAccount": false, "modifiedDate": "2022-10-26T13:36:17Z", "name": "Debiteuren", "nominalCode": "1300", "sourceModifiedDate": "2020-01-08T09:42:54Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Transfer.To.AccountRef.Id", "Transfer.From.AccountRef.Id", "Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]} + Exact (UK): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 0, "description": "Some thing account", "fullyQualifiedCategory": "Asset.Assets.AccountsReceivable", "fullyQualifiedName": "Asset.Assets.AccountsReceivable.Some thing account.PaymentsEnabled", "id": "ca2b96b7-cc45-4e35-9fa3-82a2ba1eec40", "isBankAccount": false, "modifiedDate": "2022-10-26T13:35:15Z", "name": "Some thing account", "nominalCode": "THING", "sourceModifiedDate": "2017-08-01T17:31:12Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Transfer.To.AccountRef.Id", "Transfer.From.AccountRef.Id", "Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]} + FreeAgent: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Capital", "fullyQualifiedName": "Asset.Capital.Capital Asset Brought Forward", "id": "601", "isBankAccount": false, "modifiedDate": "2023-04-25T14:19:12Z", "name": "Capital Asset Brought Forward", "nominalCode": "601", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + FreshBooks: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 51445.53, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset", "fullyQualifiedName": "Asset.Accounts Receivable", "id": "67357", "isBankAccount": false, "modifiedDate": "2023-03-24T16:07:24Z", "name": "Accounts Receivable", "nominalCode": "1200", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + KashFlow: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.BankAccount", "fullyQualifiedName": "Asset.BankAccount.16th Account", "id": "27840056", "isBankAccount": true, "modifiedDate": "2022-09-30T10:29:16Z", "name": "16th Account", "nominalCode": "70700", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + Oracle NetSuite: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "EUR", "currentBalance": -635.55, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "AcctPay.AcctPay", "fullyQualifiedName": "AcctPay.AcctPay.Accounts Payable", "id": "111", "isBankAccount": false, "modifiedDate": "2023-01-30T14:48:33Z", "name": "Accounts Payable", "nominalCode": "610", "sourceModifiedDate": "2021-08-11T12:51:21", "status": "Active", "type": "Liability", "validDatatypeLinks": []} + QuickBooks Desktop: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 93007.93, "description": "Accounts Receivable", "fullyQualifiedCategory": "Asset.CurrentAsset.AccountsReceivable", "fullyQualifiedName": "Asset.CurrentAsset.AccountsReceivable.Accounts Receivable", "id": "40000-933270541", "isBankAccount": false, "modifiedDate": "2023-04-26T09:06:23Z", "name": "Accounts Receivable", "nominalCode": "11000", "sourceModifiedDate": "2023-12-16T05:06:45", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + QuickBooks Online: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 41289.37, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Accounts Receivable.AccountsReceivable", "fullyQualifiedName": "Asset.Accounts Receivable.AccountsReceivable.Debtors", "id": "62", "isBankAccount": false, "modifiedDate": "2023-01-18T11:02:34Z", "name": "Debtors", "nominalCode": "246", "sourceModifiedDate": "2022-12-08T15:42:59Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + QuickBooks Online Sandbox: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 3041173.77, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Accounts Receivable.AccountsReceivable", "fullyQualifiedName": "Asset.Accounts Receivable.AccountsReceivable.Debtors", "id": "70", "isBankAccount": false, "modifiedDate": "2023-04-26T09:35:55Z", "name": "Debtors", "nominalCode": "610", "sourceModifiedDate": "2023-04-26T01:18:15Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + Sage 200cloud: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "USD", "currentBalance": 0, "description": "Bank Account", "fullyQualifiedCategory": "Asset.Bank Account", "fullyQualifiedName": "Asset.Bank Account.Bank Account", "id": "2864", "isBankAccount": false, "modifiedDate": "2022-10-14T09:35:52Z", "name": "Bank Account", "nominalCode": "1200", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Archived", "type": "Asset", "validDatatypeLinks": []} + Sage 50 (UK): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 90640.61, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.CurrentAssets.Debtors", "fullyQualifiedName": "Asset.CurrentAssets.Debtors.Debtors Control Account", "id": "1100", "isBankAccount": false, "modifiedDate": "2023-03-30T14:42:44Z", "name": "Debtors Control Account", "nominalCode": "1100", "sourceModifiedDate": "2022-11-25T09:43:54", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + Sage Business Cloud Accounting: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 49.61, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Bank", "fullyQualifiedName": "Asset.Bank.Abdi Internet Bank", "id": "e5889b459f544926ac5b8e6756df2ad4", "isBankAccount": true, "modifiedDate": "2022-10-24T14:52:53Z", "name": "Abdi Internet Bank", "nominalCode": "1560", "sourceModifiedDate": "2020-01-27T10:53:26Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]} + Sage Intacct: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Assets.Current Assets.Account Receivable, Net of Allowance.Accounts Receivable.Accounts Receivable", "fullyQualifiedName": "Assets.Current Assets.Account Receivable, Net of Allowance.Accounts Receivable.Accounts Receivable.Accounts Receivable", "id": "2", "isBankAccount": false, "modifiedDate": "2023-04-04T16:31:51Z", "name": "Accounts Receivable", "nominalCode": "12100", "sourceModifiedDate": "2020-01-29T01:42:43", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + Wave: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 0, "description": "Test Balance Sheet", "fullyQualifiedCategory": "Asset.CashAndBank", "fullyQualifiedName": "Asset.CashAndBank.Abdi Bank", "id": "QWNjb3VudDo5MjIzNDE3NjkzMzk3NjA2MzM7QnVzaW5lc3M6ZTI0OGQyZDctMWE5Ni00YTk4LWFkOTEtMDdlMGYyMmNhNmE2", "isBankAccount": true, "modifiedDate": "2022-11-16T18:15:17Z", "name": "Abdi Bank", "nominalCode": "610", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + Xero: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": 924.25, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Bank", "fullyQualifiedName": "Asset.Bank.Business Bank Account", "id": "bd9e85e0-0478-433d-ae9f-0b3c4f04bfe4", "isBankAccount": true, "modifiedDate": "2023-03-15T20:35:08Z", "name": "Business Bank Account", "nominalCode": "A090", "sourceModifiedDate": "2023-02-17T11:10:49", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Payment.AccountRef.Id", "BillPayment.AccountRef.Id", "DirectIncome.LineItems.AccountRef.Id", "DirectCost.LineItems.AccountRef.Id"], "property": "Id"}]} + Zoho Books: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "200": + application/json: {"currency": "GBP", "currentBalance": -959.64, "description": "The money that customers owe you becomes the accounts receivable. A good example of this is a payment expected from an invoice sent to your customer.", "fullyQualifiedCategory": "Asset.accounts_receivable", "fullyQualifiedName": "Asset.accounts_receivable.Accounts Receivable", "id": "104957000000000352", "isBankAccount": false, "modifiedDate": "2022-10-03T08:40:43Z", "name": "Accounts Receivable", "nominalCode": "", "sourceModifiedDate": "2020-02-05T14:58:44", "status": "Active", "type": "Asset", "validDatatypeLinks": []} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + accountId: "" + responses: + "401": + application/json: {"canBeRetried": "Unknown", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "detailedErrorCode": 0, "error": "Unauthorized", "service": "PublicApi", "statusCode": 401} + get-create-chartOfAccounts-model: + Exact (Netherlands): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": true, "type": "String", "validation": {"information": [{"details": "Must be provided.", "field": "NominalCode"}], "warnings": []}}, "name": {"description": "Name of the account", "displayName": "Name", "required": true, "type": "String", "validation": {"information": [{"details": "Must be provided.", "field": "Name"}], "warnings": []}}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "options": [{"displayName": "Asset.Assets.Cash", "required": false, "type": "String", "value": "Asset.Assets.Cash"}, {"displayName": "Asset.Assets.Bank", "required": false, "type": "String", "value": "Asset.Assets.Bank"}, {"displayName": "Asset.Assets.PaymentServices", "required": false, "type": "String", "value": "Asset.Assets.PaymentServices"}, {"displayName": "Asset.Assets.AccountsReceivable", "required": false, "type": "String", "value": "Asset.Assets.AccountsReceivable"}, {"displayName": "Liability.EquityAndLiabilities.AccountsPayable", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.AccountsPayable"}, {"displayName": "Asset.Assets.VAT", "required": false, "type": "String", "value": "Asset.Assets.VAT"}, {"displayName": "Liability.EquityAndLiabilities.EmployeesPayable", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.EmployeesPayable"}, {"displayName": "Asset.Assets.PrepaidExpenses", "required": false, "type": "String", "value": "Asset.Assets.PrepaidExpenses"}, {"displayName": "Liability.EquityAndLiabilities.AccruedExpenses", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.AccruedExpenses"}, {"displayName": "Liability.EquityAndLiabilities.IncomeTaxesPayable", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.IncomeTaxesPayable"}, {"displayName": "Asset.Assets.FixedAssets", "required": false, "type": "String", "value": "Asset.Assets.FixedAssets"}, {"displayName": "Asset.Assets.OtherAssets", "required": false, "type": "String", "value": "Asset.Assets.OtherAssets"}, {"displayName": "Asset.Assets.AccumulatedDeprecation", "required": false, "type": "String", "value": "Asset.Assets.AccumulatedDeprecation"}, {"displayName": "Asset.Assets.Inventory", "required": false, "type": "String", "value": "Asset.Assets.Inventory"}, {"displayName": "Equity.EquityAndLiabilities.CapitalStock", "required": false, "type": "String", "value": "Equity.EquityAndLiabilities.CapitalStock"}, {"displayName": "Equity.EquityAndLiabilities.RetainedEarnings", "required": false, "type": "String", "value": "Equity.EquityAndLiabilities.RetainedEarnings"}, {"displayName": "Liability.EquityAndLiabilities.LongTermDebt", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.LongTermDebt"}, {"displayName": "Liability.EquityAndLiabilities.CurrentPortionOfDebt", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.CurrentPortionOfDebt"}, {"displayName": "Unknown.EquityAndLiabilities.Intercompany", "required": false, "type": "String", "value": "Unknown.EquityAndLiabilities.Intercompany"}, {"displayName": "Unknown.General.General", "required": false, "type": "String", "value": "Unknown.General.General"}, {"displayName": "Income.NetIncome.Revenue", "required": false, "type": "String", "value": "Income.NetIncome.Revenue"}, {"displayName": "Expense.NetIncome.CostOfGoods", "required": false, "type": "String", "value": "Expense.NetIncome.CostOfGoods"}, {"displayName": "Expense.NetIncome.OtherCosts", "required": false, "type": "String", "value": "Expense.NetIncome.OtherCosts"}, {"displayName": "Expense.NetIncome.SalesGeneralAdministrativeExpenses", "required": false, "type": "String", "value": "Expense.NetIncome.SalesGeneralAdministrativeExpenses"}, {"displayName": "Expense.NetIncome.DeprecationCosts", "required": false, "type": "String", "value": "Expense.NetIncome.DeprecationCosts"}, {"displayName": "Expense.NetIncome.ResearchAndDevelopment", "required": false, "type": "String", "value": "Expense.NetIncome.ResearchAndDevelopment"}, {"displayName": "Expense.NetIncome.EmployeeCosts", "required": false, "type": "String", "value": "Expense.NetIncome.EmployeeCosts"}, {"displayName": "Expense.NetIncome.EmploymentCosts", "required": false, "type": "String", "value": "Expense.NetIncome.EmploymentCosts"}, {"displayName": "Expense.ExceptionalIncome.ExceptionalCosts", "required": false, "type": "String", "value": "Expense.ExceptionalIncome.ExceptionalCosts"}, {"displayName": "Income.ExceptionalIncome.ExceptionalIncome", "required": false, "type": "String", "value": "Income.ExceptionalIncome.ExceptionalIncome"}, {"displayName": "Expense.ExceptionalIncome.IncomeTaxes", "required": false, "type": "String", "value": "Expense.ExceptionalIncome.IncomeTaxes"}, {"displayName": "Income.ExceptionalIncome.InterestIncome", "required": false, "type": "String", "value": "Income.ExceptionalIncome.InterestIncome"}], "required": true, "type": "String", "validation": {"information": [{"details": "Must be provided.", "field": "FullyQualifiedCategory"}], "warnings": []}}, "status": {"description": "The status of the account", "displayName": "Account Status", "options": [{"displayName": "Active", "required": false, "type": "String", "value": "Active"}, {"displayName": "Pending", "required": false, "type": "String", "value": "Pending"}, {"displayName": "Unknown", "required": false, "type": "String", "value": "Unknown"}], "required": true, "type": "String", "validation": {"information": [{"details": "Must be provided.", "field": "Status"}], "warnings": []}}}, "required": true, "type": "Object"} + Exact (UK): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": true, "type": "String", "validation": {"information": [{"details": "Must be provided.", "field": "NominalCode"}], "warnings": []}}, "name": {"description": "Name of the account", "displayName": "Name", "required": true, "type": "String", "validation": {"information": [{"details": "Must be provided.", "field": "Name"}], "warnings": []}}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "options": [{"displayName": "Asset.Assets.Cash", "required": false, "type": "String", "value": "Asset.Assets.Cash"}, {"displayName": "Asset.Assets.Bank", "required": false, "type": "String", "value": "Asset.Assets.Bank"}, {"displayName": "Asset.Assets.PaymentServices", "required": false, "type": "String", "value": "Asset.Assets.PaymentServices"}, {"displayName": "Asset.Assets.AccountsReceivable", "required": false, "type": "String", "value": "Asset.Assets.AccountsReceivable"}, {"displayName": "Liability.EquityAndLiabilities.AccountsPayable", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.AccountsPayable"}, {"displayName": "Asset.Assets.VAT", "required": false, "type": "String", "value": "Asset.Assets.VAT"}, {"displayName": "Liability.EquityAndLiabilities.EmployeesPayable", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.EmployeesPayable"}, {"displayName": "Asset.Assets.PrepaidExpenses", "required": false, "type": "String", "value": "Asset.Assets.PrepaidExpenses"}, {"displayName": "Liability.EquityAndLiabilities.AccruedExpenses", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.AccruedExpenses"}, {"displayName": "Liability.EquityAndLiabilities.IncomeTaxesPayable", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.IncomeTaxesPayable"}, {"displayName": "Asset.Assets.FixedAssets", "required": false, "type": "String", "value": "Asset.Assets.FixedAssets"}, {"displayName": "Asset.Assets.OtherAssets", "required": false, "type": "String", "value": "Asset.Assets.OtherAssets"}, {"displayName": "Asset.Assets.AccumulatedDeprecation", "required": false, "type": "String", "value": "Asset.Assets.AccumulatedDeprecation"}, {"displayName": "Asset.Assets.Inventory", "required": false, "type": "String", "value": "Asset.Assets.Inventory"}, {"displayName": "Equity.EquityAndLiabilities.CapitalStock", "required": false, "type": "String", "value": "Equity.EquityAndLiabilities.CapitalStock"}, {"displayName": "Equity.EquityAndLiabilities.RetainedEarnings", "required": false, "type": "String", "value": "Equity.EquityAndLiabilities.RetainedEarnings"}, {"displayName": "Liability.EquityAndLiabilities.LongTermDebt", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.LongTermDebt"}, {"displayName": "Liability.EquityAndLiabilities.CurrentPortionOfDebt", "required": false, "type": "String", "value": "Liability.EquityAndLiabilities.CurrentPortionOfDebt"}, {"displayName": "Unknown.EquityAndLiabilities.Intercompany", "required": false, "type": "String", "value": "Unknown.EquityAndLiabilities.Intercompany"}, {"displayName": "Unknown.General.General", "required": false, "type": "String", "value": "Unknown.General.General"}, {"displayName": "Income.NetIncome.Revenue", "required": false, "type": "String", "value": "Income.NetIncome.Revenue"}, {"displayName": "Expense.NetIncome.CostOfGoods", "required": false, "type": "String", "value": "Expense.NetIncome.CostOfGoods"}, {"displayName": "Expense.NetIncome.OtherCosts", "required": false, "type": "String", "value": "Expense.NetIncome.OtherCosts"}, {"displayName": "Expense.NetIncome.SalesGeneralAdministrativeExpenses", "required": false, "type": "String", "value": "Expense.NetIncome.SalesGeneralAdministrativeExpenses"}, {"displayName": "Expense.NetIncome.DeprecationCosts", "required": false, "type": "String", "value": "Expense.NetIncome.DeprecationCosts"}, {"displayName": "Expense.NetIncome.ResearchAndDevelopment", "required": false, "type": "String", "value": "Expense.NetIncome.ResearchAndDevelopment"}, {"displayName": "Expense.NetIncome.EmployeeCosts", "required": false, "type": "String", "value": "Expense.NetIncome.EmployeeCosts"}, {"displayName": "Expense.NetIncome.EmploymentCosts", "required": false, "type": "String", "value": "Expense.NetIncome.EmploymentCosts"}, {"displayName": "Expense.ExceptionalIncome.ExceptionalCosts", "required": false, "type": "String", "value": "Expense.ExceptionalIncome.ExceptionalCosts"}, {"displayName": "Income.ExceptionalIncome.ExceptionalIncome", "required": false, "type": "String", "value": "Income.ExceptionalIncome.ExceptionalIncome"}, {"displayName": "Expense.ExceptionalIncome.IncomeTaxes", "required": false, "type": "String", "value": "Expense.ExceptionalIncome.IncomeTaxes"}, {"displayName": "Income.ExceptionalIncome.InterestIncome", "required": false, "type": "String", "value": "Income.ExceptionalIncome.InterestIncome"}], "required": true, "type": "String", "validation": {"information": [{"details": "Must be provided.", "field": "FullyQualifiedCategory"}], "warnings": []}}, "status": {"description": "The status of the account", "displayName": "Account Status", "options": [{"displayName": "Active", "required": false, "type": "String", "value": "Active"}, {"displayName": "Pending", "required": false, "type": "String", "value": "Pending"}, {"displayName": "Unknown", "required": false, "type": "String", "value": "Unknown"}], "required": true, "type": "String", "validation": {"information": [{"details": "Must be provided.", "field": "Status"}], "warnings": []}}}, "required": true, "type": "Object"} + MYOB AccountRight and Essentials: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": true, "type": "String", "validation": {"information": [], "warnings": [{"details": "If alphanumeric is supported, must be between 1 and 10 characters. Otherwise format is x-xxxx", "field": "NominalCode"}]}}, "name": {"description": "Name of the account", "displayName": "Name", "required": false, "type": "String", "validation": {"information": [], "warnings": [{"details": "Must have a length between 1 and 60 characters", "field": "Name"}]}}, "description": {"description": "Description of the account", "displayName": "Description", "required": false, "type": "String", "validation": {"information": [], "warnings": [{"details": "Must have a length between 1 and 255 characters", "field": "Description"}]}}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "options": [{"displayName": "Bank", "required": false, "type": "String", "value": "Asset.Bank"}, {"displayName": "Accounts Receivable", "required": false, "type": "String", "value": "Asset.AccountReceivable"}, {"displayName": "Other Current Asset", "required": false, "type": "String", "value": "Asset.OtherCurrentAsset"}, {"displayName": "Fixed Asset", "required": false, "type": "String", "value": "Asset.FixedAsset"}, {"displayName": "Other Asset", "required": false, "type": "String", "value": "Asset.OtherAsset"}, {"displayName": "Cash", "required": false, "type": "String", "value": "Asset.CashAndBank"}, {"displayName": "Equipment Machinery", "required": false, "type": "String", "value": "Asset.Property Plant and Equipment"}, {"displayName": "Credit Card", "required": false, "type": "String", "value": "Liability.CreditCard"}, {"displayName": "Accounts Payable", "required": false, "type": "String", "value": "Liability.AccountsPayable"}, {"displayName": "Other Current Liability", "required": false, "type": "String", "value": "Liability.OtherCurrentLiability"}, {"displayName": "Long Term Liability", "required": false, "type": "String", "value": "Liability.LongTermLiability"}, {"displayName": "Other Liability", "required": false, "type": "String", "value": "Liability.OtherLiability"}, {"displayName": "Equity", "required": false, "type": "String", "value": "Equity"}, {"displayName": "Retained Earnings", "required": false, "type": "String", "value": "Equity.Equity"}, {"displayName": "Retained Earnings", "required": false, "type": "String", "value": "Equity.Equity.RetainedEarnings"}, {"displayName": "Retained Earnings", "required": false, "type": "String", "value": "Equity.Owner's Equity"}, {"displayName": "Income", "required": false, "type": "String", "value": "Income"}, {"displayName": "Other Income", "required": false, "type": "String", "value": "OtherIncome"}, {"displayName": "Expense", "required": false, "type": "String", "value": "Expense"}, {"displayName": "Sales Marketing", "required": false, "type": "String", "value": "Expense.Expense"}, {"displayName": "General Administrative", "required": false, "type": "String", "value": "Expense.Expense.Insurance"}, {"displayName": "General Administrative", "required": false, "type": "String", "value": "Expense.Overhead"}, {"displayName": "Repairs Maintenance", "required": false, "type": "String", "value": "Expense.Expense.RepairMaintenance"}, {"displayName": "Other Expense", "required": false, "type": "String", "value": "OtherExpense"}, {"displayName": "Cost of Sales", "required": false, "type": "String", "value": "CostOfSales"}, {"displayName": "Other", "required": false, "type": "String", "value": "Cost Of Goods Sold.Cost of Sales"}], "required": true, "type": "String"}, "status": {"description": "The status of the account", "displayName": "Account Status", "options": [{"displayName": "Active", "required": false, "type": "String", "value": "Active"}, {"displayName": "Archived", "required": false, "type": "String", "value": "Archived"}], "required": true, "type": "String"}}, "required": true, "type": "Object"} + QuickBooks Desktop: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": true, "type": "String", "validation": {"information": [], "warnings": [{"details": "Max length of 7 characters.", "field": "NominalCode"}]}}, "name": {"description": "Name of the account", "displayName": "Name", "required": true, "type": "String", "validation": {"information": [], "warnings": [{"details": "Max length of 31 characters.", "field": "Name"}]}}, "description": {"description": "Description of the account", "displayName": "Description", "required": false, "type": "String", "validation": {"information": [], "warnings": [{"details": "Max length of 200 characters.", "field": "Description"}]}}, "currency": {"description": "The currency of the account", "displayName": "Currency", "required": false, "type": "String", "validation": {"information": [{"details": "If not set, will default to the base currency of the QuickBooks Desktop company", "field": "Currency"}], "warnings": [{"details": "The currency must match the base currency of the QuickBooks Desktop company unless the FullyQualifiedCategory is 'Asset.AccountsReceivable','Liability.AccountsPayable' or 'Liability.CreditCard'", "field": "Currency"}, {"details": "Must be a three letter ISO code that matches an existing active currency in the QuickBooks Desktop company", "field": "Currency"}, {"details": "Can only be set if the Quickbooks Desktop company has Multicurrency enabled.", "field": "Currency"}]}}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "options": [{"displayName": "Account Receivable", "required": false, "type": "String", "value": "Asset.AccountsReceivable"}, {"displayName": "Fixed Asset", "required": false, "type": "String", "value": "Asset.FixedAsset"}, {"displayName": "Other Current Asset", "required": false, "type": "String", "value": "Asset.OtherCurrentAsset"}, {"displayName": "Other Asset", "required": false, "type": "String", "value": "Asset.OtherAsset"}, {"displayName": "Income", "required": false, "type": "String", "value": "Income.Income"}, {"displayName": "Other Income", "required": false, "type": "String", "value": "Income.OtherIncome"}, {"displayName": "Accounts Payable", "required": false, "type": "String", "value": "Liability.AccountsPayable"}, {"displayName": "Credit Card", "required": false, "type": "String", "value": "Liability.CreditCard"}, {"displayName": "Long Term Liability", "required": false, "type": "String", "value": "Liability.LongTermLiability"}, {"displayName": "Other Current Liability", "required": false, "type": "String", "value": "Liability.OtherCurrentLiability"}, {"displayName": "Cost Of Goods Sold", "required": false, "type": "String", "value": "Liability.CostOfGoodsSold"}, {"displayName": "Equity", "required": false, "type": "String", "value": "Equity.Equity"}, {"displayName": "Expense", "required": false, "type": "String", "value": "Expense.Expense"}, {"displayName": "Other Expense", "required": false, "type": "String", "value": "Expense.OtherExpense"}], "required": true, "type": "String"}, "currentBalance": {"description": "The current balance in the account", "displayName": "Current Balance", "required": false, "type": "Number"}}, "required": true, "type": "Object"} + QuickBooks Online Sandbox: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": false, "type": "String", "validation": {"information": [{"details": "If included must have a length between 1 and 7 characters", "field": "NominalCode"}], "warnings": []}}, "name": {"description": "Name of the account", "displayName": "Name", "required": true, "type": "String", "validation": {"information": [], "warnings": [{"details": "Must have a length between 1 and 100 characters", "field": "Name"}]}}, "currency": {"description": "The currency of the account", "displayName": "Currency", "required": false, "type": "String", "validation": {"information": [{"details": "When not specified company base currency will be used", "field": "Currency"}], "warnings": []}}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "options": [{"displayName": "Cash On Hand", "required": false, "type": "String", "value": "Asset.Bank.CashOnHand"}, {"displayName": "Checking", "required": false, "type": "String", "value": "Asset.Bank.Checking"}, {"displayName": "Money Market", "required": false, "type": "String", "value": "Asset.Bank.MoneyMarket"}, {"displayName": "Rents Held In Trust", "required": false, "type": "String", "value": "Asset.Bank.RentsHeldInTrust"}, {"displayName": "Savings", "required": false, "type": "String", "value": "Asset.Bank.Savings"}, {"displayName": "Trust Accounts", "required": false, "type": "String", "value": "Asset.Bank.TrustAccounts"}, {"displayName": "Cash And Cash Equivalents", "required": false, "type": "String", "value": "Asset.Bank.CashAndCashEquivalents"}, {"displayName": "Other Earmarked Bank Accounts", "required": false, "type": "String", "value": "Asset.Bank.OtherEarmarkedBankAccounts"}, {"displayName": "Allowance For Bad Debts", "required": false, "type": "String", "value": "Asset.Other Current Asset.AllowanceForBadDebts"}, {"displayName": "Development Costs", "required": false, "type": "String", "value": "Asset.Other Current Asset.DevelopmentCosts"}, {"displayName": "Employee Cash Advances", "required": false, "type": "String", "value": "Asset.Other Current Asset.EmployeeCashAdvances"}, {"displayName": "Other Current Assets", "required": false, "type": "String", "value": "Asset.Other Current Asset.OtherCurrentAssets"}, {"displayName": "Inventory", "required": false, "type": "String", "value": "Asset.Other Current Asset.Inventory"}, {"displayName": "Investment Mortgage Real Estate Loans", "required": false, "type": "String", "value": "Asset.Other Current Asset.Investment_MortgageRealEstateLoans"}, {"displayName": "Investment Other", "required": false, "type": "String", "value": "Asset.Other Current Asset.Investment_Other"}, {"displayName": "Investment Tax Exempt Securities", "required": false, "type": "String", "value": "Asset.Other Current Asset.Investment_TaxExemptSecurities"}, {"displayName": "Investment US Government Obligations", "required": false, "type": "String", "value": "Asset.Other Current Asset.Investment_USGovernmentObligations"}, {"displayName": "Loans To Officers", "required": false, "type": "String", "value": "Asset.Other Current Asset.LoansToOfficers"}, {"displayName": "Loans To Others", "required": false, "type": "String", "value": "Asset.Other Current Asset.LoansToOthers"}, {"displayName": "Loans To Stockholders", "required": false, "type": "String", "value": "Asset.Other Current Asset.LoansToStockholders"}, {"displayName": "Prepaid Expenses", "required": false, "type": "String", "value": "Asset.Other Current Asset.PrepaidExpenses"}, {"displayName": "Retainage", "required": false, "type": "String", "value": "Asset.Other Current Asset.Retainage"}, {"displayName": "Undeposited Funds", "required": false, "type": "String", "value": "Asset.Other Current Asset.UndepositedFunds"}, {"displayName": "Assets Available For Sale", "required": false, "type": "String", "value": "Asset.Other Current Asset.AssetsAvailableForSale"}, {"displayName": "Balance With Govt Authorities", "required": false, "type": "String", "value": "Asset.Other Current Asset.BalWithGovtAuthorities"}, {"displayName": "Called Up Share Capital Not Paid", "required": false, "type": "String", "value": "Asset.Other Current Asset.CalledUpShareCapitalNotPaid"}, {"displayName": "Expenditure Authorisations And Letters Of Credit", "required": false, "type": "String", "value": "Asset.Other Current Asset.ExpenditureAuthorisationsAndLettersOfCredit"}, {"displayName": "Global Tax Deferred", "required": false, "type": "String", "value": "Asset.Other Current Asset.GlobalTaxDeferred"}, {"displayName": "Global Tax Refund", "required": false, "type": "String", "value": "Asset.Other Current Asset.GlobalTaxRefund"}, {"displayName": "Internal Transfers", "required": false, "type": "String", "value": "Asset.Other Current Asset.InternalTransfers"}, {"displayName": "Other Consumables", "required": false, "type": "String", "value": "Asset.Other Current Asset.OtherConsumables"}, {"displayName": "Provisions Current Assets", "required": false, "type": "String", "value": "Asset.Other Current Asset.ProvisionsCurrentAssets"}, {"displayName": "Short Term Investments In Related Parties", "required": false, "type": "String", "value": "Asset.Other Current Asset.ShortTermInvestmentsInRelatedParties"}, {"displayName": "Short Term Loans And Advances To Related Parties", "required": false, "type": "String", "value": "Asset.Other Current Asset.ShortTermLoansAndAdvancesToRelatedParties"}, {"displayName": "Trade And Other Receivables", "required": false, "type": "String", "value": "Asset.Other Current Asset.TradeAndOtherReceivables"}, {"displayName": "Accumulated Depletion", "required": false, "type": "String", "value": "Asset.Fixed Asset.AccumulatedDepletion"}, {"displayName": "Accumulated Depreciation", "required": false, "type": "String", "value": "Asset.Fixed Asset.AccumulatedDepreciation"}, {"displayName": "Depletable Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.DepletableAssets"}, {"displayName": "Fixed Asset Computers", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetComputers"}, {"displayName": "Fixed Asset Copiers", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetCopiers"}, {"displayName": "Fixed Asset Furniture", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetFurniture"}, {"displayName": "Fixed Asset Phone", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetPhone"}, {"displayName": "Fixed Asset Photo Video", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetPhotoVideo"}, {"displayName": "Fixed Asset Software", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetSoftware"}, {"displayName": "Fixed Asset Other Tools Equipment", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetOtherToolsEquipment"}, {"displayName": "Furniture And Fixtures", "required": false, "type": "String", "value": "Asset.Fixed Asset.FurnitureAndFixtures"}, {"displayName": "Land", "required": false, "type": "String", "value": "Asset.Fixed Asset.Land"}, {"displayName": "Leasehold Improvements", "required": false, "type": "String", "value": "Asset.Fixed Asset.LeaseholdImprovements"}, {"displayName": "Other Fixed Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.OtherFixedAssets"}, {"displayName": "Accumulated Amortization", "required": false, "type": "String", "value": "Asset.Fixed Asset.AccumulatedAmortization"}, {"displayName": "Buildings", "required": false, "type": "String", "value": "Asset.Fixed Asset.Buildings"}, {"displayName": "Intangible Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.IntangibleAssets"}, {"displayName": "Machinery And Equipment", "required": false, "type": "String", "value": "Asset.Fixed Asset.MachineryAndEquipment"}, {"displayName": "Vehicles", "required": false, "type": "String", "value": "Asset.Fixed Asset.Vehicles"}, {"displayName": "Assets In Course Of Construction", "required": false, "type": "String", "value": "Asset.Fixed Asset.AssetsInCourseOfConstruction"}, {"displayName": "Capital Wip", "required": false, "type": "String", "value": "Asset.Fixed Asset.CapitalWip"}, {"displayName": "Cumulative Depreciation On Intangible Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.CumulativeDepreciationOnIntangibleAssets"}, {"displayName": "Intangible Assets Under Development", "required": false, "type": "String", "value": "Asset.Fixed Asset.IntangibleAssetsUnderDevelopment"}, {"displayName": "Land Asset", "required": false, "type": "String", "value": "Asset.Fixed Asset.LandAsset"}, {"displayName": "Non Current Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.NonCurrentAssets"}, {"displayName": "Participating Interests", "required": false, "type": "String", "value": "Asset.Fixed Asset.ParticipatingInterests"}, {"displayName": "Provisions Fixed Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.ProvisionsFixedAssets"}, {"displayName": "Lease Buyout", "required": false, "type": "String", "value": "Asset.Other Asset.LeaseBuyout"}, {"displayName": "Other Long Term Assets", "required": false, "type": "String", "value": "Asset.Other Asset.OtherLongTermAssets"}, {"displayName": "Security Deposits", "required": false, "type": "String", "value": "Asset.Other Asset.SecurityDeposits"}, {"displayName": "Accumulated Amortization Of Other Assets", "required": false, "type": "String", "value": "Asset.Other Asset.AccumulatedAmortizationOfOtherAssets"}, {"displayName": "Goodwill", "required": false, "type": "String", "value": "Asset.Other Asset.Goodwill"}, {"displayName": "Licenses", "required": false, "type": "String", "value": "Asset.Other Asset.Licenses"}, {"displayName": "Organizational Costs", "required": false, "type": "String", "value": "Asset.Other Asset.OrganizationalCosts"}, {"displayName": "Assets Held For Sale", "required": false, "type": "String", "value": "Asset.Other Asset.AssetsHeldForSale"}, {"displayName": "Available For Sale Financial Assets", "required": false, "type": "String", "value": "Asset.Other Asset.AvailableForSaleFinancialAssets"}, {"displayName": "Deferred Tax", "required": false, "type": "String", "value": "Asset.Other Asset.DeferredTax"}, {"displayName": "Investments", "required": false, "type": "String", "value": "Asset.Other Asset.Investments"}, {"displayName": "Long Term Investments", "required": false, "type": "String", "value": "Asset.Other Asset.LongTermInvestments"}, {"displayName": "Long Term Loans And Advances To Related Parties", "required": false, "type": "String", "value": "Asset.Other Asset.LongTermLoansAndAdvancesToRelatedParties"}, {"displayName": "Other Intangible Assets", "required": false, "type": "String", "value": "Asset.Other Asset.OtherIntangibleAssets"}, {"displayName": "Other Long Term Investments", "required": false, "type": "String", "value": "Asset.Other Asset.OtherLongTermInvestments"}, {"displayName": "Other Long Term Loans And Advances", "required": false, "type": "String", "value": "Asset.Other Asset.OtherLongTermLoansAndAdvances"}, {"displayName": "Prepayments And Accrued Income", "required": false, "type": "String", "value": "Asset.Other Asset.PrepaymentsAndAccruedIncome"}, {"displayName": "Provisions Non-Current Assets", "required": false, "type": "String", "value": "Asset.Other Asset.ProvisionsNonCurrentAssets"}, {"displayName": "Accounts Receivable", "required": false, "type": "String", "value": "Asset.Accounts Receivable.AccountsReceivable"}, {"displayName": "Advertising/Promotional", "required": false, "type": "String", "value": "Expense.Expense.AdvertisingPromotional"}, {"displayName": "Bad Debts", "required": false, "type": "String", "value": "Expense.Expense.BadDebts"}, {"displayName": "Bank Charges", "required": false, "type": "String", "value": "Expense.Expense.BankCharges"}, {"displayName": "Charitable Contributions", "required": false, "type": "String", "value": "Expense.Expense.CharitableContributions"}, {"displayName": "Commissions And Fees", "required": false, "type": "String", "value": "Expense.Expense.CommissionsAndFees"}, {"displayName": "Entertainment", "required": false, "type": "String", "value": "Expense.Expense.Entertainment"}, {"displayName": "Entertainment Meals", "required": false, "type": "String", "value": "Expense.Expense.EntertainmentMeals"}, {"displayName": "Equipment Rental", "required": false, "type": "String", "value": "Expense.Expense.EquipmentRental"}, {"displayName": "Finance Costs", "required": false, "type": "String", "value": "Expense.Expense.FinanceCosts"}, {"displayName": "Global Tax Expense", "required": false, "type": "String", "value": "Expense.Expense.GlobalTaxExpense"}, {"displayName": "Insurance", "required": false, "type": "String", "value": "Expense.Expense.Insurance"}, {"displayName": "Interest Paid", "required": false, "type": "String", "value": "Expense.Expense.InterestPaid"}, {"displayName": "Legal And Professional Fees", "required": false, "type": "String", "value": "Expense.Expense.LegalProfessionalFees"}, {"displayName": "Office Expenses", "required": false, "type": "String", "value": "Expense.Expense.OfficeExpenses"}, {"displayName": "Office/General Administrative Expenses", "required": false, "type": "String", "value": "Expense.Expense.OfficeGeneralAdministrativeExpenses"}, {"displayName": "Other Business Expenses", "required": false, "type": "String", "value": "Expense.Expense.OtherBusinessExpenses"}, {"displayName": "Other Miscellaneous Service Cost", "required": false, "type": "String", "value": "Expense.Expense.OtherMiscellaneousServiceCost"}, {"displayName": "Promotional Meals", "required": false, "type": "String", "value": "Expense.Expense.PromotionalMeals"}, {"displayName": "Rent Or Lease Of Buildings", "required": false, "type": "String", "value": "Expense.Expense.RentOrLeaseOfBuildings"}, {"displayName": "Repair And Maintenance", "required": false, "type": "String", "value": "Expense.Expense.RepairMaintenance"}, {"displayName": "Shipping, Freight And Delivery", "required": false, "type": "String", "value": "Expense.Expense.ShippingFreightDelivery"}, {"displayName": "Supplies And Materials", "required": false, "type": "String", "value": "Expense.Expense.SuppliesMaterials"}, {"displayName": "Travel", "required": false, "type": "String", "value": "Expense.Expense.Travel"}, {"displayName": "Travel Meals", "required": false, "type": "String", "value": "Expense.Expense.TravelMeals"}, {"displayName": "Utilities", "required": false, "type": "String", "value": "Expense.Expense.Utilities"}, {"displayName": "Auto", "required": false, "type": "String", "value": "Expense.Expense.Auto"}, {"displayName": "Cost Of Labor", "required": false, "type": "String", "value": "Expense.Expense.CostOfLabor"}, {"displayName": "Dues And Subscriptions", "required": false, "type": "String", "value": "Expense.Expense.DuesSubscriptions"}, {"displayName": "Payroll Expenses", "required": false, "type": "String", "value": "Expense.Expense.PayrollExpenses"}, {"displayName": "Taxes Paid", "required": false, "type": "String", "value": "Expense.Expense.TaxesPaid"}, {"displayName": "Unapplied Cash Bill Payment Expense", "required": false, "type": "String", "value": "Expense.Expense.UnappliedCashBillPaymentExpense"}, {"displayName": "Utilities", "required": false, "type": "String", "value": "Expense.Expense.Utilities"}, {"displayName": "Amortization Expense", "required": false, "type": "String", "value": "Expense.Expense.AmortizationExpense"}, {"displayName": "Appropriations To Depreciation", "required": false, "type": "String", "value": "Expense.Expense.AppropriationsToDepreciation"}, {"displayName": "Borrowing Cost", "required": false, "type": "String", "value": "Expense.Expense.BorrowingCost"}, {"displayName": "Commissions And Fees", "required": false, "type": "String", "value": "Expense.Expense.CommissionsAndFees"}, {"displayName": "Distribution Costs", "required": false, "type": "String", "value": "Expense.Expense.DistributionCosts"}, {"displayName": "External Services", "required": false, "type": "String", "value": "Expense.Expense.ExternalServices"}, {"displayName": "Extraordinary Charges", "required": false, "type": "String", "value": "Expense.Expense.ExtraordinaryCharges"}, {"displayName": "Income Tax Expense", "required": false, "type": "String", "value": "Expense.Expense.IncomeTaxExpense"}, {"displayName": "Loss On Discontinued Operations Net Of Tax", "required": false, "type": "String", "value": "Expense.Expense.LossOnDiscontinuedOperationsNetOfTax"}, {"displayName": "Management Compensation", "required": false, "type": "String", "value": "Expense.Expense.ManagementCompensation"}, {"displayName": "Other Current Operating Charges", "required": false, "type": "String", "value": "Expense.Expense.OtherCurrentOperatingCharges"}, {"displayName": "Other External Services", "required": false, "type": "String", "value": "Expense.Expense.OtherExternalServices"}, {"displayName": "Other Rental Costs", "required": false, "type": "String", "value": "Expense.Expense.OtherRentalCosts"}, {"displayName": "Other Selling Expenses", "required": false, "type": "String", "value": "Expense.Expense.OtherSellingExpenses"}, {"displayName": "Project Studies Surveys Assessments", "required": false, "type": "String", "value": "Expense.Expense.ProjectStudiesSurveysAssessments"}, {"displayName": "Purchases Rebates", "required": false, "type": "String", "value": "Expense.Expense.PurchasesRebates"}, {"displayName": "Shipping And Delivery Expense", "required": false, "type": "String", "value": "Expense.Expense.ShippingAndDeliveryExpense"}, {"displayName": "Staff Costs", "required": false, "type": "String", "value": "Expense.Expense.StaffCosts"}, {"displayName": "Sundry", "required": false, "type": "String", "value": "Expense.Expense.Sundry"}, {"displayName": "Travel Expenses General And Admin Expenses", "required": false, "type": "String", "value": "Expense.Expense.TravelExpensesGeneralAndAdminExpenses"}, {"displayName": "Travel Expenses Selling Expense", "required": false, "type": "String", "value": "Expense.Expense.TravelExpensesSellingExpense"}, {"displayName": "Depreciation", "required": false, "type": "String", "value": "Expense.Other Expense.Depreciation"}, {"displayName": "Exchange Gain Or Loss", "required": false, "type": "String", "value": "Expense.Other Expense.ExchangeGainOrLoss"}, {"displayName": "Other Miscellaneous Expense", "required": false, "type": "String", "value": "Expense.Other Expense.OtherMiscellaneousExpense"}, {"displayName": "Penalties And Settlements", "required": false, "type": "String", "value": "Expense.Other Expense.PenaltiesSettlements"}, {"displayName": "Amortization", "required": false, "type": "String", "value": "Expense.Other Expense.Amortization"}, {"displayName": "Gas And Fuel", "required": false, "type": "String", "value": "Expense.Other Expense.GasAndFuel"}, {"displayName": "Home Office", "required": false, "type": "String", "value": "Expense.Other Expense.HomeOffice"}, {"displayName": "Home Owner Rental Insurance", "required": false, "type": "String", "value": "Expense.Other Expense.HomeOwnerRentalInsurance"}, {"displayName": "Other Home Office Expenses", "required": false, "type": "String", "value": "Expense.Other Expense.OtherHomeOfficeExpenses"}, {"displayName": "Mortgage Interest", "required": false, "type": "String", "value": "Expense.Other Expense.MortgageInterest"}, {"displayName": "Rent And Lease", "required": false, "type": "String", "value": "Expense.Other Expense.RentAndLease"}, {"displayName": "Repairs And Maintenance", "required": false, "type": "String", "value": "Expense.Other Expense.RepairsAndMaintenance"}, {"displayName": "Parking And Tolls", "required": false, "type": "String", "value": "Expense.Other Expense.ParkingAndTolls"}, {"displayName": "Vehicle", "required": false, "type": "String", "value": "Expense.Other Expense.Vehicle"}, {"displayName": "Vehicle Insurance", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleInsurance"}, {"displayName": "Vehicle Lease", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleLease"}, {"displayName": "Vehicle Loan Interest", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleLoanInterest"}, {"displayName": "Vehicle Loan", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleLoan"}, {"displayName": "Vehicle Registration", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleRegistration"}, {"displayName": "Vehicle Repairs", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleRepairs"}, {"displayName": "Other Vehicle Expenses", "required": false, "type": "String", "value": "Expense.Other Expense.OtherVehicleExpenses"}, {"displayName": "Utilities", "required": false, "type": "String", "value": "Expense.Other Expense.Utilities"}, {"displayName": "Wash And Road Services", "required": false, "type": "String", "value": "Expense.Other Expense.WashAndRoadServices"}, {"displayName": "Deferred Tax Expense", "required": false, "type": "String", "value": "Expense.Other Expense.DeferredTaxExpense"}, {"displayName": "Depletion", "required": false, "type": "String", "value": "Expense.Other Expense.Depletion"}, {"displayName": "Exceptional Items", "required": false, "type": "String", "value": "Expense.Other Expense.ExceptionalItems"}, {"displayName": "Extraordinary Items", "required": false, "type": "String", "value": "Expense.Other Expense.ExtraordinaryItems"}, {"displayName": "Income Tax Other Expense", "required": false, "type": "String", "value": "Expense.Other Expense.IncomeTaxOtherExpense"}, {"displayName": "Mat Credit", "required": false, "type": "String", "value": "Expense.Other Expense.MatCredit"}, {"displayName": "Prior Period Items", "required": false, "type": "String", "value": "Expense.Other Expense.PriorPeriodItems"}, {"displayName": "Tax Roundoff Gain Or Loss", "required": false, "type": "String", "value": "Expense.Other Expense.TaxRoundoffGainOrLoss"}, {"displayName": "Equipment Rental - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.EquipmentRentalCos"}, {"displayName": "Other Costs Of Sales - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.OtherCostsOfServiceCos"}, {"displayName": "Shipping, Freight And Delivery - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.ShippingFreightDeliveryCos"}, {"displayName": "Supplies And Materials - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.SuppliesMaterialsCogs"}, {"displayName": "Cost Of Labor - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.CostOfLaborCos"}, {"displayName": "Cost Of Sales", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.CostOfSales"}, {"displayName": "Freight And Delivery Cost", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.FreightAndDeliveryCost"}, {"displayName": "Non Profit Income", "required": false, "type": "String", "value": "Income.Income.NonProfitIncome"}, {"displayName": "Other Primary Income", "required": false, "type": "String", "value": "Income.Income.OtherPrimaryIncome"}, {"displayName": "Sales Of ProductIncome", "required": false, "type": "String", "value": "Income.Income.SalesOfProductIncome"}, {"displayName": "Service Fee Income", "required": false, "type": "String", "value": "Income.Income.ServiceFeeIncome"}, {"displayName": "Discounts Refunds Given", "required": false, "type": "String", "value": "Income.Income.DiscountsRefundsGiven"}, {"displayName": "Unapplied Cash Payment Income", "required": false, "type": "String", "value": "Income.Income.UnappliedCashPaymentIncome"}, {"displayName": "Cash Receipt Income", "required": false, "type": "String", "value": "Income.Income.CashReceiptIncome"}, {"displayName": "Operating Grants", "required": false, "type": "String", "value": "Income.Income.OperatingGrants"}, {"displayName": "Other Current Operating Income", "required": false, "type": "String", "value": "Income.Income.OtherCurrentOperatingIncome"}, {"displayName": "Own Work Capitalized", "required": false, "type": "String", "value": "Income.Income.OwnWorkCapitalized"}, {"displayName": "Revenue General", "required": false, "type": "String", "value": "Income.Income.RevenueGeneral"}, {"displayName": "Sales Retail", "required": false, "type": "String", "value": "Income.Income.SalesRetail"}, {"displayName": "Sales Wholesale", "required": false, "type": "String", "value": "Income.Income.SalesWholesale"}, {"displayName": "Savings By Tax Scheme", "required": false, "type": "String", "value": "Income.Income.SavingsByTaxScheme"}, {"displayName": "Dividend Income", "required": false, "type": "String", "value": "Income.Other Income.DividendIncome"}, {"displayName": "Interest Earned", "required": false, "type": "String", "value": "Income.Other Income.InterestEarned"}, {"displayName": "Other Investment Income", "required": false, "type": "String", "value": "Income.Other Income.OtherInvestmentIncome"}, {"displayName": "Other Miscellaneous Income", "required": false, "type": "String", "value": "Income.Other Income.OtherMiscellaneousIncome"}, {"displayName": "Tax Exempt Interest", "required": false, "type": "String", "value": "Income.Other Income.TaxExemptInterest"}, {"displayName": "Gain Loss On Sale Of Fixed Assets", "required": false, "type": "String", "value": "Income.Other Income.GainLossOnSaleOfFixedAssets"}, {"displayName": "Gain Loss On Sale Of Investments", "required": false, "type": "String", "value": "Income.Other Income.GainLossOnSaleOfInvestments"}, {"displayName": "Loss On Disposal Of Assets", "required": false, "type": "String", "value": "Income.Other Income.LossOnDisposalOfAssets"}, {"displayName": "Other Operating Income", "required": false, "type": "String", "value": "Income.Other Income.OtherOperatingIncome"}, {"displayName": "Unrealised Loss On Securities Net Of Tax", "required": false, "type": "String", "value": "Income.Other Income.UnrealisedLossOnSecuritiesNetOfTax"}, {"displayName": "Accounts Payable", "required": false, "type": "String", "value": "Liability.Accounts Payable.AccountsPayable"}, {"displayName": "Outstanding Dues Micro Small Enterprise", "required": false, "type": "String", "value": "Liability.Accounts Payable.OutstandingDuesMicroSmallEnterprise"}, {"displayName": "Outstanding Dues Other Than Micro Small Enterprise", "required": false, "type": "String", "value": "Liability.Accounts Payable.OutstandingDuesOtherThanMicroSmallEnterprise"}, {"displayName": "Credit Card", "required": false, "type": "String", "value": "Liability.Credit Card.CreditCard"}, {"displayName": "Notes Payable", "required": false, "type": "String", "value": "Liability.Long Term Liability.NotesPayable"}, {"displayName": "Other Long Term Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.OtherLongTermLiabilities"}, {"displayName": "Shareholder Notes Payable", "required": false, "type": "String", "value": "Liability.Long Term Liability.ShareholderNotesPayable"}, {"displayName": "Accruals And Deferred Income", "required": false, "type": "String", "value": "Liability.Long Term Liability.AccrualsAndDeferredIncome"}, {"displayName": "Accrued Long Lerm Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.AccruedLongLermLiabilities"}, {"displayName": "Accrued Vacation Payable", "required": false, "type": "String", "value": "Liability.Long Term Liability.AccruedVacationPayable"}, {"displayName": "Bank Loans", "required": false, "type": "String", "value": "Liability.Long Term Liability.BankLoans"}, {"displayName": "Debts Related To Participating Interests", "required": false, "type": "String", "value": "Liability.Long Term Liability.DebtsRelatedToParticipatingInterests"}, {"displayName": "Deferred Tax Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.DeferredTaxLiabilities"}, {"displayName": "Government And Other Public Authorities", "required": false, "type": "String", "value": "Liability.Long Term Liability.GovernmentAndOtherPublicAuthorities"}, {"displayName": "Group And Associates", "required": false, "type": "String", "value": "Liability.Long Term Liability.GroupAndAssociates"}, {"displayName": "Liabilities Related To Assets Held For Sale", "required": false, "type": "String", "value": "Liability.Long Term Liability.LiabilitiesRelatedToAssetsHeldForSale"}, {"displayName": "Long Term Borrowings", "required": false, "type": "String", "value": "Liability.Long Term Liability.LongTermBorrowings"}, {"displayName": "Long Term Debit", "required": false, "type": "String", "value": "Liability.Long Term Liability.LongTermDebit"}, {"displayName": "Long Term Employee Benefit Obligations", "required": false, "type": "String", "value": "Liability.Long Term Liability.LongTermEmployeeBenefitObligations"}, {"displayName": "Obligations Under Finance Leases", "required": false, "type": "String", "value": "Liability.Long Term Liability.ObligationsUnderFinanceLeases"}, {"displayName": "Other Long Term Provisions", "required": false, "type": "String", "value": "Liability.Long Term Liability.OtherLongTermProvisions"}, {"displayName": "Provision For Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.ProvisionForLiabilities"}, {"displayName": "Provisions Non Current Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.ProvisionsNonCurrentLiabilities"}, {"displayName": "Staff And Related Long Term Liability Accounts", "required": false, "type": "String", "value": "Liability.Long Term Liability.StaffAndRelatedLongTermLiabilityAccounts"}, {"displayName": "Direct Deposit Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.DirectDepositPayable"}, {"displayName": "Line Of Credit", "required": false, "type": "String", "value": "Liability.Other Current Liability.LineOfCredit"}, {"displayName": "Loan Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.LoanPayable"}, {"displayName": "Global Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.GlobalTaxPayable"}, {"displayName": "Global Tax Suspense", "required": false, "type": "String", "value": "Liability.Other Current Liability.GlobalTaxSuspense"}, {"displayName": "Other Current Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.OtherCurrentLiabilities"}, {"displayName": "Payroll Clearing", "required": false, "type": "String", "value": "Liability.Other Current Liability.PayrollClearing"}, {"displayName": "Payroll Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.PayrollTaxPayable"}, {"displayName": "Prepaid Expenses Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.PrepaidExpensesPayable"}, {"displayName": "Rents In Trust Liability", "required": false, "type": "String", "value": "Liability.Other Current Liability.RentsInTrustLiability"}, {"displayName": "Trust Accounts Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.TrustAccountsLiabilities"}, {"displayName": "Federal Income Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.FederalIncomeTaxPayable"}, {"displayName": "Insurance Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.InsurancePayable"}, {"displayName": "Sales Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.SalesTaxPayable"}, {"displayName": "State Local Income Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.StateLocalIncomeTaxPayable"}, {"displayName": "Accrued Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.AccruedLiabilities"}, {"displayName": "Current Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.CurrentLiabilities"}, {"displayName": "Current Portion EmployeeBenefits Obligations", "required": false, "type": "String", "value": "Liability.Other Current Liability.CurrentPortionEmployeeBenefitsObligations"}, {"displayName": "Current Portion Of Obligations Under Finance Leases", "required": false, "type": "String", "value": "Liability.Other Current Liability.CurrentPortionOfObligationsUnderFinanceLeases"}, {"displayName": "Current Tax Liability", "required": false, "type": "String", "value": "Liability.Other Current Liability.CurrentTaxLiability"}, {"displayName": "Dividends Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.DividendsPayable"}, {"displayName": "Duties And Taxes", "required": false, "type": "String", "value": "Liability.Other Current Liability.DutiesAndTaxes"}, {"displayName": "Interest Payables", "required": false, "type": "String", "value": "Liability.Other Current Liability.InterestPayables"}, {"displayName": "Provision For Warranty Obligations", "required": false, "type": "String", "value": "Liability.Other Current Liability.ProvisionForWarrantyObligations"}, {"displayName": "Provisions Current Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.ProvisionsCurrentLiabilities"}, {"displayName": "Short Term Borrowings", "required": false, "type": "String", "value": "Liability.Other Current Liability.ShortTermBorrowings"}, {"displayName": "Social Security Agencies", "required": false, "type": "String", "value": "Liability.Other Current Liability.SocialSecurityAgencies"}, {"displayName": "Staff And Related Liability Accounts", "required": false, "type": "String", "value": "Liability.Other Current Liability.StaffAndRelatedLiabilityAccounts"}, {"displayName": "Sundry Debtors And Creditors", "required": false, "type": "String", "value": "Liability.Other Current Liability.SundryDebtorsAndCreditors"}, {"displayName": "Trade And Other Payables", "required": false, "type": "String", "value": "Liability.Other Current Liability.TradeAndOtherPayables"}, {"displayName": "Opening Balance Equity", "required": false, "type": "String", "value": "Equity.Equity.OpeningBalanceEquity"}, {"displayName": "Partners Equity", "required": false, "type": "String", "value": "Equity.Equity.PartnersEquity"}, {"displayName": "Retained Earnings", "required": false, "type": "String", "value": "Equity.Equity.RetainedEarnings"}, {"displayName": "Accumulated Adjustment", "required": false, "type": "String", "value": "Equity.Equity.AccumulatedAdjustment"}, {"displayName": "Owners Equity", "required": false, "type": "String", "value": "Equity.Equity.OwnersEquity"}, {"displayName": "Paid In Capital Or Surplus", "required": false, "type": "String", "value": "Equity.Equity.PaidInCapitalOrSurplus"}, {"displayName": "Partner Contributions", "required": false, "type": "String", "value": "Equity.Equity.PartnerContributions"}, {"displayName": "Partner Distributions", "required": false, "type": "String", "value": "Equity.Equity.PartnerDistributions"}, {"displayName": "Preferred Stock", "required": false, "type": "String", "value": "Equity.Equity.PreferredStock"}, {"displayName": "Common Stock", "required": false, "type": "String", "value": "Equity.Equity.CommonStock"}, {"displayName": "Treasury Stock", "required": false, "type": "String", "value": "Equity.Equity.TreasuryStock"}, {"displayName": "Estimated Taxes", "required": false, "type": "String", "value": "Equity.Equity.EstimatedTaxes"}, {"displayName": "Healthcare", "required": false, "type": "String", "value": "Equity.Equity.Healthcare"}, {"displayName": "Personal Income", "required": false, "type": "String", "value": "Equity.Equity.PersonalIncome"}, {"displayName": "Personal Expense", "required": false, "type": "String", "value": "Equity.Equity.PersonalExpense"}, {"displayName": "Accumulated Other Comprehensive Income", "required": false, "type": "String", "value": "Equity.Equity.AccumulatedOtherComprehensiveIncome"}, {"displayName": "Called Up Share Capital", "required": false, "type": "String", "value": "Equity.Equity.CalledUpShareCapital"}, {"displayName": "Capital Reserves", "required": false, "type": "String", "value": "Equity.Equity.CapitalReserves"}, {"displayName": "Dividend Disbursed", "required": false, "type": "String", "value": "Equity.Equity.DividendDisbursed"}, {"displayName": "Equity In Earnings Of Subsiduaries", "required": false, "type": "String", "value": "Equity.Equity.EquityInEarningsOfSubsiduaries"}, {"displayName": "Investment Grants", "required": false, "type": "String", "value": "Equity.Equity.InvestmentGrants"}, {"displayName": "Money Received Against Share Warrants", "required": false, "type": "String", "value": "Equity.Equity.MoneyReceivedAgainstShareWarrants"}, {"displayName": "Other Free Reserves", "required": false, "type": "String", "value": "Equity.Equity.OtherFreeReserves"}, {"displayName": "Share Application Money Pending Allotment", "required": false, "type": "String", "value": "Equity.Equity.ShareApplicationMoneyPendingAllotment"}, {"displayName": "Share Capital", "required": false, "type": "String", "value": "Equity.Equity.ShareCapital"}, {"displayName": "Funds", "required": false, "type": "String", "value": "Equity.Equity.Funds"}], "required": true, "type": "String"}}, "required": true, "type": "Object"} + QuickBooks Online: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": false, "type": "String", "validation": {"information": [{"details": "If included must have a length between 1 and 7 characters", "field": "NominalCode"}], "warnings": []}}, "name": {"description": "Name of the account", "displayName": "Name", "required": true, "type": "String", "validation": {"information": [], "warnings": [{"details": "Must have a length between 1 and 100 characters", "field": "Name"}]}}, "currency": {"description": "The currency of the account", "displayName": "Currency", "required": false, "type": "String", "validation": {"information": [{"details": "When not specified company base currency will be used", "field": "Currency"}], "warnings": []}}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "options": [{"displayName": "Cash On Hand", "required": false, "type": "String", "value": "Asset.Bank.CashOnHand"}, {"displayName": "Checking", "required": false, "type": "String", "value": "Asset.Bank.Checking"}, {"displayName": "Money Market", "required": false, "type": "String", "value": "Asset.Bank.MoneyMarket"}, {"displayName": "Rents Held In Trust", "required": false, "type": "String", "value": "Asset.Bank.RentsHeldInTrust"}, {"displayName": "Savings", "required": false, "type": "String", "value": "Asset.Bank.Savings"}, {"displayName": "Trust Accounts", "required": false, "type": "String", "value": "Asset.Bank.TrustAccounts"}, {"displayName": "Cash And Cash Equivalents", "required": false, "type": "String", "value": "Asset.Bank.CashAndCashEquivalents"}, {"displayName": "Other Earmarked Bank Accounts", "required": false, "type": "String", "value": "Asset.Bank.OtherEarmarkedBankAccounts"}, {"displayName": "Allowance For Bad Debts", "required": false, "type": "String", "value": "Asset.Other Current Asset.AllowanceForBadDebts"}, {"displayName": "Development Costs", "required": false, "type": "String", "value": "Asset.Other Current Asset.DevelopmentCosts"}, {"displayName": "Employee Cash Advances", "required": false, "type": "String", "value": "Asset.Other Current Asset.EmployeeCashAdvances"}, {"displayName": "Other Current Assets", "required": false, "type": "String", "value": "Asset.Other Current Asset.OtherCurrentAssets"}, {"displayName": "Inventory", "required": false, "type": "String", "value": "Asset.Other Current Asset.Inventory"}, {"displayName": "Investment Mortgage Real Estate Loans", "required": false, "type": "String", "value": "Asset.Other Current Asset.Investment_MortgageRealEstateLoans"}, {"displayName": "Investment Other", "required": false, "type": "String", "value": "Asset.Other Current Asset.Investment_Other"}, {"displayName": "Investment Tax Exempt Securities", "required": false, "type": "String", "value": "Asset.Other Current Asset.Investment_TaxExemptSecurities"}, {"displayName": "Investment US Government Obligations", "required": false, "type": "String", "value": "Asset.Other Current Asset.Investment_USGovernmentObligations"}, {"displayName": "Loans To Officers", "required": false, "type": "String", "value": "Asset.Other Current Asset.LoansToOfficers"}, {"displayName": "Loans To Others", "required": false, "type": "String", "value": "Asset.Other Current Asset.LoansToOthers"}, {"displayName": "Loans To Stockholders", "required": false, "type": "String", "value": "Asset.Other Current Asset.LoansToStockholders"}, {"displayName": "Prepaid Expenses", "required": false, "type": "String", "value": "Asset.Other Current Asset.PrepaidExpenses"}, {"displayName": "Retainage", "required": false, "type": "String", "value": "Asset.Other Current Asset.Retainage"}, {"displayName": "Undeposited Funds", "required": false, "type": "String", "value": "Asset.Other Current Asset.UndepositedFunds"}, {"displayName": "Assets Available For Sale", "required": false, "type": "String", "value": "Asset.Other Current Asset.AssetsAvailableForSale"}, {"displayName": "Balance With Govt Authorities", "required": false, "type": "String", "value": "Asset.Other Current Asset.BalWithGovtAuthorities"}, {"displayName": "Called Up Share Capital Not Paid", "required": false, "type": "String", "value": "Asset.Other Current Asset.CalledUpShareCapitalNotPaid"}, {"displayName": "Expenditure Authorisations And Letters Of Credit", "required": false, "type": "String", "value": "Asset.Other Current Asset.ExpenditureAuthorisationsAndLettersOfCredit"}, {"displayName": "Global Tax Deferred", "required": false, "type": "String", "value": "Asset.Other Current Asset.GlobalTaxDeferred"}, {"displayName": "Global Tax Refund", "required": false, "type": "String", "value": "Asset.Other Current Asset.GlobalTaxRefund"}, {"displayName": "Internal Transfers", "required": false, "type": "String", "value": "Asset.Other Current Asset.InternalTransfers"}, {"displayName": "Other Consumables", "required": false, "type": "String", "value": "Asset.Other Current Asset.OtherConsumables"}, {"displayName": "Provisions Current Assets", "required": false, "type": "String", "value": "Asset.Other Current Asset.ProvisionsCurrentAssets"}, {"displayName": "Short Term Investments In Related Parties", "required": false, "type": "String", "value": "Asset.Other Current Asset.ShortTermInvestmentsInRelatedParties"}, {"displayName": "Short Term Loans And Advances To Related Parties", "required": false, "type": "String", "value": "Asset.Other Current Asset.ShortTermLoansAndAdvancesToRelatedParties"}, {"displayName": "Trade And Other Receivables", "required": false, "type": "String", "value": "Asset.Other Current Asset.TradeAndOtherReceivables"}, {"displayName": "Accumulated Depletion", "required": false, "type": "String", "value": "Asset.Fixed Asset.AccumulatedDepletion"}, {"displayName": "Accumulated Depreciation", "required": false, "type": "String", "value": "Asset.Fixed Asset.AccumulatedDepreciation"}, {"displayName": "Depletable Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.DepletableAssets"}, {"displayName": "Fixed Asset Computers", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetComputers"}, {"displayName": "Fixed Asset Copiers", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetCopiers"}, {"displayName": "Fixed Asset Furniture", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetFurniture"}, {"displayName": "Fixed Asset Phone", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetPhone"}, {"displayName": "Fixed Asset Photo Video", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetPhotoVideo"}, {"displayName": "Fixed Asset Software", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetSoftware"}, {"displayName": "Fixed Asset Other Tools Equipment", "required": false, "type": "String", "value": "Asset.Fixed Asset.FixedAssetOtherToolsEquipment"}, {"displayName": "Furniture And Fixtures", "required": false, "type": "String", "value": "Asset.Fixed Asset.FurnitureAndFixtures"}, {"displayName": "Land", "required": false, "type": "String", "value": "Asset.Fixed Asset.Land"}, {"displayName": "Leasehold Improvements", "required": false, "type": "String", "value": "Asset.Fixed Asset.LeaseholdImprovements"}, {"displayName": "Other Fixed Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.OtherFixedAssets"}, {"displayName": "Accumulated Amortization", "required": false, "type": "String", "value": "Asset.Fixed Asset.AccumulatedAmortization"}, {"displayName": "Buildings", "required": false, "type": "String", "value": "Asset.Fixed Asset.Buildings"}, {"displayName": "Intangible Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.IntangibleAssets"}, {"displayName": "Machinery And Equipment", "required": false, "type": "String", "value": "Asset.Fixed Asset.MachineryAndEquipment"}, {"displayName": "Vehicles", "required": false, "type": "String", "value": "Asset.Fixed Asset.Vehicles"}, {"displayName": "Assets In Course Of Construction", "required": false, "type": "String", "value": "Asset.Fixed Asset.AssetsInCourseOfConstruction"}, {"displayName": "Capital Wip", "required": false, "type": "String", "value": "Asset.Fixed Asset.CapitalWip"}, {"displayName": "Cumulative Depreciation On Intangible Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.CumulativeDepreciationOnIntangibleAssets"}, {"displayName": "Intangible Assets Under Development", "required": false, "type": "String", "value": "Asset.Fixed Asset.IntangibleAssetsUnderDevelopment"}, {"displayName": "Land Asset", "required": false, "type": "String", "value": "Asset.Fixed Asset.LandAsset"}, {"displayName": "Non Current Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.NonCurrentAssets"}, {"displayName": "Participating Interests", "required": false, "type": "String", "value": "Asset.Fixed Asset.ParticipatingInterests"}, {"displayName": "Provisions Fixed Assets", "required": false, "type": "String", "value": "Asset.Fixed Asset.ProvisionsFixedAssets"}, {"displayName": "Lease Buyout", "required": false, "type": "String", "value": "Asset.Other Asset.LeaseBuyout"}, {"displayName": "Other Long Term Assets", "required": false, "type": "String", "value": "Asset.Other Asset.OtherLongTermAssets"}, {"displayName": "Security Deposits", "required": false, "type": "String", "value": "Asset.Other Asset.SecurityDeposits"}, {"displayName": "Accumulated Amortization Of Other Assets", "required": false, "type": "String", "value": "Asset.Other Asset.AccumulatedAmortizationOfOtherAssets"}, {"displayName": "Goodwill", "required": false, "type": "String", "value": "Asset.Other Asset.Goodwill"}, {"displayName": "Licenses", "required": false, "type": "String", "value": "Asset.Other Asset.Licenses"}, {"displayName": "Organizational Costs", "required": false, "type": "String", "value": "Asset.Other Asset.OrganizationalCosts"}, {"displayName": "Assets Held For Sale", "required": false, "type": "String", "value": "Asset.Other Asset.AssetsHeldForSale"}, {"displayName": "Available For Sale Financial Assets", "required": false, "type": "String", "value": "Asset.Other Asset.AvailableForSaleFinancialAssets"}, {"displayName": "Deferred Tax", "required": false, "type": "String", "value": "Asset.Other Asset.DeferredTax"}, {"displayName": "Investments", "required": false, "type": "String", "value": "Asset.Other Asset.Investments"}, {"displayName": "Long Term Investments", "required": false, "type": "String", "value": "Asset.Other Asset.LongTermInvestments"}, {"displayName": "Long Term Loans And Advances To Related Parties", "required": false, "type": "String", "value": "Asset.Other Asset.LongTermLoansAndAdvancesToRelatedParties"}, {"displayName": "Other Intangible Assets", "required": false, "type": "String", "value": "Asset.Other Asset.OtherIntangibleAssets"}, {"displayName": "Other Long Term Investments", "required": false, "type": "String", "value": "Asset.Other Asset.OtherLongTermInvestments"}, {"displayName": "Other Long Term Loans And Advances", "required": false, "type": "String", "value": "Asset.Other Asset.OtherLongTermLoansAndAdvances"}, {"displayName": "Prepayments And Accrued Income", "required": false, "type": "String", "value": "Asset.Other Asset.PrepaymentsAndAccruedIncome"}, {"displayName": "Provisions Non-Current Assets", "required": false, "type": "String", "value": "Asset.Other Asset.ProvisionsNonCurrentAssets"}, {"displayName": "Accounts Receivable", "required": false, "type": "String", "value": "Asset.Accounts Receivable.AccountsReceivable"}, {"displayName": "Advertising/Promotional", "required": false, "type": "String", "value": "Expense.Expense.AdvertisingPromotional"}, {"displayName": "Bad Debts", "required": false, "type": "String", "value": "Expense.Expense.BadDebts"}, {"displayName": "Bank Charges", "required": false, "type": "String", "value": "Expense.Expense.BankCharges"}, {"displayName": "Charitable Contributions", "required": false, "type": "String", "value": "Expense.Expense.CharitableContributions"}, {"displayName": "Commissions And Fees", "required": false, "type": "String", "value": "Expense.Expense.CommissionsAndFees"}, {"displayName": "Entertainment", "required": false, "type": "String", "value": "Expense.Expense.Entertainment"}, {"displayName": "Entertainment Meals", "required": false, "type": "String", "value": "Expense.Expense.EntertainmentMeals"}, {"displayName": "Equipment Rental", "required": false, "type": "String", "value": "Expense.Expense.EquipmentRental"}, {"displayName": "Finance Costs", "required": false, "type": "String", "value": "Expense.Expense.FinanceCosts"}, {"displayName": "Global Tax Expense", "required": false, "type": "String", "value": "Expense.Expense.GlobalTaxExpense"}, {"displayName": "Insurance", "required": false, "type": "String", "value": "Expense.Expense.Insurance"}, {"displayName": "Interest Paid", "required": false, "type": "String", "value": "Expense.Expense.InterestPaid"}, {"displayName": "Legal And Professional Fees", "required": false, "type": "String", "value": "Expense.Expense.LegalProfessionalFees"}, {"displayName": "Office Expenses", "required": false, "type": "String", "value": "Expense.Expense.OfficeExpenses"}, {"displayName": "Office/General Administrative Expenses", "required": false, "type": "String", "value": "Expense.Expense.OfficeGeneralAdministrativeExpenses"}, {"displayName": "Other Business Expenses", "required": false, "type": "String", "value": "Expense.Expense.OtherBusinessExpenses"}, {"displayName": "Other Miscellaneous Service Cost", "required": false, "type": "String", "value": "Expense.Expense.OtherMiscellaneousServiceCost"}, {"displayName": "Promotional Meals", "required": false, "type": "String", "value": "Expense.Expense.PromotionalMeals"}, {"displayName": "Rent Or Lease Of Buildings", "required": false, "type": "String", "value": "Expense.Expense.RentOrLeaseOfBuildings"}, {"displayName": "Repair And Maintenance", "required": false, "type": "String", "value": "Expense.Expense.RepairMaintenance"}, {"displayName": "Shipping, Freight And Delivery", "required": false, "type": "String", "value": "Expense.Expense.ShippingFreightDelivery"}, {"displayName": "Supplies And Materials", "required": false, "type": "String", "value": "Expense.Expense.SuppliesMaterials"}, {"displayName": "Travel", "required": false, "type": "String", "value": "Expense.Expense.Travel"}, {"displayName": "Travel Meals", "required": false, "type": "String", "value": "Expense.Expense.TravelMeals"}, {"displayName": "Utilities", "required": false, "type": "String", "value": "Expense.Expense.Utilities"}, {"displayName": "Auto", "required": false, "type": "String", "value": "Expense.Expense.Auto"}, {"displayName": "Cost Of Labor", "required": false, "type": "String", "value": "Expense.Expense.CostOfLabor"}, {"displayName": "Dues And Subscriptions", "required": false, "type": "String", "value": "Expense.Expense.DuesSubscriptions"}, {"displayName": "Payroll Expenses", "required": false, "type": "String", "value": "Expense.Expense.PayrollExpenses"}, {"displayName": "Taxes Paid", "required": false, "type": "String", "value": "Expense.Expense.TaxesPaid"}, {"displayName": "Unapplied Cash Bill Payment Expense", "required": false, "type": "String", "value": "Expense.Expense.UnappliedCashBillPaymentExpense"}, {"displayName": "Utilities", "required": false, "type": "String", "value": "Expense.Expense.Utilities"}, {"displayName": "Amortization Expense", "required": false, "type": "String", "value": "Expense.Expense.AmortizationExpense"}, {"displayName": "Appropriations To Depreciation", "required": false, "type": "String", "value": "Expense.Expense.AppropriationsToDepreciation"}, {"displayName": "Borrowing Cost", "required": false, "type": "String", "value": "Expense.Expense.BorrowingCost"}, {"displayName": "Commissions And Fees", "required": false, "type": "String", "value": "Expense.Expense.CommissionsAndFees"}, {"displayName": "Distribution Costs", "required": false, "type": "String", "value": "Expense.Expense.DistributionCosts"}, {"displayName": "External Services", "required": false, "type": "String", "value": "Expense.Expense.ExternalServices"}, {"displayName": "Extraordinary Charges", "required": false, "type": "String", "value": "Expense.Expense.ExtraordinaryCharges"}, {"displayName": "Income Tax Expense", "required": false, "type": "String", "value": "Expense.Expense.IncomeTaxExpense"}, {"displayName": "Loss On Discontinued Operations Net Of Tax", "required": false, "type": "String", "value": "Expense.Expense.LossOnDiscontinuedOperationsNetOfTax"}, {"displayName": "Management Compensation", "required": false, "type": "String", "value": "Expense.Expense.ManagementCompensation"}, {"displayName": "Other Current Operating Charges", "required": false, "type": "String", "value": "Expense.Expense.OtherCurrentOperatingCharges"}, {"displayName": "Other External Services", "required": false, "type": "String", "value": "Expense.Expense.OtherExternalServices"}, {"displayName": "Other Rental Costs", "required": false, "type": "String", "value": "Expense.Expense.OtherRentalCosts"}, {"displayName": "Other Selling Expenses", "required": false, "type": "String", "value": "Expense.Expense.OtherSellingExpenses"}, {"displayName": "Project Studies Surveys Assessments", "required": false, "type": "String", "value": "Expense.Expense.ProjectStudiesSurveysAssessments"}, {"displayName": "Purchases Rebates", "required": false, "type": "String", "value": "Expense.Expense.PurchasesRebates"}, {"displayName": "Shipping And Delivery Expense", "required": false, "type": "String", "value": "Expense.Expense.ShippingAndDeliveryExpense"}, {"displayName": "Staff Costs", "required": false, "type": "String", "value": "Expense.Expense.StaffCosts"}, {"displayName": "Sundry", "required": false, "type": "String", "value": "Expense.Expense.Sundry"}, {"displayName": "Travel Expenses General And Admin Expenses", "required": false, "type": "String", "value": "Expense.Expense.TravelExpensesGeneralAndAdminExpenses"}, {"displayName": "Travel Expenses Selling Expense", "required": false, "type": "String", "value": "Expense.Expense.TravelExpensesSellingExpense"}, {"displayName": "Depreciation", "required": false, "type": "String", "value": "Expense.Other Expense.Depreciation"}, {"displayName": "Exchange Gain Or Loss", "required": false, "type": "String", "value": "Expense.Other Expense.ExchangeGainOrLoss"}, {"displayName": "Other Miscellaneous Expense", "required": false, "type": "String", "value": "Expense.Other Expense.OtherMiscellaneousExpense"}, {"displayName": "Penalties And Settlements", "required": false, "type": "String", "value": "Expense.Other Expense.PenaltiesSettlements"}, {"displayName": "Amortization", "required": false, "type": "String", "value": "Expense.Other Expense.Amortization"}, {"displayName": "Gas And Fuel", "required": false, "type": "String", "value": "Expense.Other Expense.GasAndFuel"}, {"displayName": "Home Office", "required": false, "type": "String", "value": "Expense.Other Expense.HomeOffice"}, {"displayName": "Home Owner Rental Insurance", "required": false, "type": "String", "value": "Expense.Other Expense.HomeOwnerRentalInsurance"}, {"displayName": "Other Home Office Expenses", "required": false, "type": "String", "value": "Expense.Other Expense.OtherHomeOfficeExpenses"}, {"displayName": "Mortgage Interest", "required": false, "type": "String", "value": "Expense.Other Expense.MortgageInterest"}, {"displayName": "Rent And Lease", "required": false, "type": "String", "value": "Expense.Other Expense.RentAndLease"}, {"displayName": "Repairs And Maintenance", "required": false, "type": "String", "value": "Expense.Other Expense.RepairsAndMaintenance"}, {"displayName": "Parking And Tolls", "required": false, "type": "String", "value": "Expense.Other Expense.ParkingAndTolls"}, {"displayName": "Vehicle", "required": false, "type": "String", "value": "Expense.Other Expense.Vehicle"}, {"displayName": "Vehicle Insurance", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleInsurance"}, {"displayName": "Vehicle Lease", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleLease"}, {"displayName": "Vehicle Loan Interest", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleLoanInterest"}, {"displayName": "Vehicle Loan", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleLoan"}, {"displayName": "Vehicle Registration", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleRegistration"}, {"displayName": "Vehicle Repairs", "required": false, "type": "String", "value": "Expense.Other Expense.VehicleRepairs"}, {"displayName": "Other Vehicle Expenses", "required": false, "type": "String", "value": "Expense.Other Expense.OtherVehicleExpenses"}, {"displayName": "Utilities", "required": false, "type": "String", "value": "Expense.Other Expense.Utilities"}, {"displayName": "Wash And Road Services", "required": false, "type": "String", "value": "Expense.Other Expense.WashAndRoadServices"}, {"displayName": "Deferred Tax Expense", "required": false, "type": "String", "value": "Expense.Other Expense.DeferredTaxExpense"}, {"displayName": "Depletion", "required": false, "type": "String", "value": "Expense.Other Expense.Depletion"}, {"displayName": "Exceptional Items", "required": false, "type": "String", "value": "Expense.Other Expense.ExceptionalItems"}, {"displayName": "Extraordinary Items", "required": false, "type": "String", "value": "Expense.Other Expense.ExtraordinaryItems"}, {"displayName": "Income Tax Other Expense", "required": false, "type": "String", "value": "Expense.Other Expense.IncomeTaxOtherExpense"}, {"displayName": "Mat Credit", "required": false, "type": "String", "value": "Expense.Other Expense.MatCredit"}, {"displayName": "Prior Period Items", "required": false, "type": "String", "value": "Expense.Other Expense.PriorPeriodItems"}, {"displayName": "Tax Roundoff Gain Or Loss", "required": false, "type": "String", "value": "Expense.Other Expense.TaxRoundoffGainOrLoss"}, {"displayName": "Equipment Rental - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.EquipmentRentalCos"}, {"displayName": "Other Costs Of Sales - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.OtherCostsOfServiceCos"}, {"displayName": "Shipping, Freight And Delivery - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.ShippingFreightDeliveryCos"}, {"displayName": "Supplies And Materials - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.SuppliesMaterialsCogs"}, {"displayName": "Cost Of Labor - COS", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.CostOfLaborCos"}, {"displayName": "Cost Of Sales", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.CostOfSales"}, {"displayName": "Freight And Delivery Cost", "required": false, "type": "String", "value": "Expense.Cost of Goods Sold.FreightAndDeliveryCost"}, {"displayName": "Non Profit Income", "required": false, "type": "String", "value": "Income.Income.NonProfitIncome"}, {"displayName": "Other Primary Income", "required": false, "type": "String", "value": "Income.Income.OtherPrimaryIncome"}, {"displayName": "Sales Of ProductIncome", "required": false, "type": "String", "value": "Income.Income.SalesOfProductIncome"}, {"displayName": "Service Fee Income", "required": false, "type": "String", "value": "Income.Income.ServiceFeeIncome"}, {"displayName": "Discounts Refunds Given", "required": false, "type": "String", "value": "Income.Income.DiscountsRefundsGiven"}, {"displayName": "Unapplied Cash Payment Income", "required": false, "type": "String", "value": "Income.Income.UnappliedCashPaymentIncome"}, {"displayName": "Cash Receipt Income", "required": false, "type": "String", "value": "Income.Income.CashReceiptIncome"}, {"displayName": "Operating Grants", "required": false, "type": "String", "value": "Income.Income.OperatingGrants"}, {"displayName": "Other Current Operating Income", "required": false, "type": "String", "value": "Income.Income.OtherCurrentOperatingIncome"}, {"displayName": "Own Work Capitalized", "required": false, "type": "String", "value": "Income.Income.OwnWorkCapitalized"}, {"displayName": "Revenue General", "required": false, "type": "String", "value": "Income.Income.RevenueGeneral"}, {"displayName": "Sales Retail", "required": false, "type": "String", "value": "Income.Income.SalesRetail"}, {"displayName": "Sales Wholesale", "required": false, "type": "String", "value": "Income.Income.SalesWholesale"}, {"displayName": "Savings By Tax Scheme", "required": false, "type": "String", "value": "Income.Income.SavingsByTaxScheme"}, {"displayName": "Dividend Income", "required": false, "type": "String", "value": "Income.Other Income.DividendIncome"}, {"displayName": "Interest Earned", "required": false, "type": "String", "value": "Income.Other Income.InterestEarned"}, {"displayName": "Other Investment Income", "required": false, "type": "String", "value": "Income.Other Income.OtherInvestmentIncome"}, {"displayName": "Other Miscellaneous Income", "required": false, "type": "String", "value": "Income.Other Income.OtherMiscellaneousIncome"}, {"displayName": "Tax Exempt Interest", "required": false, "type": "String", "value": "Income.Other Income.TaxExemptInterest"}, {"displayName": "Gain Loss On Sale Of Fixed Assets", "required": false, "type": "String", "value": "Income.Other Income.GainLossOnSaleOfFixedAssets"}, {"displayName": "Gain Loss On Sale Of Investments", "required": false, "type": "String", "value": "Income.Other Income.GainLossOnSaleOfInvestments"}, {"displayName": "Loss On Disposal Of Assets", "required": false, "type": "String", "value": "Income.Other Income.LossOnDisposalOfAssets"}, {"displayName": "Other Operating Income", "required": false, "type": "String", "value": "Income.Other Income.OtherOperatingIncome"}, {"displayName": "Unrealised Loss On Securities Net Of Tax", "required": false, "type": "String", "value": "Income.Other Income.UnrealisedLossOnSecuritiesNetOfTax"}, {"displayName": "Accounts Payable", "required": false, "type": "String", "value": "Liability.Accounts Payable.AccountsPayable"}, {"displayName": "Outstanding Dues Micro Small Enterprise", "required": false, "type": "String", "value": "Liability.Accounts Payable.OutstandingDuesMicroSmallEnterprise"}, {"displayName": "Outstanding Dues Other Than Micro Small Enterprise", "required": false, "type": "String", "value": "Liability.Accounts Payable.OutstandingDuesOtherThanMicroSmallEnterprise"}, {"displayName": "Credit Card", "required": false, "type": "String", "value": "Liability.Credit Card.CreditCard"}, {"displayName": "Notes Payable", "required": false, "type": "String", "value": "Liability.Long Term Liability.NotesPayable"}, {"displayName": "Other Long Term Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.OtherLongTermLiabilities"}, {"displayName": "Shareholder Notes Payable", "required": false, "type": "String", "value": "Liability.Long Term Liability.ShareholderNotesPayable"}, {"displayName": "Accruals And Deferred Income", "required": false, "type": "String", "value": "Liability.Long Term Liability.AccrualsAndDeferredIncome"}, {"displayName": "Accrued Long Lerm Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.AccruedLongLermLiabilities"}, {"displayName": "Accrued Vacation Payable", "required": false, "type": "String", "value": "Liability.Long Term Liability.AccruedVacationPayable"}, {"displayName": "Bank Loans", "required": false, "type": "String", "value": "Liability.Long Term Liability.BankLoans"}, {"displayName": "Debts Related To Participating Interests", "required": false, "type": "String", "value": "Liability.Long Term Liability.DebtsRelatedToParticipatingInterests"}, {"displayName": "Deferred Tax Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.DeferredTaxLiabilities"}, {"displayName": "Government And Other Public Authorities", "required": false, "type": "String", "value": "Liability.Long Term Liability.GovernmentAndOtherPublicAuthorities"}, {"displayName": "Group And Associates", "required": false, "type": "String", "value": "Liability.Long Term Liability.GroupAndAssociates"}, {"displayName": "Liabilities Related To Assets Held For Sale", "required": false, "type": "String", "value": "Liability.Long Term Liability.LiabilitiesRelatedToAssetsHeldForSale"}, {"displayName": "Long Term Borrowings", "required": false, "type": "String", "value": "Liability.Long Term Liability.LongTermBorrowings"}, {"displayName": "Long Term Debit", "required": false, "type": "String", "value": "Liability.Long Term Liability.LongTermDebit"}, {"displayName": "Long Term Employee Benefit Obligations", "required": false, "type": "String", "value": "Liability.Long Term Liability.LongTermEmployeeBenefitObligations"}, {"displayName": "Obligations Under Finance Leases", "required": false, "type": "String", "value": "Liability.Long Term Liability.ObligationsUnderFinanceLeases"}, {"displayName": "Other Long Term Provisions", "required": false, "type": "String", "value": "Liability.Long Term Liability.OtherLongTermProvisions"}, {"displayName": "Provision For Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.ProvisionForLiabilities"}, {"displayName": "Provisions Non Current Liabilities", "required": false, "type": "String", "value": "Liability.Long Term Liability.ProvisionsNonCurrentLiabilities"}, {"displayName": "Staff And Related Long Term Liability Accounts", "required": false, "type": "String", "value": "Liability.Long Term Liability.StaffAndRelatedLongTermLiabilityAccounts"}, {"displayName": "Direct Deposit Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.DirectDepositPayable"}, {"displayName": "Line Of Credit", "required": false, "type": "String", "value": "Liability.Other Current Liability.LineOfCredit"}, {"displayName": "Loan Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.LoanPayable"}, {"displayName": "Global Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.GlobalTaxPayable"}, {"displayName": "Global Tax Suspense", "required": false, "type": "String", "value": "Liability.Other Current Liability.GlobalTaxSuspense"}, {"displayName": "Other Current Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.OtherCurrentLiabilities"}, {"displayName": "Payroll Clearing", "required": false, "type": "String", "value": "Liability.Other Current Liability.PayrollClearing"}, {"displayName": "Payroll Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.PayrollTaxPayable"}, {"displayName": "Prepaid Expenses Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.PrepaidExpensesPayable"}, {"displayName": "Rents In Trust Liability", "required": false, "type": "String", "value": "Liability.Other Current Liability.RentsInTrustLiability"}, {"displayName": "Trust Accounts Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.TrustAccountsLiabilities"}, {"displayName": "Federal Income Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.FederalIncomeTaxPayable"}, {"displayName": "Insurance Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.InsurancePayable"}, {"displayName": "Sales Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.SalesTaxPayable"}, {"displayName": "State Local Income Tax Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.StateLocalIncomeTaxPayable"}, {"displayName": "Accrued Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.AccruedLiabilities"}, {"displayName": "Current Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.CurrentLiabilities"}, {"displayName": "Current Portion EmployeeBenefits Obligations", "required": false, "type": "String", "value": "Liability.Other Current Liability.CurrentPortionEmployeeBenefitsObligations"}, {"displayName": "Current Portion Of Obligations Under Finance Leases", "required": false, "type": "String", "value": "Liability.Other Current Liability.CurrentPortionOfObligationsUnderFinanceLeases"}, {"displayName": "Current Tax Liability", "required": false, "type": "String", "value": "Liability.Other Current Liability.CurrentTaxLiability"}, {"displayName": "Dividends Payable", "required": false, "type": "String", "value": "Liability.Other Current Liability.DividendsPayable"}, {"displayName": "Duties And Taxes", "required": false, "type": "String", "value": "Liability.Other Current Liability.DutiesAndTaxes"}, {"displayName": "Interest Payables", "required": false, "type": "String", "value": "Liability.Other Current Liability.InterestPayables"}, {"displayName": "Provision For Warranty Obligations", "required": false, "type": "String", "value": "Liability.Other Current Liability.ProvisionForWarrantyObligations"}, {"displayName": "Provisions Current Liabilities", "required": false, "type": "String", "value": "Liability.Other Current Liability.ProvisionsCurrentLiabilities"}, {"displayName": "Short Term Borrowings", "required": false, "type": "String", "value": "Liability.Other Current Liability.ShortTermBorrowings"}, {"displayName": "Social Security Agencies", "required": false, "type": "String", "value": "Liability.Other Current Liability.SocialSecurityAgencies"}, {"displayName": "Staff And Related Liability Accounts", "required": false, "type": "String", "value": "Liability.Other Current Liability.StaffAndRelatedLiabilityAccounts"}, {"displayName": "Sundry Debtors And Creditors", "required": false, "type": "String", "value": "Liability.Other Current Liability.SundryDebtorsAndCreditors"}, {"displayName": "Trade And Other Payables", "required": false, "type": "String", "value": "Liability.Other Current Liability.TradeAndOtherPayables"}, {"displayName": "Opening Balance Equity", "required": false, "type": "String", "value": "Equity.Equity.OpeningBalanceEquity"}, {"displayName": "Partners Equity", "required": false, "type": "String", "value": "Equity.Equity.PartnersEquity"}, {"displayName": "Retained Earnings", "required": false, "type": "String", "value": "Equity.Equity.RetainedEarnings"}, {"displayName": "Accumulated Adjustment", "required": false, "type": "String", "value": "Equity.Equity.AccumulatedAdjustment"}, {"displayName": "Owners Equity", "required": false, "type": "String", "value": "Equity.Equity.OwnersEquity"}, {"displayName": "Paid In Capital Or Surplus", "required": false, "type": "String", "value": "Equity.Equity.PaidInCapitalOrSurplus"}, {"displayName": "Partner Contributions", "required": false, "type": "String", "value": "Equity.Equity.PartnerContributions"}, {"displayName": "Partner Distributions", "required": false, "type": "String", "value": "Equity.Equity.PartnerDistributions"}, {"displayName": "Preferred Stock", "required": false, "type": "String", "value": "Equity.Equity.PreferredStock"}, {"displayName": "Common Stock", "required": false, "type": "String", "value": "Equity.Equity.CommonStock"}, {"displayName": "Treasury Stock", "required": false, "type": "String", "value": "Equity.Equity.TreasuryStock"}, {"displayName": "Estimated Taxes", "required": false, "type": "String", "value": "Equity.Equity.EstimatedTaxes"}, {"displayName": "Healthcare", "required": false, "type": "String", "value": "Equity.Equity.Healthcare"}, {"displayName": "Personal Income", "required": false, "type": "String", "value": "Equity.Equity.PersonalIncome"}, {"displayName": "Personal Expense", "required": false, "type": "String", "value": "Equity.Equity.PersonalExpense"}, {"displayName": "Accumulated Other Comprehensive Income", "required": false, "type": "String", "value": "Equity.Equity.AccumulatedOtherComprehensiveIncome"}, {"displayName": "Called Up Share Capital", "required": false, "type": "String", "value": "Equity.Equity.CalledUpShareCapital"}, {"displayName": "Capital Reserves", "required": false, "type": "String", "value": "Equity.Equity.CapitalReserves"}, {"displayName": "Dividend Disbursed", "required": false, "type": "String", "value": "Equity.Equity.DividendDisbursed"}, {"displayName": "Equity In Earnings Of Subsiduaries", "required": false, "type": "String", "value": "Equity.Equity.EquityInEarningsOfSubsiduaries"}, {"displayName": "Investment Grants", "required": false, "type": "String", "value": "Equity.Equity.InvestmentGrants"}, {"displayName": "Money Received Against Share Warrants", "required": false, "type": "String", "value": "Equity.Equity.MoneyReceivedAgainstShareWarrants"}, {"displayName": "Other Free Reserves", "required": false, "type": "String", "value": "Equity.Equity.OtherFreeReserves"}, {"displayName": "Share Application Money Pending Allotment", "required": false, "type": "String", "value": "Equity.Equity.ShareApplicationMoneyPendingAllotment"}, {"displayName": "Share Capital", "required": false, "type": "String", "value": "Equity.Equity.ShareCapital"}, {"displayName": "Funds", "required": false, "type": "String", "value": "Equity.Equity.Funds"}], "required": true, "type": "String"}}, "required": true, "type": "Object"} + Sage Business Cloud Accounting: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"name": {"description": "Name of the account", "displayName": "Name", "required": true, "type": "String", "validation": {"information": [{"details": "Should not be longer than 200 characters.", "field": "Name"}], "warnings": []}}, "nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": true, "type": "String", "validation": {"information": [{"details": "Should be a number between 1 and 99999999.", "field": "NominalCode"}], "warnings": []}}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "options": [{"displayName": "Sales", "required": false, "type": "String", "value": "SALES"}, {"displayName": "Other Income", "required": false, "type": "String", "value": "OTHER_INCOME"}, {"displayName": "Direct Expenses", "required": false, "type": "String", "value": "DIRECT_EXPENSES"}, {"displayName": "Overheads", "required": false, "type": "String", "value": "OVERHEADS"}, {"displayName": "Depreciation", "required": false, "type": "String", "value": "DEPRECIATION"}, {"displayName": "Current Assets", "required": false, "type": "String", "value": "CURRENT_ASSETS"}, {"displayName": "Fixed Assets", "required": false, "type": "String", "value": "FIXED_ASSETS"}, {"displayName": "Future Assets", "required": false, "type": "String", "value": "FUTURE_ASSETS"}, {"displayName": "Bank", "required": false, "type": "String", "value": "BANK"}, {"displayName": "Current Liability", "required": false, "type": "String", "value": "CURRENT_LIABILITY"}, {"displayName": "Future Liability", "required": false, "type": "String", "value": "FUTURE_LIABILITY"}, {"displayName": "Equity", "required": false, "type": "String", "value": "EQUITY"}, {"displayName": "Credit Card / Loan", "required": false, "type": "String", "value": "LINE_OF_CREDIT"}], "required": true, "type": "String"}}, "required": true, "type": "Object"} + Sage Intacct: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": true, "type": "String", "validation": {"information": [], "warnings": [{"details": "Must be unique within the entity.", "field": "NominalCode"}, {"details": "Must be at most 24 characters in length, although restrictions may vary between entities.", "field": "NominalCode"}]}}, "name": {"description": "Name of the account", "displayName": "Name", "required": true, "type": "String"}, "status": {"description": "The status of the account", "displayName": "Account Status", "options": [{"displayName": "Active", "required": false, "type": "String", "value": "Active"}, {"displayName": "Archived", "required": false, "type": "String", "value": "Archived"}], "required": true, "type": "String"}, "type": {"description": "The type, or base category, of the account", "displayName": "Account Type", "options": [{"displayName": "Asset", "required": false, "type": "String", "value": "Asset"}, {"displayName": "Equity", "required": false, "type": "String", "value": "Equity"}, {"displayName": "Expense", "required": false, "type": "String", "value": "Expense"}, {"displayName": "Income", "required": false, "type": "String", "value": "Income"}, {"displayName": "Liability", "required": false, "type": "String", "value": "Liability"}], "required": true, "type": "String"}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "required": true, "type": "String", "validation": {"information": [{"details": "Any category that is part of the hierarchy of one of: 'Assets', 'Equity', 'Liabilities', 'Total Expenses' and 'Total Income' is permitted.", "field": "FullyQualifiedCategory"}], "warnings": []}}}, "required": true, "type": "Object"} + Sandbox: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "The external reference given to each nominal account for a business", "displayName": "Nominal Code", "required": true, "type": "String"}, "name": {"description": "Name of the account", "displayName": "Name", "required": true, "type": "String"}, "description": {"description": "Description of the account", "displayName": "Description", "required": true, "type": "String"}, "fullyQualifiedCategory": {"description": "The full category of the account e.g. Liability.Current or Income.Revenue", "displayName": "Fully Qualified Category", "required": true, "type": "String"}, "fullyQualifiedName": {"description": "The full name of the account e.g. Liability.Current.VAT or Income.Revenue.Sales", "displayName": "Fully Qualified Name", "required": true, "type": "String"}, "currency": {"description": "The currency of the account", "displayName": "Currency", "required": true, "type": "String"}, "currentBalance": {"description": "The current balance in the account", "displayName": "Current Balance", "required": true, "type": "Number"}, "type": {"description": "The type, or base category, of the account", "displayName": "Account Type", "required": true, "type": "String"}, "status": {"description": "The status of the account", "displayName": "Account Status", "required": true, "type": "String"}, "isBankAccount": {"description": "Confirms whether the nominal account represents a bank account or not", "displayName": "Is Bank Account?", "required": true, "type": "Boolean"}, "validDatatypeLinks": {"description": "Describes which fields on other data types are valid links to this account in the originating system", "displayName": "Valid Datatype Links", "required": true, "type": "Array"}, "metadata": {"description": "Miscellaneous data about the item", "displayName": "Metadata", "required": true, "type": "Object"}}, "required": true, "type": "Object"} + Xero: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "200": + application/json: {"description": "Nominal Accounts are the categories a business uses to record transactions", "displayName": "Nominal Account", "properties": {"nominalCode": {"description": "Identifier for the nominal account.", "displayName": "Nominal Code", "required": true, "type": "String", "validation": {"information": [], "warnings": [{"details": "Max length of 10 characters.", "field": "NominalCode"}]}}, "name": {"description": "Name of account as it appears in the chart of accounts or general ledger.", "displayName": "Name", "required": true, "type": "String", "validation": {"information": [{"details": "Payments are enabled to this account if the name ends in .PaymentsEnabled.", "field": "Name"}], "warnings": []}}, "description": {"description": "Description for the nominal account.", "displayName": "Description", "required": false, "type": "String"}, "fullyQualifiedCategory": {"description": "Account type and category for nominal account.", "displayName": "Fully Qualified Category", "options": [{"displayName": "Current Asset", "required": false, "type": "String", "value": "Asset.Current"}, {"displayName": "Fixed Asset", "required": false, "type": "String", "value": "Asset.Fixed"}, {"displayName": "Inventory", "required": false, "type": "String", "value": "Asset.Inventory"}, {"displayName": "Non-current Asset", "required": false, "type": "String", "value": "Asset.NonCurrent"}, {"displayName": "Prepayment", "required": false, "type": "String", "value": "Asset.Prepayment"}, {"displayName": "Direct Costs", "required": false, "type": "String", "value": "Expense.DirectCosts"}, {"displayName": "Expense", "required": false, "type": "String", "value": "Expense.Expense"}, {"displayName": "Overhead", "required": false, "type": "String", "value": "Expense.Overhead"}, {"displayName": "Superannuation", "required": false, "type": "String", "value": "Expense.Superannuation"}, {"displayName": "Wages", "required": false, "type": "String", "value": "Expense.Wages"}, {"displayName": "Sales", "required": false, "type": "String", "value": "Income.Sales"}, {"displayName": "Revenue", "required": false, "type": "String", "value": "Income.Revenue"}, {"displayName": "Other Income", "required": false, "type": "String", "value": "Income.Other"}, {"displayName": "Current Liability", "required": false, "type": "String", "value": "Liability.Current"}, {"displayName": "Depreciation", "required": false, "type": "String", "value": "Liability.Depreciation"}, {"displayName": "Liability", "required": false, "type": "String", "value": "Liability.Liability"}, {"displayName": "Non Current Liability", "required": false, "type": "String", "value": "Liability.NonCurrent"}, {"displayName": "Pay As You Go Liability", "required": false, "type": "String", "value": "Liability.PayAsYouGo"}, {"displayName": "Superannuation Liability", "required": false, "type": "String", "value": "Liability.Superannuation"}, {"displayName": "Wages Payable Liability", "required": false, "type": "String", "value": "Liability.WagesPayable"}, {"displayName": "Equity", "required": false, "type": "String", "value": "Equity.Equity"}], "required": true, "type": "String"}}, "required": true, "type": "Object"} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "401": + application/json: {"canBeRetried": "Unknown", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "detailedErrorCode": 0, "error": "Unauthorized", "service": "PublicApi", "statusCode": 401} + list-accounts: + "": + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/{id}/data/{dataType}?page=1&pageSize=10"}, "self": {"href": "/companies/{id}/data/{dataType}"}}, "pageNumber": 1, "pageSize": 10, "results": [], "totalResults": 1} + "400": {} + Clear Books: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/354a121b-855f-4d25-90ad-0905b498c1c0/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/354a121b-855f-4d25-90ad-0905b498c1c0/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/354a121b-855f-4d25-90ad-0905b498c1c0/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Current", "fullyQualifiedName": "Asset.Current.Accounts Receivable", "id": "1b6266d1-1e44-46c5-8eb5-a8f98e03124e", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T12:38:15Z", "name": "Accounts Receivable", "nominalCode": "610", "sourceModifiedDate": "2022-12-10T16:39:00", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 0, "description": "A provision anticipating that a portion of accounts receivable will never be collected.", "fullyQualifiedCategory": "Asset.Current", "fullyQualifiedName": "Asset.Current.Accounts Receivable", "id": "76d5f23b-9623-4e3b-89cd-da57228764d3", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T12:38:15Z", "name": "Accounts Receivable", "nominalCode": "611", "sourceModifiedDate": "2022-10-19T05:49:00", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 98} + Dynamics 365 Business Central: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/d6849caf-c146-41be-8335-b73346e3bd84/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/d6849caf-c146-41be-8335-b73346e3bd84/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/d6849caf-c146-41be-8335-b73346e3bd84/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": " .", "fullyQualifiedName": "..", "id": "8eaed16d-c69f-ec11-80f1-0022481b4546", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-27T14:21:18Z", "name": "", "nominalCode": "45422026-68CA-4EF2-9", "sourceModifiedDate": "2022-03-09T16:31:54Z", "status": "Active", "type": "Unknown", "validDatatypeLinks": [{"links": ["DirectCost.LineItems.AccountRef.Id"], "property": "Id"}]}, {"currency": "GBP", "currentBalance": 27.34, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": " .", "fullyQualifiedName": "..Account no cat Balance Sheet", "id": "c0861a65-c69f-ec11-80f1-0022481b4546", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-27T14:21:18Z", "name": "Account no cat Balance Sheet", "nominalCode": "10", "sourceModifiedDate": "2022-09-13T14:45:01Z", "status": "Active", "type": "Unknown", "validDatatypeLinks": [{"links": ["DirectCost.LineItems.AccountRef.Id"], "property": "Id"}]}], "totalResults": 122} + Exact (Netherlands): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/b83b1923-4db6-45a8-a779-b4e320c15979/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/b83b1923-4db6-45a8-a779-b4e320c15979/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/b83b1923-4db6-45a8-a779-b4e320c15979/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "EUR", "currentBalance": 864435.44, "description": "Debiteuren", "fullyQualifiedCategory": "Asset.Assets.AccountsReceivable", "fullyQualifiedName": "Asset.Assets.AccountsReceivable.Debiteuren.PaymentsEnabled", "id": "ef2fde36-4416-4bc5-b239-315b2929348c", "isBankAccount": false, "modifiedDate": "2022-10-26T13:36:17Z", "name": "Debiteuren", "nominalCode": "1300", "sourceModifiedDate": "2020-01-08T09:42:54Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Transfer.To.AccountRef.Id", "Transfer.From.AccountRef.Id", "Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]}, {"currency": "EUR", "currentBalance": 2174.82, "description": "One more AR account", "fullyQualifiedCategory": "Asset.Assets.AccountsReceivable", "fullyQualifiedName": "Asset.Assets.AccountsReceivable.One more AR account.PaymentsEnabled", "id": "2052b65b-20e9-4da1-85d8-fd5ca0ea3d38", "isBankAccount": false, "modifiedDate": "2022-10-26T13:36:17Z", "name": "One more AR account", "nominalCode": "888777888", "sourceModifiedDate": "2021-06-10T11:00:20Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Transfer.To.AccountRef.Id", "Transfer.From.AccountRef.Id", "Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]}], "totalResults": 230} + Exact (UK): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/d95030cd-22b2-482b-9c7b-2980dcc2b1ce/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/d95030cd-22b2-482b-9c7b-2980dcc2b1ce/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/d95030cd-22b2-482b-9c7b-2980dcc2b1ce/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 0, "description": "Some thing account", "fullyQualifiedCategory": "Asset.Assets.AccountsReceivable", "fullyQualifiedName": "Asset.Assets.AccountsReceivable.Some thing account.PaymentsEnabled", "id": "ca2b96b7-cc45-4e35-9fa3-82a2ba1eec40", "isBankAccount": false, "modifiedDate": "2022-10-26T13:35:15Z", "name": "Some thing account", "nominalCode": "THING", "sourceModifiedDate": "2017-08-01T17:31:12Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Transfer.To.AccountRef.Id", "Transfer.From.AccountRef.Id", "Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]}, {"currency": "GBP", "currentBalance": 4484655.39, "description": "Trade Debtors", "fullyQualifiedCategory": "Asset.Assets.AccountsReceivable", "fullyQualifiedName": "Asset.Assets.AccountsReceivable.Trade Debtors.PaymentsEnabled", "id": "cf9572e7-8afa-4339-9113-af32a66d9df9", "isBankAccount": false, "modifiedDate": "2022-10-26T13:35:15Z", "name": "Trade Debtors", "nominalCode": "15400", "sourceModifiedDate": "2020-01-08T13:48:38Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Transfer.To.AccountRef.Id", "Transfer.From.AccountRef.Id", "Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]}], "totalResults": 121} + FreeAgent: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/071ad738-68f3-4561-afd0-69bab9df0803/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/071ad738-68f3-4561-afd0-69bab9df0803/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/071ad738-68f3-4561-afd0-69bab9df0803/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Capital", "fullyQualifiedName": "Asset.Capital.Capital Asset Brought Forward", "id": "601", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-25T14:19:12Z", "name": "Capital Asset Brought Forward", "nominalCode": "601", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Capital", "fullyQualifiedName": "Asset.Capital.Capital Asset Depreciation Brought Forward", "id": "605", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-25T14:19:12Z", "name": "Capital Asset Depreciation Brought Forward", "nominalCode": "605", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 292} + FreshBooks: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/3691c49e-0db4-4172-b3ab-e4084c365013/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/3691c49e-0db4-4172-b3ab-e4084c365013/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/3691c49e-0db4-4172-b3ab-e4084c365013/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 51445.53, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset", "fullyQualifiedName": "Asset.Accounts Receivable", "id": "67357", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-24T16:07:24Z", "name": "Accounts Receivable", "nominalCode": "1200", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 51445.53, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Accounts Receivable", "fullyQualifiedName": "Asset.Accounts Receivable.Accounts Receivable", "id": "128611", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-24T16:07:24Z", "name": "Accounts Receivable", "nominalCode": "1200-1", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 96} + KashFlow: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/3a707a99-89da-4b16-a5d6-595333a16352/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/3a707a99-89da-4b16-a5d6-595333a16352/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/3a707a99-89da-4b16-a5d6-595333a16352/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.BankAccount", "fullyQualifiedName": "Asset.BankAccount.16th Account", "id": "27840056", "isBankAccount": true, "modifiedDate": "2022-09-30T10:29:16Z", "name": "16th Account", "nominalCode": "70700", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.BankAccount", "fullyQualifiedName": "Asset.BankAccount.1a1a", "id": "27840049", "isBankAccount": true, "modifiedDate": "2022-09-30T10:29:16Z", "name": "1a1a", "nominalCode": "70600", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 157} + Oracle NetSuite: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/d5074b08-6a34-4b06-a742-236edf5dc4f1/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/d5074b08-6a34-4b06-a742-236edf5dc4f1/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/d5074b08-6a34-4b06-a742-236edf5dc4f1/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": -635.55, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "AcctPay.AcctPay", "fullyQualifiedName": "AcctPay.AcctPay.Accounts Payable", "id": "111", "isBankAccount": false, "modifiedDate": "2023-01-30T14:48:33Z", "name": "Accounts Payable", "nominalCode": "610", "sourceModifiedDate": "2021-08-11T12:51:21", "status": "Active", "type": "Liability", "validDatatypeLinks": []}, {"currency": "USD", "currentBalance": -565, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "AcctRec.AcctRec", "fullyQualifiedName": "AcctRec.AcctRec.Accounts Receivable", "id": "119", "isBankAccount": false, "modifiedDate": "2023-01-30T14:48:33Z", "name": "Accounts Receivable", "nominalCode": "610", "sourceModifiedDate": "2021-09-08T15:23:31", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 44} + QuickBooks Desktop: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/fc72ba08-af13-4474-b28a-01dcfa6cfb51/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/fc72ba08-af13-4474-b28a-01dcfa6cfb51/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/fc72ba08-af13-4474-b28a-01dcfa6cfb51/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 93007.93, "description": "Accounts Receivable", "fullyQualifiedCategory": "Asset.CurrentAsset.AccountsReceivable", "fullyQualifiedName": "Asset.CurrentAsset.AccountsReceivable.Accounts Receivable", "id": "40000-933270541", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:06:23Z", "name": "Accounts Receivable", "nominalCode": "11000", "sourceModifiedDate": "2023-12-16T05:06:45", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 46954.1, "description": "Cash", "fullyQualifiedCategory": "Asset.CurrentAsset.Bank", "fullyQualifiedName": "Asset.CurrentAsset.Bank.Checking", "id": "20000-933270541", "isBankAccount": true, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:06:23Z", "name": "Checking", "nominalCode": "10100", "sourceModifiedDate": "2023-12-16T05:06:45", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["BillLineItem.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]}], "totalResults": 116} + QuickBooks Online: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/10818b5e-6e6a-4ed4-a1c5-3e3efe626e87/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/10818b5e-6e6a-4ed4-a1c5-3e3efe626e87/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/10818b5e-6e6a-4ed4-a1c5-3e3efe626e87/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 41289.37, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Accounts Receivable.AccountsReceivable", "fullyQualifiedName": "Asset.Accounts Receivable.AccountsReceivable.Debtors", "id": "62", "isBankAccount": false, "modifiedDate": "2023-01-18T11:02:34Z", "name": "Debtors", "nominalCode": "246", "sourceModifiedDate": "2022-12-08T15:42:59Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "AED", "currentBalance": -1533.44, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Accounts Receivable.AccountsReceivable", "fullyQualifiedName": "Asset.Accounts Receivable.AccountsReceivable.Debtors - AED", "id": "92", "isBankAccount": false, "modifiedDate": "2023-01-18T11:02:34Z", "name": "Debtors - AED", "nominalCode": "247", "sourceModifiedDate": "2021-02-19T14:04:45Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 234} + QuickBooks Online Sandbox: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/5a7f3597-36e1-4216-86fe-289ad36088a6/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/5a7f3597-36e1-4216-86fe-289ad36088a6/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/5a7f3597-36e1-4216-86fe-289ad36088a6/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 3041173.77, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Accounts Receivable.AccountsReceivable", "fullyQualifiedName": "Asset.Accounts Receivable.AccountsReceivable.Debtors", "id": "70", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:35:55Z", "name": "Debtors", "nominalCode": "610", "sourceModifiedDate": "2023-04-26T01:18:15Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "USD", "currentBalance": 54822.37, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Accounts Receivable.AccountsReceivable", "fullyQualifiedName": "Asset.Accounts Receivable.AccountsReceivable.Debtors - USD", "id": "80", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-26T09:35:55Z", "name": "Debtors - USD", "nominalCode": "610", "sourceModifiedDate": "2023-04-12T15:10:38Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 186} + Sage 200cloud: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/93c21e2d-049c-4d24-b41b-57e61c30b69e/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/93c21e2d-049c-4d24-b41b-57e61c30b69e/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/93c21e2d-049c-4d24-b41b-57e61c30b69e/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 0, "description": "Bank Account", "fullyQualifiedCategory": "Asset.Bank Account", "fullyQualifiedName": "Asset.Bank Account.Bank Account", "id": "2864", "isBankAccount": false, "metadata": {"isDeleted": true}, "modifiedDate": "2022-10-14T09:35:52Z", "name": "Bank Account", "nominalCode": "1200", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Archived", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 0, "description": "Bank Current Account", "fullyQualifiedCategory": "Asset.Bank Account", "fullyQualifiedName": "Asset.Bank Account.Bank Current Account", "id": "2368", "isBankAccount": true, "modifiedDate": "2022-10-14T09:35:52Z", "name": "Bank Current Account", "nominalCode": "1200", "sourceModifiedDate": "2020-09-11T13:53:12Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 344} + Sage 50 (UK): + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/cf5f2a47-2990-4221-bae6-0c19c86ac304/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/cf5f2a47-2990-4221-bae6-0c19c86ac304/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/cf5f2a47-2990-4221-bae6-0c19c86ac304/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 90640.61, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.CurrentAssets.Debtors", "fullyQualifiedName": "Asset.CurrentAssets.Debtors.Debtors Control Account", "id": "1100", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-30T14:42:44Z", "name": "Debtors Control Account", "nominalCode": "1100", "sourceModifiedDate": "2022-11-25T09:43:54", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.CurrentAssets.Debtors", "fullyQualifiedName": "Asset.CurrentAssets.Debtors.Other Debtors", "id": "1102", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-30T14:42:44Z", "name": "Other Debtors", "nominalCode": "1102", "sourceModifiedDate": "2022-11-25T09:43:54", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 155} + Sage Business Cloud Accounting: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/390083e2-351b-407c-a3be-55081c36c182/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/390083e2-351b-407c-a3be-55081c36c182/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/390083e2-351b-407c-a3be-55081c36c182/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 49.61, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Bank", "fullyQualifiedName": "Asset.Bank.Abdi Internet Bank", "id": "e5889b459f544926ac5b8e6756df2ad4", "isBankAccount": true, "modifiedDate": "2022-10-24T14:52:53Z", "name": "Abdi Internet Bank", "nominalCode": "1560", "sourceModifiedDate": "2020-01-27T10:53:26Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]}, {"currency": "GBP", "currentBalance": 225830.75, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Bank", "fullyQualifiedName": "Asset.Bank.Abdi Live Test", "id": "b17083bc9b2748b4ab321b024e260eda", "isBankAccount": true, "modifiedDate": "2022-10-24T14:52:53Z", "name": "Abdi Live Test", "nominalCode": "147852", "sourceModifiedDate": "2020-01-28T14:00:20Z", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Payment.AccountRef.Id", "BillPayment.AccountRef.Id"], "property": "Id"}]}], "totalResults": 283} + Sage Intacct: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/df02b289-cb16-4964-ac4d-9fd60b04538e/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/df02b289-cb16-4964-ac4d-9fd60b04538e/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/df02b289-cb16-4964-ac4d-9fd60b04538e/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Assets.Current Assets.Account Receivable, Net of Allowance.Accounts Receivable.Accounts Receivable", "fullyQualifiedName": "Assets.Current Assets.Account Receivable, Net of Allowance.Accounts Receivable.Accounts Receivable.Accounts Receivable", "id": "2", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-04T16:31:51Z", "name": "Accounts Receivable", "nominalCode": "12100", "sourceModifiedDate": "2020-01-29T01:42:43", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Assets.Current Assets.Account Receivable, Net of Allowance.Accounts Receivable.Accounts Receivable", "fullyQualifiedName": "Assets.Current Assets.Account Receivable, Net of Allowance.Accounts Receivable.Accounts Receivable.AR - Retainage", "id": "155", "isBankAccount": false, "metadata": {"isDeleted": false}, "modifiedDate": "2023-04-04T16:31:51Z", "name": "AR - Retainage", "nominalCode": "12710", "sourceModifiedDate": "2020-10-15T15:33:15", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 181} + Wave: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/0b22b59d-b4e5-4c35-b03f-88bbbcb41256/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/0b22b59d-b4e5-4c35-b03f-88bbbcb41256/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/0b22b59d-b4e5-4c35-b03f-88bbbcb41256/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 0, "description": "Test Balance Sheet", "fullyQualifiedCategory": "Asset.CashAndBank", "fullyQualifiedName": "Asset.CashAndBank.Abdi Bank", "id": "QWNjb3VudDo5MjIzNDE3NjkzMzk3NjA2MzM7QnVzaW5lc3M6ZTI0OGQyZDctMWE5Ni00YTk4LWFkOTEtMDdlMGYyMmNhNmE2", "isBankAccount": true, "modifiedDate": "2022-11-16T18:15:17Z", "name": "Abdi Bank", "nominalCode": "610", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 0, "description": "Cash you haven�t deposited in the bank. Add your bank and credit card accounts to accurately categorize transactions that aren't cash.", "fullyQualifiedCategory": "Asset.CashAndBank", "fullyQualifiedName": "Asset.CashAndBank.Cash on Hand", "id": "QWNjb3VudDo3OTE3NTA1OTcwOTQxNzQ3MTU7QnVzaW5lc3M6ZTI0OGQyZDctMWE5Ni00YTk4LWFkOTEtMDdlMGYyMmNhNmE2", "isBankAccount": true, "modifiedDate": "2022-11-16T18:15:17Z", "name": "Cash on Hand", "nominalCode": "610", "sourceModifiedDate": "2022-10-23T00:00:00Z", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 85} + Xero: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/5ced9667-a310-443a-a711-958d36377141/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/5ced9667-a310-443a-a711-958d36377141/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/5ced9667-a310-443a-a711-958d36377141/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": 924.25, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Bank", "fullyQualifiedName": "Asset.Bank.Business Bank Account", "id": "bd9e85e0-0478-433d-ae9f-0b3c4f04bfe4", "isBankAccount": true, "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-15T20:35:08Z", "name": "Business Bank Account", "nominalCode": "A090", "sourceModifiedDate": "2023-02-17T11:10:49", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Payment.AccountRef.Id", "BillPayment.AccountRef.Id", "DirectIncome.LineItems.AccountRef.Id", "DirectCost.LineItems.AccountRef.Id"], "property": "Id"}]}, {"currency": "GBP", "currentBalance": 0, "description": "Invoices the business has issued but has not yet collected payment on.", "fullyQualifiedCategory": "Asset.Bank", "fullyQualifiedName": "Asset.Bank.Business Savings Account", "id": "a8d6fb1a-8c5d-4683-90ce-bf9d28fc62ba", "isBankAccount": true, "metadata": {"isDeleted": false}, "modifiedDate": "2023-03-15T20:35:08Z", "name": "Business Savings Account", "nominalCode": "A091", "sourceModifiedDate": "2023-02-17T11:10:49", "status": "Active", "type": "Asset", "validDatatypeLinks": [{"links": ["Payment.AccountRef.Id", "BillPayment.AccountRef.Id", "DirectIncome.LineItems.AccountRef.Id", "DirectCost.LineItems.AccountRef.Id"], "property": "Id"}]}], "totalResults": 90} + Zoho Books: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"_links": {"current": {"href": "/companies/d0b68840-db50-4bc3-b88c-96e225333fea/data/accounts?page=1&pageSize=2"}, "next": {"href": "/companies/d0b68840-db50-4bc3-b88c-96e225333fea/data/accounts?page=2&pageSize=2"}, "self": {"href": "/companies/d0b68840-db50-4bc3-b88c-96e225333fea/data/accounts"}}, "pageNumber": 1, "pageSize": 2, "results": [{"currency": "GBP", "currentBalance": -959.64, "description": "The money that customers owe you becomes the accounts receivable. A good example of this is a payment expected from an invoice sent to your customer.", "fullyQualifiedCategory": "Asset.accounts_receivable", "fullyQualifiedName": "Asset.accounts_receivable.Accounts Receivable", "id": "104957000000000352", "isBankAccount": false, "modifiedDate": "2022-10-03T08:40:43Z", "name": "Accounts Receivable", "nominalCode": "", "sourceModifiedDate": "2020-02-05T14:58:44", "status": "Active", "type": "Asset", "validDatatypeLinks": []}, {"currency": "GBP", "currentBalance": 69858.44, "description": "", "fullyQualifiedCategory": "Asset.bank", "fullyQualifiedName": "Asset.bank.Abdi Test", "id": "104957000000060010", "isBankAccount": true, "modifiedDate": "2022-10-03T08:40:43Z", "name": "Abdi Test", "nominalCode": "", "sourceModifiedDate": "2020-02-17T12:19:47", "status": "Active", "type": "Asset", "validDatatypeLinks": []}], "totalResults": 68} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"canBeRetried": "Unknown", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "detailedErrorCode": 0, "error": "Error parsing query - Malformed query.", "service": "ClientsApi", "statusCode": 400} + Unresolved property: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"canBeRetried": "Unknown", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "detailedErrorCode": 0, "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "service": "PullApi", "statusCode": 400} diff --git a/accounting/CONTRIBUTING.md b/accounting/CONTRIBUTING.md new file mode 100644 index 00000000..d585717f --- /dev/null +++ b/accounting/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to This Repository + +Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. + +## How to Report Issues + +If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: + +- A clear and descriptive title +- Steps to reproduce the issue +- Expected and actual behavior +- Any relevant logs, screenshots, or error messages +- Information about your environment (e.g., operating system, software versions) + - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed + +## Issue Triage and Upstream Fixes + +We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. + +## Contact + +If you have any questions or need further assistance, please feel free to reach out by opening an issue. + +Thank you for your understanding and cooperation! + +The Maintainers diff --git a/accounting/FUNCTIONS.md b/accounting/FUNCTIONS.md new file mode 100644 index 00000000..4846f4db --- /dev/null +++ b/accounting/FUNCTIONS.md @@ -0,0 +1,104 @@ +# Standalone Functions + +> [!NOTE] +> This section is useful if you are using a bundler and targetting browsers and +> runtimes where the size of an application affects performance and load times. + +Every method in this SDK is also available as a standalone function. This +alternative API is suitable when targetting the browser or serverless runtimes +and using a bundler to build your application since all unused functionality +will be tree-shaken away. This includes code for unused methods, Zod schemas, +encoding helpers and response handlers. The result is dramatically smaller +impact on the application's final bundle size which grows very slowly as you use +more and more functionality from this SDK. + +Calling methods through the main SDK class remains a valid and generally more +more ergonomic option. Standalone functions represent an optimisation for a +specific category of applications. + +## Example + +```typescript +import { AccountingCore } from "@speakeasy-sdks/accounting/core.js"; +import { accountTransactionsGet } from "@speakeasy-sdks/accounting/funcs/accountTransactionsGet.js"; +import { SDKValidationError } from "@speakeasy-sdks/accounting/sdk/models/errors/sdkvalidationerror.js"; + +// Use `AccountingCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const accounting = new AccountingCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await accountTransactionsGet(accounting, "", "8a210b68-6988-11ed-a1eb-0242ac120002", "2e9d2c44-f675-40ba-8049-353bfcb5e171"); + + switch (true) { + case res.ok: + // The success case will be handled outside of the switch block + break; + case res.error instanceof SDKValidationError: + // Pretty-print validation errors. + return console.log(res.error.pretty()); + case res.error instanceof Error: + return console.log(res.error); + default: + // TypeScript's type checking will fail on the following line if the above + // cases were not exhaustive. + res.error satisfies never; + throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + } + + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + +## Result types + +Standalone functions differ from SDK methods in that they return a +`Result` type to capture _known errors_ and document them using +the type system. By avoiding throwing errors, application code maintains clear +control flow and error-handling become part of the regular flow of application +code. + +> We use the term "known errors" because standalone functions, and JavaScript +> code in general, can still throw unexpected errors such as `TypeError`s, +> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be +> something this SDK addresses in the future. Nevertheless, there is still a lot +> of benefit from capturing most errors and turning them into values. + +The second reason for this style of programming is because these functions will +typically be used in front-end applications where exception throwing is +sometimes discouraged or considered unidiomatic. React and similar ecosystems +and libraries tend to promote this style of programming so that components +render useful content under all states (loading, success, error and so on). + +The general pattern when calling standalone functions looks like this: + +```typescript +import { Core } from ""; +import { fetchSomething } from "/funcs/fetchSomething.js"; + +const client = new Core(); + +async function run() { + const result = await fetchSomething(client, { id: "123" }); + if (!result.ok) { + // You can throw the error or handle it. It's your choice now. + throw result.error; + } + + console.log(result.value); +} + +run(); +``` + +Notably, `result.error` above will have an explicit type compared to a try-catch +variation where the error in the catch block can only be of type `unknown` (or +`any` depending on your TypeScript settings). \ No newline at end of file diff --git a/accounting/README.md b/accounting/README.md index 738cb0b0..b00fa435 100755 --- a/accounting/README.md +++ b/accounting/README.md @@ -6,19 +6,102 @@ + +## Summary + +Accounting API: > ### New to Codat? +> +> Our Accounting API reference is relevant only to our existing clients. +> Please reach out to your Codat contact so that we can find the right product for you. + +A flexible API for pulling accounting data, normalized and aggregated from 20 accounting integrations. + +Standardize how you connect to your customers’ accounting software. View, create, update, and delete data in the same way for all the leading accounting platforms. + + +## Endpoints + +| Endpoints | Description | +| :- |:- | +| Accounts | Access standardized Accounts from linked accounting platforms. | +| Account transactions | Access standardized Account transactions from linked accounting platforms. | +| Bank accounts | Access standardized Bank accounts from linked accounting platforms. | +| Bank account transactions | Access standardized Bank transactions for bank accounts from linked accounting platforms. | +| Bills | Access standardized Bills from linked accounting platforms. | +| Bill credit notes | Access standardized Bill credit notes from linked accounting platforms. | +| Bill payments | Access standardized Bill payments from linked accounting platforms. | +| Credit notes | Access standardized Credit notes from linked accounting platforms. | +| Customers | Access standardized Customers from linked accounting platforms. | +| Direct costs | Access standardized Direct costs from linked accounting platforms. | +| Direct incomes | Access standardized Direct incomes from linked accounting platforms. | +| Company info | Access standardized Company info from linked accounting platforms. | +| Invoices | Access standardized Invoices from linked accounting platforms. | +| Item receipts | Access standardized Item receipts from linked accounting platforms. | +| Items | Access standardized Items from linked accounting platforms. | +| Journals | Access standardized Journals from linked accounting platforms. | +| Journal entries | Access standardized Journal entries from linked accounting platforms. | +| Payments | Access standardized Payments from linked accounting platforms. | +| Payment methods | Access standardized Payment methods from linked accounting platforms. | +| Purchase orders | Access standardized Purchase orders from linked accounting platforms. | +| Sales orders | Access standardized Sales orders from linked accounting platforms. | +| Suppliers | Access standardized Suppliers from linked accounting platforms. | +| Tax rates | Access standardized Tax rates from linked accounting platforms. | +| Tracking categories | Access standardized Tracking categories from linked accounting platforms. | +| Transfers | Access standardized Transfers from linked accounting platforms. | +| Reports | Access standardized Reports from linked accounting platforms. | + + +[Read more...](https://docs.codat.io/accounting-api/overview) + +[See our OpenAPI spec](https://github.com/codatio/oas) + + + +## Table of Contents + +* [SDK Installation](#sdk-installation) +* [Requirements](#requirements) +* [SDK Example Usage](#sdk-example-usage) +* [Available Resources and Operations](#available-resources-and-operations) +* [Standalone functions](#standalone-functions) +* [Retries](#retries) +* [Error Handling](#error-handling) +* [Server Selection](#server-selection) +* [Custom HTTP Client](#custom-http-client) +* [Authentication](#authentication) +* [Debugging](#debugging) + + ## SDK Installation +The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers. + ### NPM ```bash npm add @speakeasy-sdks/accounting ``` +### PNPM + +```bash +pnpm add @speakeasy-sdks/accounting +``` + +### Bun + +```bash +bun add @speakeasy-sdks/accounting +``` + ### Yarn ```bash -yarn add @speakeasy-sdks/accounting +yarn add @speakeasy-sdks/accounting zod + +# Note that Yarn does not install peer dependencies automatically. You will need +# to install zod as shown above. ``` @@ -31,18 +114,18 @@ yarn add @speakeasy-sdks/accounting import { Accounting } from "@speakeasy-sdks/accounting"; const accounting = new Accounting({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await accounting.accountTransactions.get( - "", - "8a210b68-6988-11ed-a1eb-0242ac120002", - "2e9d2c44-f675-40ba-8049-353bfcb5e171" - ); - - // Handle the result - console.log(result); + const result = await accounting.accountTransactions.get( + "", + "8a210b68-6988-11ed-a1eb-0242ac120002", + "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ); + + // Handle the result + console.log(result); } run(); @@ -72,6 +155,32 @@ run(); For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md). + +## Standalone functions + +All the methods listed above are available as standalone functions. These +functions are ideal for use in applications running in the browser, serverless +runtimes or other environments where application bundle size is a primary +concern. When using a bundler to build your application, all unused +functionality will be either excluded from the final bundle or tree-shaken away. + +To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). + +
+ +Available standalone functions + +- [accountTransactionsGet](docs/sdks/accounttransactions/README.md#get) +- [accountTransactionsList](docs/sdks/accounttransactions/README.md#list) +- [accountsCreate](docs/sdks/accounts/README.md#create) +- [accountsGetCreateModel](docs/sdks/accounts/README.md#getcreatemodel) +- [accountsGet](docs/sdks/accounts/README.md#get) +- [accountsList](docs/sdks/accounts/README.md#list) + + +
+ + ## Retries @@ -82,30 +191,30 @@ To change the default retry strategy for a single API call, simply provide a ret import { Accounting } from "@speakeasy-sdks/accounting"; const accounting = new Accounting({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await accounting.accountTransactions.get( - "", - "8a210b68-6988-11ed-a1eb-0242ac120002", - "2e9d2c44-f675-40ba-8049-353bfcb5e171", - { - retries: { - strategy: "backoff", - backoff: { - initialInterval: 1, - maxInterval: 50, - exponent: 1.1, - maxElapsedTime: 100, - }, - retryConnectionErrors: false, - }, - } - ); + const result = await accounting.accountTransactions.get( + "", + "8a210b68-6988-11ed-a1eb-0242ac120002", + "2e9d2c44-f675-40ba-8049-353bfcb5e171", + { + retries: { + strategy: "backoff", + backoff: { + initialInterval: 1, + maxInterval: 50, + exponent: 1.1, + maxElapsedTime: 100, + }, + retryConnectionErrors: false, + }, + }, + ); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); @@ -117,28 +226,28 @@ If you'd like to override the default retry strategy for all operations that sup import { Accounting } from "@speakeasy-sdks/accounting"; const accounting = new Accounting({ - retryConfig: { - strategy: "backoff", - backoff: { - initialInterval: 1, - maxInterval: 50, - exponent: 1.1, - maxElapsedTime: 100, - }, - retryConnectionErrors: false, + retryConfig: { + strategy: "backoff", + backoff: { + initialInterval: 1, + maxInterval: 50, + exponent: 1.1, + maxElapsedTime: 100, }, - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + retryConnectionErrors: false, + }, + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await accounting.accountTransactions.get( - "", - "8a210b68-6988-11ed-a1eb-0242ac120002", - "2e9d2c44-f675-40ba-8049-353bfcb5e171" - ); - - // Handle the result - console.log(result); + const result = await accounting.accountTransactions.get( + "", + "8a210b68-6988-11ed-a1eb-0242ac120002", + "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ); + + // Handle the result + console.log(result); } run(); @@ -160,37 +269,37 @@ Validation errors can also occur when either method arguments or data returned f ```typescript import { Accounting } from "@speakeasy-sdks/accounting"; -import * as errors from "@speakeasy-sdks/accounting/sdk/models/errors"; +import { SDKValidationError } from "@speakeasy-sdks/accounting/sdk/models/errors"; const accounting = new Accounting({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - let result; - try { - result = await accounting.accountTransactions.get( - "", - "8a210b68-6988-11ed-a1eb-0242ac120002", - "2e9d2c44-f675-40ba-8049-353bfcb5e171" - ); - } catch (err) { - switch (true) { - case err instanceof errors.SDKValidationError: { - // Validation errors can be pretty-printed - console.error(err.pretty()); - // Raw value may also be inspected - console.error(err.rawValue); - return; - } - default: { - throw err; - } - } - } + let result; + try { + result = await accounting.accountTransactions.get( + "", + "8a210b68-6988-11ed-a1eb-0242ac120002", + "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ); // Handle the result console.log(result); + } catch (err) { + switch (true) { + case (err instanceof SDKValidationError): { + // Validation errors can be pretty-printed + console.error(err.pretty()); + // Raw value may also be inspected + console.error(err.rawValue); + return; + } + default: { + throw err; + } + } + } } run(); @@ -213,19 +322,19 @@ You can override the default server globally by passing a server index to the `s import { Accounting } from "@speakeasy-sdks/accounting"; const accounting = new Accounting({ - serverIdx: 0, - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + serverIdx: 0, + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await accounting.accountTransactions.get( - "", - "8a210b68-6988-11ed-a1eb-0242ac120002", - "2e9d2c44-f675-40ba-8049-353bfcb5e171" - ); - - // Handle the result - console.log(result); + const result = await accounting.accountTransactions.get( + "", + "8a210b68-6988-11ed-a1eb-0242ac120002", + "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ); + + // Handle the result + console.log(result); } run(); @@ -241,19 +350,19 @@ The default server can also be overridden globally by passing a URL to the `serv import { Accounting } from "@speakeasy-sdks/accounting"; const accounting = new Accounting({ - serverURL: "https://api.codat.io", - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + serverURL: "https://api.codat.io", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await accounting.accountTransactions.get( - "", - "8a210b68-6988-11ed-a1eb-0242ac120002", - "2e9d2c44-f675-40ba-8049-353bfcb5e171" - ); - - // Handle the result - console.log(result); + const result = await accounting.accountTransactions.get( + "", + "8a210b68-6988-11ed-a1eb-0242ac120002", + "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ); + + // Handle the result + console.log(result); } run(); @@ -326,18 +435,18 @@ To authenticate with the API the `authHeader` parameter must be set when initial import { Accounting } from "@speakeasy-sdks/accounting"; const accounting = new Accounting({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await accounting.accountTransactions.get( - "", - "8a210b68-6988-11ed-a1eb-0242ac120002", - "2e9d2c44-f675-40ba-8049-353bfcb5e171" - ); - - // Handle the result - console.log(result); + const result = await accounting.accountTransactions.get( + "", + "8a210b68-6988-11ed-a1eb-0242ac120002", + "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ); + + // Handle the result + console.log(result); } run(); @@ -345,6 +454,23 @@ run(); ``` + +## Debugging + +You can setup your SDK to emit debug logs for SDK requests and responses. + +You can pass a logger that matches `console`'s interface as an SDK option. + +> [!WARNING] +> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production. + +```typescript +import { Accounting } from "@speakeasy-sdks/accounting"; + +const sdk = new Accounting({ debugLogger: console }); +``` + + # Development diff --git a/accounting/RUNTIMES.md b/accounting/RUNTIMES.md index 71fa3dae..d08a0c07 100644 --- a/accounting/RUNTIMES.md +++ b/accounting/RUNTIMES.md @@ -3,7 +3,7 @@ This SDK is intended to be used in JavaScript runtimes that support the following features: * [Web Fetch API][web-fetch] -* [Web Streams API](web-streams) and in particular `ReadableStream` +* [Web Streams API][web-streams] and in particular `ReadableStream` * [Async iterables][async-iter] using `Symbol.asyncIterator` [web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API diff --git a/accounting/USAGE.md b/accounting/USAGE.md index d3ef5a66..e09f3c91 100644 --- a/accounting/USAGE.md +++ b/accounting/USAGE.md @@ -3,18 +3,18 @@ import { Accounting } from "@speakeasy-sdks/accounting"; const accounting = new Accounting({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await accounting.accountTransactions.get( - "", - "8a210b68-6988-11ed-a1eb-0242ac120002", - "2e9d2c44-f675-40ba-8049-353bfcb5e171" - ); + const result = await accounting.accountTransactions.get( + "", + "8a210b68-6988-11ed-a1eb-0242ac120002", + "2e9d2c44-f675-40ba-8049-353bfcb5e171", + ); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); diff --git a/accounting/docs/sdk/models/operations/createaccountrequest.md b/accounting/docs/sdk/models/operations/createaccountrequest.md index 20f57c6f..5b0e53a5 100644 --- a/accounting/docs/sdk/models/operations/createaccountrequest.md +++ b/accounting/docs/sdk/models/operations/createaccountrequest.md @@ -1,5 +1,29 @@ # CreateAccountRequest +## Example Usage + +```typescript +import { CreateAccountRequest } from "@speakeasy-sdks/accounting/sdk/models/operations"; +import { AccountStatus, AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; +import { Decimal } from "@speakeasy-sdks/accounting/sdk/types"; + +let value: CreateAccountRequest = { + accountPrototype: { + currency: "USD", + currentBalance: new Decimal("0"), + description: + "Invoices the business has issued but has not yet collected payment on.", + fullyQualifiedCategory: "Asset.Current", + fullyQualifiedName: "Cash On Hand", + name: "Accounts Receivable", + nominalCode: "610", + status: AccountStatus.Active, + type: AccountType.Asset, + }, + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/createaccountresponse.md b/accounting/docs/sdk/models/operations/createaccountresponse.md index 5c67f1e7..0e3743e5 100644 --- a/accounting/docs/sdk/models/operations/createaccountresponse.md +++ b/accounting/docs/sdk/models/operations/createaccountresponse.md @@ -1,5 +1,36 @@ # CreateAccountResponse +## Example Usage + +```typescript +import { CreateAccountResponse } from "@speakeasy-sdks/accounting/sdk/models/operations"; +import { DataType, PushOperationStatus } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: CreateAccountResponse = { + contentType: "", + createAccountResponse: { + changes: [ + { + recordRef: { + dataType: DataType.Invoices, + }, + }, + ], + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + completedOnUtc: "2022-10-23T00:00:00Z", + dataConnectionKey: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + dataType: DataType.Invoices, + pushOperationKey: "4e0f467c-c879-46ed-951a-05dfc2ddf7cc", + requestedOnUtc: "2022-10-23T00:00:00Z", + status: PushOperationStatus.Success, + statusCode: 780529, + }, + statusCode: 678880, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/getaccountrequest.md b/accounting/docs/sdk/models/operations/getaccountrequest.md index 2cac8fbc..e10f9fa1 100644 --- a/accounting/docs/sdk/models/operations/getaccountrequest.md +++ b/accounting/docs/sdk/models/operations/getaccountrequest.md @@ -1,5 +1,15 @@ # GetAccountRequest +## Example Usage + +```typescript +import { GetAccountRequest } from "@speakeasy-sdks/accounting/sdk/models/operations"; + +let value: GetAccountRequest = { + accountId: "", + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/getaccountresponse.md b/accounting/docs/sdk/models/operations/getaccountresponse.md index 1038be59..7421174b 100644 --- a/accounting/docs/sdk/models/operations/getaccountresponse.md +++ b/accounting/docs/sdk/models/operations/getaccountresponse.md @@ -1,5 +1,35 @@ # GetAccountResponse +## Example Usage + +```typescript +import { GetAccountResponse } from "@speakeasy-sdks/accounting/sdk/models/operations"; +import { AccountStatus, AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; +import { Decimal } from "@speakeasy-sdks/accounting/sdk/types"; + +let value: GetAccountResponse = { + account: { + currency: "GBP", + currentBalance: new Decimal("0"), + description: + "Invoices the business has issued but has not yet collected payment on.", + fullyQualifiedCategory: "Asset.Current", + fullyQualifiedName: "Fixed Asset", + id: "1b6266d1-1e44-46c5-8eb5-a8f98e03124e", + modifiedDate: "2022-10-23T00:00:00Z", + name: "Accounts Receivable", + nominalCode: "610", + sourceModifiedDate: "2022-10-23T00:00:00Z", + status: AccountStatus.Active, + type: AccountType.Asset, + }, + contentType: "", + statusCode: 143353, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/getaccounttransactionrequest.md b/accounting/docs/sdk/models/operations/getaccounttransactionrequest.md index d26ed091..47a339ab 100644 --- a/accounting/docs/sdk/models/operations/getaccounttransactionrequest.md +++ b/accounting/docs/sdk/models/operations/getaccounttransactionrequest.md @@ -1,5 +1,16 @@ # GetAccountTransactionRequest +## Example Usage + +```typescript +import { GetAccountTransactionRequest } from "@speakeasy-sdks/accounting/sdk/models/operations"; + +let value: GetAccountTransactionRequest = { + accountTransactionId: "", + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/getaccounttransactionresponse.md b/accounting/docs/sdk/models/operations/getaccounttransactionresponse.md index 0aff7023..0afb3889 100644 --- a/accounting/docs/sdk/models/operations/getaccounttransactionresponse.md +++ b/accounting/docs/sdk/models/operations/getaccounttransactionresponse.md @@ -1,5 +1,32 @@ # GetAccountTransactionResponse +## Example Usage + +```typescript +import { GetAccountTransactionResponse } from "@speakeasy-sdks/accounting/sdk/models/operations"; +import { AccountTransactionLineRecordRefDataType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: GetAccountTransactionResponse = { + accountTransaction: { + currency: "USD", + date: "2022-10-23T00:00:00Z", + lines: [ + { + recordRef: { + dataType: AccountTransactionLineRecordRefDataType.Transfers, + }, + }, + ], + modifiedDate: "2022-10-23T00:00:00Z", + sourceModifiedDate: "2022-10-23T00:00:00Z", + }, + contentType: "", + statusCode: 602763, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/getcreatechartofaccountsmodelrequest.md b/accounting/docs/sdk/models/operations/getcreatechartofaccountsmodelrequest.md index bdb26d3e..4b59d9bc 100644 --- a/accounting/docs/sdk/models/operations/getcreatechartofaccountsmodelrequest.md +++ b/accounting/docs/sdk/models/operations/getcreatechartofaccountsmodelrequest.md @@ -1,5 +1,15 @@ # GetCreateChartOfAccountsModelRequest +## Example Usage + +```typescript +import { GetCreateChartOfAccountsModelRequest } from "@speakeasy-sdks/accounting/sdk/models/operations"; + +let value: GetCreateChartOfAccountsModelRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/getcreatechartofaccountsmodelresponse.md b/accounting/docs/sdk/models/operations/getcreatechartofaccountsmodelresponse.md index 5eb9d4c3..010e011c 100644 --- a/accounting/docs/sdk/models/operations/getcreatechartofaccountsmodelresponse.md +++ b/accounting/docs/sdk/models/operations/getcreatechartofaccountsmodelresponse.md @@ -1,5 +1,18 @@ # GetCreateChartOfAccountsModelResponse +## Example Usage + +```typescript +import { GetCreateChartOfAccountsModelResponse } from "@speakeasy-sdks/accounting/sdk/models/operations"; + +let value: GetCreateChartOfAccountsModelResponse = { + contentType: "", + statusCode: 537373, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/listaccountsrequest.md b/accounting/docs/sdk/models/operations/listaccountsrequest.md index 87809e8d..89183ce0 100644 --- a/accounting/docs/sdk/models/operations/listaccountsrequest.md +++ b/accounting/docs/sdk/models/operations/listaccountsrequest.md @@ -1,5 +1,18 @@ # ListAccountsRequest +## Example Usage + +```typescript +import { ListAccountsRequest } from "@speakeasy-sdks/accounting/sdk/models/operations"; + +let value: ListAccountsRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + orderBy: "-modifiedDate", + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/listaccountsresponse.md b/accounting/docs/sdk/models/operations/listaccountsresponse.md index 72a4719f..4c2e4735 100644 --- a/accounting/docs/sdk/models/operations/listaccountsresponse.md +++ b/accounting/docs/sdk/models/operations/listaccountsresponse.md @@ -1,5 +1,50 @@ # ListAccountsResponse +## Example Usage + +```typescript +import { ListAccountsResponse } from "@speakeasy-sdks/accounting/sdk/models/operations"; +import { AccountStatus, AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; +import { Decimal } from "@speakeasy-sdks/accounting/sdk/types"; + +let value: ListAccountsResponse = { + accounts: { + links: { + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + self: { + href: "/companies/{id}/data/{dataType}", + }, + }, + pageNumber: 1, + pageSize: 10, + results: [ + { + currency: "EUR", + currentBalance: new Decimal("0"), + description: + "Invoices the business has issued but has not yet collected payment on.", + fullyQualifiedCategory: "Asset.Current", + fullyQualifiedName: "Fixed Asset", + id: "1b6266d1-1e44-46c5-8eb5-a8f98e03124e", + modifiedDate: "2022-10-23T00:00:00Z", + name: "Accounts Receivable", + nominalCode: "610", + sourceModifiedDate: "2022-10-23T00:00:00Z", + status: AccountStatus.Active, + type: AccountType.Asset, + }, + ], + totalResults: 1, + }, + contentType: "", + statusCode: 414662, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/listaccounttransactionsrequest.md b/accounting/docs/sdk/models/operations/listaccounttransactionsrequest.md index b6f2445f..67ea1508 100644 --- a/accounting/docs/sdk/models/operations/listaccounttransactionsrequest.md +++ b/accounting/docs/sdk/models/operations/listaccounttransactionsrequest.md @@ -1,5 +1,19 @@ # ListAccountTransactionsRequest +## Example Usage + +```typescript +import { ListAccountTransactionsRequest } from "@speakeasy-sdks/accounting/sdk/models/operations"; + +let value: ListAccountTransactionsRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + orderBy: "-modifiedDate", + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/operations/listaccounttransactionsresponse.md b/accounting/docs/sdk/models/operations/listaccounttransactionsresponse.md index 05ff432e..d5658086 100644 --- a/accounting/docs/sdk/models/operations/listaccounttransactionsresponse.md +++ b/accounting/docs/sdk/models/operations/listaccounttransactionsresponse.md @@ -1,5 +1,47 @@ # ListAccountTransactionsResponse +## Example Usage + +```typescript +import { ListAccountTransactionsResponse } from "@speakeasy-sdks/accounting/sdk/models/operations"; +import { AccountTransactionLineRecordRefDataType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: ListAccountTransactionsResponse = { + accountTransactions: { + links: { + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + self: { + href: "/companies/{id}/data/{dataType}", + }, + }, + pageNumber: 1, + pageSize: 10, + results: [ + { + currency: "EUR", + date: "2022-10-23T00:00:00Z", + lines: [ + { + recordRef: { + dataType: AccountTransactionLineRecordRefDataType.Transfers, + }, + }, + ], + modifiedDate: "2022-10-23T00:00:00Z", + sourceModifiedDate: "2022-10-23T00:00:00Z", + }, + ], + totalResults: 1, + }, + contentType: "", + statusCode: 623564, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/account.md b/accounting/docs/sdk/models/shared/account.md index beb9719f..814c2e0b 100644 --- a/accounting/docs/sdk/models/shared/account.md +++ b/accounting/docs/sdk/models/shared/account.md @@ -29,6 +29,28 @@ To determine the list of allowed categories for a specific integration, you can: > > This approach gives a true representation of the company's accounts whilst preventing distorting financials such as a company's profit and loss and balance sheet reports. +## Example Usage + +```typescript +import { Account, AccountStatus, AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; +import { Decimal } from "@speakeasy-sdks/accounting/sdk/types"; + +let value: Account = { + currency: "EUR", + currentBalance: new Decimal("0"), + description: + "Invoices the business has issued but has not yet collected payment on.", + fullyQualifiedCategory: "Asset.Current", + fullyQualifiedName: "Fixed Asset", + id: "1b6266d1-1e44-46c5-8eb5-a8f98e03124e", + modifiedDate: "2022-10-23T00:00:00Z", + name: "Accounts Receivable", + nominalCode: "610", + sourceModifiedDate: "2022-10-23T00:00:00Z", + status: AccountStatus.Active, + type: AccountType.Asset, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/accountingaccount.md b/accounting/docs/sdk/models/shared/accountingaccount.md index f8c51110..012e5f12 100644 --- a/accounting/docs/sdk/models/shared/accountingaccount.md +++ b/accounting/docs/sdk/models/shared/accountingaccount.md @@ -31,6 +31,28 @@ To determine the list of allowed categories for a specific integration, you can: > :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. +## Example Usage + +```typescript +import { AccountingAccount, AccountStatus, AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; +import { Decimal } from "@speakeasy-sdks/accounting/sdk/types"; + +let value: AccountingAccount = { + currency: "GBP", + currentBalance: new Decimal("0"), + description: + "Invoices the business has issued but has not yet collected payment on.", + fullyQualifiedCategory: "Asset.Current", + fullyQualifiedName: "Cash On Hand", + id: "1b6266d1-1e44-46c5-8eb5-a8f98e03124e", + modifiedDate: "2022-10-23T00:00:00Z", + name: "Accounts Receivable", + nominalCode: "610", + sourceModifiedDate: "2022-10-23T00:00:00Z", + status: AccountStatus.Active, + type: AccountType.Asset, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/accountprototype.md b/accounting/docs/sdk/models/shared/accountprototype.md index afadb543..2a102534 100644 --- a/accounting/docs/sdk/models/shared/accountprototype.md +++ b/accounting/docs/sdk/models/shared/accountprototype.md @@ -1,5 +1,24 @@ # AccountPrototype +## Example Usage + +```typescript +import { AccountPrototype, AccountStatus, AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; +import { Decimal } from "@speakeasy-sdks/accounting/sdk/types"; + +let value: AccountPrototype = { + currency: "USD", + currentBalance: new Decimal("0"), + description: + "Invoices the business has issued but has not yet collected payment on.", + fullyQualifiedCategory: "Asset.Current", + fullyQualifiedName: "Cash On Hand", + name: "Accounts Receivable", + nominalCode: "610", + status: AccountStatus.Active, + type: AccountType.Asset, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/accounts.md b/accounting/docs/sdk/models/shared/accounts.md index f369a4f5..f82c2e8f 100644 --- a/accounting/docs/sdk/models/shared/accounts.md +++ b/accounting/docs/sdk/models/shared/accounts.md @@ -1,5 +1,42 @@ # Accounts +## Example Usage + +```typescript +import { Accounts, AccountStatus, AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; +import { Decimal } from "@speakeasy-sdks/accounting/sdk/types"; + +let value: Accounts = { + links: { + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + self: { + href: "/companies/{id}/data/{dataType}", + }, + }, + pageNumber: 1, + pageSize: 10, + results: [ + { + currency: "EUR", + currentBalance: new Decimal("0"), + description: + "Invoices the business has issued but has not yet collected payment on.", + fullyQualifiedCategory: "Asset.Current", + fullyQualifiedName: "Cash On Hand", + id: "1b6266d1-1e44-46c5-8eb5-a8f98e03124e", + modifiedDate: "2022-10-23T00:00:00Z", + name: "Accounts Receivable", + nominalCode: "610", + sourceModifiedDate: "2022-10-23T00:00:00Z", + status: AccountStatus.Active, + type: AccountType.Asset, + }, + ], + totalResults: 1, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/accountstatus.md b/accounting/docs/sdk/models/shared/accountstatus.md index cddd64b3..f1e1899c 100644 --- a/accounting/docs/sdk/models/shared/accountstatus.md +++ b/accounting/docs/sdk/models/shared/accountstatus.md @@ -2,6 +2,13 @@ Status of the account +## Example Usage + +```typescript +import { AccountStatus } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: AccountStatus = AccountStatus.Active; +``` ## Values diff --git a/accounting/docs/sdk/models/shared/accounttransaction.md b/accounting/docs/sdk/models/shared/accounttransaction.md index c19918ac..2de8b2c5 100644 --- a/accounting/docs/sdk/models/shared/accounttransaction.md +++ b/accounting/docs/sdk/models/shared/accounttransaction.md @@ -18,6 +18,25 @@ Account transactions are created as a result of different business activities, f Account transactions is the parent data type of [payments](https://docs.codat.io/accounting-api#/schemas/Payment), [bill payments](https://docs.codat.io/accounting-api#/schemas/BillPayment), [direct costs](https://docs.codat.io/accounting-api#/schemas/DirectCost), [direct incomes](https://docs.codat.io/accounting-api#/schemas/DirectIncome), and [transfers](https://docs.codat.io/accounting-api#/schemas/Transfer). +## Example Usage + +```typescript +import { AccountTransaction, AccountTransactionLineRecordRefDataType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: AccountTransaction = { + currency: "GBP", + date: "2022-10-23T00:00:00Z", + lines: [ + { + recordRef: { + dataType: AccountTransactionLineRecordRefDataType.Transfers, + }, + }, + ], + modifiedDate: "2022-10-23T00:00:00Z", + sourceModifiedDate: "2022-10-23T00:00:00Z", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/accounttransactionline.md b/accounting/docs/sdk/models/shared/accounttransactionline.md index 700331e2..98013c37 100644 --- a/accounting/docs/sdk/models/shared/accounttransactionline.md +++ b/accounting/docs/sdk/models/shared/accounttransactionline.md @@ -1,5 +1,16 @@ # AccountTransactionLine +## Example Usage + +```typescript +import { AccountTransactionLine, AccountTransactionLineRecordRefDataType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: AccountTransactionLine = { + recordRef: { + dataType: AccountTransactionLineRecordRefDataType.Transfers, + }, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/accounttransactionlinerecordref.md b/accounting/docs/sdk/models/shared/accounttransactionlinerecordref.md index aa573408..2bf32477 100644 --- a/accounting/docs/sdk/models/shared/accounttransactionlinerecordref.md +++ b/accounting/docs/sdk/models/shared/accounttransactionlinerecordref.md @@ -2,6 +2,15 @@ Links an account transaction line to the underlying record that created it. +## Example Usage + +```typescript +import { AccountTransactionLineRecordRef, AccountTransactionLineRecordRefDataType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: AccountTransactionLineRecordRef = { + dataType: AccountTransactionLineRecordRefDataType.Transfers, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/accounttransactionlinerecordrefdatatype.md b/accounting/docs/sdk/models/shared/accounttransactionlinerecordrefdatatype.md index a5421245..1d68ca9c 100644 --- a/accounting/docs/sdk/models/shared/accounttransactionlinerecordrefdatatype.md +++ b/accounting/docs/sdk/models/shared/accounttransactionlinerecordrefdatatype.md @@ -2,6 +2,14 @@ Name of underlying data type. +## Example Usage + +```typescript +import { AccountTransactionLineRecordRefDataType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: AccountTransactionLineRecordRefDataType = + AccountTransactionLineRecordRefDataType.Transfers; +``` ## Values diff --git a/accounting/docs/sdk/models/shared/accounttransactions.md b/accounting/docs/sdk/models/shared/accounttransactions.md index f9b6ec80..f8da5375 100644 --- a/accounting/docs/sdk/models/shared/accounttransactions.md +++ b/accounting/docs/sdk/models/shared/accounttransactions.md @@ -1,5 +1,39 @@ # AccountTransactions +## Example Usage + +```typescript +import { AccountTransactionLineRecordRefDataType, AccountTransactions } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: AccountTransactions = { + links: { + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + self: { + href: "/companies/{id}/data/{dataType}", + }, + }, + pageNumber: 1, + pageSize: 10, + results: [ + { + currency: "USD", + date: "2022-10-23T00:00:00Z", + lines: [ + { + recordRef: { + dataType: AccountTransactionLineRecordRefDataType.Transfers, + }, + }, + ], + modifiedDate: "2022-10-23T00:00:00Z", + sourceModifiedDate: "2022-10-23T00:00:00Z", + }, + ], + totalResults: 1, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/accounttype.md b/accounting/docs/sdk/models/shared/accounttype.md index 938ae146..fcb469be 100644 --- a/accounting/docs/sdk/models/shared/accounttype.md +++ b/accounting/docs/sdk/models/shared/accounttype.md @@ -2,6 +2,13 @@ Type of account +## Example Usage + +```typescript +import { AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: AccountType = AccountType.Asset; +``` ## Values diff --git a/accounting/docs/sdk/models/shared/bankaccountref.md b/accounting/docs/sdk/models/shared/bankaccountref.md index 4f4ce8e0..c7883e42 100644 --- a/accounting/docs/sdk/models/shared/bankaccountref.md +++ b/accounting/docs/sdk/models/shared/bankaccountref.md @@ -2,6 +2,13 @@ Links to the Account transactions data type. +## Example Usage + +```typescript +import { BankAccountRef } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: BankAccountRef = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/createaccountresponse.md b/accounting/docs/sdk/models/shared/createaccountresponse.md index 0ad0d9a7..4f333f27 100644 --- a/accounting/docs/sdk/models/shared/createaccountresponse.md +++ b/accounting/docs/sdk/models/shared/createaccountresponse.md @@ -1,5 +1,28 @@ # CreateAccountResponse +## Example Usage + +```typescript +import { CreateAccountResponse, DataType, PushOperationStatus } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: CreateAccountResponse = { + changes: [ + { + recordRef: { + dataType: DataType.Invoices, + }, + }, + ], + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + completedOnUtc: "2022-10-23T00:00:00Z", + dataConnectionKey: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + dataType: DataType.Invoices, + pushOperationKey: "396fea75-96eb-410f-aaa2-352c5955907a", + requestedOnUtc: "2022-10-23T00:00:00Z", + status: PushOperationStatus.TimedOut, + statusCode: 102044, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/datatype.md b/accounting/docs/sdk/models/shared/datatype.md index 4f6ed341..a721dd9e 100644 --- a/accounting/docs/sdk/models/shared/datatype.md +++ b/accounting/docs/sdk/models/shared/datatype.md @@ -2,6 +2,13 @@ Available data types +## Example Usage + +```typescript +import { DataType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: DataType = DataType.Invoices; +``` ## Values diff --git a/accounting/docs/sdk/models/shared/errormessage.md b/accounting/docs/sdk/models/shared/errormessage.md index 4d3abac9..1403bca6 100644 --- a/accounting/docs/sdk/models/shared/errormessage.md +++ b/accounting/docs/sdk/models/shared/errormessage.md @@ -1,5 +1,12 @@ # ErrorMessage +## Example Usage + +```typescript +import { ErrorMessage } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: ErrorMessage = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/errorvalidation.md b/accounting/docs/sdk/models/shared/errorvalidation.md index 232c51fd..43fc973e 100644 --- a/accounting/docs/sdk/models/shared/errorvalidation.md +++ b/accounting/docs/sdk/models/shared/errorvalidation.md @@ -2,6 +2,13 @@ A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. +## Example Usage + +```typescript +import { ErrorValidation } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: ErrorValidation = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/errorvalidationitem.md b/accounting/docs/sdk/models/shared/errorvalidationitem.md index 257d7818..39f49453 100644 --- a/accounting/docs/sdk/models/shared/errorvalidationitem.md +++ b/accounting/docs/sdk/models/shared/errorvalidationitem.md @@ -1,5 +1,12 @@ # ErrorValidationItem +## Example Usage + +```typescript +import { ErrorValidationItem } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: ErrorValidationItem = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/halref.md b/accounting/docs/sdk/models/shared/halref.md index a1902370..b88a07ab 100644 --- a/accounting/docs/sdk/models/shared/halref.md +++ b/accounting/docs/sdk/models/shared/halref.md @@ -1,5 +1,12 @@ # HalRef +## Example Usage + +```typescript +import { HalRef } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: HalRef = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/links.md b/accounting/docs/sdk/models/shared/links.md index 37df2ee7..8a138d13 100644 --- a/accounting/docs/sdk/models/shared/links.md +++ b/accounting/docs/sdk/models/shared/links.md @@ -1,5 +1,19 @@ # Links +## Example Usage + +```typescript +import { Links } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: Links = { + current: { + href: "/companies?page=1&pageSize=10", + }, + self: { + href: "/companies", + }, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/metadata.md b/accounting/docs/sdk/models/shared/metadata.md index 7dd6cd51..07784692 100644 --- a/accounting/docs/sdk/models/shared/metadata.md +++ b/accounting/docs/sdk/models/shared/metadata.md @@ -1,5 +1,12 @@ # Metadata +## Example Usage + +```typescript +import { Metadata } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: Metadata = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/pushchangetype.md b/accounting/docs/sdk/models/shared/pushchangetype.md index 7585e9c8..65675f7e 100644 --- a/accounting/docs/sdk/models/shared/pushchangetype.md +++ b/accounting/docs/sdk/models/shared/pushchangetype.md @@ -2,6 +2,13 @@ Type of change being applied to record in third party platform. +## Example Usage + +```typescript +import { PushChangeType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushChangeType = PushChangeType.Created; +``` ## Values diff --git a/accounting/docs/sdk/models/shared/pushfieldvalidation.md b/accounting/docs/sdk/models/shared/pushfieldvalidation.md index d8ab81aa..239dae00 100644 --- a/accounting/docs/sdk/models/shared/pushfieldvalidation.md +++ b/accounting/docs/sdk/models/shared/pushfieldvalidation.md @@ -1,5 +1,14 @@ # PushFieldValidation +## Example Usage + +```typescript +import { PushFieldValidation } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushFieldValidation = { + details: "", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/pushoperationchange.md b/accounting/docs/sdk/models/shared/pushoperationchange.md index 67d462c0..c7384a98 100644 --- a/accounting/docs/sdk/models/shared/pushoperationchange.md +++ b/accounting/docs/sdk/models/shared/pushoperationchange.md @@ -1,5 +1,16 @@ # PushOperationChange +## Example Usage + +```typescript +import { DataType, PushOperationChange } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushOperationChange = { + recordRef: { + dataType: DataType.Invoices, + }, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/pushoperationref.md b/accounting/docs/sdk/models/shared/pushoperationref.md index 93296889..be7d14f8 100644 --- a/accounting/docs/sdk/models/shared/pushoperationref.md +++ b/accounting/docs/sdk/models/shared/pushoperationref.md @@ -1,5 +1,14 @@ # PushOperationRef +## Example Usage + +```typescript +import { DataType, PushOperationRef } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushOperationRef = { + dataType: DataType.Invoices, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/pushoperationstatus.md b/accounting/docs/sdk/models/shared/pushoperationstatus.md index 4e041b53..289f233a 100644 --- a/accounting/docs/sdk/models/shared/pushoperationstatus.md +++ b/accounting/docs/sdk/models/shared/pushoperationstatus.md @@ -2,6 +2,13 @@ The current status of the push operation. +## Example Usage + +```typescript +import { PushOperationStatus } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushOperationStatus = PushOperationStatus.Success; +``` ## Values diff --git a/accounting/docs/sdk/models/shared/pushoption.md b/accounting/docs/sdk/models/shared/pushoption.md index 1e8cf6a0..fb19f07e 100644 --- a/accounting/docs/sdk/models/shared/pushoption.md +++ b/accounting/docs/sdk/models/shared/pushoption.md @@ -1,5 +1,16 @@ # PushOption +## Example Usage + +```typescript +import { PushOption, PushOptionType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushOption = { + displayName: "Harvey.Konopelski", + required: false, + type: PushOptionType.Boolean, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/pushoptionchoice.md b/accounting/docs/sdk/models/shared/pushoptionchoice.md index efdac3c0..ca667abe 100644 --- a/accounting/docs/sdk/models/shared/pushoptionchoice.md +++ b/accounting/docs/sdk/models/shared/pushoptionchoice.md @@ -1,5 +1,12 @@ # PushOptionChoice +## Example Usage + +```typescript +import { PushOptionChoice } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushOptionChoice = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/pushoptionproperty.md b/accounting/docs/sdk/models/shared/pushoptionproperty.md index 3eaa3080..33ffc527 100644 --- a/accounting/docs/sdk/models/shared/pushoptionproperty.md +++ b/accounting/docs/sdk/models/shared/pushoptionproperty.md @@ -1,5 +1,17 @@ # PushOptionProperty +## Example Usage + +```typescript +import { PushOptionProperty, PushOptionType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushOptionProperty = { + description: "Fundamental background neural-net", + displayName: "Madison77", + required: false, + type: PushOptionType.Object, +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/pushoptiontype.md b/accounting/docs/sdk/models/shared/pushoptiontype.md index f1bb3708..056488cf 100644 --- a/accounting/docs/sdk/models/shared/pushoptiontype.md +++ b/accounting/docs/sdk/models/shared/pushoptiontype.md @@ -2,6 +2,13 @@ The option type. +## Example Usage + +```typescript +import { PushOptionType } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushOptionType = PushOptionType.Object; +``` ## Values diff --git a/accounting/docs/sdk/models/shared/pushvalidationinfo.md b/accounting/docs/sdk/models/shared/pushvalidationinfo.md index 00a893d2..7062c174 100644 --- a/accounting/docs/sdk/models/shared/pushvalidationinfo.md +++ b/accounting/docs/sdk/models/shared/pushvalidationinfo.md @@ -1,5 +1,12 @@ # PushValidationInfo +## Example Usage + +```typescript +import { PushValidationInfo } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: PushValidationInfo = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/security.md b/accounting/docs/sdk/models/shared/security.md index 30160fe1..d131f2dd 100644 --- a/accounting/docs/sdk/models/shared/security.md +++ b/accounting/docs/sdk/models/shared/security.md @@ -1,5 +1,14 @@ # Security +## Example Usage + +```typescript +import { Security } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: Security = { + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/status.md b/accounting/docs/sdk/models/shared/status.md index 3c342140..baa9cc60 100644 --- a/accounting/docs/sdk/models/shared/status.md +++ b/accounting/docs/sdk/models/shared/status.md @@ -2,6 +2,13 @@ The status of the account transaction. +## Example Usage + +```typescript +import { Status } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: Status = Status.Unreconciled; +``` ## Values diff --git a/accounting/docs/sdk/models/shared/supplementaldata.md b/accounting/docs/sdk/models/shared/supplementaldata.md index 7d292339..2a00d22c 100644 --- a/accounting/docs/sdk/models/shared/supplementaldata.md +++ b/accounting/docs/sdk/models/shared/supplementaldata.md @@ -4,6 +4,13 @@ Supplemental data is additional data you can include in our standard data types. It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. +## Example Usage + +```typescript +import { SupplementalData } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: SupplementalData = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/validation.md b/accounting/docs/sdk/models/shared/validation.md index 87b89a60..2b1bda5e 100644 --- a/accounting/docs/sdk/models/shared/validation.md +++ b/accounting/docs/sdk/models/shared/validation.md @@ -2,6 +2,13 @@ A human-readable object describing validation decisions Codat has made when pushing data into the platform. If a push has failed because of validation errors, they will be detailed here. +## Example Usage + +```typescript +import { Validation } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: Validation = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/validationitem.md b/accounting/docs/sdk/models/shared/validationitem.md index 6f7fb323..ff4e00ca 100644 --- a/accounting/docs/sdk/models/shared/validationitem.md +++ b/accounting/docs/sdk/models/shared/validationitem.md @@ -1,5 +1,12 @@ # ValidationItem +## Example Usage + +```typescript +import { ValidationItem } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: ValidationItem = {}; +``` ## Fields diff --git a/accounting/docs/sdk/models/shared/validdatatypelinks.md b/accounting/docs/sdk/models/shared/validdatatypelinks.md index 013ebcb3..d9571a26 100644 --- a/accounting/docs/sdk/models/shared/validdatatypelinks.md +++ b/accounting/docs/sdk/models/shared/validdatatypelinks.md @@ -41,6 +41,13 @@ Codat currently supports `validDatatypeLinks` for some data types on our Xero, Q If you'd like us to extend support to more data types or integrations, suggest or vote for this on our Product Roadmap. +## Example Usage + +```typescript +import { ValidDataTypeLinks } from "@speakeasy-sdks/accounting/sdk/models/shared"; + +let value: ValidDataTypeLinks = {}; +``` ## Fields diff --git a/accounting/docs/sdks/accounting/README.md b/accounting/docs/sdks/accounting/README.md index 5a4af37c..fb938677 100644 --- a/accounting/docs/sdks/accounting/README.md +++ b/accounting/docs/sdks/accounting/README.md @@ -1,6 +1,5 @@ # Accounting SDK - ## Overview Accounting API: > ### New to Codat? @@ -47,7 +46,4 @@ Standardize how you connect to your customers’ accounting software. View, crea [Read more...](https://docs.codat.io/accounting-api/overview) -[See our OpenAPI spec](https://github.com/codatio/oas) - -### Available Operations - +[See our OpenAPI spec](https://github.com/codatio/oas) \ No newline at end of file diff --git a/accounting/docs/sdks/accounts/README.md b/accounting/docs/sdks/accounts/README.md index 1e8deff5..bf57cc32 100644 --- a/accounting/docs/sdks/accounts/README.md +++ b/accounting/docs/sdks/accounts/README.md @@ -47,7 +47,49 @@ async function run() { nominalCode: "610", status: AccountStatus.Active, type: AccountType.Asset, - }, 638424); + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { AccountingCore } from "@speakeasy-sdks/accounting/core.js"; +import { accountsCreate } from "@speakeasy-sdks/accounting/funcs/accountsCreate.js"; +import { AccountStatus, AccountType } from "@speakeasy-sdks/accounting/sdk/models/shared"; +import { Decimal } from "@speakeasy-sdks/accounting/sdk/types"; + +// Use `AccountingCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const accounting = new AccountingCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await accountsCreate(accounting, "8a210b68-6988-11ed-a1eb-0242ac120002", "2e9d2c44-f675-40ba-8049-353bfcb5e171", { + currency: "USD", + currentBalance: new Decimal("0"), + description: "Invoices the business has issued but has not yet collected payment on.", + fullyQualifiedCategory: "Asset.Current", + fullyQualifiedName: "Cash On Hand", + name: "Accounts Receivable", + nominalCode: "610", + status: AccountStatus.Active, + type: AccountType.Asset, + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -68,16 +110,17 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.CreateAccountResponse](../../sdk/models/operations/createaccountresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | + ## get The *Get account* endpoint returns a single account for a given accountId. @@ -100,6 +143,36 @@ const accounting = new Accounting({ async function run() { const result = await accounting.accounts.get("", "8a210b68-6988-11ed-a1eb-0242ac120002"); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { AccountingCore } from "@speakeasy-sdks/accounting/core.js"; +import { accountsGet } from "@speakeasy-sdks/accounting/funcs/accountsGet.js"; + +// Use `AccountingCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const accounting = new AccountingCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await accountsGet(accounting, "", "8a210b68-6988-11ed-a1eb-0242ac120002"); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -118,16 +191,17 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.GetAccountResponse](../../sdk/models/operations/getaccountresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | + ## getCreateModel The *Get create account model* endpoint returns the expected data for the request payload when creating an [account](https://docs.codat.io/accounting-api#/schemas/Account) for a given company and integration. @@ -152,6 +226,36 @@ const accounting = new Accounting({ async function run() { const result = await accounting.accounts.getCreateModel("8a210b68-6988-11ed-a1eb-0242ac120002", "2e9d2c44-f675-40ba-8049-353bfcb5e171"); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { AccountingCore } from "@speakeasy-sdks/accounting/core.js"; +import { accountsGetCreateModel } from "@speakeasy-sdks/accounting/funcs/accountsGetCreateModel.js"; + +// Use `AccountingCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const accounting = new AccountingCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await accountsGetCreateModel(accounting, "8a210b68-6988-11ed-a1eb-0242ac120002", "2e9d2c44-f675-40ba-8049-353bfcb5e171"); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -170,16 +274,17 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.GetCreateChartOfAccountsModelResponse](../../sdk/models/operations/getcreatechartofaccountsmodelresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | + ## list The *List accounts* endpoint returns a list of [accounts](https://docs.codat.io/accounting-api#/schemas/Account) for a given company's connection. @@ -205,6 +310,42 @@ async function run() { pageSize: 100, query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { AccountingCore } from "@speakeasy-sdks/accounting/core.js"; +import { accountsList } from "@speakeasy-sdks/accounting/funcs/accountsList.js"; + +// Use `AccountingCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const accounting = new AccountingCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await accountsList(accounting, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + orderBy: "-modifiedDate", + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -222,10 +363,10 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.ListAccountsResponse](../../sdk/models/operations/listaccountsresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | diff --git a/accounting/docs/sdks/accounttransactions/README.md b/accounting/docs/sdks/accounttransactions/README.md index 341b15ac..c742e41e 100644 --- a/accounting/docs/sdks/accounttransactions/README.md +++ b/accounting/docs/sdks/accounttransactions/README.md @@ -32,6 +32,36 @@ const accounting = new Accounting({ async function run() { const result = await accounting.accountTransactions.get("", "8a210b68-6988-11ed-a1eb-0242ac120002", "2e9d2c44-f675-40ba-8049-353bfcb5e171"); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { AccountingCore } from "@speakeasy-sdks/accounting/core.js"; +import { accountTransactionsGet } from "@speakeasy-sdks/accounting/funcs/accountTransactionsGet.js"; + +// Use `AccountingCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const accounting = new AccountingCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await accountTransactionsGet(accounting, "", "8a210b68-6988-11ed-a1eb-0242ac120002", "2e9d2c44-f675-40ba-8049-353bfcb5e171"); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -51,16 +81,17 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.GetAccountTransactionResponse](../../sdk/models/operations/getaccounttransactionresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | + ## list The *List account transactions* endpoint returns a list of [account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) for a given company's connection. @@ -88,6 +119,43 @@ async function run() { pageSize: 100, query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { AccountingCore } from "@speakeasy-sdks/accounting/core.js"; +import { accountTransactionsList } from "@speakeasy-sdks/accounting/funcs/accountTransactionsList.js"; + +// Use `AccountingCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const accounting = new AccountingCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await accountTransactionsList(accounting, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + orderBy: "-modifiedDate", + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -105,10 +173,10 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.ListAccountTransactionsResponse](../../sdk/models/operations/listaccounttransactionsresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | diff --git a/accounting/gen.yaml b/accounting/gen.yaml index 6c081568..746c9c57 100644 --- a/accounting/gen.yaml +++ b/accounting/gen.yaml @@ -11,7 +11,7 @@ generation: oAuth2ClientCredentialsEnabled: false telemetryEnabled: true typescript: - version: 0.6.0 + version: 0.7.0 additionalDependencies: dependencies: {} devDependencies: {} @@ -33,7 +33,9 @@ typescript: inputModelSuffix: input maxMethodParams: 4 methodArguments: require-security-and-request + moduleFormat: commonjs outputModelSuffix: output packageName: '@speakeasy-sdks/accounting' responseFormat: envelope templateVersion: v2 + useIndexModules: true diff --git a/accounting/jsr.json b/accounting/jsr.json index bd743611..97f39889 100644 --- a/accounting/jsr.json +++ b/accounting/jsr.json @@ -2,7 +2,7 @@ { "name": "@speakeasy-sdks/accounting", - "version": "0.6.0", + "version": "0.7.0", "exports": { ".": "./src/index.ts", "./sdk/models/errors": "./src/sdk/models/errors/index.ts", diff --git a/accounting/package-lock.json b/accounting/package-lock.json index 154bab12..23713342 100644 --- a/accounting/package-lock.json +++ b/accounting/package-lock.json @@ -1,17 +1,17 @@ { "name": "@speakeasy-sdks/accounting", - "version": "0.6.0", + "version": "0.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@speakeasy-sdks/accounting", - "version": "0.6.0", + "version": "0.7.0", "dependencies": { "decimal.js": "^10.4.3" }, "devDependencies": { - "@types/jsonpath": "^0.2.4", + "@types/node": "^18.19.3", "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", "eslint": "^8.57.0", @@ -198,11 +198,15 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, - "node_modules/@types/jsonpath": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@types/jsonpath/-/jsonpath-0.2.4.tgz", - "integrity": "sha512-K3hxB8Blw0qgW6ExKgMbXQv2UPZBoE2GqLpVY+yr7nMD2Pq86lsuIzyAaiQ7eMqFL5B6di6pxSkogLJEyEHoGA==", - "dev": true + "node_modules/@types/node": { + "version": "18.19.50", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.50.tgz", + "integrity": "sha512-xonK+NRrMBRtkL1hVCc3G+uXtjh1Al4opBLjqVmipe5ZAaBYWW6cNAiBVZ1BvmkBhep698rP3UM3aRAdSALuhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.10.0", @@ -2984,6 +2988,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/accounting/package.json b/accounting/package.json index d76e05d2..3177a89b 100644 --- a/accounting/package.json +++ b/accounting/package.json @@ -1,7 +1,7 @@ { "name": "@speakeasy-sdks/accounting", - "version": "0.6.0", - "author": "Accounting", + "version": "0.7.0", + "author": "Accounting", "main": "./index.js", "sideEffects": false, "repository": { @@ -18,7 +18,7 @@ "zod": ">= 3" }, "devDependencies": { - "@types/jsonpath": "^0.2.4", + "@types/node": "^18.19.3", "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", "eslint": "^8.57.0", diff --git a/accounting/src/core.ts b/accounting/src/core.ts new file mode 100644 index 00000000..91c87e0d --- /dev/null +++ b/accounting/src/core.ts @@ -0,0 +1,13 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { ClientSDK } from "./lib/sdks.js"; + +/** + * A minimal client to use when calling standalone SDK functions. Typically, an + * instance of this class would be instantiated once at the start of an + * application and passed around through some dependency injection mechanism to + * parts of an application that need to make SDK calls. + */ +export class AccountingCore extends ClientSDK {} diff --git a/accounting/src/funcs/accountTransactionsGet.ts b/accounting/src/funcs/accountTransactionsGet.ts new file mode 100644 index 00000000..0b8b6714 --- /dev/null +++ b/accounting/src/funcs/accountTransactionsGet.ts @@ -0,0 +1,172 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { AccountingCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get account transaction + * + * @remarks + * The *Get account transaction* endpoint returns a single account transaction for a given accountTransactionId. + * + * [Account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) represent bank activity within an accounting platform. All transactions that go through a bank account are recorded as account transactions. + * + * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=accountTransactions) for integrations that support getting a specific account transaction. + * + * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). + */ +export async function accountTransactionsGet( + client$: AccountingCore, + accountTransactionId: string, + companyId: string, + connectionId: string, + options?: RequestOptions, +): Promise< + Result< + operations.GetAccountTransactionResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.GetAccountTransactionRequest = { + accountTransactionId: accountTransactionId, + companyId: companyId, + connectionId: connectionId, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => + operations.GetAccountTransactionRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + accountTransactionId: encodeSimple$( + "accountTransactionId", + payload$.accountTransactionId, + { explode: false, charEncoding: "percent" }, + ), + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + connectionId: encodeSimple$("connectionId", payload$.connectionId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc( + "/companies/{companyId}/connections/{connectionId}/data/accountTransactions/{accountTransactionId}", + )(pathParams$); + + const headers$ = new Headers({ + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "get-account-transaction", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: [], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") + ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.GetAccountTransactionResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.GetAccountTransactionResponse$inboundSchema, { + key: "AccountTransaction", + }), + m$.json( + [401, 402, 403, 404, 409, 429, 500, 503], + operations.GetAccountTransactionResponse$inboundSchema, + { key: "ErrorMessage" }, + ), + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/accounting/src/funcs/accountTransactionsList.ts b/accounting/src/funcs/accountTransactionsList.ts new file mode 100644 index 00000000..0ee5c2ac --- /dev/null +++ b/accounting/src/funcs/accountTransactionsList.ts @@ -0,0 +1,170 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { AccountingCore } from "../core.js"; +import { + encodeFormQuery as encodeFormQuery$, + encodeSimple as encodeSimple$, +} from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * List account transactions + * + * @remarks + * The *List account transactions* endpoint returns a list of [account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) for a given company's connection. + * + * [Account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) represent bank activity within an accounting platform. All transactions that go through a bank account are recorded as account transactions. + * + * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). + */ +export async function accountTransactionsList( + client$: AccountingCore, + request: operations.ListAccountTransactionsRequest, + options?: RequestOptions, +): Promise< + Result< + operations.ListAccountTransactionsResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$ = request; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => + operations.ListAccountTransactionsRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + connectionId: encodeSimple$("connectionId", payload$.connectionId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc( + "/companies/{companyId}/connections/{connectionId}/data/accountTransactions", + )(pathParams$); + + const query$ = encodeFormQuery$({ + "orderBy": payload$.orderBy, + "page": payload$.page, + "pageSize": payload$.pageSize, + "query": payload$.query, + }); + + const headers$ = new Headers({ + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "list-account-transactions", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + query: query$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: [], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") + ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.ListAccountTransactionsResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.ListAccountTransactionsResponse$inboundSchema, { + key: "AccountTransactions", + }), + m$.json( + [400, 401, 402, 403, 404, 409, 429, 500, 503], + operations.ListAccountTransactionsResponse$inboundSchema, + { key: "ErrorMessage" }, + ), + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/accounting/src/funcs/accountsCreate.ts b/accounting/src/funcs/accountsCreate.ts new file mode 100644 index 00000000..ba299496 --- /dev/null +++ b/accounting/src/funcs/accountsCreate.ts @@ -0,0 +1,183 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { AccountingCore } from "../core.js"; +import { + encodeFormQuery as encodeFormQuery$, + encodeJSON as encodeJSON$, + encodeSimple as encodeSimple$, +} from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Create account + * + * @remarks + * The *Create account* endpoint creates a new [account](https://docs.codat.io/accounting-api#/schemas/Account) for a given company's connection. + * + * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. + * + * **Integration-specific behaviour** + * + * Required data may vary by integration. To see what data to post, first call [Get create account model](https://docs.codat.io/accounting-api#/operations/get-create-chartOfAccounts-model). + * + * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support creating an account. + */ +export async function accountsCreate( + client$: AccountingCore, + companyId: string, + connectionId: string, + accountPrototype?: shared.AccountPrototype | undefined, + timeoutInMinutes?: number | undefined, + options?: RequestOptions, +): Promise< + Result< + operations.CreateAccountResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.CreateAccountRequest = { + accountPrototype: accountPrototype, + companyId: companyId, + connectionId: connectionId, + timeoutInMinutes: timeoutInMinutes, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.CreateAccountRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$.accountPrototype, { + explode: true, + }); + + const pathParams$ = { + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + connectionId: encodeSimple$("connectionId", payload$.connectionId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc( + "/companies/{companyId}/connections/{connectionId}/push/accounts", + )(pathParams$); + + const query$ = encodeFormQuery$({ + "timeoutInMinutes": payload$.timeoutInMinutes, + }); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "create-account", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + query: query$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: [], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") + ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.CreateAccountResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.CreateAccountResponse$inboundSchema, { + key: "CreateAccountResponse", + }), + m$.json( + [400, 401, 402, 403, 404, 429, 500, 503], + operations.CreateAccountResponse$inboundSchema, + { key: "ErrorMessage" }, + ), + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/accounting/src/funcs/accountsGet.ts b/accounting/src/funcs/accountsGet.ts new file mode 100644 index 00000000..8af5661a --- /dev/null +++ b/accounting/src/funcs/accountsGet.ts @@ -0,0 +1,164 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { AccountingCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get account + * + * @remarks + * The *Get account* endpoint returns a single account for a given accountId. + * + * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. + * + * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support getting a specific account. + * + * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). + */ +export async function accountsGet( + client$: AccountingCore, + accountId: string, + companyId: string, + options?: RequestOptions, +): Promise< + Result< + operations.GetAccountResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.GetAccountRequest = { + accountId: accountId, + companyId: companyId, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.GetAccountRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + accountId: encodeSimple$("accountId", payload$.accountId, { + explode: false, + charEncoding: "percent", + }), + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc("/companies/{companyId}/data/accounts/{accountId}")( + pathParams$, + ); + + const headers$ = new Headers({ + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "get-account", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: [], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") + ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.GetAccountResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.GetAccountResponse$inboundSchema, { + key: "Account", + }), + m$.json( + [401, 402, 403, 404, 409, 429, 500, 503], + operations.GetAccountResponse$inboundSchema, + { key: "ErrorMessage" }, + ), + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/accounting/src/funcs/accountsGetCreateModel.ts b/accounting/src/funcs/accountsGetCreateModel.ts new file mode 100644 index 00000000..e4baf008 --- /dev/null +++ b/accounting/src/funcs/accountsGetCreateModel.ts @@ -0,0 +1,171 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { AccountingCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get create account model + * + * @remarks + * The *Get create account model* endpoint returns the expected data for the request payload when creating an [account](https://docs.codat.io/accounting-api#/schemas/Account) for a given company and integration. + * + * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. + * + * **Integration-specific behaviour** + * + * See the *response examples* for integration-specific indicative models. + * + * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support creating an account. + */ +export async function accountsGetCreateModel( + client$: AccountingCore, + companyId: string, + connectionId: string, + options?: RequestOptions, +): Promise< + Result< + operations.GetCreateChartOfAccountsModelResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.GetCreateChartOfAccountsModelRequest = { + companyId: companyId, + connectionId: connectionId, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => + operations.GetCreateChartOfAccountsModelRequest$outboundSchema.parse( + value$, + ), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + connectionId: encodeSimple$("connectionId", payload$.connectionId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc( + "/companies/{companyId}/connections/{connectionId}/options/chartOfAccounts", + )(pathParams$); + + const headers$ = new Headers({ + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "get-create-chartOfAccounts-model", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: [], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") + ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.GetCreateChartOfAccountsModelResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json( + 200, + operations.GetCreateChartOfAccountsModelResponse$inboundSchema, + { key: "PushOption" }, + ), + m$.json( + [401, 402, 403, 404, 429, 500, 503], + operations.GetCreateChartOfAccountsModelResponse$inboundSchema, + { key: "ErrorMessage" }, + ), + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/accounting/src/funcs/accountsList.ts b/accounting/src/funcs/accountsList.ts new file mode 100644 index 00000000..38886a0d --- /dev/null +++ b/accounting/src/funcs/accountsList.ts @@ -0,0 +1,163 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { AccountingCore } from "../core.js"; +import { + encodeFormQuery as encodeFormQuery$, + encodeSimple as encodeSimple$, +} from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * List accounts + * + * @remarks + * The *List accounts* endpoint returns a list of [accounts](https://docs.codat.io/accounting-api#/schemas/Account) for a given company's connection. + * + * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. + * + * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). + */ +export async function accountsList( + client$: AccountingCore, + request: operations.ListAccountsRequest, + options?: RequestOptions, +): Promise< + Result< + operations.ListAccountsResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$ = request; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.ListAccountsRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc("/companies/{companyId}/data/accounts")(pathParams$); + + const query$ = encodeFormQuery$({ + "orderBy": payload$.orderBy, + "page": payload$.page, + "pageSize": payload$.pageSize, + "query": payload$.query, + }); + + const headers$ = new Headers({ + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "list-accounts", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + query: query$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: [], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") + ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.ListAccountsResponse, + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.ListAccountsResponse$inboundSchema, { + key: "Accounts", + }), + m$.json( + [400, 401, 402, 403, 404, 409, 429, 500, 503], + operations.ListAccountsResponse$inboundSchema, + { key: "ErrorMessage" }, + ), + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/accounting/src/hooks/hooks.ts b/accounting/src/hooks/hooks.ts index 8a3db0da..d1b3396f 100644 --- a/accounting/src/hooks/hooks.ts +++ b/accounting/src/hooks/hooks.ts @@ -1,103 +1,112 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { RequestInput } from "../lib/http"; +import { RequestInput } from "../lib/http.js"; import { - AfterErrorContext, - AfterErrorHook, - AfterSuccessContext, - AfterSuccessHook, - BeforeRequestContext, - BeforeRequestHook, - BeforeCreateRequestHook, - BeforeCreateRequestContext, - Hooks, - SDKInitHook, - SDKInitOptions, -} from "./types"; - -import { initHooks } from "./registration"; + AfterErrorContext, + AfterErrorHook, + AfterSuccessContext, + AfterSuccessHook, + BeforeCreateRequestContext, + BeforeCreateRequestHook, + BeforeRequestContext, + BeforeRequestHook, + Hooks, + SDKInitHook, + SDKInitOptions, +} from "./types.js"; + +import { initHooks } from "./registration.js"; export class SDKHooks implements Hooks { - sdkInitHooks: SDKInitHook[] = []; - beforeCreateRequestHooks: BeforeCreateRequestHook[] = []; - beforeRequestHooks: BeforeRequestHook[] = []; - afterSuccessHooks: AfterSuccessHook[] = []; - afterErrorHooks: AfterErrorHook[] = []; - - constructor() { - initHooks(this); + sdkInitHooks: SDKInitHook[] = []; + beforeCreateRequestHooks: BeforeCreateRequestHook[] = []; + beforeRequestHooks: BeforeRequestHook[] = []; + afterSuccessHooks: AfterSuccessHook[] = []; + afterErrorHooks: AfterErrorHook[] = []; + + constructor() { + initHooks(this); + } + + registerSDKInitHook(hook: SDKInitHook) { + this.sdkInitHooks.push(hook); + } + + registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook) { + this.beforeCreateRequestHooks.push(hook); + } + + registerBeforeRequestHook(hook: BeforeRequestHook) { + this.beforeRequestHooks.push(hook); + } + + registerAfterSuccessHook(hook: AfterSuccessHook) { + this.afterSuccessHooks.push(hook); + } + + registerAfterErrorHook(hook: AfterErrorHook) { + this.afterErrorHooks.push(hook); + } + + sdkInit(opts: SDKInitOptions): SDKInitOptions { + return this.sdkInitHooks.reduce((opts, hook) => hook.sdkInit(opts), opts); + } + + beforeCreateRequest( + hookCtx: BeforeCreateRequestContext, + input: RequestInput, + ): RequestInput { + let inp = input; + + for (const hook of this.beforeCreateRequestHooks) { + inp = hook.beforeCreateRequest(hookCtx, inp); } - registerSDKInitHook(hook: SDKInitHook) { - this.sdkInitHooks.push(hook); - } + return inp; + } - registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook) { - this.beforeCreateRequestHooks.push(hook); - } + async beforeRequest( + hookCtx: BeforeRequestContext, + request: Request, + ): Promise { + let req = request; - registerBeforeRequestHook(hook: BeforeRequestHook) { - this.beforeRequestHooks.push(hook); + for (const hook of this.beforeRequestHooks) { + req = await hook.beforeRequest(hookCtx, req); } - registerAfterSuccessHook(hook: AfterSuccessHook) { - this.afterSuccessHooks.push(hook); - } + return req; + } - registerAfterErrorHook(hook: AfterErrorHook) { - this.afterErrorHooks.push(hook); - } + async afterSuccess( + hookCtx: AfterSuccessContext, + response: Response, + ): Promise { + let res = response; - sdkInit(opts: SDKInitOptions): SDKInitOptions { - return this.sdkInitHooks.reduce((opts, hook) => hook.sdkInit(opts), opts); + for (const hook of this.afterSuccessHooks) { + res = await hook.afterSuccess(hookCtx, res); } - beforeCreateRequest(hookCtx: BeforeCreateRequestContext, input: RequestInput): RequestInput { - let inp = input; - - for (const hook of this.beforeCreateRequestHooks) { - inp = hook.beforeCreateRequest(hookCtx, inp); - } - - return inp; + return res; + } + + async afterError( + hookCtx: AfterErrorContext, + response: Response | null, + error: unknown, + ): Promise<{ response: Response | null; error: unknown }> { + let res = response; + let err = error; + + for (const hook of this.afterErrorHooks) { + const result = await hook.afterError(hookCtx, res, err); + res = result.response; + err = result.error; } - async beforeRequest(hookCtx: BeforeRequestContext, request: Request): Promise { - let req = request; - - for (const hook of this.beforeRequestHooks) { - req = await hook.beforeRequest(hookCtx, req); - } - - return req; - } - - async afterSuccess(hookCtx: AfterSuccessContext, response: Response): Promise { - let res = response; - - for (const hook of this.afterSuccessHooks) { - res = await hook.afterSuccess(hookCtx, res); - } - - return res; - } - - async afterError( - hookCtx: AfterErrorContext, - response: Response | null, - error: unknown - ): Promise<{ response: Response | null; error: unknown }> { - let res = response; - let err = error; - - for (const hook of this.afterErrorHooks) { - const result = await hook.afterError(hookCtx, res, err); - res = result.response; - err = result.error; - } - - return { response: res, error: err }; - } + return { response: res, error: err }; + } } diff --git a/accounting/src/hooks/index.ts b/accounting/src/hooks/index.ts index 3df03930..f60ec7ac 100644 --- a/accounting/src/hooks/index.ts +++ b/accounting/src/hooks/index.ts @@ -1,6 +1,6 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./types"; -export * from "./hooks"; +export * from "./hooks.js"; +export * from "./types.js"; diff --git a/accounting/src/hooks/types.ts b/accounting/src/hooks/types.ts index a5b367a8..656b9e37 100644 --- a/accounting/src/hooks/types.ts +++ b/accounting/src/hooks/types.ts @@ -1,20 +1,20 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { HTTPClient, RequestInput } from "../lib/http"; +import { HTTPClient, RequestInput } from "../lib/http.js"; export type HookContext = { - operationID: string; - oAuth2Scopes?: string[]; - securitySource?: any | (() => Promise); + operationID: string; + oAuth2Scopes?: string[]; + securitySource?: any | (() => Promise); }; export type Awaitable = T | Promise; export type SDKInitOptions = { - baseURL: URL | null; - client: HTTPClient; + baseURL: URL | null; + client: HTTPClient; }; export type BeforeCreateRequestContext = HookContext & {}; @@ -27,63 +27,72 @@ export type AfterErrorContext = HookContext & {}; * hook can return a new baseURL and HTTP client to be used by the SDK. */ export interface SDKInitHook { - sdkInit: (opts: SDKInitOptions) => SDKInitOptions; + sdkInit: (opts: SDKInitOptions) => SDKInitOptions; } export interface BeforeCreateRequestHook { - /** - * A hook that is called before the SDK creates a `Request` object. The hook - * can modify how a request is constructed since certain modifications, like - * changing the request URL, cannot be done on a request object directly. - */ - beforeCreateRequest: (hookCtx: BeforeCreateRequestContext, input: RequestInput) => RequestInput; + /** + * A hook that is called before the SDK creates a `Request` object. The hook + * can modify how a request is constructed since certain modifications, like + * changing the request URL, cannot be done on a request object directly. + */ + beforeCreateRequest: ( + hookCtx: BeforeCreateRequestContext, + input: RequestInput, + ) => RequestInput; } export interface BeforeRequestHook { - /** - * A hook that is called before the SDK sends a request. The hook can - * introduce instrumentation code such as logging, tracing and metrics or - * replace the request before it is sent or throw an error to stop the - * request from being sent. - */ - beforeRequest: (hookCtx: BeforeRequestContext, request: Request) => Awaitable; + /** + * A hook that is called before the SDK sends a request. The hook can + * introduce instrumentation code such as logging, tracing and metrics or + * replace the request before it is sent or throw an error to stop the + * request from being sent. + */ + beforeRequest: ( + hookCtx: BeforeRequestContext, + request: Request, + ) => Awaitable; } export interface AfterSuccessHook { - /** - * A hook that is called after the SDK receives a response. The hook can - * introduce instrumentation code such as logging, tracing and metrics or - * modify the response before it is handled or throw an error to stop the - * response from being handled. - */ - afterSuccess: (hookCtx: AfterSuccessContext, response: Response) => Awaitable; + /** + * A hook that is called after the SDK receives a response. The hook can + * introduce instrumentation code such as logging, tracing and metrics or + * modify the response before it is handled or throw an error to stop the + * response from being handled. + */ + afterSuccess: ( + hookCtx: AfterSuccessContext, + response: Response, + ) => Awaitable; } export interface AfterErrorHook { - /** - * A hook that is called after the SDK encounters an error, or a - * non-successful response. The hook can introduce instrumentation code such - * as logging, tracing and metrics or modify the response or error values. - */ - afterError: ( - hookCtx: AfterErrorContext, - response: Response | null, - error: unknown - ) => Awaitable<{ - response: Response | null; - error: unknown; - }>; + /** + * A hook that is called after the SDK encounters an error, or a + * non-successful response. The hook can introduce instrumentation code such + * as logging, tracing and metrics or modify the response or error values. + */ + afterError: ( + hookCtx: AfterErrorContext, + response: Response | null, + error: unknown, + ) => Awaitable<{ + response: Response | null; + error: unknown; + }>; } export interface Hooks { - /** Registers a hook to be used by the SDK for initialization event. */ - registerSDKInitHook(hook: SDKInitHook): void; - /** Registers a hook to be used by the SDK for to modify `Request` construction. */ - registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; - /** Registers a hook to be used by the SDK for the before request event. */ - registerBeforeRequestHook(hook: BeforeRequestHook): void; - /** Registers a hook to be used by the SDK for the after success event. */ - registerAfterSuccessHook(hook: AfterSuccessHook): void; - /** Registers a hook to be used by the SDK for the after error event. */ - registerAfterErrorHook(hook: AfterErrorHook): void; + /** Registers a hook to be used by the SDK for initialization event. */ + registerSDKInitHook(hook: SDKInitHook): void; + /** Registers a hook to be used by the SDK for to modify `Request` construction. */ + registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; + /** Registers a hook to be used by the SDK for the before request event. */ + registerBeforeRequestHook(hook: BeforeRequestHook): void; + /** Registers a hook to be used by the SDK for the after success event. */ + registerAfterSuccessHook(hook: AfterSuccessHook): void; + /** Registers a hook to be used by the SDK for the after error event. */ + registerAfterErrorHook(hook: AfterErrorHook): void; } diff --git a/accounting/src/index.ts b/accounting/src/index.ts index 32044eba..5ddc765e 100644 --- a/accounting/src/index.ts +++ b/accounting/src/index.ts @@ -1,6 +1,7 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./sdk"; -export * from "./lib/config"; +export * from "./lib/config.js"; +export * as files from "./lib/files.js"; +export * from "./sdk/sdk.js"; diff --git a/accounting/src/lib/base64.ts b/accounting/src/lib/base64.ts index cda07641..c2d5b389 100644 --- a/accounting/src/lib/base64.ts +++ b/accounting/src/lib/base64.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/accounting/src/lib/config.ts b/accounting/src/lib/config.ts index 84ee56a4..51a05e20 100644 --- a/accounting/src/lib/config.ts +++ b/accounting/src/lib/config.ts @@ -1,60 +1,64 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { HTTPClient } from "./http"; -import { RetryConfig } from "./retries"; -import { Params, pathToFunc } from "./url"; +import { HTTPClient } from "./http.js"; +import { Logger } from "./logger.js"; +import { RetryConfig } from "./retries.js"; +import { Params, pathToFunc } from "./url.js"; /** * Contains the list of servers available to the SDK */ export const ServerList = [ - /** - * Production - */ - "https://api.codat.io", + /** + * Production + */ + "https://api.codat.io", ] as const; export type SDKOptions = { - authHeader?: string | (() => Promise); - - httpClient?: HTTPClient; - /** - * Allows overriding the default server used by the SDK - */ - serverIdx?: number; - /** - * Allows overriding the default server URL used by the SDK - */ - serverURL?: string; - /** - * Allows overriding the default retry config used by the SDK - */ - retryConfig?: RetryConfig; + authHeader?: string | (() => Promise); + + httpClient?: HTTPClient; + /** + * Allows overriding the default server used by the SDK + */ + serverIdx?: number; + /** + * Allows overriding the default server URL used by the SDK + */ + serverURL?: string; + /** + * Allows overriding the default retry config used by the SDK + */ + retryConfig?: RetryConfig; + timeoutMs?: number; + debugLogger?: Logger; }; export function serverURLFromOptions(options: SDKOptions): URL | null { - let serverURL = options.serverURL; + let serverURL = options.serverURL; - const params: Params = {}; + const params: Params = {}; - if (!serverURL) { - const serverIdx = options.serverIdx ?? 0; - if (serverIdx < 0 || serverIdx >= ServerList.length) { - throw new Error(`Invalid server index ${serverIdx}`); - } - serverURL = ServerList[serverIdx] || ""; + if (!serverURL) { + const serverIdx = options.serverIdx ?? 0; + if (serverIdx < 0 || serverIdx >= ServerList.length) { + throw new Error(`Invalid server index ${serverIdx}`); } + serverURL = ServerList[serverIdx] || ""; + } - const u = pathToFunc(serverURL)(params); - return new URL(u); + const u = pathToFunc(serverURL)(params); + return new URL(u); } export const SDK_METADATA = { - language: "typescript", - openapiDocVersion: "3.0.0", - sdkVersion: "0.6.0", - genVersion: "2.338.1", - userAgent: "speakeasy-sdk/typescript 0.6.0 2.338.1 3.0.0 @speakeasy-sdks/accounting", + language: "typescript", + openapiDocVersion: "3.0.0", + sdkVersion: "0.7.0", + genVersion: "2.415.0", + userAgent: + "speakeasy-sdk/typescript 0.7.0 2.415.0 3.0.0 @speakeasy-sdks/accounting", } as const; diff --git a/accounting/src/lib/dlv.ts b/accounting/src/lib/dlv.ts new file mode 100644 index 00000000..e81091f5 --- /dev/null +++ b/accounting/src/lib/dlv.ts @@ -0,0 +1,53 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/* +MIT License + +Copyright (c) 2024 Jason Miller (http://jasonformat.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +/** + * @param obj The object to walk + * @param key The key path to walk the object with + * @param def A default value to return if the result is undefined + * + * @example + * dlv(obj, "a.b.c.d") + * @example + * dlv(object, ["a", "b", "c", "d"]) + * @example + * dlv(object, "foo.bar.baz", "Hello, default value!") + */ +export function dlv( + obj: any, + key: string | string[], + def?: T, + p?: number, + undef?: never, +): T | undefined { + key = Array.isArray(key) ? key : key.split("."); + for (p = 0; p < key.length; p++) { + const k = key[p]; + obj = k != null && obj ? obj[k] : undef; + } + return obj === undef ? def : obj; +} diff --git a/accounting/src/lib/encodings.ts b/accounting/src/lib/encodings.ts index 8cd50f68..44fa7284 100644 --- a/accounting/src/lib/encodings.ts +++ b/accounting/src/lib/encodings.ts @@ -1,9 +1,9 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { bytesToBase64 } from "./base64"; -import { isPlainObject } from "./is-plain-object"; +import { bytesToBase64 } from "./base64.js"; +import { isPlainObject } from "./is-plain-object.js"; export class EncodingError extends Error { constructor(message: string) { @@ -212,6 +212,24 @@ export function encodeDeepObject( return ""; } + if (!isPlainObject(value)) { + throw new EncodingError( + `Value of parameter '${key}' which uses deepObject encoding must be an object`, + ); + } + + return encodeDeepObjectObject(key, value, options); +} + +export function encodeDeepObjectObject( + key: string, + value: unknown, + options?: { charEncoding?: "percent" | "none" }, +): string { + if (value == null) { + return ""; + } + let out = ""; const encodeString = (v: string) => { @@ -219,9 +237,7 @@ export function encodeDeepObject( }; if (!isPlainObject(value)) { - throw new EncodingError( - `Value of parameter '${key}' which uses deepObject encoding must be an object`, - ); + throw new EncodingError(`Expected parameter '${key}' to be an object.`); } Object.entries(value).forEach(([ck, cv]) => { @@ -232,9 +248,11 @@ export function encodeDeepObject( const pk = `${key}[${ck}]`; if (isPlainObject(cv)) { - throw new EncodingError( - `Value of parameter field '${pk}' cannot be an array or object.`, - ); + const objOut = encodeDeepObjectObject(pk, cv, options); + + out += `&${objOut}`; + + return; } const pairs: unknown[] = Array.isArray(cv) ? cv : [cv]; @@ -383,3 +401,49 @@ function mapDefinedEntries( return acc; } + +export function queryJoin(...args: string[]): string { + return args.filter(Boolean).join("&"); +} + +type QueryEncoderOptions = { + explode?: boolean; + charEncoding?: "percent" | "none"; +}; + +type QueryEncoder = ( + key: string, + value: unknown, + options?: QueryEncoderOptions, +) => string; + +type BulkQueryEncoder = ( + values: Record, + options?: QueryEncoderOptions, +) => string; + +export function queryEncoder(f: QueryEncoder): BulkQueryEncoder { + const bulkEncode = function ( + values: Record, + options?: QueryEncoderOptions, + ): string { + const opts: QueryEncoderOptions = { + ...options, + explode: options?.explode ?? true, + charEncoding: options?.charEncoding ?? "percent", + }; + + const encoded = Object.entries(values).map(([key, value]) => { + return f(key, value, opts); + }); + return queryJoin(...encoded); + }; + + return bulkEncode; +} + +export const encodeJSONQuery = queryEncoder(encodeJSON); +export const encodeFormQuery = queryEncoder(encodeForm); +export const encodeSpaceDelimitedQuery = queryEncoder(encodeSpaceDelimited); +export const encodePipeDelimitedQuery = queryEncoder(encodePipeDelimited); +export const encodeDeepObjectQuery = queryEncoder(encodeDeepObject); diff --git a/accounting/src/lib/files.ts b/accounting/src/lib/files.ts new file mode 100644 index 00000000..19e08041 --- /dev/null +++ b/accounting/src/lib/files.ts @@ -0,0 +1,40 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * Consumes a stream and returns a concatenated array buffer. Useful in + * situations where we need to read the whole file because it forms part of a + * larger payload containing other fields, and we can't modify the underlying + * request structure. + */ +export async function readableStreamToArrayBuffer( + readable: ReadableStream, +): Promise { + const reader = readable.getReader(); + const chunks: Uint8Array[] = []; + + let totalLength = 0; + let done = false; + + while (!done) { + const { value, done: doneReading } = await reader.read(); + + if (doneReading) { + done = true; + } else { + chunks.push(value); + totalLength += value.length; + } + } + + const concatenatedChunks = new Uint8Array(totalLength); + let offset = 0; + + for (const chunk of chunks) { + concatenatedChunks.set(chunk, offset); + offset += chunk.length; + } + + return concatenatedChunks.buffer; +} diff --git a/accounting/src/lib/http.ts b/accounting/src/lib/http.ts index 9ac108ed..13cf1fd7 100644 --- a/accounting/src/lib/http.ts +++ b/accounting/src/lib/http.ts @@ -1,41 +1,39 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { never as znever } from "zod"; -import { parse } from "./schemas"; -import { isPlainObject } from "./is-plain-object"; -import * as errors from "../sdk/models/errors"; - -export type Fetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise; +export type Fetcher = ( + input: RequestInfo | URL, + init?: RequestInit, +) => Promise; export type Awaitable = T | Promise; const DEFAULT_FETCHER: Fetcher = (input, init) => { - // If input is a Request and init is undefined, Bun will discard the method, - // headers, body and other options that were set on the request object. - // Node.js and browers would ignore an undefined init value. This check is - // therefore needed for interop with Bun. - if (init == null) { - return fetch(input); - } else { - return fetch(input, init); - } + // If input is a Request and init is undefined, Bun will discard the method, + // headers, body and other options that were set on the request object. + // Node.js and browers would ignore an undefined init value. This check is + // therefore needed for interop with Bun. + if (init == null) { + return fetch(input); + } else { + return fetch(input, init); + } }; export type RequestInput = { - /** - * The URL the request will use. - */ - url: URL; - /** - * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). - */ - options?: RequestInit | undefined; + /** + * The URL the request will use. + */ + url: URL; + /** + * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). + */ + options?: RequestInit | undefined; }; export interface HTTPClientOptions { - fetcher?: Fetcher; + fetcher?: Fetcher; } export type BeforeRequestHook = (req: Request) => Awaitable; @@ -43,114 +41,114 @@ export type RequestErrorHook = (err: unknown, req: Request) => Awaitable; export type ResponseHook = (res: Response, req: Request) => Awaitable; export class HTTPClient { - private fetcher: Fetcher; - private requestHooks: BeforeRequestHook[] = []; - private requestErrorHooks: RequestErrorHook[] = []; - private responseHooks: ResponseHook[] = []; - - constructor(private options: HTTPClientOptions = {}) { - this.fetcher = options.fetcher || DEFAULT_FETCHER; + private fetcher: Fetcher; + private requestHooks: BeforeRequestHook[] = []; + private requestErrorHooks: RequestErrorHook[] = []; + private responseHooks: ResponseHook[] = []; + + constructor(private options: HTTPClientOptions = {}) { + this.fetcher = options.fetcher || DEFAULT_FETCHER; + } + + async request(request: Request): Promise { + let req = request; + for (const hook of this.requestHooks) { + const nextRequest = await hook(req); + if (nextRequest) { + req = nextRequest; + } } - async request(request: Request): Promise { - let req = request; - for (const hook of this.requestHooks) { - const nextRequest = await hook(req); - if (nextRequest) { - req = nextRequest; - } - } - - try { - const res = await this.fetcher(req); - - for (const hook of this.responseHooks) { - await hook(res, req); - } - - return res; - } catch (err) { - for (const hook of this.requestErrorHooks) { - await hook(err, req); - } - - throw err; - } - } + try { + const res = await this.fetcher(req); + + for (const hook of this.responseHooks) { + await hook(res, req); + } + + return res; + } catch (err) { + for (const hook of this.requestErrorHooks) { + await hook(err, req); + } - /** - * Registers a hook that is called before a request is made. The hook function - * can mutate the request or return a new request. This may be useful to add - * additional information to request such as request IDs and tracing headers. - */ - addHook(hook: "beforeRequest", fn: BeforeRequestHook): this; - /** - * Registers a hook that is called when a request cannot be made due to a - * network error. - */ - addHook(hook: "requestError", fn: RequestErrorHook): this; - /** - * Registers a hook that is called when a response has been received from the - * server. - */ - addHook(hook: "response", fn: ResponseHook): this; - addHook( - ...args: - | [hook: "beforeRequest", fn: BeforeRequestHook] - | [hook: "requestError", fn: RequestErrorHook] - | [hook: "response", fn: ResponseHook] - ) { - if (args[0] === "beforeRequest") { - this.requestHooks.push(args[1]); - } else if (args[0] === "requestError") { - this.requestErrorHooks.push(args[1]); - } else if (args[0] === "response") { - this.responseHooks.push(args[1]); - } else { - throw new Error(`Invalid hook type: ${args[0]}`); - } - return this; + throw err; + } + } + + /** + * Registers a hook that is called before a request is made. The hook function + * can mutate the request or return a new request. This may be useful to add + * additional information to request such as request IDs and tracing headers. + */ + addHook(hook: "beforeRequest", fn: BeforeRequestHook): this; + /** + * Registers a hook that is called when a request cannot be made due to a + * network error. + */ + addHook(hook: "requestError", fn: RequestErrorHook): this; + /** + * Registers a hook that is called when a response has been received from the + * server. + */ + addHook(hook: "response", fn: ResponseHook): this; + addHook( + ...args: + | [hook: "beforeRequest", fn: BeforeRequestHook] + | [hook: "requestError", fn: RequestErrorHook] + | [hook: "response", fn: ResponseHook] + ) { + if (args[0] === "beforeRequest") { + this.requestHooks.push(args[1]); + } else if (args[0] === "requestError") { + this.requestErrorHooks.push(args[1]); + } else if (args[0] === "response") { + this.responseHooks.push(args[1]); + } else { + throw new Error(`Invalid hook type: ${args[0]}`); + } + return this; + } + + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this; + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "requestError", fn: RequestErrorHook): this; + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "response", fn: ResponseHook): this; + removeHook( + ...args: + | [hook: "beforeRequest", fn: BeforeRequestHook] + | [hook: "requestError", fn: RequestErrorHook] + | [hook: "response", fn: ResponseHook] + ): this { + let target: unknown[]; + if (args[0] === "beforeRequest") { + target = this.requestHooks; + } else if (args[0] === "requestError") { + target = this.requestErrorHooks; + } else if (args[0] === "response") { + target = this.responseHooks; + } else { + throw new Error(`Invalid hook type: ${args[0]}`); } - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this; - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "requestError", fn: RequestErrorHook): this; - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "response", fn: ResponseHook): this; - removeHook( - ...args: - | [hook: "beforeRequest", fn: BeforeRequestHook] - | [hook: "requestError", fn: RequestErrorHook] - | [hook: "response", fn: ResponseHook] - ): this { - let target: unknown[]; - if (args[0] === "beforeRequest") { - target = this.requestHooks; - } else if (args[0] === "requestError") { - target = this.requestErrorHooks; - } else if (args[0] === "response") { - target = this.responseHooks; - } else { - throw new Error(`Invalid hook type: ${args[0]}`); - } - - const index = target.findIndex((v) => v === args[1]); - if (index >= 0) { - target.splice(index, 1); - } - - return this; + const index = target.findIndex((v) => v === args[1]); + if (index >= 0) { + target.splice(index, 1); } - clone(): HTTPClient { - const child = new HTTPClient(this.options); - child.requestHooks = this.requestHooks.slice(); - child.requestErrorHooks = this.requestErrorHooks.slice(); - child.responseHooks = this.responseHooks.slice(); + return this; + } - return child; - } + clone(): HTTPClient { + const child = new HTTPClient(this.options); + child.requestHooks = this.requestHooks.slice(); + child.requestErrorHooks = this.requestErrorHooks.slice(); + child.responseHooks = this.responseHooks.slice(); + + return child; + } } export type StatusCodePredicate = number | string | (number | string)[]; @@ -159,347 +157,167 @@ export type StatusCodePredicate = number | string | (number | string)[]; // segments in a media type string. const mediaParamSeparator = /\s*;\s*/g; -function matchContentType(response: Response, pattern: string): boolean { - // `*` is a special case which means anything is acceptable. - if (pattern === "*") { - return true; +export function matchContentType(response: Response, pattern: string): boolean { + // `*` is a special case which means anything is acceptable. + if (pattern === "*") { + return true; + } + + let contentType = + response.headers.get("content-type")?.trim() || "application/octet-stream"; + contentType = contentType.toLowerCase(); + + const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); + const [wantType = "", ...wantParams] = wantParts; + + if (wantType.split("/").length !== 2) { + return false; + } + + const gotParts = contentType.split(mediaParamSeparator); + const [gotType = "", ...gotParams] = gotParts; + + const [type = "", subtype = ""] = gotType.split("/"); + if (!type || !subtype) { + return false; + } + + if ( + wantType !== "*/*" && + gotType !== wantType && + `${type}/*` !== wantType && + `*/${subtype}` !== wantType + ) { + return false; + } + + if (gotParams.length < wantParams.length) { + return false; + } + + const params = new Set(gotParams); + for (const wantParam of wantParams) { + if (!params.has(wantParam)) { + return false; } + } - let contentType = response.headers.get("content-type")?.trim() || "application/octet-stream"; - contentType = contentType.toLowerCase(); + return true; +} - const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); - const [wantType = "", ...wantParams] = wantParts; +const codeRangeRE = new RegExp("^[0-9]xx$", "i"); - if (wantType.split("/").length !== 2) { - return false; - } +export function matchStatusCode( + response: Response, + codes: StatusCodePredicate, +): boolean { + const actual = `${response.status}`; + const expectedCodes = Array.isArray(codes) ? codes : [codes]; + if (!expectedCodes.length) { + return false; + } - const gotParts = contentType.split(mediaParamSeparator); - const [gotType = "", ...gotParams] = gotParts; + return expectedCodes.some((ec) => { + const code = `${ec}`; - const [type = "", subtype = ""] = gotType.split("/"); - if (!type || !subtype) { - return false; + if (code === "default") { + return true; } - if ( - wantType !== "*/*" && - gotType !== wantType && - `${type}/*` !== wantType && - `*/${subtype}` !== wantType - ) { - return false; + if (!codeRangeRE.test(`${code}`)) { + return code === actual; } - if (gotParams.length < wantParams.length) { - return false; + const expectFamily = code.charAt(0); + if (!expectFamily) { + throw new Error("Invalid status code range"); } - const params = new Set(gotParams); - for (const wantParam of wantParams) { - if (!params.has(wantParam)) { - return false; - } + const actualFamily = actual.charAt(0); + if (!actualFamily) { + throw new Error(`Invalid response status code: ${actual}`); } - return true; -} - -const codeRangeRE = new RegExp("^[0-9]xx$", "i"); - -export function matchStatusCode(response: Response, codes: StatusCodePredicate): boolean { - const actual = `${response.status}`; - const expectedCodes = Array.isArray(codes) ? codes : [codes]; - if (!expectedCodes.length) { - return false; - } - - return expectedCodes.some((ec) => { - const code = `${ec}`; - - if (code === "default") { - return true; - } - - if (!codeRangeRE.test(`${code}`)) { - return code === actual; - } - - const expectFamily = code.charAt(0); - if (!expectFamily) { - throw new Error("Invalid status code range"); - } - - const actualFamily = actual.charAt(0); - if (!actualFamily) { - throw new Error(`Invalid response status code: ${actual}`); - } - - return actualFamily === expectFamily; - }); + return actualFamily === expectFamily; + }); } export function matchResponse( - response: Response, - code: StatusCodePredicate, - contentTypePattern: string + response: Response, + code: StatusCodePredicate, + contentTypePattern: string, ): boolean { - return matchStatusCode(response, code) && matchContentType(response, contentTypePattern); -} - -const headerValRE = /, */; -export function unpackHeaders(headers: Headers): Record { - const out: Record = {}; - - for (const [k, v] of headers.entries()) { - out[k] = v.split(headerValRE); - } - - return out; + return ( + matchStatusCode(response, code) && + matchContentType(response, contentTypePattern) + ); } -type ResponseMatcherSchema = - | { parse: (data: unknown) => T } - | { inboundSchema: { parse: (data: unknown) => T } }; +/** + * Uses various heurisitics to determine if an error is a connection error. + */ +export function isConnectionError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } -type SerializationMethod = "sse" | "json" | "rawBytes" | "rawStream" | "text" | "void" | "fail"; + // Covers fetch in Deno as well + const isBrowserErr = + err instanceof TypeError && + err.message.toLowerCase().startsWith("failed to fetch"); -const defaultContentTypes: Record = { - sse: "text/event-stream", - json: "application/json", - rawBytes: "application/octet-stream", - rawStream: "application/octet-stream", - text: "text/plain", - void: "", - fail: "", -}; + const isNodeErr = + err instanceof TypeError && + err.message.toLowerCase().startsWith("fetch failed"); -type ResponsePredicateMatch = { - method: SerializationMethod; - codes: StatusCodePredicate; - ctype: string; - schema: ResponseMatcherSchema; - hdrs: boolean; - key: string | undefined; - err: boolean; - fail: boolean; -}; + const isBunErr = "name" in err && err.name === "ConnectionError"; -type ResponsePredicateOptions = { - /** Content type to match on. */ - ctype?: string; - /** Pass HTTP headers to deserializer. */ - hdrs?: boolean; -} & ( - | { - /** The result key to store the deserialized value into. */ - key?: string; - fail?: never; - err?: never; - } - | { - /** Indicates the matched response must throw the built-in error. */ - fail: true; - key?: never; - err?: never; - } - | { - /** Indicates the matched response is a custom error. */ - err: true; - key?: never; - fail?: never; - } -); - -export class ResponseMatcher { - private predicates: ResponsePredicateMatch[] = []; - - #any( - method: SerializationMethod, - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ) { - const ctype = opts?.ctype || defaultContentTypes[method]; - const hdrs = !!opts?.hdrs; - const key = opts?.key; - const err = !!opts?.err; - const fail = !!opts?.fail; - this.predicates.push({ - method, - codes, - ctype, - schema, - hdrs, - key, - err, - fail, - }); - return this; - } + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnreset"; - json( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("json", codes, schema, opts); - } - bytes( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("rawBytes", codes, schema, opts); - } - stream( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("rawStream", codes, schema, opts); - } - text( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("text", codes, schema, opts); - } - sse( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: Omit - ): this { - return this.#any("sse", codes, schema, opts); - } - void( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: Pick - ): this { - return this.#any("void", codes, schema, opts); - } - fail(codes: StatusCodePredicate): this { - return this.#any("fail", codes, znever(), { fail: true }); - } - - async match( - response: Response, - // envelope - options?: { - resultKey?: string; - extraFields?: Record; - } - ): Promise<[result: Result, rawData: unknown]> { - let pred: ResponsePredicateMatch | undefined; - for (const predicate of this.predicates) { - const { codes, ctype } = predicate; - if (ctype && matchResponse(response, codes, ctype)) { - pred = predicate; - break; - } else if (!ctype && matchStatusCode(response, codes)) { - pred = predicate; - break; - } - } - if (pred == null) { - const responseBody = await response.text(); - throw new errors.SDKError( - "Unexpected API response status or content-type", - response, - responseBody - ); - } - - const { method, schema } = pred; - - let raw: unknown; - switch (method) { - case "json": - raw = await response.json(); - break; - case "rawBytes": - raw = await response.arrayBuffer(); - break; - case "rawStream": - raw = response.body; - break; - case "text": - raw = await response.text(); - break; - case "sse": - raw = response.body; - break; - case "void": - raw = await discardResponseBody(response); - break; - case "fail": - raw = await response.text(); - break; - default: - method satisfies never; - throw new Error(`Unsupported response type: ${method}`); - } - - const resultKey = pred.key || options?.resultKey; - let data: unknown; - if (pred.fail) { - throw new errors.SDKError( - "API error occurred", - response, - typeof raw === "string" ? raw : "" - ); - } else if (pred.err) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - ...(isPlainObject(raw) ? raw : null), - }; - } else if (resultKey) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - [resultKey]: raw, - }; - } else { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - }; - } - - const parser = "inboundSchema" in schema ? schema.inboundSchema : schema; - const body = parse(data, (v: unknown) => parser.parse(v), "Response validation failed"); - - if (body instanceof Error) { - throw body; - } - - return [body, raw]; - } + return isBrowserErr || isNodeErr || isGenericErr || isBunErr; } /** - * Discards the response body to free up resources. - * - * To learn why this is need, see the undici docs: - * https://undici.nodejs.org/#/?id=garbage-collection + * Uses various heurisitics to determine if an error is a timeout error. */ -export async function discardResponseBody(res: Response) { - const reader = res.body?.getReader(); - if (reader == null) { - return; - } +export function isTimeoutError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } + + // Fetch in browser, Node.js, Bun, Deno + const isNative = "name" in err && err.name === "TimeoutError"; + const isLegacyNative = "code" in err && err.code === 23; + + // Node.js HTTP client and Axios + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnaborted"; + + return isNative || isLegacyNative || isGenericErr; +} - try { - let done = false; - while (!done) { - const res = await reader.read(); - done = res.done; - } - } finally { - reader.releaseLock(); - } +/** + * Uses various heurisitics to determine if an error is a abort error. + */ +export function isAbortError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } + + // Fetch in browser, Node.js, Bun, Deno + const isNative = "name" in err && err.name === "AbortError"; + const isLegacyNative = "code" in err && err.code === 20; + + // Node.js HTTP client and Axios + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnaborted"; + + return isNative || isLegacyNative || isGenericErr; } diff --git a/accounting/src/lib/is-plain-object.ts b/accounting/src/lib/is-plain-object.ts index af0d6e7e..61070d3d 100644 --- a/accounting/src/lib/is-plain-object.ts +++ b/accounting/src/lib/is-plain-object.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ /* diff --git a/accounting/src/lib/logger.ts b/accounting/src/lib/logger.ts new file mode 100644 index 00000000..d181f293 --- /dev/null +++ b/accounting/src/lib/logger.ts @@ -0,0 +1,9 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export interface Logger { + group(label?: string): void; + groupEnd(): void; + log(message: any, ...args: any[]): void; +} diff --git a/accounting/src/lib/matchers.ts b/accounting/src/lib/matchers.ts new file mode 100644 index 00000000..1ff641e4 --- /dev/null +++ b/accounting/src/lib/matchers.ts @@ -0,0 +1,319 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import { Result } from "../sdk/types/fp.js"; +import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js"; +import { isPlainObject } from "./is-plain-object.js"; +import { safeParse } from "./schemas.js"; + +export type Encoding = + | "json" + | "text" + | "bytes" + | "stream" + | "sse" + | "nil" + | "fail"; + +const DEFAULT_CONTENT_TYPES: Record = { + json: "application/json", + text: "text/plain", + bytes: "application/octet-stream", + stream: "application/octet-stream", + sse: "text/event-stream", + nil: "*", + fail: "*", +}; + +type Schema = { parse(raw: unknown): T }; + +type MatchOptions = { + ctype?: string; + hdrs?: boolean; + key?: string; + sseSentinel?: string; +}; + +export type ValueMatcher = MatchOptions & { + enc: Encoding; + codes: StatusCodePredicate; + schema: Schema; +}; + +export type ErrorMatcher = MatchOptions & { + enc: Encoding; + codes: StatusCodePredicate; + schema: Schema; + err: true; +}; + +export type FailMatcher = { + enc: "fail"; + codes: StatusCodePredicate; +}; + +export type Matcher = ValueMatcher | ErrorMatcher | FailMatcher; + +export function jsonErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "json", codes, schema }; +} +export function json( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "json", codes, schema }; +} + +export function textErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "text", codes, schema }; +} +export function text( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "text", codes, schema }; +} + +export function bytesErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "bytes", codes, schema }; +} +export function bytes( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "bytes", codes, schema }; +} + +export function streamErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "stream", codes, schema }; +} +export function stream( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "stream", codes, schema }; +} + +export function sseErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "sse", codes, schema }; +} +export function sse( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "sse", codes, schema }; +} + +export function nilErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "nil", codes, schema }; +} +export function nil( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "nil", codes, schema }; +} + +export function fail(codes: StatusCodePredicate): FailMatcher { + return { enc: "fail", codes }; +} + +export type MatchedValue = Matchers extends Matcher[] + ? T + : never; +export type MatchedError = Matchers extends Matcher[] + ? E + : never; +export type MatchFunc = ( + response: Response, + options?: { resultKey?: string; extraFields?: Record }, +) => Promise<[result: Result, raw: unknown]>; + +export function match( + ...matchers: Array> +): MatchFunc { + return async function matchFunc( + response: Response, + options?: { resultKey?: string; extraFields?: Record }, + ): Promise< + [result: Result, raw: unknown] + > { + let raw: unknown; + let matcher: Matcher | undefined; + for (const match of matchers) { + const { codes } = match; + const ctpattern = "ctype" in match + ? match.ctype + : DEFAULT_CONTENT_TYPES[match.enc]; + if (ctpattern && matchResponse(response, codes, ctpattern)) { + matcher = match; + break; + } else if (!ctpattern && matchStatusCode(response, codes)) { + matcher = match; + break; + } + } + + if (!matcher) { + const responseBody = await response.text(); + return [{ + ok: false, + error: new SDKError( + "Unexpected API response status or content-type", + response, + responseBody, + ), + }, responseBody]; + } + + const encoding = matcher.enc; + switch (encoding) { + case "json": + raw = await response.json(); + break; + case "bytes": + raw = await response.arrayBuffer(); + break; + case "stream": + raw = response.body; + break; + case "text": + raw = await response.text(); + break; + case "sse": + raw = response.body; + break; + case "nil": + raw = await discardResponseBody(response); + break; + case "fail": + raw = await response.text(); + break; + default: + encoding satisfies never; + throw new Error(`Unsupported response type: ${encoding}`); + } + + if (matcher.enc === "fail") { + return [{ + ok: false, + error: new SDKError( + "API error occurred", + response, + typeof raw === "string" ? raw : "", + ), + }, raw]; + } + + const resultKey = matcher.key || options?.resultKey; + let data: unknown; + + if ("err" in matcher) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + ...(isPlainObject(raw) ? raw : null), + }; + } else if (resultKey) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + [resultKey]: raw, + }; + } else { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + }; + } + + if ("err" in matcher) { + const result = safeParse( + data, + (v: unknown) => matcher.schema.parse(v), + "Response validation failed", + ); + return [result.ok ? { ok: false, error: result.value } : result, raw]; + } else { + return [ + safeParse( + data, + (v: unknown) => matcher.schema.parse(v), + "Response validation failed", + ), + raw, + ]; + } + }; +} + +const headerValRE = /, */; +/** + * Iterates over a Headers object and returns an object with all the header + * entries. Values are represented as an array to account for repeated headers. + */ +export function unpackHeaders(headers: Headers): Record { + const out: Record = {}; + + for (const [k, v] of headers.entries()) { + out[k] = v.split(headerValRE); + } + + return out; +} + +/** + * Discards the response body to free up resources. + * + * To learn why this is need, see the undici docs: + * https://undici.nodejs.org/#/?id=garbage-collection + */ +export async function discardResponseBody(res: Response) { + const reader = res.body?.getReader(); + if (reader == null) { + return; + } + + try { + let done = false; + while (!done) { + const res = await reader.read(); + done = res.done; + } + } finally { + reader.releaseLock(); + } +} diff --git a/accounting/src/lib/primitives.ts b/accounting/src/lib/primitives.ts new file mode 100644 index 00000000..23794a2b --- /dev/null +++ b/accounting/src/lib/primitives.ts @@ -0,0 +1,40 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export type Remap = { + [k in keyof Inp as Mapping[k] extends string /* if we have a string mapping for this key then use it */ + ? Mapping[k] + : Mapping[k] extends null /* if the mapping is to `null` then drop the key */ + ? never + : k /* otherwise keep the key as-is */]: Inp[k]; +}; + +/** + * Converts or omits an object's keys according to a mapping. + * + * @param inp An object whose keys will be remapped + * @param mappings A mapping of original keys to new keys. If a key is not present in the mapping, it will be left as is. If a key is mapped to `null`, it will be removed in the resulting object. + * @returns A new object with keys remapped or omitted according to the mappings + */ +export function remap< + Inp extends Record, + const Mapping extends { [k in keyof Inp]?: string | null }, +>(inp: Inp, mappings: Mapping): Remap { + let out: any = {}; + + if (!Object.keys(mappings).length) { + out = inp; + return out; + } + + for (const [k, v] of Object.entries(inp)) { + const j = mappings[k]; + if (j === null) { + continue; + } + out[j ?? k] = v; + } + + return out; +} diff --git a/accounting/src/lib/retries.ts b/accounting/src/lib/retries.ts index ed9b4959..df3e0bc2 100644 --- a/accounting/src/lib/retries.ts +++ b/accounting/src/lib/retries.ts @@ -1,7 +1,9 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { isConnectionError, isTimeoutError } from "./http.js"; + export type BackoffStrategy = { initialInterval: number; maxInterval: number; @@ -99,47 +101,6 @@ function wrapFetcher( }; } -function isConnectionError(err: unknown) { - if (typeof err !== "object" || err == null) { - return false; - } - - // Covers fetch in Deno as well - const isBrowserErr = - err instanceof TypeError && - err.message.toLowerCase().startsWith("failed to fetch"); - - const isNodeErr = - err instanceof TypeError && - err.message.toLowerCase().startsWith("fetch failed"); - - const isBunErr = "name" in err && err.name === "ConnectionError"; - - const isGenericErr = - "code" in err && - typeof err.code === "string" && - err.code.toLowerCase() === "econnreset"; - - return isBrowserErr || isNodeErr || isGenericErr || isBunErr; -} - -function isTimeoutError(err: unknown) { - if (typeof err !== "object" || err == null) { - return false; - } - - // Fetch in browser, Node.js, Bun, Deno - const isNative = "name" in err && err.name === "TimeoutError"; - - // Node.js HTTP client and Axios - const isGenericErr = - "code" in err && - typeof err.code === "string" && - err.code.toLowerCase() === "econnaborted"; - - return isNative || isGenericErr; -} - const codeRangeRE = new RegExp("^[0-9]xx$", "i"); function isRetryableResponse(res: Response, statusCodes: string[]): boolean { diff --git a/accounting/src/lib/schemas.ts b/accounting/src/lib/schemas.ts index 5c745251..a2ad30da 100644 --- a/accounting/src/lib/schemas.ts +++ b/accounting/src/lib/schemas.ts @@ -1,22 +1,86 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ZodError } from "zod"; -import * as errors from "../sdk/models/errors"; +import { + output, + ZodEffects, + ZodError, + ZodObject, + ZodRawShape, + ZodTypeAny, +} from "zod"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import { ERR, OK, Result } from "../sdk/types/fp.js"; /** * Utility function that executes some code which may throw a ZodError. It * intercepts this error and converts it to an SDKValidationError so as to not * leak Zod implementation details to user code. */ -export function parse(rawValue: Inp, fn: (value: Inp) => Out, errorMessage: string): Out { - try { - return fn(rawValue); - } catch (err) { - if (err instanceof ZodError) { - throw new errors.SDKValidationError(errorMessage, err, rawValue); - } - throw err; +export function parse( + rawValue: Inp, + fn: (value: Inp) => Out, + errorMessage: string, +): Out { + try { + return fn(rawValue); + } catch (err) { + if (err instanceof ZodError) { + throw new SDKValidationError(errorMessage, err, rawValue); } + throw err; + } +} + +/** + * Utility function that executes some code which may result in a ZodError. It + * intercepts this error and converts it to an SDKValidationError so as to not + * leak Zod implementation details to user code. + */ +export function safeParse( + rawValue: Inp, + fn: (value: Inp) => Out, + errorMessage: string, +): Result { + try { + return OK(fn(rawValue)); + } catch (err) { + return ERR(new SDKValidationError(errorMessage, err, rawValue)); + } +} + +export function collectExtraKeys< + Shape extends ZodRawShape, + Catchall extends ZodTypeAny, + K extends string, +>( + obj: ZodObject, + extrasKey: K, +): ZodEffects< + typeof obj, + & output> + & { + [k in K]: Record>; + } +> { + return obj.transform((val) => { + const extras: Record> = {}; + const { shape } = obj; + for (const [key] of Object.entries(val)) { + if (key in shape) { + continue; + } + + const v = val[key]; + if (typeof v === "undefined") { + continue; + } + + extras[key] = v; + delete val[key]; + } + + return { ...val, [extrasKey]: extras }; + }); } diff --git a/accounting/src/lib/sdks.ts b/accounting/src/lib/sdks.ts index 9ec697e7..dc42cb99 100644 --- a/accounting/src/lib/sdks.ts +++ b/accounting/src/lib/sdks.ts @@ -1,147 +1,384 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ResponseMatcher, HTTPClient, matchStatusCode } from "./http"; -import { SecurityState, resolveSecurity, resolveGlobalSecurity } from "./security"; -import { pathToFunc } from "./url"; -import { encodeForm } from "./encodings"; -import { stringToBase64 } from "./base64"; -import { SDKHooks, HookContext } from "../hooks"; +import { SDKHooks } from "../hooks/hooks.js"; +import { HookContext } from "../hooks/types.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import { ERR, OK, Result } from "../sdk/types/fp.js"; +import { stringToBase64 } from "./base64.js"; +import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "./config.js"; +import { encodeForm } from "./encodings.js"; +import { + HTTPClient, + isAbortError, + isConnectionError, + isTimeoutError, + matchContentType, + matchStatusCode, +} from "./http.js"; +import { Logger } from "./logger.js"; +import { retry, RetryConfig } from "./retries.js"; +import { SecurityState } from "./security.js"; export type RequestOptions = { - fetchOptions?: Omit; + /** + * Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If + * `fetchOptions.signal` is set then it will take precedence over this option. + */ + timeoutMs?: number; + /** + * Set or override a retry policy on HTTP calls. + */ + retries?: RetryConfig; + /** + * Specifies the status codes which should be retried using the given retry policy. + */ + retryCodes?: string[]; + /** + * Sets various request options on the `fetch` call made by an SDK method. + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request} + */ + fetchOptions?: Omit; }; type RequestConfig = { - method: string; - path: string; - baseURL?: string | URL; - query?: string; - body?: RequestInit["body"]; - headers?: HeadersInit; - security?: SecurityState | null; + method: string; + path: string; + baseURL?: string | URL; + query?: string; + body?: RequestInit["body"]; + headers?: HeadersInit; + security?: SecurityState | null; + uaHeader?: string; + timeoutMs?: number; }; +const gt: unknown = typeof globalThis === "undefined" ? null : globalThis; +const webWorkerLike = typeof gt === "object" + && gt != null + && "importScripts" in gt + && typeof gt["importScripts"] === "function"; +const isBrowserLike = webWorkerLike + || (typeof navigator !== "undefined" && "serviceWorker" in navigator) + || (typeof window === "object" && typeof window.document !== "undefined"); + export class ClientSDK { - private readonly client: HTTPClient; - protected readonly baseURL: URL | null; - protected readonly hooks$: SDKHooks; - - constructor(init: { client: HTTPClient; baseURL: URL | null; hooks: SDKHooks }) { - const url = init.baseURL; - if (url) { - url.pathname = url.pathname.replace(/\/+$/, "") + "/"; - } + private readonly httpClient: HTTPClient; + protected readonly baseURL: URL | null; + protected readonly hooks$: SDKHooks; + protected readonly logger?: Logger | undefined; + public readonly options$: SDKOptions & { hooks?: SDKHooks }; - this.hooks$ = init.hooks; - const { baseURL, client } = this.hooks$.sdkInit({ baseURL: url, client: init.client }); - this.baseURL = baseURL; - this.client = client; + constructor(options: SDKOptions = {}) { + const opt = options as unknown; + if ( + typeof opt === "object" + && opt != null + && "hooks" in opt + && opt.hooks instanceof SDKHooks + ) { + this.hooks$ = opt.hooks; + } else { + this.hooks$ = new SDKHooks(); } + this.options$ = { ...options, hooks: this.hooks$ }; - protected createRequest$( - context: HookContext, - conf: RequestConfig, - options?: RequestOptions - ): Request { - const { method, path, query, headers: opHeaders, security } = conf; + const url = serverURLFromOptions(options); + if (url) { + url.pathname = url.pathname.replace(/\/+$/, "") + "/"; + } + const { baseURL, client } = this.hooks$.sdkInit({ + baseURL: url, + client: options.httpClient || new HTTPClient(), + }); + this.baseURL = baseURL; + this.httpClient = client; + this.logger = options.debugLogger; + } - const base = conf.baseURL ?? this.baseURL; - if (!base) { - throw new TypeError("No base URL provided for operation"); - } - const reqURL = new URL(base); - const inputURL = new URL(path, reqURL); + public createRequest$( + context: HookContext, + conf: RequestConfig, + options?: RequestOptions, + ): Result { + const { method, path, query, headers: opHeaders, security } = conf; - if (path) { - reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); - } + const base = conf.baseURL ?? this.baseURL; + if (!base) { + return ERR(new InvalidRequestError("No base URL provided for operation")); + } + const reqURL = new URL(base); + const inputURL = new URL(path, reqURL); - let finalQuery = query || ""; + if (path) { + reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); + } - const secQuery: string[] = []; - for (const [k, v] of Object.entries(security?.queryParams || {})) { - secQuery.push(encodeForm(k, v, { charEncoding: "percent" })); - } - if (secQuery.length) { - finalQuery += `&${secQuery.join("&")}`; - } + let finalQuery = query || ""; - if (finalQuery) { - const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery; - reqURL.search = `?${q}`; - } + const secQuery: string[] = []; + for (const [k, v] of Object.entries(security?.queryParams || {})) { + secQuery.push(encodeForm(k, v, { charEncoding: "percent" })); + } + if (secQuery.length) { + finalQuery += `&${secQuery.join("&")}`; + } - const headers = new Headers(opHeaders); + if (finalQuery) { + const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery; + reqURL.search = `?${q}`; + } - const username = security?.basic.username; - const password = security?.basic.password; - if (username != null || password != null) { - const encoded = stringToBase64([username || "", password || ""].join(":")); - headers.set("Authorization", `Basic ${encoded}`); - } + const headers = new Headers(opHeaders); - const securityHeaders = new Headers(security?.headers || {}); - for (const [k, v] of securityHeaders) { - headers.set(k, v); - } + const username = security?.basic.username; + const password = security?.basic.password; + if (username != null || password != null) { + const encoded = stringToBase64( + [username || "", password || ""].join(":"), + ); + headers.set("Authorization", `Basic ${encoded}`); + } - let cookie = headers.get("cookie") || ""; - for (const [k, v] of Object.entries(security?.cookies || {})) { - cookie += `; ${k}=${v}`; - } - cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie; - headers.set("cookie", cookie); + const securityHeaders = new Headers(security?.headers || {}); + for (const [k, v] of securityHeaders) { + headers.set(k, v); + } - const userHeaders = new Headers(options?.fetchOptions?.headers); - for (const [k, v] of userHeaders) { - headers.set(k, v); - } + let cookie = headers.get("cookie") || ""; + for (const [k, v] of Object.entries(security?.cookies || {})) { + cookie += `; ${k}=${v}`; + } + cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie; + headers.set("cookie", cookie); - const input = this.hooks$.beforeCreateRequest(context, { - url: reqURL, - options: { - ...options?.fetchOptions, - body: conf.body ?? null, - headers, - method, - }, - }); + const userHeaders = new Headers(options?.fetchOptions?.headers); + for (const [k, v] of userHeaders) { + headers.set(k, v); + } + + // Only set user agent header in non-browser-like environments since CORS + // policy disallows setting it in browsers e.g. Chrome throws an error. + if (!isBrowserLike) { + headers.set(conf.uaHeader ?? "user-agent", SDK_METADATA.userAgent); + } - return new Request(input.url, input.options); + let fetchOptions = options?.fetchOptions; + if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) { + const timeoutSignal = AbortSignal.timeout(conf.timeoutMs); + if (!fetchOptions) { + fetchOptions = { signal: timeoutSignal }; + } else { + fetchOptions.signal = timeoutSignal; + } } - protected async do$( - req: Request, + if (conf.body instanceof ReadableStream) { + if (!fetchOptions) { + fetchOptions = { + // @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769 + duplex: "half", + }; + } else { + // @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769 + fetchOptions.duplex = "half"; + } + } + + let input; + try { + input = this.hooks$.beforeCreateRequest(context, { + url: reqURL, options: { - context: HookContext; - errorCodes: number | string | (number | string)[]; - } - ): Promise { - const { context, errorCodes } = options; + ...fetchOptions, + body: conf.body ?? null, + headers, + method, + }, + }); + } catch (err: unknown) { + return ERR( + new UnexpectedClientError("Create request hook failed to execute", { + cause: err, + }), + ); + } + + return OK(new Request(input.url, input.options)); + } + + public async do$( + request: Request, + options: { + context: HookContext; + errorCodes: number | string | (number | string)[]; + retryConfig?: RetryConfig | undefined; + retryCodes?: string[] | undefined; + }, + ): Promise< + Result< + Response, + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + | UnexpectedClientError + > + > { + const { context, errorCodes } = options; + const retryConfig = options.retryConfig || { strategy: "none" }; + const retryCodes = options.retryCodes || []; - let response = await this.client.request(await this.hooks$.beforeRequest(context, req)); + return retry( + async () => { + const req = await this.hooks$.beforeRequest(context, request.clone()); + await logRequest(this.logger, req).catch((e) => + this.logger?.log("Failed to log request:", e) + ); + + let response = await this.httpClient.request(req); if (matchStatusCode(response, errorCodes)) { - const result = await this.hooks$.afterError(context, response, null); - if (result.error) { - throw result.error; - } - response = result.response || response; + const result = await this.hooks$.afterError(context, response, null); + if (result.error) { + throw result.error; + } + response = result.response || response; } else { - response = await this.hooks$.afterSuccess(context, response); + response = await this.hooks$.afterSuccess(context, response); } + await logResponse(this.logger, response, req) + .catch(e => this.logger?.log("Failed to log response:", e)); + return response; - } + }, + { config: retryConfig, statusCodes: retryCodes }, + ).then( + (r) => OK(r), + (err) => { + switch (true) { + case isAbortError(err): + return ERR( + new RequestAbortedError("Request aborted by client", { + cause: err, + }), + ); + case isTimeoutError(err): + return ERR( + new RequestTimeoutError("Request timed out", { cause: err }), + ); + case isConnectionError(err): + return ERR( + new ConnectionError("Unable to make request", { cause: err }), + ); + default: + return ERR( + new UnexpectedClientError("Unexpected HTTP client error", { + cause: err, + }), + ); + } + }, + ); + } +} - protected matcher(): ResponseMatcher { - return new ResponseMatcher(); +const jsonLikeContentTypeRE = /^application\/(?:.{0,100}\+)?json/; +async function logRequest(logger: Logger | undefined, req: Request) { + if (!logger) { + return; + } + + const contentType = req.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`> Request: ${req.method} ${req.url}`); + + logger.group("Headers:"); + for (const [k, v] of req.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case jsonLikeContentTypeRE.test(ct): + logger.log(await req.clone().json()); + break; + case ct.startsWith("text/"): + logger.log(await req.clone().text()); + break; + case ct === "multipart/form-data": { + const body = await req.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); + + logger.groupEnd(); +} - protected templateURLComponent = pathToFunc; +async function logResponse( + logger: Logger | undefined, + res: Response, + req: Request, +) { + if (!logger) { + return; + } + + const contentType = res.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`< Response: ${req.method} ${req.url}`); + logger.log("Status Code:", res.status, res.statusText); + + logger.group("Headers:"); + for (const [k, v] of res.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case matchContentType(res, "application/json") + || jsonLikeContentTypeRE.test(ct): + logger.log(await res.clone().json()); + break; + case matchContentType(res, "text/event-stream"): + logger.log(`<${contentType}>`); + break; + case matchContentType(res, "text/*"): + logger.log(await res.clone().text()); + break; + case matchContentType(res, "multipart/form-data"): { + const body = await res.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); - protected resolveSecurity = resolveSecurity; - protected resolveGlobalSecurity = resolveGlobalSecurity; + logger.groupEnd(); } diff --git a/accounting/src/lib/security.ts b/accounting/src/lib/security.ts index 94bc7d00..bdb5865a 100644 --- a/accounting/src/lib/security.ts +++ b/accounting/src/lib/security.ts @@ -1,182 +1,217 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../sdk/models/shared"; +import * as shared from "../sdk/models/shared/index.js"; export enum SecurityErrorCode { - Incomplete = "incomplete", - UnrecognisedSecurityType = "unrecognized_security_type", + Incomplete = "incomplete", + UnrecognisedSecurityType = "unrecognized_security_type", } export class SecurityError extends Error { - constructor(public code: SecurityErrorCode, message: string) { - super(message); - this.name = "SecurityError"; - } - - static incomplete(): SecurityError { - return new SecurityError( - SecurityErrorCode.Incomplete, - "Security requirements not met in order to perform the operation" - ); - } - static unrecognizedType(type: string): SecurityError { - return new SecurityError( - SecurityErrorCode.UnrecognisedSecurityType, - `Unrecognised security type: ${type}` - ); - } + constructor( + public code: SecurityErrorCode, + message: string, + ) { + super(message); + this.name = "SecurityError"; + } + + static incomplete(): SecurityError { + return new SecurityError( + SecurityErrorCode.Incomplete, + "Security requirements not met in order to perform the operation", + ); + } + static unrecognizedType(type: string): SecurityError { + return new SecurityError( + SecurityErrorCode.UnrecognisedSecurityType, + `Unrecognised security type: ${type}`, + ); + } } export type SecurityState = { - basic: { username?: string | undefined; password?: string | undefined }; - headers: Record; - queryParams: Record; - cookies: Record; + basic: { username?: string | undefined; password?: string | undefined }; + headers: Record; + queryParams: Record; + cookies: Record; }; type SecurityInputBasic = { - type: "http:basic"; - value: { username?: string | undefined; password?: string | undefined } | null | undefined; + type: "http:basic"; + value: + | { username?: string | undefined; password?: string | undefined } + | null + | undefined; }; type SecurityInputBearer = { - type: "http:bearer"; - value: string | null | undefined; - fieldName: string; + type: "http:bearer"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputAPIKey = { - type: "apiKey:header" | "apiKey:query" | "apiKey:cookie"; - value: string | null | undefined; - fieldName: string; + type: "apiKey:header" | "apiKey:query" | "apiKey:cookie"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOIDC = { - type: "openIdConnect"; - value: string | null | undefined; - fieldName: string; + type: "openIdConnect"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOAuth2 = { - type: "oauth2"; - value: string | null | undefined; - fieldName: string; + type: "oauth2"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOAuth2ClientCredentials = { - type: "oauth2:client_credentials"; - value: string | null | undefined; - fieldName: string; + type: "oauth2:client_credentials"; + value: string | null | undefined; + fieldName: string; +}; + +type SecurityInputCustom = { + type: "http:custom"; + value: any | null | undefined; + fieldName: string; }; export type SecurityInput = - | SecurityInputBasic - | SecurityInputBearer - | SecurityInputAPIKey - | SecurityInputOAuth2 - | SecurityInputOAuth2ClientCredentials - | SecurityInputOIDC; - -export function resolveSecurity(...options: SecurityInput[][]): SecurityState | null { - const state: SecurityState = { - basic: { username: "", password: "" }, - headers: {}, - queryParams: {}, - cookies: {}, - }; - - const option = options.find((opts) => { - return opts.every((o) => { - if (o.value == null) { - return false; - } else if (o.type === "http:basic") { - return o.value.username != null || o.value.password != null; - } else if (typeof o.value === "string") { - return !!o.value; - } else { - throw new Error( - `Unrecognized security type: ${o.type} (value type: ${typeof o.value})` - ); - } - }); - }); - if (option == null) { + | SecurityInputBasic + | SecurityInputBearer + | SecurityInputAPIKey + | SecurityInputOAuth2 + | SecurityInputOAuth2ClientCredentials + | SecurityInputOIDC + | SecurityInputCustom; + +export function resolveSecurity( + ...options: SecurityInput[][] +): SecurityState | null { + const state: SecurityState = { + basic: { username: "", password: "" }, + headers: {}, + queryParams: {}, + cookies: {}, + }; + + const option = options.find((opts) => { + return opts.every((o) => { + if (o.value == null) { + return false; + } else if (o.type === "http:basic") { + return o.value.username != null || o.value.password != null; + } else if (o.type === "http:custom") { return null; + } else if (typeof o.value === "string") { + return !!o.value; + } else { + throw new Error( + `Unrecognized security type: ${o.type} (value type: ${typeof o + .value})`, + ); + } + }); + }); + if (option == null) { + return null; + } + + option.forEach((spec) => { + if (spec.value == null) { + return; } - option.forEach((spec) => { - if (spec.value == null) { - return; - } - - const { type } = spec; - - switch (type) { - case "apiKey:header": - state.headers[spec.fieldName] = spec.value; - break; - case "apiKey:query": - state.queryParams[spec.fieldName] = spec.value; - break; - case "apiKey:cookie": - state.cookies[spec.fieldName] = spec.value; - break; - case "http:basic": - applyBasic(state, spec); - break; - case "http:bearer": - applyBearer(state, spec); - break; - case "oauth2": - applyBearer(state, spec); - break; - case "oauth2:client_credentials": - break; - case "openIdConnect": - applyBearer(state, spec); - break; - default: - spec satisfies never; - throw SecurityError.unrecognizedType(type); - } - }); + const { type } = spec; + + switch (type) { + case "apiKey:header": + state.headers[spec.fieldName] = spec.value; + break; + case "apiKey:query": + state.queryParams[spec.fieldName] = spec.value; + break; + case "apiKey:cookie": + state.cookies[spec.fieldName] = spec.value; + break; + case "http:basic": + applyBasic(state, spec); + break; + case "http:custom": + break; + case "http:bearer": + applyBearer(state, spec); + break; + case "oauth2": + applyBearer(state, spec); + break; + case "oauth2:client_credentials": + break; + case "openIdConnect": + applyBearer(state, spec); + break; + default: + spec satisfies never; + throw SecurityError.unrecognizedType(type); + } + }); - return state; + return state; } -function applyBasic(state: SecurityState, spec: SecurityInputBasic) { - if (spec.value == null) { - return; - } +function applyBasic( + state: SecurityState, + spec: SecurityInputBasic, +) { + if (spec.value == null) { + return; + } - state.basic = spec.value; + state.basic = spec.value; } function applyBearer( - state: SecurityState, - spec: SecurityInputBearer | SecurityInputOAuth2 | SecurityInputOIDC + state: SecurityState, + spec: SecurityInputBearer | SecurityInputOAuth2 | SecurityInputOIDC, ) { - if (spec.value == null) { - return; - } + if (spec.value == null) { + return; + } - let value = spec.value; - if (value.slice(0, 7).toLowerCase() !== "bearer ") { - value = `Bearer ${value}`; - } + let value = spec.value; + if (value.slice(0, 7).toLowerCase() !== "bearer ") { + value = `Bearer ${value}`; + } - state.headers[spec.fieldName] = value; + state.headers[spec.fieldName] = value; } export function resolveGlobalSecurity( - security: Partial | null | undefined + security: Partial | null | undefined, ): SecurityState | null { - return resolveSecurity([ - { - fieldName: "Authorization", - type: "apiKey:header", - value: security?.authHeader, - }, - ]); + return resolveSecurity( + [ + { + fieldName: "Authorization", + type: "apiKey:header", + value: security?.authHeader, + }, + ], + ); +} + +export async function extractSecurity< + T extends string | Record, +>(sec: T | (() => Promise) | undefined): Promise { + if (sec == null) { + return; + } + + return typeof sec === "function" ? sec() : sec; } diff --git a/accounting/src/lib/url.ts b/accounting/src/lib/url.ts index df58acbb..6bc6356e 100644 --- a/accounting/src/lib/url.ts +++ b/accounting/src/lib/url.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ const hasOwn = Object.prototype.hasOwnProperty; diff --git a/accounting/src/sdk/accounts.ts b/accounting/src/sdk/accounts.ts index 737688ac..9ea1deb1 100644 --- a/accounting/src/sdk/accounts.ts +++ b/accounting/src/sdk/accounts.ts @@ -1,522 +1,118 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks"; -import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; -import { HTTPClient } from "../lib/http"; -import * as retries$ from "../lib/retries"; -import * as schemas$ from "../lib/schemas"; -import { ClientSDK, RequestOptions } from "../lib/sdks"; -import * as operations from "./models/operations"; -import * as shared from "./models/shared"; +import { accountsCreate } from "../funcs/accountsCreate.js"; +import { accountsGet } from "../funcs/accountsGet.js"; +import { accountsGetCreateModel } from "../funcs/accountsGetCreateModel.js"; +import { accountsList } from "../funcs/accountsList.js"; +import { ClientSDK, RequestOptions } from "../lib/sdks.js"; +import * as operations from "./models/operations/index.js"; +import * as shared from "./models/shared/index.js"; +import { unwrapAsync } from "./types/fp.js"; export class Accounts extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - /** - * Create account - * - * @remarks - * The *Create account* endpoint creates a new [account](https://docs.codat.io/accounting-api#/schemas/Account) for a given company's connection. - * - * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. - * - * **Integration-specific behaviour** - * - * Required data may vary by integration. To see what data to post, first call [Get create account model](https://docs.codat.io/accounting-api#/operations/get-create-chartOfAccounts-model). - * - * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support creating an account. - * - */ - async create( - companyId: string, - connectionId: string, - accountPrototype?: shared.AccountPrototype | undefined, - timeoutInMinutes?: number | undefined, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$: operations.CreateAccountRequest = { - accountPrototype: accountPrototype, - companyId: companyId, - connectionId: connectionId, - timeoutInMinutes: timeoutInMinutes, - }; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Content-Type", "application/json"); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.CreateAccountRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = enc$.encodeJSON("body", payload$.accountPrototype, { explode: true }); - - const pathParams$ = { - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - connectionId: enc$.encodeSimple("connectionId", payload$.connectionId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/connections/{connectionId}/push/accounts" - )(pathParams$); - - const query$ = [ - enc$.encodeForm("timeoutInMinutes", payload$.timeoutInMinutes, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "create-account", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { context, errorCodes: [] }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.CreateAccountResponse$, { key: "CreateAccountResponse" }) - .json([400, 401, 402, 403, 404, 429, 500, 503], operations.CreateAccountResponse$, { - key: "ErrorMessage", - }) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Get account - * - * @remarks - * The *Get account* endpoint returns a single account for a given accountId. - * - * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. - * - * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support getting a specific account. - * - * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). - * - */ - async get( - accountId: string, - companyId: string, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$: operations.GetAccountRequest = { - accountId: accountId, - companyId: companyId, - }; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetAccountRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - accountId: enc$.encodeSimple("accountId", payload$.accountId, { - explode: false, - charEncoding: "percent", - }), - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/companies/{companyId}/data/accounts/{accountId}")( - pathParams$ - ); - - const query$ = ""; - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-account", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { context, errorCodes: [] }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.GetAccountResponse$, { key: "Account" }) - .json([401, 402, 403, 404, 409, 429, 500, 503], operations.GetAccountResponse$, { - key: "ErrorMessage", - }) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Get create account model - * - * @remarks - * The *Get create account model* endpoint returns the expected data for the request payload when creating an [account](https://docs.codat.io/accounting-api#/schemas/Account) for a given company and integration. - * - * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. - * - * **Integration-specific behaviour** - * - * See the *response examples* for integration-specific indicative models. - * - * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support creating an account. - * - */ - async getCreateModel( - companyId: string, - connectionId: string, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$: operations.GetCreateChartOfAccountsModelRequest = { - companyId: companyId, - connectionId: connectionId, - }; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => - operations.GetCreateChartOfAccountsModelRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - connectionId: enc$.encodeSimple("connectionId", payload$.connectionId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/connections/{connectionId}/options/chartOfAccounts" - )(pathParams$); - - const query$ = ""; - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-create-chartOfAccounts-model", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { context, errorCodes: [] }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.GetCreateChartOfAccountsModelResponse$, { key: "PushOption" }) - .json( - [401, 402, 403, 404, 429, 500, 503], - operations.GetCreateChartOfAccountsModelResponse$, - { key: "ErrorMessage" } - ) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * List accounts - * - * @remarks - * The *List accounts* endpoint returns a list of [accounts](https://docs.codat.io/accounting-api#/schemas/Account) for a given company's connection. - * - * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. - * - * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). - */ - async list( - request: operations.ListAccountsRequest, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$ = request; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.ListAccountsRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/companies/{companyId}/data/accounts")( - pathParams$ - ); - - const query$ = [ - enc$.encodeForm("orderBy", payload$.orderBy, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("page", payload$.page, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("pageSize", payload$.pageSize, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("query", payload$.query, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "list-accounts", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { context, errorCodes: [] }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.ListAccountsResponse$, { key: "Accounts" }) - .json([400, 401, 402, 403, 404, 409, 429, 500, 503], operations.ListAccountsResponse$, { - key: "ErrorMessage", - }) - .match(response, { extraFields: responseFields$ }); - - return result$; - } + /** + * Create account + * + * @remarks + * The *Create account* endpoint creates a new [account](https://docs.codat.io/accounting-api#/schemas/Account) for a given company's connection. + * + * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. + * + * **Integration-specific behaviour** + * + * Required data may vary by integration. To see what data to post, first call [Get create account model](https://docs.codat.io/accounting-api#/operations/get-create-chartOfAccounts-model). + * + * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support creating an account. + */ + async create( + companyId: string, + connectionId: string, + accountPrototype?: shared.AccountPrototype | undefined, + timeoutInMinutes?: number | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(accountsCreate( + this, + companyId, + connectionId, + accountPrototype, + timeoutInMinutes, + options, + )); + } + + /** + * Get account + * + * @remarks + * The *Get account* endpoint returns a single account for a given accountId. + * + * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. + * + * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support getting a specific account. + * + * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). + */ + async get( + accountId: string, + companyId: string, + options?: RequestOptions, + ): Promise { + return unwrapAsync(accountsGet( + this, + accountId, + companyId, + options, + )); + } + + /** + * Get create account model + * + * @remarks + * The *Get create account model* endpoint returns the expected data for the request payload when creating an [account](https://docs.codat.io/accounting-api#/schemas/Account) for a given company and integration. + * + * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. + * + * **Integration-specific behaviour** + * + * See the *response examples* for integration-specific indicative models. + * + * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=chartOfAccounts) for integrations that support creating an account. + */ + async getCreateModel( + companyId: string, + connectionId: string, + options?: RequestOptions, + ): Promise { + return unwrapAsync(accountsGetCreateModel( + this, + companyId, + connectionId, + options, + )); + } + + /** + * List accounts + * + * @remarks + * The *List accounts* endpoint returns a list of [accounts](https://docs.codat.io/accounting-api#/schemas/Account) for a given company's connection. + * + * [Accounts](https://docs.codat.io/accounting-api#/schemas/Account) are the categories a business uses to record accounting transactions. + * + * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). + */ + async list( + request: operations.ListAccountsRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(accountsList( + this, + request, + options, + )); + } } diff --git a/accounting/src/sdk/accounttransactions.ts b/accounting/src/sdk/accounttransactions.ts index 345a7bc8..746f3c27 100644 --- a/accounting/src/sdk/accounttransactions.ts +++ b/accounting/src/sdk/accounttransactions.ts @@ -1,288 +1,59 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks"; -import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; -import { HTTPClient } from "../lib/http"; -import * as retries$ from "../lib/retries"; -import * as schemas$ from "../lib/schemas"; -import { ClientSDK, RequestOptions } from "../lib/sdks"; -import * as operations from "./models/operations"; +import { accountTransactionsGet } from "../funcs/accountTransactionsGet.js"; +import { accountTransactionsList } from "../funcs/accountTransactionsList.js"; +import { ClientSDK, RequestOptions } from "../lib/sdks.js"; +import * as operations from "./models/operations/index.js"; +import { unwrapAsync } from "./types/fp.js"; export class AccountTransactions extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - /** - * Get account transaction - * - * @remarks - * The *Get account transaction* endpoint returns a single account transaction for a given accountTransactionId. - * - * [Account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) represent bank activity within an accounting platform. All transactions that go through a bank account are recorded as account transactions. - * - * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=accountTransactions) for integrations that support getting a specific account transaction. - * - * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). - * - */ - async get( - accountTransactionId: string, - companyId: string, - connectionId: string, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$: operations.GetAccountTransactionRequest = { - accountTransactionId: accountTransactionId, - companyId: companyId, - connectionId: connectionId, - }; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetAccountTransactionRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - accountTransactionId: enc$.encodeSimple( - "accountTransactionId", - payload$.accountTransactionId, - { explode: false, charEncoding: "percent" } - ), - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - connectionId: enc$.encodeSimple("connectionId", payload$.connectionId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/connections/{connectionId}/data/accountTransactions/{accountTransactionId}" - )(pathParams$); - - const query$ = ""; - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-account-transaction", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { context, errorCodes: [] }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.GetAccountTransactionResponse$, { key: "AccountTransaction" }) - .json( - [401, 402, 403, 404, 409, 429, 500, 503], - operations.GetAccountTransactionResponse$, - { key: "ErrorMessage" } - ) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * List account transactions - * - * @remarks - * The *List account transactions* endpoint returns a list of [account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) for a given company's connection. - * - * [Account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) represent bank activity within an accounting platform. All transactions that go through a bank account are recorded as account transactions. - * - * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). - * - */ - async list( - request: operations.ListAccountTransactionsRequest, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$ = request; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.ListAccountTransactionsRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - connectionId: enc$.encodeSimple("connectionId", payload$.connectionId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/connections/{connectionId}/data/accountTransactions" - )(pathParams$); - - const query$ = [ - enc$.encodeForm("orderBy", payload$.orderBy, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("page", payload$.page, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("pageSize", payload$.pageSize, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("query", payload$.query, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "list-account-transactions", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { context, errorCodes: [] }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.ListAccountTransactionsResponse$, { key: "AccountTransactions" }) - .json( - [400, 401, 402, 403, 404, 409, 429, 500, 503], - operations.ListAccountTransactionsResponse$, - { key: "ErrorMessage" } - ) - .match(response, { extraFields: responseFields$ }); - - return result$; - } + /** + * Get account transaction + * + * @remarks + * The *Get account transaction* endpoint returns a single account transaction for a given accountTransactionId. + * + * [Account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) represent bank activity within an accounting platform. All transactions that go through a bank account are recorded as account transactions. + * + * Check out our [coverage explorer](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=accountTransactions) for integrations that support getting a specific account transaction. + * + * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). + */ + async get( + accountTransactionId: string, + companyId: string, + connectionId: string, + options?: RequestOptions, + ): Promise { + return unwrapAsync(accountTransactionsGet( + this, + accountTransactionId, + companyId, + connectionId, + options, + )); + } + + /** + * List account transactions + * + * @remarks + * The *List account transactions* endpoint returns a list of [account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) for a given company's connection. + * + * [Account transactions](https://docs.codat.io/accounting-api#/schemas/AccountTransaction) represent bank activity within an accounting platform. All transactions that go through a bank account are recorded as account transactions. + * + * Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data). + */ + async list( + request: operations.ListAccountTransactionsRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(accountTransactionsList( + this, + request, + options, + )); + } } diff --git a/accounting/src/sdk/index.ts b/accounting/src/sdk/index.ts index 31303148..ecac2264 100644 --- a/accounting/src/sdk/index.ts +++ b/accounting/src/sdk/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./sdk"; +export * from "./sdk.js"; diff --git a/accounting/src/sdk/models/errors/httpclienterrors.ts b/accounting/src/sdk/models/errors/httpclienterrors.ts new file mode 100644 index 00000000..b34f6121 --- /dev/null +++ b/accounting/src/sdk/models/errors/httpclienterrors.ts @@ -0,0 +1,62 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * Base class for all HTTP errors. + */ +export class HTTPClientError extends Error { + /** The underlying cause of the error. */ + override readonly cause: unknown; + override name = "HTTPClientError"; + constructor(message: string, opts?: { cause?: unknown }) { + let msg = message; + if (opts?.cause) { + msg += `: ${opts.cause}`; + } + + super(msg, opts); + // In older runtimes, the cause field would not have been assigned through + // the super() call. + if (typeof this.cause === "undefined") { + this.cause = opts?.cause; + } + } +} + +/** + * An error to capture unrecognised or unexpected errors when making HTTP calls. + */ +export class UnexpectedClientError extends HTTPClientError { + override name = "UnexpectedClientError"; +} + +/** + * An error that is raised when any inputs used to create a request are invalid. + */ +export class InvalidRequestError extends HTTPClientError { + override name = "InvalidRequestError"; +} + +/** + * An error that is raised when a HTTP request was aborted by the client error. + */ +export class RequestAbortedError extends HTTPClientError { + override readonly name = "RequestAbortedError"; +} + +/** + * An error that is raised when a HTTP request timed out due to an AbortSignal + * signal timeout. + */ +export class RequestTimeoutError extends HTTPClientError { + override readonly name = "RequestTimeoutError"; +} + +/** + * An error that is raised when a HTTP client is unable to make a request to + * a server. + */ +export class ConnectionError extends HTTPClientError { + override readonly name = "ConnectionError"; +} diff --git a/accounting/src/sdk/models/errors/index.ts b/accounting/src/sdk/models/errors/index.ts index 87f62af9..900ee9d5 100644 --- a/accounting/src/sdk/models/errors/index.ts +++ b/accounting/src/sdk/models/errors/index.ts @@ -1,6 +1,7 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./sdkerror"; -export * from "./sdkvalidationerror"; +export * from "./httpclienterrors.js"; +export * from "./sdkerror.js"; +export * from "./sdkvalidationerror.js"; diff --git a/accounting/src/sdk/models/errors/sdkerror.ts b/accounting/src/sdk/models/errors/sdkerror.ts index 5a94e842..001f4659 100644 --- a/accounting/src/sdk/models/errors/sdkerror.ts +++ b/accounting/src/sdk/models/errors/sdkerror.ts @@ -1,25 +1,27 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export class SDKError extends Error { - public readonly statusCode: number; - public readonly contentType: string; + public readonly statusCode: number; + public readonly contentType: string; - constructor( - message: string, - public readonly rawResponse: Response, - public readonly body: string = "" - ) { - const statusCode = rawResponse.status; - const contentType = rawResponse.headers.get("content-type") || ""; - const bodyString = body.length > 0 ? `\n${body}` : ""; + constructor( + message: string, + public readonly rawResponse: Response, + public readonly body: string = "", + ) { + const statusCode = rawResponse.status; + const contentType = rawResponse.headers.get("content-type") || ""; + const bodyString = body.length > 0 ? `\n${body}` : ""; - super(`${message}: Status ${statusCode} Content-Type ${contentType} Body ${bodyString}`); + super( + `${message}: Status ${statusCode} Content-Type ${contentType} Body ${bodyString}`, + ); - this.statusCode = statusCode; - this.contentType = contentType; + this.statusCode = statusCode; + this.contentType = contentType; - this.name = "SDKError"; - } + this.name = "SDKError"; + } } diff --git a/accounting/src/sdk/models/errors/sdkvalidationerror.ts b/accounting/src/sdk/models/errors/sdkvalidationerror.ts index 5eb92182..16929b9e 100644 --- a/accounting/src/sdk/models/errors/sdkvalidationerror.ts +++ b/accounting/src/sdk/models/errors/sdkvalidationerror.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -10,15 +10,17 @@ export class SDKValidationError extends Error { */ public readonly rawValue: unknown; + /** + * The raw message that failed validation. + */ + public readonly rawMessage: unknown; + constructor(message: string, cause: unknown, rawValue: unknown) { - super(message); + super(`${message}: ${cause}`); this.name = "SDKValidationError"; this.cause = cause; this.rawValue = rawValue; - } - - public override toString(): string { - return `${this.message}: ${this.cause}`; + this.rawMessage = message; } /** @@ -28,7 +30,7 @@ export class SDKValidationError extends Error { */ public pretty(): string { if (this.cause instanceof z.ZodError) { - return `${this.message}\n${formatZodError(this.cause)}`; + return `${this.rawMessage}\n${formatZodError(this.cause)}`; } else { return this.toString(); } diff --git a/accounting/src/sdk/models/operations/createaccount.ts b/accounting/src/sdk/models/operations/createaccount.ts index 02e1a4e9..50c433b0 100644 --- a/accounting/src/sdk/models/operations/createaccount.ts +++ b/accounting/src/sdk/models/operations/createaccount.ts @@ -1,148 +1,157 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../shared"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import * as shared from "../shared/index.js"; export type CreateAccountRequest = { - accountPrototype?: shared.AccountPrototype | undefined; - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Unique identifier for a connection. - */ - connectionId: string; - /** - * Time limit for the push operation to complete before it is timed out. - */ - timeoutInMinutes?: number | undefined; + accountPrototype?: shared.AccountPrototype | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Unique identifier for a connection. + */ + connectionId: string; + /** + * Time limit for the push operation to complete before it is timed out. + */ + timeoutInMinutes?: number | undefined; }; export type CreateAccountResponse = { - /** - * HTTP response content type for this operation - */ - contentType: string; - /** - * Success - */ - createAccountResponse?: shared.CreateAccountResponse | undefined; - /** - * The request made is not valid. - */ - errorMessage?: shared.ErrorMessage | undefined; - /** - * HTTP response status code for this operation - */ - statusCode: number; - /** - * Raw HTTP response; suitable for custom response parsing - */ - rawResponse: Response; + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * Success + */ + createAccountResponse?: shared.CreateAccountResponse | undefined; + /** + * The request made is not valid. + */ + errorMessage?: shared.ErrorMessage | undefined; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; }; /** @internal */ -export namespace CreateAccountRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - accountPrototype: shared.AccountPrototype$.inboundSchema.optional(), - companyId: z.string(), - connectionId: z.string(), - timeoutInMinutes: z.number().int().optional(), - }) - .transform((v) => { - return { - ...(v.accountPrototype === undefined - ? null - : { accountPrototype: v.accountPrototype }), - companyId: v.companyId, - connectionId: v.connectionId, - ...(v.timeoutInMinutes === undefined - ? null - : { timeoutInMinutes: v.timeoutInMinutes }), - }; - }); +export const CreateAccountRequest$inboundSchema: z.ZodType< + CreateAccountRequest, + z.ZodTypeDef, + unknown +> = z.object({ + accountPrototype: shared.AccountPrototype$inboundSchema.optional(), + companyId: z.string(), + connectionId: z.string(), + timeoutInMinutes: z.number().int().optional(), +}); - export type Outbound = { - accountPrototype?: shared.AccountPrototype$.Outbound | undefined; - companyId: string; - connectionId: string; - timeoutInMinutes?: number | undefined; - }; +/** @internal */ +export type CreateAccountRequest$Outbound = { + accountPrototype?: shared.AccountPrototype$Outbound | undefined; + companyId: string; + connectionId: string; + timeoutInMinutes?: number | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - accountPrototype: shared.AccountPrototype$.outboundSchema.optional(), - companyId: z.string(), - connectionId: z.string(), - timeoutInMinutes: z.number().int().optional(), - }) - .transform((v) => { - return { - ...(v.accountPrototype === undefined - ? null - : { accountPrototype: v.accountPrototype }), - companyId: v.companyId, - connectionId: v.connectionId, - ...(v.timeoutInMinutes === undefined - ? null - : { timeoutInMinutes: v.timeoutInMinutes }), - }; - }); +/** @internal */ +export const CreateAccountRequest$outboundSchema: z.ZodType< + CreateAccountRequest$Outbound, + z.ZodTypeDef, + CreateAccountRequest +> = z.object({ + accountPrototype: shared.AccountPrototype$outboundSchema.optional(), + companyId: z.string(), + connectionId: z.string(), + timeoutInMinutes: z.number().int().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace CreateAccountRequest$ { + /** @deprecated use `CreateAccountRequest$inboundSchema` instead. */ + export const inboundSchema = CreateAccountRequest$inboundSchema; + /** @deprecated use `CreateAccountRequest$outboundSchema` instead. */ + export const outboundSchema = CreateAccountRequest$outboundSchema; + /** @deprecated use `CreateAccountRequest$Outbound` instead. */ + export type Outbound = CreateAccountRequest$Outbound; } /** @internal */ -export namespace CreateAccountResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - ContentType: z.string(), - CreateAccountResponse: shared.CreateAccountResponse$.inboundSchema.optional(), - ErrorMessage: shared.ErrorMessage$.inboundSchema.optional(), - StatusCode: z.number().int(), - RawResponse: z.instanceof(Response), - }) - .transform((v) => { - return { - contentType: v.ContentType, - ...(v.CreateAccountResponse === undefined - ? null - : { createAccountResponse: v.CreateAccountResponse }), - ...(v.ErrorMessage === undefined ? null : { errorMessage: v.ErrorMessage }), - statusCode: v.StatusCode, - rawResponse: v.RawResponse, - }; - }); +export const CreateAccountResponse$inboundSchema: z.ZodType< + CreateAccountResponse, + z.ZodTypeDef, + unknown +> = z.object({ + ContentType: z.string(), + CreateAccountResponse: shared.CreateAccountResponse$inboundSchema.optional(), + ErrorMessage: shared.ErrorMessage$inboundSchema.optional(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), +}).transform((v) => { + return remap$(v, { + "ContentType": "contentType", + "CreateAccountResponse": "createAccountResponse", + "ErrorMessage": "errorMessage", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + }); +}); - export type Outbound = { - ContentType: string; - CreateAccountResponse?: shared.CreateAccountResponse$.Outbound | undefined; - ErrorMessage?: shared.ErrorMessage$.Outbound | undefined; - StatusCode: number; - RawResponse: never; - }; +/** @internal */ +export type CreateAccountResponse$Outbound = { + ContentType: string; + CreateAccountResponse?: shared.CreateAccountResponse$Outbound | undefined; + ErrorMessage?: shared.ErrorMessage$Outbound | undefined; + StatusCode: number; + RawResponse: never; +}; - export const outboundSchema: z.ZodType = z - .object({ - contentType: z.string(), - createAccountResponse: shared.CreateAccountResponse$.outboundSchema.optional(), - errorMessage: shared.ErrorMessage$.outboundSchema.optional(), - statusCode: z.number().int(), - rawResponse: z.instanceof(Response).transform(() => { - throw new Error("Response cannot be serialized"); - }), - }) - .transform((v) => { - return { - ContentType: v.contentType, - ...(v.createAccountResponse === undefined - ? null - : { CreateAccountResponse: v.createAccountResponse }), - ...(v.errorMessage === undefined ? null : { ErrorMessage: v.errorMessage }), - StatusCode: v.statusCode, - RawResponse: v.rawResponse, - }; - }); +/** @internal */ +export const CreateAccountResponse$outboundSchema: z.ZodType< + CreateAccountResponse$Outbound, + z.ZodTypeDef, + CreateAccountResponse +> = z.object({ + contentType: z.string(), + createAccountResponse: shared.CreateAccountResponse$outboundSchema.optional(), + errorMessage: shared.ErrorMessage$outboundSchema.optional(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), +}).transform((v) => { + return remap$(v, { + contentType: "ContentType", + createAccountResponse: "CreateAccountResponse", + errorMessage: "ErrorMessage", + statusCode: "StatusCode", + rawResponse: "RawResponse", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace CreateAccountResponse$ { + /** @deprecated use `CreateAccountResponse$inboundSchema` instead. */ + export const inboundSchema = CreateAccountResponse$inboundSchema; + /** @deprecated use `CreateAccountResponse$outboundSchema` instead. */ + export const outboundSchema = CreateAccountResponse$outboundSchema; + /** @deprecated use `CreateAccountResponse$Outbound` instead. */ + export type Outbound = CreateAccountResponse$Outbound; } diff --git a/accounting/src/sdk/models/operations/getaccount.ts b/accounting/src/sdk/models/operations/getaccount.ts index 0814a6b7..29e62c93 100644 --- a/accounting/src/sdk/models/operations/getaccount.ts +++ b/accounting/src/sdk/models/operations/getaccount.ts @@ -1,121 +1,146 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../shared"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import * as shared from "../shared/index.js"; export type GetAccountRequest = { - /** - * Unique identifier for an account. - */ - accountId: string; - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for an account. + */ + accountId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; export type GetAccountResponse = { - /** - * Success - */ - account?: shared.Account | null | undefined; - /** - * HTTP response content type for this operation - */ - contentType: string; - /** - * Your API request was not properly authorized. - */ - errorMessage?: shared.ErrorMessage | undefined; - /** - * HTTP response status code for this operation - */ - statusCode: number; - /** - * Raw HTTP response; suitable for custom response parsing - */ - rawResponse: Response; + /** + * Success + */ + account?: shared.Account | null | undefined; + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * Your API request was not properly authorized. + */ + errorMessage?: shared.ErrorMessage | undefined; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; }; /** @internal */ -export namespace GetAccountRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - accountId: z.string(), - companyId: z.string(), - }) - .transform((v) => { - return { - accountId: v.accountId, - companyId: v.companyId, - }; - }); +export const GetAccountRequest$inboundSchema: z.ZodType< + GetAccountRequest, + z.ZodTypeDef, + unknown +> = z.object({ + accountId: z.string(), + companyId: z.string(), +}); - export type Outbound = { - accountId: string; - companyId: string; - }; +/** @internal */ +export type GetAccountRequest$Outbound = { + accountId: string; + companyId: string; +}; - export const outboundSchema: z.ZodType = z - .object({ - accountId: z.string(), - companyId: z.string(), - }) - .transform((v) => { - return { - accountId: v.accountId, - companyId: v.companyId, - }; - }); +/** @internal */ +export const GetAccountRequest$outboundSchema: z.ZodType< + GetAccountRequest$Outbound, + z.ZodTypeDef, + GetAccountRequest +> = z.object({ + accountId: z.string(), + companyId: z.string(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetAccountRequest$ { + /** @deprecated use `GetAccountRequest$inboundSchema` instead. */ + export const inboundSchema = GetAccountRequest$inboundSchema; + /** @deprecated use `GetAccountRequest$outboundSchema` instead. */ + export const outboundSchema = GetAccountRequest$outboundSchema; + /** @deprecated use `GetAccountRequest$Outbound` instead. */ + export type Outbound = GetAccountRequest$Outbound; } /** @internal */ -export namespace GetAccountResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - Account: z.nullable(shared.Account$.inboundSchema).optional(), - ContentType: z.string(), - ErrorMessage: shared.ErrorMessage$.inboundSchema.optional(), - StatusCode: z.number().int(), - RawResponse: z.instanceof(Response), - }) - .transform((v) => { - return { - ...(v.Account === undefined ? null : { account: v.Account }), - contentType: v.ContentType, - ...(v.ErrorMessage === undefined ? null : { errorMessage: v.ErrorMessage }), - statusCode: v.StatusCode, - rawResponse: v.RawResponse, - }; - }); +export const GetAccountResponse$inboundSchema: z.ZodType< + GetAccountResponse, + z.ZodTypeDef, + unknown +> = z.object({ + Account: z.nullable(shared.Account$inboundSchema).optional(), + ContentType: z.string(), + ErrorMessage: shared.ErrorMessage$inboundSchema.optional(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), +}).transform((v) => { + return remap$(v, { + "Account": "account", + "ContentType": "contentType", + "ErrorMessage": "errorMessage", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + }); +}); - export type Outbound = { - Account?: shared.Account$.Outbound | null | undefined; - ContentType: string; - ErrorMessage?: shared.ErrorMessage$.Outbound | undefined; - StatusCode: number; - RawResponse: never; - }; +/** @internal */ +export type GetAccountResponse$Outbound = { + Account?: shared.Account$Outbound | null | undefined; + ContentType: string; + ErrorMessage?: shared.ErrorMessage$Outbound | undefined; + StatusCode: number; + RawResponse: never; +}; - export const outboundSchema: z.ZodType = z - .object({ - account: z.nullable(shared.Account$.outboundSchema).optional(), - contentType: z.string(), - errorMessage: shared.ErrorMessage$.outboundSchema.optional(), - statusCode: z.number().int(), - rawResponse: z.instanceof(Response).transform(() => { - throw new Error("Response cannot be serialized"); - }), - }) - .transform((v) => { - return { - ...(v.account === undefined ? null : { Account: v.account }), - ContentType: v.contentType, - ...(v.errorMessage === undefined ? null : { ErrorMessage: v.errorMessage }), - StatusCode: v.statusCode, - RawResponse: v.rawResponse, - }; - }); +/** @internal */ +export const GetAccountResponse$outboundSchema: z.ZodType< + GetAccountResponse$Outbound, + z.ZodTypeDef, + GetAccountResponse +> = z.object({ + account: z.nullable(shared.Account$outboundSchema).optional(), + contentType: z.string(), + errorMessage: shared.ErrorMessage$outboundSchema.optional(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), +}).transform((v) => { + return remap$(v, { + account: "Account", + contentType: "ContentType", + errorMessage: "ErrorMessage", + statusCode: "StatusCode", + rawResponse: "RawResponse", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetAccountResponse$ { + /** @deprecated use `GetAccountResponse$inboundSchema` instead. */ + export const inboundSchema = GetAccountResponse$inboundSchema; + /** @deprecated use `GetAccountResponse$outboundSchema` instead. */ + export const outboundSchema = GetAccountResponse$outboundSchema; + /** @deprecated use `GetAccountResponse$Outbound` instead. */ + export type Outbound = GetAccountResponse$Outbound; } diff --git a/accounting/src/sdk/models/operations/getaccounttransaction.ts b/accounting/src/sdk/models/operations/getaccounttransaction.ts index 4632f550..71ef824f 100644 --- a/accounting/src/sdk/models/operations/getaccounttransaction.ts +++ b/accounting/src/sdk/models/operations/getaccounttransaction.ts @@ -1,137 +1,155 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../shared"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import * as shared from "../shared/index.js"; export type GetAccountTransactionRequest = { - /** - * Unique identifier for an account transaction. - */ - accountTransactionId: string; - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Unique identifier for a connection. - */ - connectionId: string; + /** + * Unique identifier for an account transaction. + */ + accountTransactionId: string; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Unique identifier for a connection. + */ + connectionId: string; }; export type GetAccountTransactionResponse = { - /** - * Success - */ - accountTransaction?: shared.AccountTransaction | null | undefined; - /** - * HTTP response content type for this operation - */ - contentType: string; - /** - * Your API request was not properly authorized. - */ - errorMessage?: shared.ErrorMessage | undefined; - /** - * HTTP response status code for this operation - */ - statusCode: number; - /** - * Raw HTTP response; suitable for custom response parsing - */ - rawResponse: Response; + /** + * Success + */ + accountTransaction?: shared.AccountTransaction | null | undefined; + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * Your API request was not properly authorized. + */ + errorMessage?: shared.ErrorMessage | undefined; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; }; /** @internal */ -export namespace GetAccountTransactionRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - accountTransactionId: z.string(), - companyId: z.string(), - connectionId: z.string(), - }) - .transform((v) => { - return { - accountTransactionId: v.accountTransactionId, - companyId: v.companyId, - connectionId: v.connectionId, - }; - }); +export const GetAccountTransactionRequest$inboundSchema: z.ZodType< + GetAccountTransactionRequest, + z.ZodTypeDef, + unknown +> = z.object({ + accountTransactionId: z.string(), + companyId: z.string(), + connectionId: z.string(), +}); - export type Outbound = { - accountTransactionId: string; - companyId: string; - connectionId: string; - }; +/** @internal */ +export type GetAccountTransactionRequest$Outbound = { + accountTransactionId: string; + companyId: string; + connectionId: string; +}; - export const outboundSchema: z.ZodType = z - .object({ - accountTransactionId: z.string(), - companyId: z.string(), - connectionId: z.string(), - }) - .transform((v) => { - return { - accountTransactionId: v.accountTransactionId, - companyId: v.companyId, - connectionId: v.connectionId, - }; - }); +/** @internal */ +export const GetAccountTransactionRequest$outboundSchema: z.ZodType< + GetAccountTransactionRequest$Outbound, + z.ZodTypeDef, + GetAccountTransactionRequest +> = z.object({ + accountTransactionId: z.string(), + companyId: z.string(), + connectionId: z.string(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetAccountTransactionRequest$ { + /** @deprecated use `GetAccountTransactionRequest$inboundSchema` instead. */ + export const inboundSchema = GetAccountTransactionRequest$inboundSchema; + /** @deprecated use `GetAccountTransactionRequest$outboundSchema` instead. */ + export const outboundSchema = GetAccountTransactionRequest$outboundSchema; + /** @deprecated use `GetAccountTransactionRequest$Outbound` instead. */ + export type Outbound = GetAccountTransactionRequest$Outbound; } /** @internal */ -export namespace GetAccountTransactionResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - AccountTransaction: z.nullable(shared.AccountTransaction$.inboundSchema).optional(), - ContentType: z.string(), - ErrorMessage: shared.ErrorMessage$.inboundSchema.optional(), - StatusCode: z.number().int(), - RawResponse: z.instanceof(Response), - }) - .transform((v) => { - return { - ...(v.AccountTransaction === undefined - ? null - : { accountTransaction: v.AccountTransaction }), - contentType: v.ContentType, - ...(v.ErrorMessage === undefined ? null : { errorMessage: v.ErrorMessage }), - statusCode: v.StatusCode, - rawResponse: v.RawResponse, - }; - }); +export const GetAccountTransactionResponse$inboundSchema: z.ZodType< + GetAccountTransactionResponse, + z.ZodTypeDef, + unknown +> = z.object({ + AccountTransaction: z.nullable(shared.AccountTransaction$inboundSchema) + .optional(), + ContentType: z.string(), + ErrorMessage: shared.ErrorMessage$inboundSchema.optional(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), +}).transform((v) => { + return remap$(v, { + "AccountTransaction": "accountTransaction", + "ContentType": "contentType", + "ErrorMessage": "errorMessage", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + }); +}); - export type Outbound = { - AccountTransaction?: shared.AccountTransaction$.Outbound | null | undefined; - ContentType: string; - ErrorMessage?: shared.ErrorMessage$.Outbound | undefined; - StatusCode: number; - RawResponse: never; - }; +/** @internal */ +export type GetAccountTransactionResponse$Outbound = { + AccountTransaction?: shared.AccountTransaction$Outbound | null | undefined; + ContentType: string; + ErrorMessage?: shared.ErrorMessage$Outbound | undefined; + StatusCode: number; + RawResponse: never; +}; - export const outboundSchema: z.ZodType = - z - .object({ - accountTransaction: z - .nullable(shared.AccountTransaction$.outboundSchema) - .optional(), - contentType: z.string(), - errorMessage: shared.ErrorMessage$.outboundSchema.optional(), - statusCode: z.number().int(), - rawResponse: z.instanceof(Response).transform(() => { - throw new Error("Response cannot be serialized"); - }), - }) - .transform((v) => { - return { - ...(v.accountTransaction === undefined - ? null - : { AccountTransaction: v.accountTransaction }), - ContentType: v.contentType, - ...(v.errorMessage === undefined ? null : { ErrorMessage: v.errorMessage }), - StatusCode: v.statusCode, - RawResponse: v.rawResponse, - }; - }); +/** @internal */ +export const GetAccountTransactionResponse$outboundSchema: z.ZodType< + GetAccountTransactionResponse$Outbound, + z.ZodTypeDef, + GetAccountTransactionResponse +> = z.object({ + accountTransaction: z.nullable(shared.AccountTransaction$outboundSchema) + .optional(), + contentType: z.string(), + errorMessage: shared.ErrorMessage$outboundSchema.optional(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), +}).transform((v) => { + return remap$(v, { + accountTransaction: "AccountTransaction", + contentType: "ContentType", + errorMessage: "ErrorMessage", + statusCode: "StatusCode", + rawResponse: "RawResponse", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetAccountTransactionResponse$ { + /** @deprecated use `GetAccountTransactionResponse$inboundSchema` instead. */ + export const inboundSchema = GetAccountTransactionResponse$inboundSchema; + /** @deprecated use `GetAccountTransactionResponse$outboundSchema` instead. */ + export const outboundSchema = GetAccountTransactionResponse$outboundSchema; + /** @deprecated use `GetAccountTransactionResponse$Outbound` instead. */ + export type Outbound = GetAccountTransactionResponse$Outbound; } diff --git a/accounting/src/sdk/models/operations/getcreatechartofaccountsmodel.ts b/accounting/src/sdk/models/operations/getcreatechartofaccountsmodel.ts index 868049f1..a5fc63a1 100644 --- a/accounting/src/sdk/models/operations/getcreatechartofaccountsmodel.ts +++ b/accounting/src/sdk/models/operations/getcreatechartofaccountsmodel.ts @@ -1,137 +1,150 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../shared"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import * as shared from "../shared/index.js"; export type GetCreateChartOfAccountsModelRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Unique identifier for a connection. - */ - connectionId: string; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Unique identifier for a connection. + */ + connectionId: string; }; export type GetCreateChartOfAccountsModelResponse = { - /** - * HTTP response content type for this operation - */ - contentType: string; - /** - * Your API request was not properly authorized. - */ - errorMessage?: shared.ErrorMessage | undefined; - /** - * OK - */ - pushOption?: shared.PushOption | undefined; - /** - * HTTP response status code for this operation - */ - statusCode: number; - /** - * Raw HTTP response; suitable for custom response parsing - */ - rawResponse: Response; + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * Your API request was not properly authorized. + */ + errorMessage?: shared.ErrorMessage | undefined; + /** + * OK + */ + pushOption?: shared.PushOption | undefined; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; }; /** @internal */ -export namespace GetCreateChartOfAccountsModelRequest$ { - export const inboundSchema: z.ZodType< - GetCreateChartOfAccountsModelRequest, - z.ZodTypeDef, - unknown - > = z - .object({ - companyId: z.string(), - connectionId: z.string(), - }) - .transform((v) => { - return { - companyId: v.companyId, - connectionId: v.connectionId, - }; - }); +export const GetCreateChartOfAccountsModelRequest$inboundSchema: z.ZodType< + GetCreateChartOfAccountsModelRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + connectionId: z.string(), +}); - export type Outbound = { - companyId: string; - connectionId: string; - }; +/** @internal */ +export type GetCreateChartOfAccountsModelRequest$Outbound = { + companyId: string; + connectionId: string; +}; - export const outboundSchema: z.ZodType< - Outbound, - z.ZodTypeDef, - GetCreateChartOfAccountsModelRequest - > = z - .object({ - companyId: z.string(), - connectionId: z.string(), - }) - .transform((v) => { - return { - companyId: v.companyId, - connectionId: v.connectionId, - }; - }); +/** @internal */ +export const GetCreateChartOfAccountsModelRequest$outboundSchema: z.ZodType< + GetCreateChartOfAccountsModelRequest$Outbound, + z.ZodTypeDef, + GetCreateChartOfAccountsModelRequest +> = z.object({ + companyId: z.string(), + connectionId: z.string(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetCreateChartOfAccountsModelRequest$ { + /** @deprecated use `GetCreateChartOfAccountsModelRequest$inboundSchema` instead. */ + export const inboundSchema = + GetCreateChartOfAccountsModelRequest$inboundSchema; + /** @deprecated use `GetCreateChartOfAccountsModelRequest$outboundSchema` instead. */ + export const outboundSchema = + GetCreateChartOfAccountsModelRequest$outboundSchema; + /** @deprecated use `GetCreateChartOfAccountsModelRequest$Outbound` instead. */ + export type Outbound = GetCreateChartOfAccountsModelRequest$Outbound; } /** @internal */ -export namespace GetCreateChartOfAccountsModelResponse$ { - export const inboundSchema: z.ZodType< - GetCreateChartOfAccountsModelResponse, - z.ZodTypeDef, - unknown - > = z - .object({ - ContentType: z.string(), - ErrorMessage: shared.ErrorMessage$.inboundSchema.optional(), - PushOption: shared.PushOption$.inboundSchema.optional(), - StatusCode: z.number().int(), - RawResponse: z.instanceof(Response), - }) - .transform((v) => { - return { - contentType: v.ContentType, - ...(v.ErrorMessage === undefined ? null : { errorMessage: v.ErrorMessage }), - ...(v.PushOption === undefined ? null : { pushOption: v.PushOption }), - statusCode: v.StatusCode, - rawResponse: v.RawResponse, - }; - }); +export const GetCreateChartOfAccountsModelResponse$inboundSchema: z.ZodType< + GetCreateChartOfAccountsModelResponse, + z.ZodTypeDef, + unknown +> = z.object({ + ContentType: z.string(), + ErrorMessage: shared.ErrorMessage$inboundSchema.optional(), + PushOption: shared.PushOption$inboundSchema.optional(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), +}).transform((v) => { + return remap$(v, { + "ContentType": "contentType", + "ErrorMessage": "errorMessage", + "PushOption": "pushOption", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + }); +}); - export type Outbound = { - ContentType: string; - ErrorMessage?: shared.ErrorMessage$.Outbound | undefined; - PushOption?: shared.PushOption$.Outbound | undefined; - StatusCode: number; - RawResponse: never; - }; +/** @internal */ +export type GetCreateChartOfAccountsModelResponse$Outbound = { + ContentType: string; + ErrorMessage?: shared.ErrorMessage$Outbound | undefined; + PushOption?: shared.PushOption$Outbound | undefined; + StatusCode: number; + RawResponse: never; +}; - export const outboundSchema: z.ZodType< - Outbound, - z.ZodTypeDef, - GetCreateChartOfAccountsModelResponse - > = z - .object({ - contentType: z.string(), - errorMessage: shared.ErrorMessage$.outboundSchema.optional(), - pushOption: shared.PushOption$.outboundSchema.optional(), - statusCode: z.number().int(), - rawResponse: z.instanceof(Response).transform(() => { - throw new Error("Response cannot be serialized"); - }), - }) - .transform((v) => { - return { - ContentType: v.contentType, - ...(v.errorMessage === undefined ? null : { ErrorMessage: v.errorMessage }), - ...(v.pushOption === undefined ? null : { PushOption: v.pushOption }), - StatusCode: v.statusCode, - RawResponse: v.rawResponse, - }; - }); +/** @internal */ +export const GetCreateChartOfAccountsModelResponse$outboundSchema: z.ZodType< + GetCreateChartOfAccountsModelResponse$Outbound, + z.ZodTypeDef, + GetCreateChartOfAccountsModelResponse +> = z.object({ + contentType: z.string(), + errorMessage: shared.ErrorMessage$outboundSchema.optional(), + pushOption: shared.PushOption$outboundSchema.optional(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), +}).transform((v) => { + return remap$(v, { + contentType: "ContentType", + errorMessage: "ErrorMessage", + pushOption: "PushOption", + statusCode: "StatusCode", + rawResponse: "RawResponse", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetCreateChartOfAccountsModelResponse$ { + /** @deprecated use `GetCreateChartOfAccountsModelResponse$inboundSchema` instead. */ + export const inboundSchema = + GetCreateChartOfAccountsModelResponse$inboundSchema; + /** @deprecated use `GetCreateChartOfAccountsModelResponse$outboundSchema` instead. */ + export const outboundSchema = + GetCreateChartOfAccountsModelResponse$outboundSchema; + /** @deprecated use `GetCreateChartOfAccountsModelResponse$Outbound` instead. */ + export type Outbound = GetCreateChartOfAccountsModelResponse$Outbound; } diff --git a/accounting/src/sdk/models/operations/index.ts b/accounting/src/sdk/models/operations/index.ts index 404b25e5..53adb124 100644 --- a/accounting/src/sdk/models/operations/index.ts +++ b/accounting/src/sdk/models/operations/index.ts @@ -1,10 +1,10 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./createaccount"; -export * from "./getaccount"; -export * from "./getaccounttransaction"; -export * from "./getcreatechartofaccountsmodel"; -export * from "./listaccounts"; -export * from "./listaccounttransactions"; +export * from "./createaccount.js"; +export * from "./getaccount.js"; +export * from "./getaccounttransaction.js"; +export * from "./getcreatechartofaccountsmodel.js"; +export * from "./listaccounts.js"; +export * from "./listaccounttransactions.js"; diff --git a/accounting/src/sdk/models/operations/listaccounts.ts b/accounting/src/sdk/models/operations/listaccounts.ts index cb1d8e62..fbff210e 100644 --- a/accounting/src/sdk/models/operations/listaccounts.ts +++ b/accounting/src/sdk/models/operations/listaccounts.ts @@ -1,148 +1,167 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../shared"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import * as shared from "../shared/index.js"; export type ListAccountsRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). - */ - orderBy?: string | undefined; - /** - * Page number. [Read more](https://docs.codat.io/using-the-api/paging). - */ - page?: number | undefined; - /** - * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). - */ - pageSize?: number | undefined; - /** - * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). - */ - query?: string | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). + */ + orderBy?: string | undefined; + /** + * Page number. [Read more](https://docs.codat.io/using-the-api/paging). + */ + page?: number | undefined; + /** + * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). + */ + pageSize?: number | undefined; + /** + * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). + */ + query?: string | undefined; }; export type ListAccountsResponse = { - /** - * Success - */ - accounts?: shared.Accounts | undefined; - /** - * HTTP response content type for this operation - */ - contentType: string; - /** - * Your `query` parameter was not correctly formed - */ - errorMessage?: shared.ErrorMessage | undefined; - /** - * HTTP response status code for this operation - */ - statusCode: number; - /** - * Raw HTTP response; suitable for custom response parsing - */ - rawResponse: Response; + /** + * Success + */ + accounts?: shared.Accounts | undefined; + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * Your `query` parameter was not correctly formed + */ + errorMessage?: shared.ErrorMessage | undefined; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; }; /** @internal */ -export namespace ListAccountsRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - orderBy: z.string().optional(), - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - }) - .transform((v) => { - return { - companyId: v.companyId, - ...(v.orderBy === undefined ? null : { orderBy: v.orderBy }), - page: v.page, - pageSize: v.pageSize, - ...(v.query === undefined ? null : { query: v.query }), - }; - }); +export const ListAccountsRequest$inboundSchema: z.ZodType< + ListAccountsRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + orderBy: z.string().optional(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), +}); - export type Outbound = { - companyId: string; - orderBy?: string | undefined; - page: number; - pageSize: number; - query?: string | undefined; - }; +/** @internal */ +export type ListAccountsRequest$Outbound = { + companyId: string; + orderBy?: string | undefined; + page: number; + pageSize: number; + query?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - orderBy: z.string().optional(), - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - }) - .transform((v) => { - return { - companyId: v.companyId, - ...(v.orderBy === undefined ? null : { orderBy: v.orderBy }), - page: v.page, - pageSize: v.pageSize, - ...(v.query === undefined ? null : { query: v.query }), - }; - }); +/** @internal */ +export const ListAccountsRequest$outboundSchema: z.ZodType< + ListAccountsRequest$Outbound, + z.ZodTypeDef, + ListAccountsRequest +> = z.object({ + companyId: z.string(), + orderBy: z.string().optional(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ListAccountsRequest$ { + /** @deprecated use `ListAccountsRequest$inboundSchema` instead. */ + export const inboundSchema = ListAccountsRequest$inboundSchema; + /** @deprecated use `ListAccountsRequest$outboundSchema` instead. */ + export const outboundSchema = ListAccountsRequest$outboundSchema; + /** @deprecated use `ListAccountsRequest$Outbound` instead. */ + export type Outbound = ListAccountsRequest$Outbound; } /** @internal */ -export namespace ListAccountsResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - Accounts: shared.Accounts$.inboundSchema.optional(), - ContentType: z.string(), - ErrorMessage: shared.ErrorMessage$.inboundSchema.optional(), - StatusCode: z.number().int(), - RawResponse: z.instanceof(Response), - }) - .transform((v) => { - return { - ...(v.Accounts === undefined ? null : { accounts: v.Accounts }), - contentType: v.ContentType, - ...(v.ErrorMessage === undefined ? null : { errorMessage: v.ErrorMessage }), - statusCode: v.StatusCode, - rawResponse: v.RawResponse, - }; - }); +export const ListAccountsResponse$inboundSchema: z.ZodType< + ListAccountsResponse, + z.ZodTypeDef, + unknown +> = z.object({ + Accounts: shared.Accounts$inboundSchema.optional(), + ContentType: z.string(), + ErrorMessage: shared.ErrorMessage$inboundSchema.optional(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), +}).transform((v) => { + return remap$(v, { + "Accounts": "accounts", + "ContentType": "contentType", + "ErrorMessage": "errorMessage", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + }); +}); - export type Outbound = { - Accounts?: shared.Accounts$.Outbound | undefined; - ContentType: string; - ErrorMessage?: shared.ErrorMessage$.Outbound | undefined; - StatusCode: number; - RawResponse: never; - }; +/** @internal */ +export type ListAccountsResponse$Outbound = { + Accounts?: shared.Accounts$Outbound | undefined; + ContentType: string; + ErrorMessage?: shared.ErrorMessage$Outbound | undefined; + StatusCode: number; + RawResponse: never; +}; - export const outboundSchema: z.ZodType = z - .object({ - accounts: shared.Accounts$.outboundSchema.optional(), - contentType: z.string(), - errorMessage: shared.ErrorMessage$.outboundSchema.optional(), - statusCode: z.number().int(), - rawResponse: z.instanceof(Response).transform(() => { - throw new Error("Response cannot be serialized"); - }), - }) - .transform((v) => { - return { - ...(v.accounts === undefined ? null : { Accounts: v.accounts }), - ContentType: v.contentType, - ...(v.errorMessage === undefined ? null : { ErrorMessage: v.errorMessage }), - StatusCode: v.statusCode, - RawResponse: v.rawResponse, - }; - }); +/** @internal */ +export const ListAccountsResponse$outboundSchema: z.ZodType< + ListAccountsResponse$Outbound, + z.ZodTypeDef, + ListAccountsResponse +> = z.object({ + accounts: shared.Accounts$outboundSchema.optional(), + contentType: z.string(), + errorMessage: shared.ErrorMessage$outboundSchema.optional(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), +}).transform((v) => { + return remap$(v, { + accounts: "Accounts", + contentType: "ContentType", + errorMessage: "ErrorMessage", + statusCode: "StatusCode", + rawResponse: "RawResponse", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ListAccountsResponse$ { + /** @deprecated use `ListAccountsResponse$inboundSchema` instead. */ + export const inboundSchema = ListAccountsResponse$inboundSchema; + /** @deprecated use `ListAccountsResponse$outboundSchema` instead. */ + export const outboundSchema = ListAccountsResponse$outboundSchema; + /** @deprecated use `ListAccountsResponse$Outbound` instead. */ + export type Outbound = ListAccountsResponse$Outbound; } diff --git a/accounting/src/sdk/models/operations/listaccounttransactions.ts b/accounting/src/sdk/models/operations/listaccounttransactions.ts index 669a6491..b03125e0 100644 --- a/accounting/src/sdk/models/operations/listaccounttransactions.ts +++ b/accounting/src/sdk/models/operations/listaccounttransactions.ts @@ -1,167 +1,174 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../shared"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import * as shared from "../shared/index.js"; export type ListAccountTransactionsRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Unique identifier for a connection. - */ - connectionId: string; - /** - * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). - */ - orderBy?: string | undefined; - /** - * Page number. [Read more](https://docs.codat.io/using-the-api/paging). - */ - page?: number | undefined; - /** - * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). - */ - pageSize?: number | undefined; - /** - * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). - */ - query?: string | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Unique identifier for a connection. + */ + connectionId: string; + /** + * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). + */ + orderBy?: string | undefined; + /** + * Page number. [Read more](https://docs.codat.io/using-the-api/paging). + */ + page?: number | undefined; + /** + * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). + */ + pageSize?: number | undefined; + /** + * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). + */ + query?: string | undefined; }; export type ListAccountTransactionsResponse = { - /** - * Success - */ - accountTransactions?: shared.AccountTransactions | undefined; - /** - * HTTP response content type for this operation - */ - contentType: string; - /** - * Your `query` parameter was not correctly formed - */ - errorMessage?: shared.ErrorMessage | undefined; - /** - * HTTP response status code for this operation - */ - statusCode: number; - /** - * Raw HTTP response; suitable for custom response parsing - */ - rawResponse: Response; + /** + * Success + */ + accountTransactions?: shared.AccountTransactions | undefined; + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * Your `query` parameter was not correctly formed + */ + errorMessage?: shared.ErrorMessage | undefined; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; }; /** @internal */ -export namespace ListAccountTransactionsRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - connectionId: z.string(), - orderBy: z.string().optional(), - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - }) - .transform((v) => { - return { - companyId: v.companyId, - connectionId: v.connectionId, - ...(v.orderBy === undefined ? null : { orderBy: v.orderBy }), - page: v.page, - pageSize: v.pageSize, - ...(v.query === undefined ? null : { query: v.query }), - }; - }); +export const ListAccountTransactionsRequest$inboundSchema: z.ZodType< + ListAccountTransactionsRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + connectionId: z.string(), + orderBy: z.string().optional(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), +}); - export type Outbound = { - companyId: string; - connectionId: string; - orderBy?: string | undefined; - page: number; - pageSize: number; - query?: string | undefined; - }; +/** @internal */ +export type ListAccountTransactionsRequest$Outbound = { + companyId: string; + connectionId: string; + orderBy?: string | undefined; + page: number; + pageSize: number; + query?: string | undefined; +}; - export const outboundSchema: z.ZodType = - z - .object({ - companyId: z.string(), - connectionId: z.string(), - orderBy: z.string().optional(), - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - }) - .transform((v) => { - return { - companyId: v.companyId, - connectionId: v.connectionId, - ...(v.orderBy === undefined ? null : { orderBy: v.orderBy }), - page: v.page, - pageSize: v.pageSize, - ...(v.query === undefined ? null : { query: v.query }), - }; - }); +/** @internal */ +export const ListAccountTransactionsRequest$outboundSchema: z.ZodType< + ListAccountTransactionsRequest$Outbound, + z.ZodTypeDef, + ListAccountTransactionsRequest +> = z.object({ + companyId: z.string(), + connectionId: z.string(), + orderBy: z.string().optional(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ListAccountTransactionsRequest$ { + /** @deprecated use `ListAccountTransactionsRequest$inboundSchema` instead. */ + export const inboundSchema = ListAccountTransactionsRequest$inboundSchema; + /** @deprecated use `ListAccountTransactionsRequest$outboundSchema` instead. */ + export const outboundSchema = ListAccountTransactionsRequest$outboundSchema; + /** @deprecated use `ListAccountTransactionsRequest$Outbound` instead. */ + export type Outbound = ListAccountTransactionsRequest$Outbound; } /** @internal */ -export namespace ListAccountTransactionsResponse$ { - export const inboundSchema: z.ZodType = - z - .object({ - AccountTransactions: shared.AccountTransactions$.inboundSchema.optional(), - ContentType: z.string(), - ErrorMessage: shared.ErrorMessage$.inboundSchema.optional(), - StatusCode: z.number().int(), - RawResponse: z.instanceof(Response), - }) - .transform((v) => { - return { - ...(v.AccountTransactions === undefined - ? null - : { accountTransactions: v.AccountTransactions }), - contentType: v.ContentType, - ...(v.ErrorMessage === undefined ? null : { errorMessage: v.ErrorMessage }), - statusCode: v.StatusCode, - rawResponse: v.RawResponse, - }; - }); +export const ListAccountTransactionsResponse$inboundSchema: z.ZodType< + ListAccountTransactionsResponse, + z.ZodTypeDef, + unknown +> = z.object({ + AccountTransactions: shared.AccountTransactions$inboundSchema.optional(), + ContentType: z.string(), + ErrorMessage: shared.ErrorMessage$inboundSchema.optional(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), +}).transform((v) => { + return remap$(v, { + "AccountTransactions": "accountTransactions", + "ContentType": "contentType", + "ErrorMessage": "errorMessage", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + }); +}); - export type Outbound = { - AccountTransactions?: shared.AccountTransactions$.Outbound | undefined; - ContentType: string; - ErrorMessage?: shared.ErrorMessage$.Outbound | undefined; - StatusCode: number; - RawResponse: never; - }; +/** @internal */ +export type ListAccountTransactionsResponse$Outbound = { + AccountTransactions?: shared.AccountTransactions$Outbound | undefined; + ContentType: string; + ErrorMessage?: shared.ErrorMessage$Outbound | undefined; + StatusCode: number; + RawResponse: never; +}; - export const outboundSchema: z.ZodType< - Outbound, - z.ZodTypeDef, - ListAccountTransactionsResponse - > = z - .object({ - accountTransactions: shared.AccountTransactions$.outboundSchema.optional(), - contentType: z.string(), - errorMessage: shared.ErrorMessage$.outboundSchema.optional(), - statusCode: z.number().int(), - rawResponse: z.instanceof(Response).transform(() => { - throw new Error("Response cannot be serialized"); - }), - }) - .transform((v) => { - return { - ...(v.accountTransactions === undefined - ? null - : { AccountTransactions: v.accountTransactions }), - ContentType: v.contentType, - ...(v.errorMessage === undefined ? null : { ErrorMessage: v.errorMessage }), - StatusCode: v.statusCode, - RawResponse: v.rawResponse, - }; - }); +/** @internal */ +export const ListAccountTransactionsResponse$outboundSchema: z.ZodType< + ListAccountTransactionsResponse$Outbound, + z.ZodTypeDef, + ListAccountTransactionsResponse +> = z.object({ + accountTransactions: shared.AccountTransactions$outboundSchema.optional(), + contentType: z.string(), + errorMessage: shared.ErrorMessage$outboundSchema.optional(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), +}).transform((v) => { + return remap$(v, { + accountTransactions: "AccountTransactions", + contentType: "ContentType", + errorMessage: "ErrorMessage", + statusCode: "StatusCode", + rawResponse: "RawResponse", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ListAccountTransactionsResponse$ { + /** @deprecated use `ListAccountTransactionsResponse$inboundSchema` instead. */ + export const inboundSchema = ListAccountTransactionsResponse$inboundSchema; + /** @deprecated use `ListAccountTransactionsResponse$outboundSchema` instead. */ + export const outboundSchema = ListAccountTransactionsResponse$outboundSchema; + /** @deprecated use `ListAccountTransactionsResponse$Outbound` instead. */ + export type Outbound = ListAccountTransactionsResponse$Outbound; } diff --git a/accounting/src/sdk/models/shared/account.ts b/accounting/src/sdk/models/shared/account.ts index e3d12a46..c8a4eb48 100644 --- a/accounting/src/sdk/models/shared/account.ts +++ b/accounting/src/sdk/models/shared/account.ts @@ -1,14 +1,37 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Decimal as Decimal$ } from "../../types"; -import { AccountStatus, AccountStatus$ } from "./accountstatus"; -import { AccountType, AccountType$ } from "./accounttype"; -import { Metadata, Metadata$ } from "./metadata"; -import { SupplementalData, SupplementalData$ } from "./supplementaldata"; -import { ValidDataTypeLinks, ValidDataTypeLinks$ } from "./validdatatypelinks"; import * as z from "zod"; +import { Decimal as Decimal$ } from "../../types/decimal.js"; +import { + AccountStatus, + AccountStatus$inboundSchema, + AccountStatus$outboundSchema, +} from "./accountstatus.js"; +import { + AccountType, + AccountType$inboundSchema, + AccountType$outboundSchema, +} from "./accounttype.js"; +import { + Metadata, + Metadata$inboundSchema, + Metadata$Outbound, + Metadata$outboundSchema, +} from "./metadata.js"; +import { + SupplementalData, + SupplementalData$inboundSchema, + SupplementalData$Outbound, + SupplementalData$outboundSchema, +} from "./supplementaldata.js"; +import { + ValidDataTypeLinks, + ValidDataTypeLinks$inboundSchema, + ValidDataTypeLinks$Outbound, + ValidDataTypeLinks$outboundSchema, +} from "./validdatatypelinks.js"; /** * > **Language tip:** Accounts are also referred to as **chart of accounts**, **nominal accounts**, and **general ledger**. @@ -43,208 +66,165 @@ import * as z from "zod"; * > This approach gives a true representation of the company's accounts whilst preventing distorting financials such as a company's profit and loss and balance sheet reports. */ export type Account = { - /** - * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. - * - * @remarks - * - * ## Unknown currencies - * - * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. - * - * There are only a very small number of edge cases where this currency code is returned by the Codat system. - */ - currency?: string | undefined; - /** - * Current balance in the account. - */ - currentBalance?: Decimal$ | number | null | undefined; - /** - * Description for the account. - */ - description?: string | null | undefined; - /** - * Full category of the account. - * - * @remarks - * - * For example, `Liability.Current` or `Income.Revenue`. To determine a list of possible categories for each integration, see our examples, follow our [Create, update, delete data](https://docs.codat.io/using-the-api/push) guide, or refer to the integration's own documentation. - */ - fullyQualifiedCategory?: string | null | undefined; - /** - * Full name of the account, for example: - * - * @remarks - * - `Cash On Hand` - * - `Rents Held In Trust` - * - `Fixed Asset` - */ - fullyQualifiedName?: string | null | undefined; - /** - * Identifier for the account, unique for the company. - */ - id?: string | undefined; - /** - * Confirms whether the account is a bank account or not. - */ - isBankAccount?: boolean | undefined; - metadata?: Metadata | undefined; - modifiedDate?: string | undefined; - /** - * Name of the account. - */ - name?: string | null | undefined; - /** - * Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. - */ - nominalCode?: string | null | undefined; - sourceModifiedDate?: string | undefined; - /** - * Status of the account - */ - status?: AccountStatus | undefined; - /** - * Supplemental data is additional data you can include in our standard data types. - * - * @remarks - * - * It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. - */ - supplementalData?: SupplementalData | undefined; - /** - * Type of account - */ - type?: AccountType | undefined; - /** - * The validDatatypeLinks can be used to determine whether an account can be correctly mapped to another object; for example, accounts with a `type` of `income` might only support being used on an Invoice and Direct Income. For more information, see [Valid Data Type Links](/accounting-api#/schemas/ValidDataTypeLinks). - */ - validDatatypeLinks?: Array | null | undefined; + /** + * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + * + * @remarks + * + * ## Unknown currencies + * + * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + * + * There are only a very small number of edge cases where this currency code is returned by the Codat system. + */ + currency?: string | undefined; + /** + * Current balance in the account. + */ + currentBalance?: Decimal$ | number | null | undefined; + /** + * Description for the account. + */ + description?: string | null | undefined; + /** + * Full category of the account. + * + * @remarks + * + * For example, `Liability.Current` or `Income.Revenue`. To determine a list of possible categories for each integration, see our examples, follow our [Create, update, delete data](https://docs.codat.io/using-the-api/push) guide, or refer to the integration's own documentation. + */ + fullyQualifiedCategory?: string | null | undefined; + /** + * Full name of the account, for example: + * + * @remarks + * - `Cash On Hand` + * - `Rents Held In Trust` + * - `Fixed Asset` + */ + fullyQualifiedName?: string | null | undefined; + /** + * Identifier for the account, unique for the company. + */ + id?: string | undefined; + /** + * Confirms whether the account is a bank account or not. + */ + isBankAccount?: boolean | undefined; + metadata?: Metadata | undefined; + modifiedDate?: string | undefined; + /** + * Name of the account. + */ + name?: string | null | undefined; + /** + * Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. + */ + nominalCode?: string | null | undefined; + sourceModifiedDate?: string | undefined; + /** + * Status of the account + */ + status?: AccountStatus | undefined; + /** + * Supplemental data is additional data you can include in our standard data types. + * + * @remarks + * + * It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. + */ + supplementalData?: SupplementalData | undefined; + /** + * Type of account + */ + type?: AccountType | undefined; + /** + * The validDatatypeLinks can be used to determine whether an account can be correctly mapped to another object; for example, accounts with a `type` of `income` might only support being used on an Invoice and Direct Income. For more information, see [Valid Data Type Links](/accounting-api#/schemas/ValidDataTypeLinks). + */ + validDatatypeLinks?: Array | null | undefined; }; /** @internal */ -export namespace Account$ { - export const inboundSchema: z.ZodType = z - .object({ - currency: z.string().optional(), - currentBalance: z.nullable(z.number().transform((v) => new Decimal$(v))).optional(), - description: z.nullable(z.string()).optional(), - fullyQualifiedCategory: z.nullable(z.string()).optional(), - fullyQualifiedName: z.nullable(z.string()).optional(), - id: z.string().optional(), - isBankAccount: z.boolean().optional(), - metadata: Metadata$.inboundSchema.optional(), - modifiedDate: z.string().optional(), - name: z.nullable(z.string()).optional(), - nominalCode: z.nullable(z.string()).optional(), - sourceModifiedDate: z.string().optional(), - status: AccountStatus$.inboundSchema.optional(), - supplementalData: SupplementalData$.inboundSchema.optional(), - type: AccountType$.inboundSchema.optional(), - validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$.inboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.currency === undefined ? null : { currency: v.currency }), - ...(v.currentBalance === undefined ? null : { currentBalance: v.currentBalance }), - ...(v.description === undefined ? null : { description: v.description }), - ...(v.fullyQualifiedCategory === undefined - ? null - : { fullyQualifiedCategory: v.fullyQualifiedCategory }), - ...(v.fullyQualifiedName === undefined - ? null - : { fullyQualifiedName: v.fullyQualifiedName }), - ...(v.id === undefined ? null : { id: v.id }), - ...(v.isBankAccount === undefined ? null : { isBankAccount: v.isBankAccount }), - ...(v.metadata === undefined ? null : { metadata: v.metadata }), - ...(v.modifiedDate === undefined ? null : { modifiedDate: v.modifiedDate }), - ...(v.name === undefined ? null : { name: v.name }), - ...(v.nominalCode === undefined ? null : { nominalCode: v.nominalCode }), - ...(v.sourceModifiedDate === undefined - ? null - : { sourceModifiedDate: v.sourceModifiedDate }), - ...(v.status === undefined ? null : { status: v.status }), - ...(v.supplementalData === undefined - ? null - : { supplementalData: v.supplementalData }), - ...(v.type === undefined ? null : { type: v.type }), - ...(v.validDatatypeLinks === undefined - ? null - : { validDatatypeLinks: v.validDatatypeLinks }), - }; - }); +export const Account$inboundSchema: z.ZodType = + z.object({ + currency: z.string().optional(), + currentBalance: z.nullable(z.number().transform(v => new Decimal$(v))) + .optional(), + description: z.nullable(z.string()).optional(), + fullyQualifiedCategory: z.nullable(z.string()).optional(), + fullyQualifiedName: z.nullable(z.string()).optional(), + id: z.string().optional(), + isBankAccount: z.boolean().optional(), + metadata: Metadata$inboundSchema.optional(), + modifiedDate: z.string().optional(), + name: z.nullable(z.string()).optional(), + nominalCode: z.nullable(z.string()).optional(), + sourceModifiedDate: z.string().optional(), + status: AccountStatus$inboundSchema.optional(), + supplementalData: SupplementalData$inboundSchema.optional(), + type: AccountType$inboundSchema.optional(), + validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$inboundSchema)) + .optional(), + }); + +/** @internal */ +export type Account$Outbound = { + currency?: string | undefined; + currentBalance?: number | null | undefined; + description?: string | null | undefined; + fullyQualifiedCategory?: string | null | undefined; + fullyQualifiedName?: string | null | undefined; + id?: string | undefined; + isBankAccount?: boolean | undefined; + metadata?: Metadata$Outbound | undefined; + modifiedDate?: string | undefined; + name?: string | null | undefined; + nominalCode?: string | null | undefined; + sourceModifiedDate?: string | undefined; + status?: string | undefined; + supplementalData?: SupplementalData$Outbound | undefined; + type?: string | undefined; + validDatatypeLinks?: Array | null | undefined; +}; - export type Outbound = { - currency?: string | undefined; - currentBalance?: number | null | undefined; - description?: string | null | undefined; - fullyQualifiedCategory?: string | null | undefined; - fullyQualifiedName?: string | null | undefined; - id?: string | undefined; - isBankAccount?: boolean | undefined; - metadata?: Metadata$.Outbound | undefined; - modifiedDate?: string | undefined; - name?: string | null | undefined; - nominalCode?: string | null | undefined; - sourceModifiedDate?: string | undefined; - status?: string | undefined; - supplementalData?: SupplementalData$.Outbound | undefined; - type?: string | undefined; - validDatatypeLinks?: Array | null | undefined; - }; +/** @internal */ +export const Account$outboundSchema: z.ZodType< + Account$Outbound, + z.ZodTypeDef, + Account +> = z.object({ + currency: z.string().optional(), + currentBalance: z.nullable( + z.union([z.instanceof(Decimal$), z.number()]).transform(v => + typeof v === "number" ? v : v.toNumber() + ), + ).optional(), + description: z.nullable(z.string()).optional(), + fullyQualifiedCategory: z.nullable(z.string()).optional(), + fullyQualifiedName: z.nullable(z.string()).optional(), + id: z.string().optional(), + isBankAccount: z.boolean().optional(), + metadata: Metadata$outboundSchema.optional(), + modifiedDate: z.string().optional(), + name: z.nullable(z.string()).optional(), + nominalCode: z.nullable(z.string()).optional(), + sourceModifiedDate: z.string().optional(), + status: AccountStatus$outboundSchema.optional(), + supplementalData: SupplementalData$outboundSchema.optional(), + type: AccountType$outboundSchema.optional(), + validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$outboundSchema)) + .optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - currency: z.string().optional(), - currentBalance: z - .nullable( - z - .union([z.instanceof(Decimal$), z.number()]) - .transform((v) => (typeof v === "number" ? v : v.toNumber())) - ) - .optional(), - description: z.nullable(z.string()).optional(), - fullyQualifiedCategory: z.nullable(z.string()).optional(), - fullyQualifiedName: z.nullable(z.string()).optional(), - id: z.string().optional(), - isBankAccount: z.boolean().optional(), - metadata: Metadata$.outboundSchema.optional(), - modifiedDate: z.string().optional(), - name: z.nullable(z.string()).optional(), - nominalCode: z.nullable(z.string()).optional(), - sourceModifiedDate: z.string().optional(), - status: AccountStatus$.outboundSchema.optional(), - supplementalData: SupplementalData$.outboundSchema.optional(), - type: AccountType$.outboundSchema.optional(), - validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$.outboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.currency === undefined ? null : { currency: v.currency }), - ...(v.currentBalance === undefined ? null : { currentBalance: v.currentBalance }), - ...(v.description === undefined ? null : { description: v.description }), - ...(v.fullyQualifiedCategory === undefined - ? null - : { fullyQualifiedCategory: v.fullyQualifiedCategory }), - ...(v.fullyQualifiedName === undefined - ? null - : { fullyQualifiedName: v.fullyQualifiedName }), - ...(v.id === undefined ? null : { id: v.id }), - ...(v.isBankAccount === undefined ? null : { isBankAccount: v.isBankAccount }), - ...(v.metadata === undefined ? null : { metadata: v.metadata }), - ...(v.modifiedDate === undefined ? null : { modifiedDate: v.modifiedDate }), - ...(v.name === undefined ? null : { name: v.name }), - ...(v.nominalCode === undefined ? null : { nominalCode: v.nominalCode }), - ...(v.sourceModifiedDate === undefined - ? null - : { sourceModifiedDate: v.sourceModifiedDate }), - ...(v.status === undefined ? null : { status: v.status }), - ...(v.supplementalData === undefined - ? null - : { supplementalData: v.supplementalData }), - ...(v.type === undefined ? null : { type: v.type }), - ...(v.validDatatypeLinks === undefined - ? null - : { validDatatypeLinks: v.validDatatypeLinks }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Account$ { + /** @deprecated use `Account$inboundSchema` instead. */ + export const inboundSchema = Account$inboundSchema; + /** @deprecated use `Account$outboundSchema` instead. */ + export const outboundSchema = Account$outboundSchema; + /** @deprecated use `Account$Outbound` instead. */ + export type Outbound = Account$Outbound; } diff --git a/accounting/src/sdk/models/shared/accountprototype.ts b/accounting/src/sdk/models/shared/accountprototype.ts index c100df1a..868ca194 100644 --- a/accounting/src/sdk/models/shared/accountprototype.ts +++ b/accounting/src/sdk/models/shared/accountprototype.ts @@ -1,186 +1,176 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Decimal as Decimal$ } from "../../types"; -import { AccountStatus, AccountStatus$ } from "./accountstatus"; -import { AccountType, AccountType$ } from "./accounttype"; -import { SupplementalData, SupplementalData$ } from "./supplementaldata"; -import { ValidDataTypeLinks, ValidDataTypeLinks$ } from "./validdatatypelinks"; import * as z from "zod"; +import { Decimal as Decimal$ } from "../../types/decimal.js"; +import { + AccountStatus, + AccountStatus$inboundSchema, + AccountStatus$outboundSchema, +} from "./accountstatus.js"; +import { + AccountType, + AccountType$inboundSchema, + AccountType$outboundSchema, +} from "./accounttype.js"; +import { + SupplementalData, + SupplementalData$inboundSchema, + SupplementalData$Outbound, + SupplementalData$outboundSchema, +} from "./supplementaldata.js"; +import { + ValidDataTypeLinks, + ValidDataTypeLinks$inboundSchema, + ValidDataTypeLinks$Outbound, + ValidDataTypeLinks$outboundSchema, +} from "./validdatatypelinks.js"; export type AccountPrototype = { - /** - * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. - * - * @remarks - * - * ## Unknown currencies - * - * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. - * - * There are only a very small number of edge cases where this currency code is returned by the Codat system. - */ - currency?: string | undefined; - /** - * Current balance in the account. - */ - currentBalance?: Decimal$ | number | null | undefined; - /** - * Description for the account. - */ - description?: string | null | undefined; - /** - * Full category of the account. - * - * @remarks - * - * For example, `Liability.Current` or `Income.Revenue`. To determine a list of possible categories for each integration, see our examples, follow our [Create, update, delete data](https://docs.codat.io/using-the-api/push) guide, or refer to the integration's own documentation. - */ - fullyQualifiedCategory?: string | null | undefined; - /** - * Full name of the account, for example: - * - * @remarks - * - `Cash On Hand` - * - `Rents Held In Trust` - * - `Fixed Asset` - */ - fullyQualifiedName?: string | null | undefined; - /** - * Confirms whether the account is a bank account or not. - */ - isBankAccount?: boolean | undefined; - /** - * Name of the account. - */ - name?: string | null | undefined; - /** - * Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. - */ - nominalCode?: string | null | undefined; - /** - * Status of the account - */ - status?: AccountStatus | undefined; - /** - * Supplemental data is additional data you can include in our standard data types. - * - * @remarks - * - * It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. - */ - supplementalData?: SupplementalData | undefined; - /** - * Type of account - */ - type?: AccountType | undefined; - /** - * The validDatatypeLinks can be used to determine whether an account can be correctly mapped to another object; for example, accounts with a `type` of `income` might only support being used on an Invoice and Direct Income. For more information, see [Valid Data Type Links](/accounting-api#/schemas/ValidDataTypeLinks). - */ - validDatatypeLinks?: Array | null | undefined; + /** + * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + * + * @remarks + * + * ## Unknown currencies + * + * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + * + * There are only a very small number of edge cases where this currency code is returned by the Codat system. + */ + currency?: string | undefined; + /** + * Current balance in the account. + */ + currentBalance?: Decimal$ | number | null | undefined; + /** + * Description for the account. + */ + description?: string | null | undefined; + /** + * Full category of the account. + * + * @remarks + * + * For example, `Liability.Current` or `Income.Revenue`. To determine a list of possible categories for each integration, see our examples, follow our [Create, update, delete data](https://docs.codat.io/using-the-api/push) guide, or refer to the integration's own documentation. + */ + fullyQualifiedCategory?: string | null | undefined; + /** + * Full name of the account, for example: + * + * @remarks + * - `Cash On Hand` + * - `Rents Held In Trust` + * - `Fixed Asset` + */ + fullyQualifiedName?: string | null | undefined; + /** + * Confirms whether the account is a bank account or not. + */ + isBankAccount?: boolean | undefined; + /** + * Name of the account. + */ + name?: string | null | undefined; + /** + * Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. + */ + nominalCode?: string | null | undefined; + /** + * Status of the account + */ + status?: AccountStatus | undefined; + /** + * Supplemental data is additional data you can include in our standard data types. + * + * @remarks + * + * It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. + */ + supplementalData?: SupplementalData | undefined; + /** + * Type of account + */ + type?: AccountType | undefined; + /** + * The validDatatypeLinks can be used to determine whether an account can be correctly mapped to another object; for example, accounts with a `type` of `income` might only support being used on an Invoice and Direct Income. For more information, see [Valid Data Type Links](/accounting-api#/schemas/ValidDataTypeLinks). + */ + validDatatypeLinks?: Array | null | undefined; }; /** @internal */ -export namespace AccountPrototype$ { - export const inboundSchema: z.ZodType = z - .object({ - currency: z.string().optional(), - currentBalance: z.nullable(z.number().transform((v) => new Decimal$(v))).optional(), - description: z.nullable(z.string()).optional(), - fullyQualifiedCategory: z.nullable(z.string()).optional(), - fullyQualifiedName: z.nullable(z.string()).optional(), - isBankAccount: z.boolean().optional(), - name: z.nullable(z.string()).optional(), - nominalCode: z.nullable(z.string()).optional(), - status: AccountStatus$.inboundSchema.optional(), - supplementalData: SupplementalData$.inboundSchema.optional(), - type: AccountType$.inboundSchema.optional(), - validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$.inboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.currency === undefined ? null : { currency: v.currency }), - ...(v.currentBalance === undefined ? null : { currentBalance: v.currentBalance }), - ...(v.description === undefined ? null : { description: v.description }), - ...(v.fullyQualifiedCategory === undefined - ? null - : { fullyQualifiedCategory: v.fullyQualifiedCategory }), - ...(v.fullyQualifiedName === undefined - ? null - : { fullyQualifiedName: v.fullyQualifiedName }), - ...(v.isBankAccount === undefined ? null : { isBankAccount: v.isBankAccount }), - ...(v.name === undefined ? null : { name: v.name }), - ...(v.nominalCode === undefined ? null : { nominalCode: v.nominalCode }), - ...(v.status === undefined ? null : { status: v.status }), - ...(v.supplementalData === undefined - ? null - : { supplementalData: v.supplementalData }), - ...(v.type === undefined ? null : { type: v.type }), - ...(v.validDatatypeLinks === undefined - ? null - : { validDatatypeLinks: v.validDatatypeLinks }), - }; - }); +export const AccountPrototype$inboundSchema: z.ZodType< + AccountPrototype, + z.ZodTypeDef, + unknown +> = z.object({ + currency: z.string().optional(), + currentBalance: z.nullable(z.number().transform(v => new Decimal$(v))) + .optional(), + description: z.nullable(z.string()).optional(), + fullyQualifiedCategory: z.nullable(z.string()).optional(), + fullyQualifiedName: z.nullable(z.string()).optional(), + isBankAccount: z.boolean().optional(), + name: z.nullable(z.string()).optional(), + nominalCode: z.nullable(z.string()).optional(), + status: AccountStatus$inboundSchema.optional(), + supplementalData: SupplementalData$inboundSchema.optional(), + type: AccountType$inboundSchema.optional(), + validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$inboundSchema)) + .optional(), +}); - export type Outbound = { - currency?: string | undefined; - currentBalance?: number | null | undefined; - description?: string | null | undefined; - fullyQualifiedCategory?: string | null | undefined; - fullyQualifiedName?: string | null | undefined; - isBankAccount?: boolean | undefined; - name?: string | null | undefined; - nominalCode?: string | null | undefined; - status?: string | undefined; - supplementalData?: SupplementalData$.Outbound | undefined; - type?: string | undefined; - validDatatypeLinks?: Array | null | undefined; - }; +/** @internal */ +export type AccountPrototype$Outbound = { + currency?: string | undefined; + currentBalance?: number | null | undefined; + description?: string | null | undefined; + fullyQualifiedCategory?: string | null | undefined; + fullyQualifiedName?: string | null | undefined; + isBankAccount?: boolean | undefined; + name?: string | null | undefined; + nominalCode?: string | null | undefined; + status?: string | undefined; + supplementalData?: SupplementalData$Outbound | undefined; + type?: string | undefined; + validDatatypeLinks?: Array | null | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - currency: z.string().optional(), - currentBalance: z - .nullable( - z - .union([z.instanceof(Decimal$), z.number()]) - .transform((v) => (typeof v === "number" ? v : v.toNumber())) - ) - .optional(), - description: z.nullable(z.string()).optional(), - fullyQualifiedCategory: z.nullable(z.string()).optional(), - fullyQualifiedName: z.nullable(z.string()).optional(), - isBankAccount: z.boolean().optional(), - name: z.nullable(z.string()).optional(), - nominalCode: z.nullable(z.string()).optional(), - status: AccountStatus$.outboundSchema.optional(), - supplementalData: SupplementalData$.outboundSchema.optional(), - type: AccountType$.outboundSchema.optional(), - validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$.outboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.currency === undefined ? null : { currency: v.currency }), - ...(v.currentBalance === undefined ? null : { currentBalance: v.currentBalance }), - ...(v.description === undefined ? null : { description: v.description }), - ...(v.fullyQualifiedCategory === undefined - ? null - : { fullyQualifiedCategory: v.fullyQualifiedCategory }), - ...(v.fullyQualifiedName === undefined - ? null - : { fullyQualifiedName: v.fullyQualifiedName }), - ...(v.isBankAccount === undefined ? null : { isBankAccount: v.isBankAccount }), - ...(v.name === undefined ? null : { name: v.name }), - ...(v.nominalCode === undefined ? null : { nominalCode: v.nominalCode }), - ...(v.status === undefined ? null : { status: v.status }), - ...(v.supplementalData === undefined - ? null - : { supplementalData: v.supplementalData }), - ...(v.type === undefined ? null : { type: v.type }), - ...(v.validDatatypeLinks === undefined - ? null - : { validDatatypeLinks: v.validDatatypeLinks }), - }; - }); +/** @internal */ +export const AccountPrototype$outboundSchema: z.ZodType< + AccountPrototype$Outbound, + z.ZodTypeDef, + AccountPrototype +> = z.object({ + currency: z.string().optional(), + currentBalance: z.nullable( + z.union([z.instanceof(Decimal$), z.number()]).transform(v => + typeof v === "number" ? v : v.toNumber() + ), + ).optional(), + description: z.nullable(z.string()).optional(), + fullyQualifiedCategory: z.nullable(z.string()).optional(), + fullyQualifiedName: z.nullable(z.string()).optional(), + isBankAccount: z.boolean().optional(), + name: z.nullable(z.string()).optional(), + nominalCode: z.nullable(z.string()).optional(), + status: AccountStatus$outboundSchema.optional(), + supplementalData: SupplementalData$outboundSchema.optional(), + type: AccountType$outboundSchema.optional(), + validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$outboundSchema)) + .optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AccountPrototype$ { + /** @deprecated use `AccountPrototype$inboundSchema` instead. */ + export const inboundSchema = AccountPrototype$inboundSchema; + /** @deprecated use `AccountPrototype$outboundSchema` instead. */ + export const outboundSchema = AccountPrototype$outboundSchema; + /** @deprecated use `AccountPrototype$Outbound` instead. */ + export type Outbound = AccountPrototype$Outbound; } diff --git a/accounting/src/sdk/models/shared/accounts.ts b/accounting/src/sdk/models/shared/accounts.ts index 1d20b617..7aeb3448 100644 --- a/accounting/src/sdk/models/shared/accounts.ts +++ b/accounting/src/sdk/models/shared/accounts.ts @@ -1,71 +1,91 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Account, Account$ } from "./account"; -import { Links, Links$ } from "./links"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import { + Account, + Account$inboundSchema, + Account$Outbound, + Account$outboundSchema, +} from "./account.js"; +import { + Links, + Links$inboundSchema, + Links$Outbound, + Links$outboundSchema, +} from "./links.js"; export type Accounts = { - links: Links; - /** - * Current page number. - */ - pageNumber: number; - /** - * Number of items to return in results array. - */ - pageSize: number; - results?: Array | undefined; - /** - * Total number of items. - */ - totalResults: number; + links: Links; + /** + * Current page number. + */ + pageNumber: number; + /** + * Number of items to return in results array. + */ + pageSize: number; + results?: Array | undefined; + /** + * Total number of items. + */ + totalResults: number; }; /** @internal */ -export namespace Accounts$ { - export const inboundSchema: z.ZodType = z - .object({ - _links: Links$.inboundSchema, - pageNumber: z.number().int(), - pageSize: z.number().int(), - results: z.array(Account$.inboundSchema).optional(), - totalResults: z.number().int(), - }) - .transform((v) => { - return { - links: v._links, - pageNumber: v.pageNumber, - pageSize: v.pageSize, - ...(v.results === undefined ? null : { results: v.results }), - totalResults: v.totalResults, - }; - }); +export const Accounts$inboundSchema: z.ZodType< + Accounts, + z.ZodTypeDef, + unknown +> = z.object({ + _links: Links$inboundSchema, + pageNumber: z.number().int(), + pageSize: z.number().int(), + results: z.array(Account$inboundSchema).optional(), + totalResults: z.number().int(), +}).transform((v) => { + return remap$(v, { + "_links": "links", + }); +}); - export type Outbound = { - _links: Links$.Outbound; - pageNumber: number; - pageSize: number; - results?: Array | undefined; - totalResults: number; - }; +/** @internal */ +export type Accounts$Outbound = { + _links: Links$Outbound; + pageNumber: number; + pageSize: number; + results?: Array | undefined; + totalResults: number; +}; - export const outboundSchema: z.ZodType = z - .object({ - links: Links$.outboundSchema, - pageNumber: z.number().int(), - pageSize: z.number().int(), - results: z.array(Account$.outboundSchema).optional(), - totalResults: z.number().int(), - }) - .transform((v) => { - return { - _links: v.links, - pageNumber: v.pageNumber, - pageSize: v.pageSize, - ...(v.results === undefined ? null : { results: v.results }), - totalResults: v.totalResults, - }; - }); +/** @internal */ +export const Accounts$outboundSchema: z.ZodType< + Accounts$Outbound, + z.ZodTypeDef, + Accounts +> = z.object({ + links: Links$outboundSchema, + pageNumber: z.number().int(), + pageSize: z.number().int(), + results: z.array(Account$outboundSchema).optional(), + totalResults: z.number().int(), +}).transform((v) => { + return remap$(v, { + links: "_links", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Accounts$ { + /** @deprecated use `Accounts$inboundSchema` instead. */ + export const inboundSchema = Accounts$inboundSchema; + /** @deprecated use `Accounts$outboundSchema` instead. */ + export const outboundSchema = Accounts$outboundSchema; + /** @deprecated use `Accounts$Outbound` instead. */ + export type Outbound = Accounts$Outbound; } diff --git a/accounting/src/sdk/models/shared/accountstatus.ts b/accounting/src/sdk/models/shared/accountstatus.ts index c699eb57..3f5e80b2 100644 --- a/accounting/src/sdk/models/shared/accountstatus.ts +++ b/accounting/src/sdk/models/shared/accountstatus.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,14 +8,29 @@ import * as z from "zod"; * Status of the account */ export enum AccountStatus { - Unknown = "Unknown", - Active = "Active", - Archived = "Archived", - Pending = "Pending", + Unknown = "Unknown", + Active = "Active", + Archived = "Archived", + Pending = "Pending", } /** @internal */ +export const AccountStatus$inboundSchema: z.ZodNativeEnum< + typeof AccountStatus +> = z.nativeEnum(AccountStatus); + +/** @internal */ +export const AccountStatus$outboundSchema: z.ZodNativeEnum< + typeof AccountStatus +> = AccountStatus$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace AccountStatus$ { - export const inboundSchema = z.nativeEnum(AccountStatus); - export const outboundSchema = inboundSchema; + /** @deprecated use `AccountStatus$inboundSchema` instead. */ + export const inboundSchema = AccountStatus$inboundSchema; + /** @deprecated use `AccountStatus$outboundSchema` instead. */ + export const outboundSchema = AccountStatus$outboundSchema; } diff --git a/accounting/src/sdk/models/shared/accounttransaction.ts b/accounting/src/sdk/models/shared/accounttransaction.ts index 9eb377e8..e94eef3d 100644 --- a/accounting/src/sdk/models/shared/accounttransaction.ts +++ b/accounting/src/sdk/models/shared/accounttransaction.ts @@ -1,21 +1,36 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Decimal as Decimal$ } from "../../types"; -import { AccountTransactionLine, AccountTransactionLine$ } from "./accounttransactionline"; -import { BankAccountRef, BankAccountRef$ } from "./bankaccountref"; -import { Metadata, Metadata$ } from "./metadata"; import * as z from "zod"; +import { Decimal as Decimal$ } from "../../types/decimal.js"; +import { + AccountTransactionLine, + AccountTransactionLine$inboundSchema, + AccountTransactionLine$Outbound, + AccountTransactionLine$outboundSchema, +} from "./accounttransactionline.js"; +import { + BankAccountRef, + BankAccountRef$inboundSchema, + BankAccountRef$Outbound, + BankAccountRef$outboundSchema, +} from "./bankaccountref.js"; +import { + Metadata, + Metadata$inboundSchema, + Metadata$Outbound, + Metadata$outboundSchema, +} from "./metadata.js"; /** * The status of the account transaction. */ export enum Status { - Unknown = "Unknown", - Unreconciled = "Unreconciled", - Reconciled = "Reconciled", - Void = "Void", + Unknown = "Unknown", + Unreconciled = "Unreconciled", + Reconciled = "Reconciled", + Void = "Void", } /** @@ -40,217 +55,203 @@ export enum Status { * Account transactions is the parent data type of [payments](https://docs.codat.io/accounting-api#/schemas/Payment), [bill payments](https://docs.codat.io/accounting-api#/schemas/BillPayment), [direct costs](https://docs.codat.io/accounting-api#/schemas/DirectCost), [direct incomes](https://docs.codat.io/accounting-api#/schemas/DirectIncome), and [transfers](https://docs.codat.io/accounting-api#/schemas/Transfer). */ export type AccountTransaction = { - /** - * Links to the Account transactions data type. - */ - bankAccountRef?: BankAccountRef | undefined; - /** - * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. - * - * @remarks - * - * ## Unknown currencies - * - * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. - * - * There are only a very small number of edge cases where this currency code is returned by the Codat system. - */ - currency?: string | undefined; - /** - * Rate to convert the total amount of the payment into the base currency for the company at the time of the payment. - * - * @remarks - * - * Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit. - * - * It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR. - * - * Where the currency rate is provided by the underlying accounting platform, it will be available from Codat with the same precision (up to a maximum of 9 decimal places). - * - * For accounting platforms which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places. - * - * ## Examples with base currency of GBP - * - * | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (GBP) | - * | :--------------- | :------------- | :------------ | :------------------------- | - * | **USD** | $20 | 0.781 | £15.62 | - * | **EUR** | €20 | 0.885 | £17.70 | - * | **RUB** | ₽20 | 0.011 | £0.22 | - * - * ## Examples with base currency of USD - * - * | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (USD) | - * | :--------------- | :------------- | :------------ | :------------------------- | - * | **GBP** | £20 | 1.277 | $25.54 | - * | **EUR** | €20 | 1.134 | $22.68 | - * | **RUB** | ₽20 | 0.015 | $0.30 | - * - * - * ### Integration-specific details - * - * | Integration | Scenario | System behavior | - * |-------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| - * | QuickBooks Online | Transaction currency differs from base currency | If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, include the required currency rate in the expense transaction. | - */ - currencyRate?: Decimal$ | number | null | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - date?: string | undefined; - /** - * Identifier of the direct cost (unique to the company). - */ - id?: string | undefined; - /** - * Array of account transaction lines. - */ - lines?: Array | null | undefined; - metadata?: Metadata | undefined; - modifiedDate?: string | undefined; - /** - * Additional information about the account transaction, if available. - */ - note?: string | null | undefined; - sourceModifiedDate?: string | undefined; - /** - * The status of the account transaction. - */ - status?: Status | undefined; - /** - * Total amount of the account transactions, inclusive of tax. - */ - totalAmount?: Decimal$ | number | undefined; - /** - * Identifier of the transaction (unique to the company). - */ - transactionId?: string | null | undefined; + /** + * Links to the Account transactions data type. + */ + bankAccountRef?: BankAccountRef | undefined; + /** + * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + * + * @remarks + * + * ## Unknown currencies + * + * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + * + * There are only a very small number of edge cases where this currency code is returned by the Codat system. + */ + currency?: string | undefined; + /** + * Rate to convert the total amount of the payment into the base currency for the company at the time of the payment. + * + * @remarks + * + * Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit. + * + * It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR. + * + * Where the currency rate is provided by the underlying accounting platform, it will be available from Codat with the same precision (up to a maximum of 9 decimal places). + * + * For accounting platforms which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places. + * + * ## Examples with base currency of GBP + * + * | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (GBP) | + * | :--------------- | :------------- | :------------ | :------------------------- | + * | **USD** | $20 | 0.781 | £15.62 | + * | **EUR** | €20 | 0.885 | £17.70 | + * | **RUB** | ₽20 | 0.011 | £0.22 | + * + * ## Examples with base currency of USD + * + * | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (USD) | + * | :--------------- | :------------- | :------------ | :------------------------- | + * | **GBP** | £20 | 1.277 | $25.54 | + * | **EUR** | €20 | 1.134 | $22.68 | + * | **RUB** | ₽20 | 0.015 | $0.30 | + * + * ### Integration-specific details + * + * | Integration | Scenario | System behavior | + * |-------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| + * | QuickBooks Online | Transaction currency differs from base currency | If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, include the required currency rate in the expense transaction. | + */ + currencyRate?: Decimal$ | number | null | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + date?: string | undefined; + /** + * Identifier of the direct cost (unique to the company). + */ + id?: string | undefined; + /** + * Array of account transaction lines. + */ + lines?: Array | null | undefined; + metadata?: Metadata | undefined; + modifiedDate?: string | undefined; + /** + * Additional information about the account transaction, if available. + */ + note?: string | null | undefined; + sourceModifiedDate?: string | undefined; + /** + * The status of the account transaction. + */ + status?: Status | undefined; + /** + * Total amount of the account transactions, inclusive of tax. + */ + totalAmount?: Decimal$ | number | undefined; + /** + * Identifier of the transaction (unique to the company). + */ + transactionId?: string | null | undefined; }; /** @internal */ +export const Status$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(Status); + +/** @internal */ +export const Status$outboundSchema: z.ZodNativeEnum = + Status$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace Status$ { - export const inboundSchema = z.nativeEnum(Status); - export const outboundSchema = inboundSchema; + /** @deprecated use `Status$inboundSchema` instead. */ + export const inboundSchema = Status$inboundSchema; + /** @deprecated use `Status$outboundSchema` instead. */ + export const outboundSchema = Status$outboundSchema; } /** @internal */ -export namespace AccountTransaction$ { - export const inboundSchema: z.ZodType = z - .object({ - bankAccountRef: BankAccountRef$.inboundSchema.optional(), - currency: z.string().optional(), - currencyRate: z.nullable(z.number().transform((v) => new Decimal$(v))).optional(), - date: z.string().optional(), - id: z.string().optional(), - lines: z.nullable(z.array(AccountTransactionLine$.inboundSchema)).optional(), - metadata: Metadata$.inboundSchema.optional(), - modifiedDate: z.string().optional(), - note: z.nullable(z.string()).optional(), - sourceModifiedDate: z.string().optional(), - status: Status$.inboundSchema.optional(), - totalAmount: z - .number() - .transform((v) => new Decimal$(v)) - .optional(), - transactionId: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.bankAccountRef === undefined ? null : { bankAccountRef: v.bankAccountRef }), - ...(v.currency === undefined ? null : { currency: v.currency }), - ...(v.currencyRate === undefined ? null : { currencyRate: v.currencyRate }), - ...(v.date === undefined ? null : { date: v.date }), - ...(v.id === undefined ? null : { id: v.id }), - ...(v.lines === undefined ? null : { lines: v.lines }), - ...(v.metadata === undefined ? null : { metadata: v.metadata }), - ...(v.modifiedDate === undefined ? null : { modifiedDate: v.modifiedDate }), - ...(v.note === undefined ? null : { note: v.note }), - ...(v.sourceModifiedDate === undefined - ? null - : { sourceModifiedDate: v.sourceModifiedDate }), - ...(v.status === undefined ? null : { status: v.status }), - ...(v.totalAmount === undefined ? null : { totalAmount: v.totalAmount }), - ...(v.transactionId === undefined ? null : { transactionId: v.transactionId }), - }; - }); +export const AccountTransaction$inboundSchema: z.ZodType< + AccountTransaction, + z.ZodTypeDef, + unknown +> = z.object({ + bankAccountRef: BankAccountRef$inboundSchema.optional(), + currency: z.string().optional(), + currencyRate: z.nullable(z.number().transform(v => new Decimal$(v))) + .optional(), + date: z.string().optional(), + id: z.string().optional(), + lines: z.nullable(z.array(AccountTransactionLine$inboundSchema)).optional(), + metadata: Metadata$inboundSchema.optional(), + modifiedDate: z.string().optional(), + note: z.nullable(z.string()).optional(), + sourceModifiedDate: z.string().optional(), + status: Status$inboundSchema.optional(), + totalAmount: z.number().transform(v => new Decimal$(v)).optional(), + transactionId: z.nullable(z.string()).optional(), +}); - export type Outbound = { - bankAccountRef?: BankAccountRef$.Outbound | undefined; - currency?: string | undefined; - currencyRate?: number | null | undefined; - date?: string | undefined; - id?: string | undefined; - lines?: Array | null | undefined; - metadata?: Metadata$.Outbound | undefined; - modifiedDate?: string | undefined; - note?: string | null | undefined; - sourceModifiedDate?: string | undefined; - status?: string | undefined; - totalAmount?: number | undefined; - transactionId?: string | null | undefined; - }; +/** @internal */ +export type AccountTransaction$Outbound = { + bankAccountRef?: BankAccountRef$Outbound | undefined; + currency?: string | undefined; + currencyRate?: number | null | undefined; + date?: string | undefined; + id?: string | undefined; + lines?: Array | null | undefined; + metadata?: Metadata$Outbound | undefined; + modifiedDate?: string | undefined; + note?: string | null | undefined; + sourceModifiedDate?: string | undefined; + status?: string | undefined; + totalAmount?: number | undefined; + transactionId?: string | null | undefined; +}; + +/** @internal */ +export const AccountTransaction$outboundSchema: z.ZodType< + AccountTransaction$Outbound, + z.ZodTypeDef, + AccountTransaction +> = z.object({ + bankAccountRef: BankAccountRef$outboundSchema.optional(), + currency: z.string().optional(), + currencyRate: z.nullable( + z.union([z.instanceof(Decimal$), z.number()]).transform(v => + typeof v === "number" ? v : v.toNumber() + ), + ).optional(), + date: z.string().optional(), + id: z.string().optional(), + lines: z.nullable(z.array(AccountTransactionLine$outboundSchema)).optional(), + metadata: Metadata$outboundSchema.optional(), + modifiedDate: z.string().optional(), + note: z.nullable(z.string()).optional(), + sourceModifiedDate: z.string().optional(), + status: Status$outboundSchema.optional(), + totalAmount: z.union([z.instanceof(Decimal$), z.number()]).transform(v => + typeof v === "number" ? v : v.toNumber() + ).optional(), + transactionId: z.nullable(z.string()).optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - bankAccountRef: BankAccountRef$.outboundSchema.optional(), - currency: z.string().optional(), - currencyRate: z - .nullable( - z - .union([z.instanceof(Decimal$), z.number()]) - .transform((v) => (typeof v === "number" ? v : v.toNumber())) - ) - .optional(), - date: z.string().optional(), - id: z.string().optional(), - lines: z.nullable(z.array(AccountTransactionLine$.outboundSchema)).optional(), - metadata: Metadata$.outboundSchema.optional(), - modifiedDate: z.string().optional(), - note: z.nullable(z.string()).optional(), - sourceModifiedDate: z.string().optional(), - status: Status$.outboundSchema.optional(), - totalAmount: z - .union([z.instanceof(Decimal$), z.number()]) - .transform((v) => (typeof v === "number" ? v : v.toNumber())) - .optional(), - transactionId: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.bankAccountRef === undefined ? null : { bankAccountRef: v.bankAccountRef }), - ...(v.currency === undefined ? null : { currency: v.currency }), - ...(v.currencyRate === undefined ? null : { currencyRate: v.currencyRate }), - ...(v.date === undefined ? null : { date: v.date }), - ...(v.id === undefined ? null : { id: v.id }), - ...(v.lines === undefined ? null : { lines: v.lines }), - ...(v.metadata === undefined ? null : { metadata: v.metadata }), - ...(v.modifiedDate === undefined ? null : { modifiedDate: v.modifiedDate }), - ...(v.note === undefined ? null : { note: v.note }), - ...(v.sourceModifiedDate === undefined - ? null - : { sourceModifiedDate: v.sourceModifiedDate }), - ...(v.status === undefined ? null : { status: v.status }), - ...(v.totalAmount === undefined ? null : { totalAmount: v.totalAmount }), - ...(v.transactionId === undefined ? null : { transactionId: v.transactionId }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AccountTransaction$ { + /** @deprecated use `AccountTransaction$inboundSchema` instead. */ + export const inboundSchema = AccountTransaction$inboundSchema; + /** @deprecated use `AccountTransaction$outboundSchema` instead. */ + export const outboundSchema = AccountTransaction$outboundSchema; + /** @deprecated use `AccountTransaction$Outbound` instead. */ + export type Outbound = AccountTransaction$Outbound; } diff --git a/accounting/src/sdk/models/shared/accounttransactionline.ts b/accounting/src/sdk/models/shared/accounttransactionline.ts index 0c04ce3d..02a8a672 100644 --- a/accounting/src/sdk/models/shared/accounttransactionline.ts +++ b/accounting/src/sdk/models/shared/accounttransactionline.ts @@ -1,68 +1,71 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Decimal as Decimal$ } from "../../types"; -import { - AccountTransactionLineRecordRef, - AccountTransactionLineRecordRef$, -} from "./accounttransactionlinerecordref"; import * as z from "zod"; +import { Decimal as Decimal$ } from "../../types/decimal.js"; +import { + AccountTransactionLineRecordRef, + AccountTransactionLineRecordRef$inboundSchema, + AccountTransactionLineRecordRef$Outbound, + AccountTransactionLineRecordRef$outboundSchema, +} from "./accounttransactionlinerecordref.js"; export type AccountTransactionLine = { - /** - * Amount in the bill payment currency. - */ - amount?: Decimal$ | number | undefined; - /** - * Description of the account transaction. - */ - description?: string | null | undefined; - /** - * Links an account transaction line to the underlying record that created it. - */ - recordRef?: AccountTransactionLineRecordRef | undefined; + /** + * Amount in the bill payment currency. + */ + amount?: Decimal$ | number | undefined; + /** + * Description of the account transaction. + */ + description?: string | null | undefined; + /** + * Links an account transaction line to the underlying record that created it. + */ + recordRef?: AccountTransactionLineRecordRef | undefined; }; /** @internal */ -export namespace AccountTransactionLine$ { - export const inboundSchema: z.ZodType = z - .object({ - amount: z - .number() - .transform((v) => new Decimal$(v)) - .optional(), - description: z.nullable(z.string()).optional(), - recordRef: AccountTransactionLineRecordRef$.inboundSchema.optional(), - }) - .transform((v) => { - return { - ...(v.amount === undefined ? null : { amount: v.amount }), - ...(v.description === undefined ? null : { description: v.description }), - ...(v.recordRef === undefined ? null : { recordRef: v.recordRef }), - }; - }); +export const AccountTransactionLine$inboundSchema: z.ZodType< + AccountTransactionLine, + z.ZodTypeDef, + unknown +> = z.object({ + amount: z.number().transform(v => new Decimal$(v)).optional(), + description: z.nullable(z.string()).optional(), + recordRef: AccountTransactionLineRecordRef$inboundSchema.optional(), +}); - export type Outbound = { - amount?: number | undefined; - description?: string | null | undefined; - recordRef?: AccountTransactionLineRecordRef$.Outbound | undefined; - }; +/** @internal */ +export type AccountTransactionLine$Outbound = { + amount?: number | undefined; + description?: string | null | undefined; + recordRef?: AccountTransactionLineRecordRef$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - amount: z - .union([z.instanceof(Decimal$), z.number()]) - .transform((v) => (typeof v === "number" ? v : v.toNumber())) - .optional(), - description: z.nullable(z.string()).optional(), - recordRef: AccountTransactionLineRecordRef$.outboundSchema.optional(), - }) - .transform((v) => { - return { - ...(v.amount === undefined ? null : { amount: v.amount }), - ...(v.description === undefined ? null : { description: v.description }), - ...(v.recordRef === undefined ? null : { recordRef: v.recordRef }), - }; - }); +/** @internal */ +export const AccountTransactionLine$outboundSchema: z.ZodType< + AccountTransactionLine$Outbound, + z.ZodTypeDef, + AccountTransactionLine +> = z.object({ + amount: z.union([z.instanceof(Decimal$), z.number()]).transform(v => + typeof v === "number" ? v : v.toNumber() + ).optional(), + description: z.nullable(z.string()).optional(), + recordRef: AccountTransactionLineRecordRef$outboundSchema.optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AccountTransactionLine$ { + /** @deprecated use `AccountTransactionLine$inboundSchema` instead. */ + export const inboundSchema = AccountTransactionLine$inboundSchema; + /** @deprecated use `AccountTransactionLine$outboundSchema` instead. */ + export const outboundSchema = AccountTransactionLine$outboundSchema; + /** @deprecated use `AccountTransactionLine$Outbound` instead. */ + export type Outbound = AccountTransactionLine$Outbound; } diff --git a/accounting/src/sdk/models/shared/accounttransactionlinerecordref.ts b/accounting/src/sdk/models/shared/accounttransactionlinerecordref.ts index a5618e4a..f953e216 100644 --- a/accounting/src/sdk/models/shared/accounttransactionlinerecordref.ts +++ b/accounting/src/sdk/models/shared/accounttransactionlinerecordref.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,72 +8,91 @@ import * as z from "zod"; * Name of underlying data type. */ export enum AccountTransactionLineRecordRefDataType { - BankTransactions = "bankTransactions", - BillCreditNotes = "billCreditNotes", - BillPayments = "billPayments", - Bills = "bills", - CreditNotes = "creditNotes", - DirectCosts = "directCosts", - DirectIncomes = "directIncomes", - Invoices = "invoices", - JournalEntries = "journalEntries", - Payments = "payments", - Transfers = "transfers", + BankTransactions = "bankTransactions", + BillCreditNotes = "billCreditNotes", + BillPayments = "billPayments", + Bills = "bills", + CreditNotes = "creditNotes", + DirectCosts = "directCosts", + DirectIncomes = "directIncomes", + Invoices = "invoices", + JournalEntries = "journalEntries", + Payments = "payments", + Transfers = "transfers", } /** * Links an account transaction line to the underlying record that created it. */ export type AccountTransactionLineRecordRef = { - /** - * Name of underlying data type. - */ - dataType?: AccountTransactionLineRecordRefDataType | undefined; - /** - * 'id' of the underlying record or data type. - */ - id?: string | undefined; + /** + * Name of underlying data type. + */ + dataType?: AccountTransactionLineRecordRefDataType | undefined; + /** + * 'id' of the underlying record or data type. + */ + id?: string | undefined; }; /** @internal */ +export const AccountTransactionLineRecordRefDataType$inboundSchema: + z.ZodNativeEnum = z + .nativeEnum(AccountTransactionLineRecordRefDataType); + +/** @internal */ +export const AccountTransactionLineRecordRefDataType$outboundSchema: + z.ZodNativeEnum = + AccountTransactionLineRecordRefDataType$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace AccountTransactionLineRecordRefDataType$ { - export const inboundSchema = z.nativeEnum(AccountTransactionLineRecordRefDataType); - export const outboundSchema = inboundSchema; + /** @deprecated use `AccountTransactionLineRecordRefDataType$inboundSchema` instead. */ + export const inboundSchema = + AccountTransactionLineRecordRefDataType$inboundSchema; + /** @deprecated use `AccountTransactionLineRecordRefDataType$outboundSchema` instead. */ + export const outboundSchema = + AccountTransactionLineRecordRefDataType$outboundSchema; } /** @internal */ -export namespace AccountTransactionLineRecordRef$ { - export const inboundSchema: z.ZodType = - z - .object({ - dataType: AccountTransactionLineRecordRefDataType$.inboundSchema.optional(), - id: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.dataType === undefined ? null : { dataType: v.dataType }), - ...(v.id === undefined ? null : { id: v.id }), - }; - }); +export const AccountTransactionLineRecordRef$inboundSchema: z.ZodType< + AccountTransactionLineRecordRef, + z.ZodTypeDef, + unknown +> = z.object({ + dataType: AccountTransactionLineRecordRefDataType$inboundSchema.optional(), + id: z.string().optional(), +}); - export type Outbound = { - dataType?: string | undefined; - id?: string | undefined; - }; +/** @internal */ +export type AccountTransactionLineRecordRef$Outbound = { + dataType?: string | undefined; + id?: string | undefined; +}; + +/** @internal */ +export const AccountTransactionLineRecordRef$outboundSchema: z.ZodType< + AccountTransactionLineRecordRef$Outbound, + z.ZodTypeDef, + AccountTransactionLineRecordRef +> = z.object({ + dataType: AccountTransactionLineRecordRefDataType$outboundSchema.optional(), + id: z.string().optional(), +}); - export const outboundSchema: z.ZodType< - Outbound, - z.ZodTypeDef, - AccountTransactionLineRecordRef - > = z - .object({ - dataType: AccountTransactionLineRecordRefDataType$.outboundSchema.optional(), - id: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.dataType === undefined ? null : { dataType: v.dataType }), - ...(v.id === undefined ? null : { id: v.id }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AccountTransactionLineRecordRef$ { + /** @deprecated use `AccountTransactionLineRecordRef$inboundSchema` instead. */ + export const inboundSchema = AccountTransactionLineRecordRef$inboundSchema; + /** @deprecated use `AccountTransactionLineRecordRef$outboundSchema` instead. */ + export const outboundSchema = AccountTransactionLineRecordRef$outboundSchema; + /** @deprecated use `AccountTransactionLineRecordRef$Outbound` instead. */ + export type Outbound = AccountTransactionLineRecordRef$Outbound; } diff --git a/accounting/src/sdk/models/shared/accounttransactions.ts b/accounting/src/sdk/models/shared/accounttransactions.ts index e8bcfced..bba63616 100644 --- a/accounting/src/sdk/models/shared/accounttransactions.ts +++ b/accounting/src/sdk/models/shared/accounttransactions.ts @@ -1,71 +1,91 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { AccountTransaction, AccountTransaction$ } from "./accounttransaction"; -import { Links, Links$ } from "./links"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import { + AccountTransaction, + AccountTransaction$inboundSchema, + AccountTransaction$Outbound, + AccountTransaction$outboundSchema, +} from "./accounttransaction.js"; +import { + Links, + Links$inboundSchema, + Links$Outbound, + Links$outboundSchema, +} from "./links.js"; export type AccountTransactions = { - links: Links; - /** - * Current page number. - */ - pageNumber: number; - /** - * Number of items to return in results array. - */ - pageSize: number; - results?: Array | undefined; - /** - * Total number of items. - */ - totalResults: number; + links: Links; + /** + * Current page number. + */ + pageNumber: number; + /** + * Number of items to return in results array. + */ + pageSize: number; + results?: Array | undefined; + /** + * Total number of items. + */ + totalResults: number; }; /** @internal */ -export namespace AccountTransactions$ { - export const inboundSchema: z.ZodType = z - .object({ - _links: Links$.inboundSchema, - pageNumber: z.number().int(), - pageSize: z.number().int(), - results: z.array(AccountTransaction$.inboundSchema).optional(), - totalResults: z.number().int(), - }) - .transform((v) => { - return { - links: v._links, - pageNumber: v.pageNumber, - pageSize: v.pageSize, - ...(v.results === undefined ? null : { results: v.results }), - totalResults: v.totalResults, - }; - }); +export const AccountTransactions$inboundSchema: z.ZodType< + AccountTransactions, + z.ZodTypeDef, + unknown +> = z.object({ + _links: Links$inboundSchema, + pageNumber: z.number().int(), + pageSize: z.number().int(), + results: z.array(AccountTransaction$inboundSchema).optional(), + totalResults: z.number().int(), +}).transform((v) => { + return remap$(v, { + "_links": "links", + }); +}); - export type Outbound = { - _links: Links$.Outbound; - pageNumber: number; - pageSize: number; - results?: Array | undefined; - totalResults: number; - }; +/** @internal */ +export type AccountTransactions$Outbound = { + _links: Links$Outbound; + pageNumber: number; + pageSize: number; + results?: Array | undefined; + totalResults: number; +}; - export const outboundSchema: z.ZodType = z - .object({ - links: Links$.outboundSchema, - pageNumber: z.number().int(), - pageSize: z.number().int(), - results: z.array(AccountTransaction$.outboundSchema).optional(), - totalResults: z.number().int(), - }) - .transform((v) => { - return { - _links: v.links, - pageNumber: v.pageNumber, - pageSize: v.pageSize, - ...(v.results === undefined ? null : { results: v.results }), - totalResults: v.totalResults, - }; - }); +/** @internal */ +export const AccountTransactions$outboundSchema: z.ZodType< + AccountTransactions$Outbound, + z.ZodTypeDef, + AccountTransactions +> = z.object({ + links: Links$outboundSchema, + pageNumber: z.number().int(), + pageSize: z.number().int(), + results: z.array(AccountTransaction$outboundSchema).optional(), + totalResults: z.number().int(), +}).transform((v) => { + return remap$(v, { + links: "_links", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AccountTransactions$ { + /** @deprecated use `AccountTransactions$inboundSchema` instead. */ + export const inboundSchema = AccountTransactions$inboundSchema; + /** @deprecated use `AccountTransactions$outboundSchema` instead. */ + export const outboundSchema = AccountTransactions$outboundSchema; + /** @deprecated use `AccountTransactions$Outbound` instead. */ + export type Outbound = AccountTransactions$Outbound; } diff --git a/accounting/src/sdk/models/shared/accounttype.ts b/accounting/src/sdk/models/shared/accounttype.ts index 56c0a33b..fc505ac0 100644 --- a/accounting/src/sdk/models/shared/accounttype.ts +++ b/accounting/src/sdk/models/shared/accounttype.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,16 +8,29 @@ import * as z from "zod"; * Type of account */ export enum AccountType { - Unknown = "Unknown", - Asset = "Asset", - Expense = "Expense", - Income = "Income", - Liability = "Liability", - Equity = "Equity", + Unknown = "Unknown", + Asset = "Asset", + Expense = "Expense", + Income = "Income", + Liability = "Liability", + Equity = "Equity", } /** @internal */ +export const AccountType$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(AccountType); + +/** @internal */ +export const AccountType$outboundSchema: z.ZodNativeEnum = + AccountType$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace AccountType$ { - export const inboundSchema = z.nativeEnum(AccountType); - export const outboundSchema = inboundSchema; + /** @deprecated use `AccountType$inboundSchema` instead. */ + export const inboundSchema = AccountType$inboundSchema; + /** @deprecated use `AccountType$outboundSchema` instead. */ + export const outboundSchema = AccountType$outboundSchema; } diff --git a/accounting/src/sdk/models/shared/bankaccountref.ts b/accounting/src/sdk/models/shared/bankaccountref.ts index 6fc021fc..35da9a2c 100644 --- a/accounting/src/sdk/models/shared/bankaccountref.ts +++ b/accounting/src/sdk/models/shared/bankaccountref.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,44 +8,51 @@ import * as z from "zod"; * Links to the Account transactions data type. */ export type BankAccountRef = { - /** - * Bank account 'id' for the account transaction. - */ - id?: string | undefined; - /** - * bank account 'name' for the account transaction. - */ - name?: string | undefined; + /** + * Bank account 'id' for the account transaction. + */ + id?: string | undefined; + /** + * bank account 'name' for the account transaction. + */ + name?: string | undefined; }; /** @internal */ -export namespace BankAccountRef$ { - export const inboundSchema: z.ZodType = z - .object({ - id: z.string().optional(), - name: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.id === undefined ? null : { id: v.id }), - ...(v.name === undefined ? null : { name: v.name }), - }; - }); +export const BankAccountRef$inboundSchema: z.ZodType< + BankAccountRef, + z.ZodTypeDef, + unknown +> = z.object({ + id: z.string().optional(), + name: z.string().optional(), +}); + +/** @internal */ +export type BankAccountRef$Outbound = { + id?: string | undefined; + name?: string | undefined; +}; - export type Outbound = { - id?: string | undefined; - name?: string | undefined; - }; +/** @internal */ +export const BankAccountRef$outboundSchema: z.ZodType< + BankAccountRef$Outbound, + z.ZodTypeDef, + BankAccountRef +> = z.object({ + id: z.string().optional(), + name: z.string().optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - id: z.string().optional(), - name: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.id === undefined ? null : { id: v.id }), - ...(v.name === undefined ? null : { name: v.name }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace BankAccountRef$ { + /** @deprecated use `BankAccountRef$inboundSchema` instead. */ + export const inboundSchema = BankAccountRef$inboundSchema; + /** @deprecated use `BankAccountRef$outboundSchema` instead. */ + export const outboundSchema = BankAccountRef$outboundSchema; + /** @deprecated use `BankAccountRef$Outbound` instead. */ + export type Outbound = BankAccountRef$Outbound; } diff --git a/accounting/src/sdk/models/shared/createaccountresponse.ts b/accounting/src/sdk/models/shared/createaccountresponse.ts index 0cb62287..8265b8bd 100644 --- a/accounting/src/sdk/models/shared/createaccountresponse.ts +++ b/accounting/src/sdk/models/shared/createaccountresponse.ts @@ -1,18 +1,59 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Decimal as Decimal$ } from "../../types"; -import { AccountStatus, AccountStatus$ } from "./accountstatus"; -import { AccountType, AccountType$ } from "./accounttype"; -import { DataType, DataType$ } from "./datatype"; -import { Metadata, Metadata$ } from "./metadata"; -import { PushOperationChange, PushOperationChange$ } from "./pushoperationchange"; -import { PushOperationStatus, PushOperationStatus$ } from "./pushoperationstatus"; -import { SupplementalData, SupplementalData$ } from "./supplementaldata"; -import { Validation, Validation$ } from "./validation"; -import { ValidDataTypeLinks, ValidDataTypeLinks$ } from "./validdatatypelinks"; import * as z from "zod"; +import { Decimal as Decimal$ } from "../../types/decimal.js"; +import { + AccountStatus, + AccountStatus$inboundSchema, + AccountStatus$outboundSchema, +} from "./accountstatus.js"; +import { + AccountType, + AccountType$inboundSchema, + AccountType$outboundSchema, +} from "./accounttype.js"; +import { + DataType, + DataType$inboundSchema, + DataType$outboundSchema, +} from "./datatype.js"; +import { + Metadata, + Metadata$inboundSchema, + Metadata$Outbound, + Metadata$outboundSchema, +} from "./metadata.js"; +import { + PushOperationChange, + PushOperationChange$inboundSchema, + PushOperationChange$Outbound, + PushOperationChange$outboundSchema, +} from "./pushoperationchange.js"; +import { + PushOperationStatus, + PushOperationStatus$inboundSchema, + PushOperationStatus$outboundSchema, +} from "./pushoperationstatus.js"; +import { + SupplementalData, + SupplementalData$inboundSchema, + SupplementalData$Outbound, + SupplementalData$outboundSchema, +} from "./supplementaldata.js"; +import { + Validation, + Validation$inboundSchema, + Validation$Outbound, + Validation$outboundSchema, +} from "./validation.js"; +import { + ValidDataTypeLinks, + ValidDataTypeLinks$inboundSchema, + ValidDataTypeLinks$Outbound, + ValidDataTypeLinks$outboundSchema, +} from "./validdatatypelinks.js"; /** * > **Language tip:** Accounts are also referred to as **chart of accounts**, **nominal accounts**, and **general ledger**. @@ -49,406 +90,337 @@ import * as z from "zod"; * @deprecated class: This will be removed in a future release, please migrate away from it as soon as possible. */ export type AccountingAccount = { - /** - * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. - * - * @remarks - * - * ## Unknown currencies - * - * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. - * - * There are only a very small number of edge cases where this currency code is returned by the Codat system. - */ - currency?: string | undefined; - /** - * Current balance in the account. - */ - currentBalance?: Decimal$ | number | null | undefined; - /** - * Description for the account. - */ - description?: string | null | undefined; - /** - * Full category of the account. - * - * @remarks - * - * For example, `Liability.Current` or `Income.Revenue`. To determine a list of possible categories for each integration, see our examples, follow our [Create, update, delete data](https://docs.codat.io/using-the-api/push) guide, or refer to the integration's own documentation. - */ - fullyQualifiedCategory?: string | null | undefined; - /** - * Full name of the account, for example: - * - * @remarks - * - `Cash On Hand` - * - `Rents Held In Trust` - * - `Fixed Asset` - */ - fullyQualifiedName?: string | null | undefined; - /** - * Identifier for the account, unique for the company. - */ - id?: string | undefined; - /** - * Confirms whether the account is a bank account or not. - */ - isBankAccount?: boolean | undefined; - metadata?: Metadata | undefined; - modifiedDate?: string | undefined; - /** - * Name of the account. - */ - name?: string | null | undefined; - /** - * Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. - */ - nominalCode?: string | null | undefined; - sourceModifiedDate?: string | undefined; - /** - * Status of the account - */ - status?: AccountStatus | undefined; - /** - * Supplemental data is additional data you can include in our standard data types. - * - * @remarks - * - * It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. - */ - supplementalData?: SupplementalData | undefined; - /** - * Type of account - */ - type?: AccountType | undefined; - /** - * The validDatatypeLinks can be used to determine whether an account can be correctly mapped to another object; for example, accounts with a `type` of `income` might only support being used on an Invoice and Direct Income. For more information, see [Valid Data Type Links](/accounting-api#/schemas/ValidDataTypeLinks). - */ - validDatatypeLinks?: Array | null | undefined; + /** + * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. + * + * @remarks + * + * ## Unknown currencies + * + * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. + * + * There are only a very small number of edge cases where this currency code is returned by the Codat system. + */ + currency?: string | undefined; + /** + * Current balance in the account. + */ + currentBalance?: Decimal$ | number | null | undefined; + /** + * Description for the account. + */ + description?: string | null | undefined; + /** + * Full category of the account. + * + * @remarks + * + * For example, `Liability.Current` or `Income.Revenue`. To determine a list of possible categories for each integration, see our examples, follow our [Create, update, delete data](https://docs.codat.io/using-the-api/push) guide, or refer to the integration's own documentation. + */ + fullyQualifiedCategory?: string | null | undefined; + /** + * Full name of the account, for example: + * + * @remarks + * - `Cash On Hand` + * - `Rents Held In Trust` + * - `Fixed Asset` + */ + fullyQualifiedName?: string | null | undefined; + /** + * Identifier for the account, unique for the company. + */ + id?: string | undefined; + /** + * Confirms whether the account is a bank account or not. + */ + isBankAccount?: boolean | undefined; + metadata?: Metadata | undefined; + modifiedDate?: string | undefined; + /** + * Name of the account. + */ + name?: string | null | undefined; + /** + * Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. + */ + nominalCode?: string | null | undefined; + sourceModifiedDate?: string | undefined; + /** + * Status of the account + */ + status?: AccountStatus | undefined; + /** + * Supplemental data is additional data you can include in our standard data types. + * + * @remarks + * + * It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. + */ + supplementalData?: SupplementalData | undefined; + /** + * Type of account + */ + type?: AccountType | undefined; + /** + * The validDatatypeLinks can be used to determine whether an account can be correctly mapped to another object; for example, accounts with a `type` of `income` might only support being used on an Invoice and Direct Income. For more information, see [Valid Data Type Links](/accounting-api#/schemas/ValidDataTypeLinks). + */ + validDatatypeLinks?: Array | null | undefined; }; export type CreateAccountResponse = { - /** - * Contains a single entry that communicates which record has changed and the manner in which it changed. - */ - changes?: Array | null | undefined; - /** - * Unique identifier for your SMB in Codat. - */ - companyId: string; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - completedOnUtc?: string | undefined; - data?: AccountingAccount | null | undefined; - /** - * Unique identifier for a company's data connection. - */ - dataConnectionKey: string; - /** - * Available data types - */ - dataType?: DataType | undefined; - /** - * A message about the error. - */ - errorMessage?: string | null | undefined; - /** - * A unique identifier generated by Codat to represent this single push operation. This identifier can be used to track the status of the push, and should be persisted. - */ - pushOperationKey: string; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - requestedOnUtc: string; - /** - * The current status of the push operation. - */ - status: PushOperationStatus; - /** - * Push status code. - */ - statusCode: number; - /** - * Number of minutes the push operation must complete within before it times out. - */ - timeoutInMinutes?: number | null | undefined; - /** - * Number of seconds the push operation must complete within before it times out. - * - * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. - */ - timeoutInSeconds?: number | null | undefined; - /** - * A human-readable object describing validation decisions Codat has made when pushing data into the platform. If a push has failed because of validation errors, they will be detailed here. - */ - validation?: Validation | undefined; + /** + * Contains a single entry that communicates which record has changed and the manner in which it changed. + */ + changes?: Array | null | undefined; + /** + * Unique identifier for your SMB in Codat. + */ + companyId: string; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + completedOnUtc?: string | undefined; + data?: AccountingAccount | null | undefined; + /** + * Unique identifier for a company's data connection. + */ + dataConnectionKey: string; + /** + * Available data types + */ + dataType?: DataType | undefined; + /** + * A message about the error. + */ + errorMessage?: string | null | undefined; + /** + * A unique identifier generated by Codat to represent this single push operation. This identifier can be used to track the status of the push, and should be persisted. + */ + pushOperationKey: string; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + requestedOnUtc: string; + /** + * The current status of the push operation. + */ + status: PushOperationStatus; + /** + * Push status code. + */ + statusCode: number; + /** + * Number of minutes the push operation must complete within before it times out. + */ + timeoutInMinutes?: number | null | undefined; + /** + * Number of seconds the push operation must complete within before it times out. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + timeoutInSeconds?: number | null | undefined; + /** + * A human-readable object describing validation decisions Codat has made when pushing data into the platform. If a push has failed because of validation errors, they will be detailed here. + */ + validation?: Validation | undefined; }; /** @internal */ -export namespace AccountingAccount$ { - export const inboundSchema: z.ZodType = z - .object({ - currency: z.string().optional(), - currentBalance: z.nullable(z.number().transform((v) => new Decimal$(v))).optional(), - description: z.nullable(z.string()).optional(), - fullyQualifiedCategory: z.nullable(z.string()).optional(), - fullyQualifiedName: z.nullable(z.string()).optional(), - id: z.string().optional(), - isBankAccount: z.boolean().optional(), - metadata: Metadata$.inboundSchema.optional(), - modifiedDate: z.string().optional(), - name: z.nullable(z.string()).optional(), - nominalCode: z.nullable(z.string()).optional(), - sourceModifiedDate: z.string().optional(), - status: AccountStatus$.inboundSchema.optional(), - supplementalData: SupplementalData$.inboundSchema.optional(), - type: AccountType$.inboundSchema.optional(), - validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$.inboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.currency === undefined ? null : { currency: v.currency }), - ...(v.currentBalance === undefined ? null : { currentBalance: v.currentBalance }), - ...(v.description === undefined ? null : { description: v.description }), - ...(v.fullyQualifiedCategory === undefined - ? null - : { fullyQualifiedCategory: v.fullyQualifiedCategory }), - ...(v.fullyQualifiedName === undefined - ? null - : { fullyQualifiedName: v.fullyQualifiedName }), - ...(v.id === undefined ? null : { id: v.id }), - ...(v.isBankAccount === undefined ? null : { isBankAccount: v.isBankAccount }), - ...(v.metadata === undefined ? null : { metadata: v.metadata }), - ...(v.modifiedDate === undefined ? null : { modifiedDate: v.modifiedDate }), - ...(v.name === undefined ? null : { name: v.name }), - ...(v.nominalCode === undefined ? null : { nominalCode: v.nominalCode }), - ...(v.sourceModifiedDate === undefined - ? null - : { sourceModifiedDate: v.sourceModifiedDate }), - ...(v.status === undefined ? null : { status: v.status }), - ...(v.supplementalData === undefined - ? null - : { supplementalData: v.supplementalData }), - ...(v.type === undefined ? null : { type: v.type }), - ...(v.validDatatypeLinks === undefined - ? null - : { validDatatypeLinks: v.validDatatypeLinks }), - }; - }); +export const AccountingAccount$inboundSchema: z.ZodType< + AccountingAccount, + z.ZodTypeDef, + unknown +> = z.object({ + currency: z.string().optional(), + currentBalance: z.nullable(z.number().transform(v => new Decimal$(v))) + .optional(), + description: z.nullable(z.string()).optional(), + fullyQualifiedCategory: z.nullable(z.string()).optional(), + fullyQualifiedName: z.nullable(z.string()).optional(), + id: z.string().optional(), + isBankAccount: z.boolean().optional(), + metadata: Metadata$inboundSchema.optional(), + modifiedDate: z.string().optional(), + name: z.nullable(z.string()).optional(), + nominalCode: z.nullable(z.string()).optional(), + sourceModifiedDate: z.string().optional(), + status: AccountStatus$inboundSchema.optional(), + supplementalData: SupplementalData$inboundSchema.optional(), + type: AccountType$inboundSchema.optional(), + validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$inboundSchema)) + .optional(), +}); + +/** @internal */ +export type AccountingAccount$Outbound = { + currency?: string | undefined; + currentBalance?: number | null | undefined; + description?: string | null | undefined; + fullyQualifiedCategory?: string | null | undefined; + fullyQualifiedName?: string | null | undefined; + id?: string | undefined; + isBankAccount?: boolean | undefined; + metadata?: Metadata$Outbound | undefined; + modifiedDate?: string | undefined; + name?: string | null | undefined; + nominalCode?: string | null | undefined; + sourceModifiedDate?: string | undefined; + status?: string | undefined; + supplementalData?: SupplementalData$Outbound | undefined; + type?: string | undefined; + validDatatypeLinks?: Array | null | undefined; +}; - export type Outbound = { - currency?: string | undefined; - currentBalance?: number | null | undefined; - description?: string | null | undefined; - fullyQualifiedCategory?: string | null | undefined; - fullyQualifiedName?: string | null | undefined; - id?: string | undefined; - isBankAccount?: boolean | undefined; - metadata?: Metadata$.Outbound | undefined; - modifiedDate?: string | undefined; - name?: string | null | undefined; - nominalCode?: string | null | undefined; - sourceModifiedDate?: string | undefined; - status?: string | undefined; - supplementalData?: SupplementalData$.Outbound | undefined; - type?: string | undefined; - validDatatypeLinks?: Array | null | undefined; - }; +/** @internal */ +export const AccountingAccount$outboundSchema: z.ZodType< + AccountingAccount$Outbound, + z.ZodTypeDef, + AccountingAccount +> = z.object({ + currency: z.string().optional(), + currentBalance: z.nullable( + z.union([z.instanceof(Decimal$), z.number()]).transform(v => + typeof v === "number" ? v : v.toNumber() + ), + ).optional(), + description: z.nullable(z.string()).optional(), + fullyQualifiedCategory: z.nullable(z.string()).optional(), + fullyQualifiedName: z.nullable(z.string()).optional(), + id: z.string().optional(), + isBankAccount: z.boolean().optional(), + metadata: Metadata$outboundSchema.optional(), + modifiedDate: z.string().optional(), + name: z.nullable(z.string()).optional(), + nominalCode: z.nullable(z.string()).optional(), + sourceModifiedDate: z.string().optional(), + status: AccountStatus$outboundSchema.optional(), + supplementalData: SupplementalData$outboundSchema.optional(), + type: AccountType$outboundSchema.optional(), + validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$outboundSchema)) + .optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - currency: z.string().optional(), - currentBalance: z - .nullable( - z - .union([z.instanceof(Decimal$), z.number()]) - .transform((v) => (typeof v === "number" ? v : v.toNumber())) - ) - .optional(), - description: z.nullable(z.string()).optional(), - fullyQualifiedCategory: z.nullable(z.string()).optional(), - fullyQualifiedName: z.nullable(z.string()).optional(), - id: z.string().optional(), - isBankAccount: z.boolean().optional(), - metadata: Metadata$.outboundSchema.optional(), - modifiedDate: z.string().optional(), - name: z.nullable(z.string()).optional(), - nominalCode: z.nullable(z.string()).optional(), - sourceModifiedDate: z.string().optional(), - status: AccountStatus$.outboundSchema.optional(), - supplementalData: SupplementalData$.outboundSchema.optional(), - type: AccountType$.outboundSchema.optional(), - validDatatypeLinks: z.nullable(z.array(ValidDataTypeLinks$.outboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.currency === undefined ? null : { currency: v.currency }), - ...(v.currentBalance === undefined ? null : { currentBalance: v.currentBalance }), - ...(v.description === undefined ? null : { description: v.description }), - ...(v.fullyQualifiedCategory === undefined - ? null - : { fullyQualifiedCategory: v.fullyQualifiedCategory }), - ...(v.fullyQualifiedName === undefined - ? null - : { fullyQualifiedName: v.fullyQualifiedName }), - ...(v.id === undefined ? null : { id: v.id }), - ...(v.isBankAccount === undefined ? null : { isBankAccount: v.isBankAccount }), - ...(v.metadata === undefined ? null : { metadata: v.metadata }), - ...(v.modifiedDate === undefined ? null : { modifiedDate: v.modifiedDate }), - ...(v.name === undefined ? null : { name: v.name }), - ...(v.nominalCode === undefined ? null : { nominalCode: v.nominalCode }), - ...(v.sourceModifiedDate === undefined - ? null - : { sourceModifiedDate: v.sourceModifiedDate }), - ...(v.status === undefined ? null : { status: v.status }), - ...(v.supplementalData === undefined - ? null - : { supplementalData: v.supplementalData }), - ...(v.type === undefined ? null : { type: v.type }), - ...(v.validDatatypeLinks === undefined - ? null - : { validDatatypeLinks: v.validDatatypeLinks }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AccountingAccount$ { + /** @deprecated use `AccountingAccount$inboundSchema` instead. */ + export const inboundSchema = AccountingAccount$inboundSchema; + /** @deprecated use `AccountingAccount$outboundSchema` instead. */ + export const outboundSchema = AccountingAccount$outboundSchema; + /** @deprecated use `AccountingAccount$Outbound` instead. */ + export type Outbound = AccountingAccount$Outbound; } /** @internal */ -export namespace CreateAccountResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - changes: z.nullable(z.array(PushOperationChange$.inboundSchema)).optional(), - companyId: z.string(), - completedOnUtc: z.string().optional(), - data: z.nullable(z.lazy(() => AccountingAccount$.inboundSchema)).optional(), - dataConnectionKey: z.string(), - dataType: DataType$.inboundSchema.optional(), - errorMessage: z.nullable(z.string()).optional(), - pushOperationKey: z.string(), - requestedOnUtc: z.string(), - status: PushOperationStatus$.inboundSchema, - statusCode: z.number().int(), - timeoutInMinutes: z.nullable(z.number().int()).optional(), - timeoutInSeconds: z.nullable(z.number().int()).optional(), - validation: Validation$.inboundSchema.optional(), - }) - .transform((v) => { - return { - ...(v.changes === undefined ? null : { changes: v.changes }), - companyId: v.companyId, - ...(v.completedOnUtc === undefined ? null : { completedOnUtc: v.completedOnUtc }), - ...(v.data === undefined ? null : { data: v.data }), - dataConnectionKey: v.dataConnectionKey, - ...(v.dataType === undefined ? null : { dataType: v.dataType }), - ...(v.errorMessage === undefined ? null : { errorMessage: v.errorMessage }), - pushOperationKey: v.pushOperationKey, - requestedOnUtc: v.requestedOnUtc, - status: v.status, - statusCode: v.statusCode, - ...(v.timeoutInMinutes === undefined - ? null - : { timeoutInMinutes: v.timeoutInMinutes }), - ...(v.timeoutInSeconds === undefined - ? null - : { timeoutInSeconds: v.timeoutInSeconds }), - ...(v.validation === undefined ? null : { validation: v.validation }), - }; - }); +export const CreateAccountResponse$inboundSchema: z.ZodType< + CreateAccountResponse, + z.ZodTypeDef, + unknown +> = z.object({ + changes: z.nullable(z.array(PushOperationChange$inboundSchema)).optional(), + companyId: z.string(), + completedOnUtc: z.string().optional(), + data: z.nullable(z.lazy(() => AccountingAccount$inboundSchema)).optional(), + dataConnectionKey: z.string(), + dataType: DataType$inboundSchema.optional(), + errorMessage: z.nullable(z.string()).optional(), + pushOperationKey: z.string(), + requestedOnUtc: z.string(), + status: PushOperationStatus$inboundSchema, + statusCode: z.number().int(), + timeoutInMinutes: z.nullable(z.number().int()).optional(), + timeoutInSeconds: z.nullable(z.number().int()).optional(), + validation: Validation$inboundSchema.optional(), +}); + +/** @internal */ +export type CreateAccountResponse$Outbound = { + changes?: Array | null | undefined; + companyId: string; + completedOnUtc?: string | undefined; + data?: AccountingAccount$Outbound | null | undefined; + dataConnectionKey: string; + dataType?: string | undefined; + errorMessage?: string | null | undefined; + pushOperationKey: string; + requestedOnUtc: string; + status: string; + statusCode: number; + timeoutInMinutes?: number | null | undefined; + timeoutInSeconds?: number | null | undefined; + validation?: Validation$Outbound | undefined; +}; - export type Outbound = { - changes?: Array | null | undefined; - companyId: string; - completedOnUtc?: string | undefined; - data?: AccountingAccount$.Outbound | null | undefined; - dataConnectionKey: string; - dataType?: string | undefined; - errorMessage?: string | null | undefined; - pushOperationKey: string; - requestedOnUtc: string; - status: string; - statusCode: number; - timeoutInMinutes?: number | null | undefined; - timeoutInSeconds?: number | null | undefined; - validation?: Validation$.Outbound | undefined; - }; +/** @internal */ +export const CreateAccountResponse$outboundSchema: z.ZodType< + CreateAccountResponse$Outbound, + z.ZodTypeDef, + CreateAccountResponse +> = z.object({ + changes: z.nullable(z.array(PushOperationChange$outboundSchema)).optional(), + companyId: z.string(), + completedOnUtc: z.string().optional(), + data: z.nullable(z.lazy(() => AccountingAccount$outboundSchema)).optional(), + dataConnectionKey: z.string(), + dataType: DataType$outboundSchema.optional(), + errorMessage: z.nullable(z.string()).optional(), + pushOperationKey: z.string(), + requestedOnUtc: z.string(), + status: PushOperationStatus$outboundSchema, + statusCode: z.number().int(), + timeoutInMinutes: z.nullable(z.number().int()).optional(), + timeoutInSeconds: z.nullable(z.number().int()).optional(), + validation: Validation$outboundSchema.optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - changes: z.nullable(z.array(PushOperationChange$.outboundSchema)).optional(), - companyId: z.string(), - completedOnUtc: z.string().optional(), - data: z.nullable(z.lazy(() => AccountingAccount$.outboundSchema)).optional(), - dataConnectionKey: z.string(), - dataType: DataType$.outboundSchema.optional(), - errorMessage: z.nullable(z.string()).optional(), - pushOperationKey: z.string(), - requestedOnUtc: z.string(), - status: PushOperationStatus$.outboundSchema, - statusCode: z.number().int(), - timeoutInMinutes: z.nullable(z.number().int()).optional(), - timeoutInSeconds: z.nullable(z.number().int()).optional(), - validation: Validation$.outboundSchema.optional(), - }) - .transform((v) => { - return { - ...(v.changes === undefined ? null : { changes: v.changes }), - companyId: v.companyId, - ...(v.completedOnUtc === undefined ? null : { completedOnUtc: v.completedOnUtc }), - ...(v.data === undefined ? null : { data: v.data }), - dataConnectionKey: v.dataConnectionKey, - ...(v.dataType === undefined ? null : { dataType: v.dataType }), - ...(v.errorMessage === undefined ? null : { errorMessage: v.errorMessage }), - pushOperationKey: v.pushOperationKey, - requestedOnUtc: v.requestedOnUtc, - status: v.status, - statusCode: v.statusCode, - ...(v.timeoutInMinutes === undefined - ? null - : { timeoutInMinutes: v.timeoutInMinutes }), - ...(v.timeoutInSeconds === undefined - ? null - : { timeoutInSeconds: v.timeoutInSeconds }), - ...(v.validation === undefined ? null : { validation: v.validation }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace CreateAccountResponse$ { + /** @deprecated use `CreateAccountResponse$inboundSchema` instead. */ + export const inboundSchema = CreateAccountResponse$inboundSchema; + /** @deprecated use `CreateAccountResponse$outboundSchema` instead. */ + export const outboundSchema = CreateAccountResponse$outboundSchema; + /** @deprecated use `CreateAccountResponse$Outbound` instead. */ + export type Outbound = CreateAccountResponse$Outbound; } diff --git a/accounting/src/sdk/models/shared/datatype.ts b/accounting/src/sdk/models/shared/datatype.ts index f3d26f4b..47c17d8d 100644 --- a/accounting/src/sdk/models/shared/datatype.ts +++ b/accounting/src/sdk/models/shared/datatype.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,53 +8,66 @@ import * as z from "zod"; * Available data types */ export enum DataType { - AccountTransactions = "accountTransactions", - BalanceSheet = "balanceSheet", - BankAccounts = "bankAccounts", - BankTransactions = "bankTransactions", - BillCreditNotes = "billCreditNotes", - BillPayments = "billPayments", - Bills = "bills", - CashFlowStatement = "cashFlowStatement", - ChartOfAccounts = "chartOfAccounts", - Company = "company", - CreditNotes = "creditNotes", - Customers = "customers", - DirectCosts = "directCosts", - DirectIncomes = "directIncomes", - Invoices = "invoices", - ItemReceipts = "itemReceipts", - Items = "items", - JournalEntries = "journalEntries", - Journals = "journals", - PaymentMethods = "paymentMethods", - Payments = "payments", - ProfitAndLoss = "profitAndLoss", - PurchaseOrders = "purchaseOrders", - SalesOrders = "salesOrders", - Suppliers = "suppliers", - TaxRates = "taxRates", - TrackingCategories = "trackingCategories", - Transfers = "transfers", - BankingAccountBalances = "banking-accountBalances", - BankingAccounts = "banking-accounts", - BankingTransactionCategories = "banking-transactionCategories", - BankingTransactions = "banking-transactions", - CommerceCompanyInfo = "commerce-companyInfo", - CommerceCustomers = "commerce-customers", - CommerceDisputes = "commerce-disputes", - CommerceLocations = "commerce-locations", - CommerceOrders = "commerce-orders", - CommercePaymentMethods = "commerce-paymentMethods", - CommercePayments = "commerce-payments", - CommerceProductCategories = "commerce-productCategories", - CommerceProducts = "commerce-products", - CommerceTaxComponents = "commerce-taxComponents", - CommerceTransactions = "commerce-transactions", + AccountTransactions = "accountTransactions", + BalanceSheet = "balanceSheet", + BankAccounts = "bankAccounts", + BankTransactions = "bankTransactions", + BillCreditNotes = "billCreditNotes", + BillPayments = "billPayments", + Bills = "bills", + CashFlowStatement = "cashFlowStatement", + ChartOfAccounts = "chartOfAccounts", + Company = "company", + CreditNotes = "creditNotes", + Customers = "customers", + DirectCosts = "directCosts", + DirectIncomes = "directIncomes", + Invoices = "invoices", + ItemReceipts = "itemReceipts", + Items = "items", + JournalEntries = "journalEntries", + Journals = "journals", + PaymentMethods = "paymentMethods", + Payments = "payments", + ProfitAndLoss = "profitAndLoss", + PurchaseOrders = "purchaseOrders", + SalesOrders = "salesOrders", + Suppliers = "suppliers", + TaxRates = "taxRates", + TrackingCategories = "trackingCategories", + Transfers = "transfers", + BankingAccountBalances = "banking-accountBalances", + BankingAccounts = "banking-accounts", + BankingTransactionCategories = "banking-transactionCategories", + BankingTransactions = "banking-transactions", + CommerceCompanyInfo = "commerce-companyInfo", + CommerceCustomers = "commerce-customers", + CommerceDisputes = "commerce-disputes", + CommerceLocations = "commerce-locations", + CommerceOrders = "commerce-orders", + CommercePaymentMethods = "commerce-paymentMethods", + CommercePayments = "commerce-payments", + CommerceProductCategories = "commerce-productCategories", + CommerceProducts = "commerce-products", + CommerceTaxComponents = "commerce-taxComponents", + CommerceTransactions = "commerce-transactions", } /** @internal */ +export const DataType$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(DataType); + +/** @internal */ +export const DataType$outboundSchema: z.ZodNativeEnum = + DataType$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace DataType$ { - export const inboundSchema = z.nativeEnum(DataType); - export const outboundSchema = inboundSchema; + /** @deprecated use `DataType$inboundSchema` instead. */ + export const inboundSchema = DataType$inboundSchema; + /** @deprecated use `DataType$outboundSchema` instead. */ + export const outboundSchema = DataType$outboundSchema; } diff --git a/accounting/src/sdk/models/shared/errormessage.ts b/accounting/src/sdk/models/shared/errormessage.ts index 9129143b..4e53b0d9 100644 --- a/accounting/src/sdk/models/shared/errormessage.ts +++ b/accounting/src/sdk/models/shared/errormessage.ts @@ -1,98 +1,96 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ErrorValidation, ErrorValidation$ } from "./errorvalidation"; import * as z from "zod"; +import { + ErrorValidation, + ErrorValidation$inboundSchema, + ErrorValidation$Outbound, + ErrorValidation$outboundSchema, +} from "./errorvalidation.js"; export type ErrorMessage = { - /** - * `True` if the error occurred transiently and can be retried. - */ - canBeRetried?: string | undefined; - /** - * Unique identifier used to propagate to all downstream services and determine the source of the error. - */ - correlationId?: string | undefined; - /** - * Machine readable error code used to automate processes based on the code returned. - */ - detailedErrorCode?: number | undefined; - /** - * A brief description of the error. - */ - error?: string | undefined; - /** - * Codat's service the returned the error. - */ - service?: string | undefined; - /** - * The HTTP status code returned by the error. - */ - statusCode?: number | undefined; - /** - * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. - */ - validation?: ErrorValidation | null | undefined; + /** + * `True` if the error occurred transiently and can be retried. + */ + canBeRetried?: string | undefined; + /** + * Unique identifier used to propagate to all downstream services and determine the source of the error. + */ + correlationId?: string | undefined; + /** + * Machine readable error code used to automate processes based on the code returned. + */ + detailedErrorCode?: number | undefined; + /** + * A brief description of the error. + */ + error?: string | undefined; + /** + * Codat's service the returned the error. + */ + service?: string | undefined; + /** + * The HTTP status code returned by the error. + */ + statusCode?: number | undefined; + /** + * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. + */ + validation?: ErrorValidation | null | undefined; }; /** @internal */ -export namespace ErrorMessage$ { - export const inboundSchema: z.ZodType = z - .object({ - canBeRetried: z.string().optional(), - correlationId: z.string().optional(), - detailedErrorCode: z.number().int().optional(), - error: z.string().optional(), - service: z.string().optional(), - statusCode: z.number().int().optional(), - validation: z.nullable(ErrorValidation$.inboundSchema).optional(), - }) - .transform((v) => { - return { - ...(v.canBeRetried === undefined ? null : { canBeRetried: v.canBeRetried }), - ...(v.correlationId === undefined ? null : { correlationId: v.correlationId }), - ...(v.detailedErrorCode === undefined - ? null - : { detailedErrorCode: v.detailedErrorCode }), - ...(v.error === undefined ? null : { error: v.error }), - ...(v.service === undefined ? null : { service: v.service }), - ...(v.statusCode === undefined ? null : { statusCode: v.statusCode }), - ...(v.validation === undefined ? null : { validation: v.validation }), - }; - }); +export const ErrorMessage$inboundSchema: z.ZodType< + ErrorMessage, + z.ZodTypeDef, + unknown +> = z.object({ + canBeRetried: z.string().optional(), + correlationId: z.string().optional(), + detailedErrorCode: z.number().int().optional(), + error: z.string().optional(), + service: z.string().optional(), + statusCode: z.number().int().optional(), + validation: z.nullable(ErrorValidation$inboundSchema).optional(), +}); - export type Outbound = { - canBeRetried?: string | undefined; - correlationId?: string | undefined; - detailedErrorCode?: number | undefined; - error?: string | undefined; - service?: string | undefined; - statusCode?: number | undefined; - validation?: ErrorValidation$.Outbound | null | undefined; - }; +/** @internal */ +export type ErrorMessage$Outbound = { + canBeRetried?: string | undefined; + correlationId?: string | undefined; + detailedErrorCode?: number | undefined; + error?: string | undefined; + service?: string | undefined; + statusCode?: number | undefined; + validation?: ErrorValidation$Outbound | null | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - canBeRetried: z.string().optional(), - correlationId: z.string().optional(), - detailedErrorCode: z.number().int().optional(), - error: z.string().optional(), - service: z.string().optional(), - statusCode: z.number().int().optional(), - validation: z.nullable(ErrorValidation$.outboundSchema).optional(), - }) - .transform((v) => { - return { - ...(v.canBeRetried === undefined ? null : { canBeRetried: v.canBeRetried }), - ...(v.correlationId === undefined ? null : { correlationId: v.correlationId }), - ...(v.detailedErrorCode === undefined - ? null - : { detailedErrorCode: v.detailedErrorCode }), - ...(v.error === undefined ? null : { error: v.error }), - ...(v.service === undefined ? null : { service: v.service }), - ...(v.statusCode === undefined ? null : { statusCode: v.statusCode }), - ...(v.validation === undefined ? null : { validation: v.validation }), - }; - }); +/** @internal */ +export const ErrorMessage$outboundSchema: z.ZodType< + ErrorMessage$Outbound, + z.ZodTypeDef, + ErrorMessage +> = z.object({ + canBeRetried: z.string().optional(), + correlationId: z.string().optional(), + detailedErrorCode: z.number().int().optional(), + error: z.string().optional(), + service: z.string().optional(), + statusCode: z.number().int().optional(), + validation: z.nullable(ErrorValidation$outboundSchema).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ErrorMessage$ { + /** @deprecated use `ErrorMessage$inboundSchema` instead. */ + export const inboundSchema = ErrorMessage$inboundSchema; + /** @deprecated use `ErrorMessage$outboundSchema` instead. */ + export const outboundSchema = ErrorMessage$outboundSchema; + /** @deprecated use `ErrorMessage$Outbound` instead. */ + export type Outbound = ErrorMessage$Outbound; } diff --git a/accounting/src/sdk/models/shared/errorvalidation.ts b/accounting/src/sdk/models/shared/errorvalidation.ts index 9f1a7806..c79e9490 100644 --- a/accounting/src/sdk/models/shared/errorvalidation.ts +++ b/accounting/src/sdk/models/shared/errorvalidation.ts @@ -1,46 +1,58 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ErrorValidationItem, ErrorValidationItem$ } from "./errorvalidationitem"; import * as z from "zod"; +import { + ErrorValidationItem, + ErrorValidationItem$inboundSchema, + ErrorValidationItem$Outbound, + ErrorValidationItem$outboundSchema, +} from "./errorvalidationitem.js"; /** * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. */ export type ErrorValidation = { - errors?: Array | null | undefined; - warnings?: Array | null | undefined; + errors?: Array | null | undefined; + warnings?: Array | null | undefined; }; /** @internal */ -export namespace ErrorValidation$ { - export const inboundSchema: z.ZodType = z - .object({ - errors: z.nullable(z.array(ErrorValidationItem$.inboundSchema)).optional(), - warnings: z.nullable(z.array(ErrorValidationItem$.inboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.errors === undefined ? null : { errors: v.errors }), - ...(v.warnings === undefined ? null : { warnings: v.warnings }), - }; - }); +export const ErrorValidation$inboundSchema: z.ZodType< + ErrorValidation, + z.ZodTypeDef, + unknown +> = z.object({ + errors: z.nullable(z.array(ErrorValidationItem$inboundSchema)).optional(), + warnings: z.nullable(z.array(ErrorValidationItem$inboundSchema)).optional(), +}); + +/** @internal */ +export type ErrorValidation$Outbound = { + errors?: Array | null | undefined; + warnings?: Array | null | undefined; +}; - export type Outbound = { - errors?: Array | null | undefined; - warnings?: Array | null | undefined; - }; +/** @internal */ +export const ErrorValidation$outboundSchema: z.ZodType< + ErrorValidation$Outbound, + z.ZodTypeDef, + ErrorValidation +> = z.object({ + errors: z.nullable(z.array(ErrorValidationItem$outboundSchema)).optional(), + warnings: z.nullable(z.array(ErrorValidationItem$outboundSchema)).optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - errors: z.nullable(z.array(ErrorValidationItem$.outboundSchema)).optional(), - warnings: z.nullable(z.array(ErrorValidationItem$.outboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.errors === undefined ? null : { errors: v.errors }), - ...(v.warnings === undefined ? null : { warnings: v.warnings }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ErrorValidation$ { + /** @deprecated use `ErrorValidation$inboundSchema` instead. */ + export const inboundSchema = ErrorValidation$inboundSchema; + /** @deprecated use `ErrorValidation$outboundSchema` instead. */ + export const outboundSchema = ErrorValidation$outboundSchema; + /** @deprecated use `ErrorValidation$Outbound` instead. */ + export type Outbound = ErrorValidation$Outbound; } diff --git a/accounting/src/sdk/models/shared/errorvalidationitem.ts b/accounting/src/sdk/models/shared/errorvalidationitem.ts index e5eb3946..ec4d7aac 100644 --- a/accounting/src/sdk/models/shared/errorvalidationitem.ts +++ b/accounting/src/sdk/models/shared/errorvalidationitem.ts @@ -1,57 +1,62 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type ErrorValidationItem = { - /** - * Unique identifier for a validation item. - */ - itemId?: string | null | undefined; - /** - * A message outlining validation item's issue. - */ - message?: string | null | undefined; - /** - * Name of validator. - */ - validatorName?: string | null | undefined; + /** + * Unique identifier for a validation item. + */ + itemId?: string | null | undefined; + /** + * A message outlining validation item's issue. + */ + message?: string | null | undefined; + /** + * Name of validator. + */ + validatorName?: string | null | undefined; }; /** @internal */ -export namespace ErrorValidationItem$ { - export const inboundSchema: z.ZodType = z - .object({ - itemId: z.nullable(z.string()).optional(), - message: z.nullable(z.string()).optional(), - validatorName: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.itemId === undefined ? null : { itemId: v.itemId }), - ...(v.message === undefined ? null : { message: v.message }), - ...(v.validatorName === undefined ? null : { validatorName: v.validatorName }), - }; - }); +export const ErrorValidationItem$inboundSchema: z.ZodType< + ErrorValidationItem, + z.ZodTypeDef, + unknown +> = z.object({ + itemId: z.nullable(z.string()).optional(), + message: z.nullable(z.string()).optional(), + validatorName: z.nullable(z.string()).optional(), +}); - export type Outbound = { - itemId?: string | null | undefined; - message?: string | null | undefined; - validatorName?: string | null | undefined; - }; +/** @internal */ +export type ErrorValidationItem$Outbound = { + itemId?: string | null | undefined; + message?: string | null | undefined; + validatorName?: string | null | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - itemId: z.nullable(z.string()).optional(), - message: z.nullable(z.string()).optional(), - validatorName: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.itemId === undefined ? null : { itemId: v.itemId }), - ...(v.message === undefined ? null : { message: v.message }), - ...(v.validatorName === undefined ? null : { validatorName: v.validatorName }), - }; - }); +/** @internal */ +export const ErrorValidationItem$outboundSchema: z.ZodType< + ErrorValidationItem$Outbound, + z.ZodTypeDef, + ErrorValidationItem +> = z.object({ + itemId: z.nullable(z.string()).optional(), + message: z.nullable(z.string()).optional(), + validatorName: z.nullable(z.string()).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ErrorValidationItem$ { + /** @deprecated use `ErrorValidationItem$inboundSchema` instead. */ + export const inboundSchema = ErrorValidationItem$inboundSchema; + /** @deprecated use `ErrorValidationItem$outboundSchema` instead. */ + export const outboundSchema = ErrorValidationItem$outboundSchema; + /** @deprecated use `ErrorValidationItem$Outbound` instead. */ + export type Outbound = ErrorValidationItem$Outbound; } diff --git a/accounting/src/sdk/models/shared/halref.ts b/accounting/src/sdk/models/shared/halref.ts index 1d335538..322dda69 100644 --- a/accounting/src/sdk/models/shared/halref.ts +++ b/accounting/src/sdk/models/shared/halref.ts @@ -1,39 +1,45 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type HalRef = { - /** - * Uri hypertext reference. - */ - href?: string | undefined; + /** + * Uri hypertext reference. + */ + href?: string | undefined; }; /** @internal */ -export namespace HalRef$ { - export const inboundSchema: z.ZodType = z - .object({ - href: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.href === undefined ? null : { href: v.href }), - }; - }); +export const HalRef$inboundSchema: z.ZodType = z + .object({ + href: z.string().optional(), + }); - export type Outbound = { - href?: string | undefined; - }; +/** @internal */ +export type HalRef$Outbound = { + href?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - href: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.href === undefined ? null : { href: v.href }), - }; - }); +/** @internal */ +export const HalRef$outboundSchema: z.ZodType< + HalRef$Outbound, + z.ZodTypeDef, + HalRef +> = z.object({ + href: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace HalRef$ { + /** @deprecated use `HalRef$inboundSchema` instead. */ + export const inboundSchema = HalRef$inboundSchema; + /** @deprecated use `HalRef$outboundSchema` instead. */ + export const outboundSchema = HalRef$outboundSchema; + /** @deprecated use `HalRef$Outbound` instead. */ + export type Outbound = HalRef$Outbound; } diff --git a/accounting/src/sdk/models/shared/index.ts b/accounting/src/sdk/models/shared/index.ts index 9d14a79d..0a0a18f2 100644 --- a/accounting/src/sdk/models/shared/index.ts +++ b/accounting/src/sdk/models/shared/index.ts @@ -1,37 +1,37 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./account"; -export * from "./accountprototype"; -export * from "./accounts"; -export * from "./accountstatus"; -export * from "./accounttransaction"; -export * from "./accounttransactionline"; -export * from "./accounttransactionlinerecordref"; -export * from "./accounttransactions"; -export * from "./accounttype"; -export * from "./bankaccountref"; -export * from "./createaccountresponse"; -export * from "./datatype"; -export * from "./errormessage"; -export * from "./errorvalidation"; -export * from "./errorvalidationitem"; -export * from "./halref"; -export * from "./links"; -export * from "./metadata"; -export * from "./pushchangetype"; -export * from "./pushfieldvalidation"; -export * from "./pushoperationchange"; -export * from "./pushoperationref"; -export * from "./pushoperationstatus"; -export * from "./pushoption"; -export * from "./pushoptionchoice"; -export * from "./pushoptionproperty"; -export * from "./pushoptiontype"; -export * from "./pushvalidationinfo"; -export * from "./security"; -export * from "./supplementaldata"; -export * from "./validation"; -export * from "./validationitem"; -export * from "./validdatatypelinks"; +export * from "./account.js"; +export * from "./accountprototype.js"; +export * from "./accounts.js"; +export * from "./accountstatus.js"; +export * from "./accounttransaction.js"; +export * from "./accounttransactionline.js"; +export * from "./accounttransactionlinerecordref.js"; +export * from "./accounttransactions.js"; +export * from "./accounttype.js"; +export * from "./bankaccountref.js"; +export * from "./createaccountresponse.js"; +export * from "./datatype.js"; +export * from "./errormessage.js"; +export * from "./errorvalidation.js"; +export * from "./errorvalidationitem.js"; +export * from "./halref.js"; +export * from "./links.js"; +export * from "./metadata.js"; +export * from "./pushchangetype.js"; +export * from "./pushfieldvalidation.js"; +export * from "./pushoperationchange.js"; +export * from "./pushoperationref.js"; +export * from "./pushoperationstatus.js"; +export * from "./pushoption.js"; +export * from "./pushoptionchoice.js"; +export * from "./pushoptionproperty.js"; +export * from "./pushoptiontype.js"; +export * from "./pushvalidationinfo.js"; +export * from "./security.js"; +export * from "./supplementaldata.js"; +export * from "./validation.js"; +export * from "./validationitem.js"; +export * from "./validdatatypelinks.js"; diff --git a/accounting/src/sdk/models/shared/links.ts b/accounting/src/sdk/models/shared/links.ts index 48d60e45..b9842f64 100644 --- a/accounting/src/sdk/models/shared/links.ts +++ b/accounting/src/sdk/models/shared/links.ts @@ -1,55 +1,60 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { HalRef, HalRef$ } from "./halref"; import * as z from "zod"; +import { + HalRef, + HalRef$inboundSchema, + HalRef$Outbound, + HalRef$outboundSchema, +} from "./halref.js"; export type Links = { - current: HalRef; - next?: HalRef | undefined; - previous?: HalRef | undefined; - self: HalRef; + current: HalRef; + next?: HalRef | undefined; + previous?: HalRef | undefined; + self: HalRef; }; /** @internal */ -export namespace Links$ { - export const inboundSchema: z.ZodType = z - .object({ - current: HalRef$.inboundSchema, - next: HalRef$.inboundSchema.optional(), - previous: HalRef$.inboundSchema.optional(), - self: HalRef$.inboundSchema, - }) - .transform((v) => { - return { - current: v.current, - ...(v.next === undefined ? null : { next: v.next }), - ...(v.previous === undefined ? null : { previous: v.previous }), - self: v.self, - }; - }); +export const Links$inboundSchema: z.ZodType = z + .object({ + current: HalRef$inboundSchema, + next: HalRef$inboundSchema.optional(), + previous: HalRef$inboundSchema.optional(), + self: HalRef$inboundSchema, + }); - export type Outbound = { - current: HalRef$.Outbound; - next?: HalRef$.Outbound | undefined; - previous?: HalRef$.Outbound | undefined; - self: HalRef$.Outbound; - }; +/** @internal */ +export type Links$Outbound = { + current: HalRef$Outbound; + next?: HalRef$Outbound | undefined; + previous?: HalRef$Outbound | undefined; + self: HalRef$Outbound; +}; - export const outboundSchema: z.ZodType = z - .object({ - current: HalRef$.outboundSchema, - next: HalRef$.outboundSchema.optional(), - previous: HalRef$.outboundSchema.optional(), - self: HalRef$.outboundSchema, - }) - .transform((v) => { - return { - current: v.current, - ...(v.next === undefined ? null : { next: v.next }), - ...(v.previous === undefined ? null : { previous: v.previous }), - self: v.self, - }; - }); +/** @internal */ +export const Links$outboundSchema: z.ZodType< + Links$Outbound, + z.ZodTypeDef, + Links +> = z.object({ + current: HalRef$outboundSchema, + next: HalRef$outboundSchema.optional(), + previous: HalRef$outboundSchema.optional(), + self: HalRef$outboundSchema, +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Links$ { + /** @deprecated use `Links$inboundSchema` instead. */ + export const inboundSchema = Links$inboundSchema; + /** @deprecated use `Links$outboundSchema` instead. */ + export const outboundSchema = Links$outboundSchema; + /** @deprecated use `Links$Outbound` instead. */ + export type Outbound = Links$Outbound; } diff --git a/accounting/src/sdk/models/shared/metadata.ts b/accounting/src/sdk/models/shared/metadata.ts index a6fea43b..ceed8f31 100644 --- a/accounting/src/sdk/models/shared/metadata.ts +++ b/accounting/src/sdk/models/shared/metadata.ts @@ -1,39 +1,48 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type Metadata = { - /** - * Indicates whether the record has been deleted in the third-party system this record originated from. - */ - isDeleted?: boolean | null | undefined; + /** + * Indicates whether the record has been deleted in the third-party system this record originated from. + */ + isDeleted?: boolean | null | undefined; }; /** @internal */ -export namespace Metadata$ { - export const inboundSchema: z.ZodType = z - .object({ - isDeleted: z.nullable(z.boolean()).optional(), - }) - .transform((v) => { - return { - ...(v.isDeleted === undefined ? null : { isDeleted: v.isDeleted }), - }; - }); +export const Metadata$inboundSchema: z.ZodType< + Metadata, + z.ZodTypeDef, + unknown +> = z.object({ + isDeleted: z.nullable(z.boolean()).optional(), +}); - export type Outbound = { - isDeleted?: boolean | null | undefined; - }; +/** @internal */ +export type Metadata$Outbound = { + isDeleted?: boolean | null | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - isDeleted: z.nullable(z.boolean()).optional(), - }) - .transform((v) => { - return { - ...(v.isDeleted === undefined ? null : { isDeleted: v.isDeleted }), - }; - }); +/** @internal */ +export const Metadata$outboundSchema: z.ZodType< + Metadata$Outbound, + z.ZodTypeDef, + Metadata +> = z.object({ + isDeleted: z.nullable(z.boolean()).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Metadata$ { + /** @deprecated use `Metadata$inboundSchema` instead. */ + export const inboundSchema = Metadata$inboundSchema; + /** @deprecated use `Metadata$outboundSchema` instead. */ + export const outboundSchema = Metadata$outboundSchema; + /** @deprecated use `Metadata$Outbound` instead. */ + export type Outbound = Metadata$Outbound; } diff --git a/accounting/src/sdk/models/shared/pushchangetype.ts b/accounting/src/sdk/models/shared/pushchangetype.ts index e3526f23..d8250ae0 100644 --- a/accounting/src/sdk/models/shared/pushchangetype.ts +++ b/accounting/src/sdk/models/shared/pushchangetype.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,15 +8,30 @@ import * as z from "zod"; * Type of change being applied to record in third party platform. */ export enum PushChangeType { - Unknown = "Unknown", - Created = "Created", - Modified = "Modified", - Deleted = "Deleted", - AttachmentUploaded = "AttachmentUploaded", + Unknown = "Unknown", + Created = "Created", + Modified = "Modified", + Deleted = "Deleted", + AttachmentUploaded = "AttachmentUploaded", } /** @internal */ +export const PushChangeType$inboundSchema: z.ZodNativeEnum< + typeof PushChangeType +> = z.nativeEnum(PushChangeType); + +/** @internal */ +export const PushChangeType$outboundSchema: z.ZodNativeEnum< + typeof PushChangeType +> = PushChangeType$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace PushChangeType$ { - export const inboundSchema = z.nativeEnum(PushChangeType); - export const outboundSchema = inboundSchema; + /** @deprecated use `PushChangeType$inboundSchema` instead. */ + export const inboundSchema = PushChangeType$inboundSchema; + /** @deprecated use `PushChangeType$outboundSchema` instead. */ + export const outboundSchema = PushChangeType$outboundSchema; } diff --git a/accounting/src/sdk/models/shared/pushfieldvalidation.ts b/accounting/src/sdk/models/shared/pushfieldvalidation.ts index 446c581d..90c48138 100644 --- a/accounting/src/sdk/models/shared/pushfieldvalidation.ts +++ b/accounting/src/sdk/models/shared/pushfieldvalidation.ts @@ -1,57 +1,62 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type PushFieldValidation = { - /** - * Details on the validation issue. - */ - details: string; - /** - * Field name that resulted in the validation issue. - */ - field?: string | undefined; - /** - * Unique reference identifier for the validation issue. - */ - ref?: string | null | undefined; + /** + * Details on the validation issue. + */ + details: string; + /** + * Field name that resulted in the validation issue. + */ + field?: string | undefined; + /** + * Unique reference identifier for the validation issue. + */ + ref?: string | null | undefined; }; /** @internal */ -export namespace PushFieldValidation$ { - export const inboundSchema: z.ZodType = z - .object({ - details: z.string(), - field: z.string().optional(), - ref: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - details: v.details, - ...(v.field === undefined ? null : { field: v.field }), - ...(v.ref === undefined ? null : { ref: v.ref }), - }; - }); +export const PushFieldValidation$inboundSchema: z.ZodType< + PushFieldValidation, + z.ZodTypeDef, + unknown +> = z.object({ + details: z.string(), + field: z.string().optional(), + ref: z.nullable(z.string()).optional(), +}); - export type Outbound = { - details: string; - field?: string | undefined; - ref?: string | null | undefined; - }; +/** @internal */ +export type PushFieldValidation$Outbound = { + details: string; + field?: string | undefined; + ref?: string | null | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - details: z.string(), - field: z.string().optional(), - ref: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - details: v.details, - ...(v.field === undefined ? null : { field: v.field }), - ...(v.ref === undefined ? null : { ref: v.ref }), - }; - }); +/** @internal */ +export const PushFieldValidation$outboundSchema: z.ZodType< + PushFieldValidation$Outbound, + z.ZodTypeDef, + PushFieldValidation +> = z.object({ + details: z.string(), + field: z.string().optional(), + ref: z.nullable(z.string()).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PushFieldValidation$ { + /** @deprecated use `PushFieldValidation$inboundSchema` instead. */ + export const inboundSchema = PushFieldValidation$inboundSchema; + /** @deprecated use `PushFieldValidation$outboundSchema` instead. */ + export const outboundSchema = PushFieldValidation$outboundSchema; + /** @deprecated use `PushFieldValidation$Outbound` instead. */ + export type Outbound = PushFieldValidation$Outbound; } diff --git a/accounting/src/sdk/models/shared/pushoperationchange.ts b/accounting/src/sdk/models/shared/pushoperationchange.ts index d536a2ee..e91e727c 100644 --- a/accounting/src/sdk/models/shared/pushoperationchange.ts +++ b/accounting/src/sdk/models/shared/pushoperationchange.ts @@ -1,56 +1,70 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { PushChangeType, PushChangeType$ } from "./pushchangetype"; -import { PushOperationRef, PushOperationRef$ } from "./pushoperationref"; import * as z from "zod"; +import { + PushChangeType, + PushChangeType$inboundSchema, + PushChangeType$outboundSchema, +} from "./pushchangetype.js"; +import { + PushOperationRef, + PushOperationRef$inboundSchema, + PushOperationRef$Outbound, + PushOperationRef$outboundSchema, +} from "./pushoperationref.js"; export type PushOperationChange = { - /** - * Unique identifier for the attachment created otherwise null. - */ - attachmentId?: string | null | undefined; - recordRef?: PushOperationRef | undefined; - /** - * Type of change being applied to record in third party platform. - */ - type?: PushChangeType | undefined; + /** + * Unique identifier for the attachment created otherwise null. + */ + attachmentId?: string | null | undefined; + recordRef?: PushOperationRef | undefined; + /** + * Type of change being applied to record in third party platform. + */ + type?: PushChangeType | undefined; }; /** @internal */ -export namespace PushOperationChange$ { - export const inboundSchema: z.ZodType = z - .object({ - attachmentId: z.nullable(z.string()).optional(), - recordRef: PushOperationRef$.inboundSchema.optional(), - type: PushChangeType$.inboundSchema.optional(), - }) - .transform((v) => { - return { - ...(v.attachmentId === undefined ? null : { attachmentId: v.attachmentId }), - ...(v.recordRef === undefined ? null : { recordRef: v.recordRef }), - ...(v.type === undefined ? null : { type: v.type }), - }; - }); +export const PushOperationChange$inboundSchema: z.ZodType< + PushOperationChange, + z.ZodTypeDef, + unknown +> = z.object({ + attachmentId: z.nullable(z.string()).optional(), + recordRef: PushOperationRef$inboundSchema.optional(), + type: PushChangeType$inboundSchema.optional(), +}); - export type Outbound = { - attachmentId?: string | null | undefined; - recordRef?: PushOperationRef$.Outbound | undefined; - type?: string | undefined; - }; +/** @internal */ +export type PushOperationChange$Outbound = { + attachmentId?: string | null | undefined; + recordRef?: PushOperationRef$Outbound | undefined; + type?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - attachmentId: z.nullable(z.string()).optional(), - recordRef: PushOperationRef$.outboundSchema.optional(), - type: PushChangeType$.outboundSchema.optional(), - }) - .transform((v) => { - return { - ...(v.attachmentId === undefined ? null : { attachmentId: v.attachmentId }), - ...(v.recordRef === undefined ? null : { recordRef: v.recordRef }), - ...(v.type === undefined ? null : { type: v.type }), - }; - }); +/** @internal */ +export const PushOperationChange$outboundSchema: z.ZodType< + PushOperationChange$Outbound, + z.ZodTypeDef, + PushOperationChange +> = z.object({ + attachmentId: z.nullable(z.string()).optional(), + recordRef: PushOperationRef$outboundSchema.optional(), + type: PushChangeType$outboundSchema.optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PushOperationChange$ { + /** @deprecated use `PushOperationChange$inboundSchema` instead. */ + export const inboundSchema = PushOperationChange$inboundSchema; + /** @deprecated use `PushOperationChange$outboundSchema` instead. */ + export const outboundSchema = PushOperationChange$outboundSchema; + /** @deprecated use `PushOperationChange$Outbound` instead. */ + export type Outbound = PushOperationChange$Outbound; } diff --git a/accounting/src/sdk/models/shared/pushoperationref.ts b/accounting/src/sdk/models/shared/pushoperationref.ts index 12aba9b9..b4803fa9 100644 --- a/accounting/src/sdk/models/shared/pushoperationref.ts +++ b/accounting/src/sdk/models/shared/pushoperationref.ts @@ -1,49 +1,60 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { DataType, DataType$ } from "./datatype"; import * as z from "zod"; +import { + DataType, + DataType$inboundSchema, + DataType$outboundSchema, +} from "./datatype.js"; export type PushOperationRef = { - /** - * Available data types - */ - dataType?: DataType | undefined; - /** - * Unique identifier for a push operation. - */ - id?: string | undefined; + /** + * Available data types + */ + dataType?: DataType | undefined; + /** + * Unique identifier for a push operation. + */ + id?: string | undefined; }; /** @internal */ -export namespace PushOperationRef$ { - export const inboundSchema: z.ZodType = z - .object({ - dataType: DataType$.inboundSchema.optional(), - id: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.dataType === undefined ? null : { dataType: v.dataType }), - ...(v.id === undefined ? null : { id: v.id }), - }; - }); +export const PushOperationRef$inboundSchema: z.ZodType< + PushOperationRef, + z.ZodTypeDef, + unknown +> = z.object({ + dataType: DataType$inboundSchema.optional(), + id: z.string().optional(), +}); - export type Outbound = { - dataType?: string | undefined; - id?: string | undefined; - }; +/** @internal */ +export type PushOperationRef$Outbound = { + dataType?: string | undefined; + id?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - dataType: DataType$.outboundSchema.optional(), - id: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.dataType === undefined ? null : { dataType: v.dataType }), - ...(v.id === undefined ? null : { id: v.id }), - }; - }); +/** @internal */ +export const PushOperationRef$outboundSchema: z.ZodType< + PushOperationRef$Outbound, + z.ZodTypeDef, + PushOperationRef +> = z.object({ + dataType: DataType$outboundSchema.optional(), + id: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PushOperationRef$ { + /** @deprecated use `PushOperationRef$inboundSchema` instead. */ + export const inboundSchema = PushOperationRef$inboundSchema; + /** @deprecated use `PushOperationRef$outboundSchema` instead. */ + export const outboundSchema = PushOperationRef$outboundSchema; + /** @deprecated use `PushOperationRef$Outbound` instead. */ + export type Outbound = PushOperationRef$Outbound; } diff --git a/accounting/src/sdk/models/shared/pushoperationstatus.ts b/accounting/src/sdk/models/shared/pushoperationstatus.ts index 5e1527d7..5898e1f9 100644 --- a/accounting/src/sdk/models/shared/pushoperationstatus.ts +++ b/accounting/src/sdk/models/shared/pushoperationstatus.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,14 +8,29 @@ import * as z from "zod"; * The current status of the push operation. */ export enum PushOperationStatus { - Pending = "Pending", - Failed = "Failed", - Success = "Success", - TimedOut = "TimedOut", + Pending = "Pending", + Failed = "Failed", + Success = "Success", + TimedOut = "TimedOut", } /** @internal */ +export const PushOperationStatus$inboundSchema: z.ZodNativeEnum< + typeof PushOperationStatus +> = z.nativeEnum(PushOperationStatus); + +/** @internal */ +export const PushOperationStatus$outboundSchema: z.ZodNativeEnum< + typeof PushOperationStatus +> = PushOperationStatus$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace PushOperationStatus$ { - export const inboundSchema = z.nativeEnum(PushOperationStatus); - export const outboundSchema = inboundSchema; + /** @deprecated use `PushOperationStatus$inboundSchema` instead. */ + export const inboundSchema = PushOperationStatus$inboundSchema; + /** @deprecated use `PushOperationStatus$outboundSchema` instead. */ + export const outboundSchema = PushOperationStatus$outboundSchema; } diff --git a/accounting/src/sdk/models/shared/pushoption.ts b/accounting/src/sdk/models/shared/pushoption.ts index 4f35adbe..1e87bae5 100644 --- a/accounting/src/sdk/models/shared/pushoption.ts +++ b/accounting/src/sdk/models/shared/pushoption.ts @@ -1,88 +1,105 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { PushOptionChoice, PushOptionChoice$ } from "./pushoptionchoice"; -import { PushOptionProperty, PushOptionProperty$ } from "./pushoptionproperty"; -import { PushOptionType, PushOptionType$ } from "./pushoptiontype"; -import { PushValidationInfo, PushValidationInfo$ } from "./pushvalidationinfo"; import * as z from "zod"; +import { + PushOptionChoice, + PushOptionChoice$inboundSchema, + PushOptionChoice$Outbound, + PushOptionChoice$outboundSchema, +} from "./pushoptionchoice.js"; +import { + PushOptionProperty, + PushOptionProperty$inboundSchema, + PushOptionProperty$Outbound, + PushOptionProperty$outboundSchema, +} from "./pushoptionproperty.js"; +import { + PushOptionType, + PushOptionType$inboundSchema, + PushOptionType$outboundSchema, +} from "./pushoptiontype.js"; +import { + PushValidationInfo, + PushValidationInfo$inboundSchema, + PushValidationInfo$Outbound, + PushValidationInfo$outboundSchema, +} from "./pushvalidationinfo.js"; export type PushOption = { - /** - * A description of the property. - */ - description?: string | undefined; - /** - * The property's display name. - */ - displayName: string; - options?: Array | null | undefined; - properties?: { [k: string]: PushOptionProperty } | null | undefined; - /** - * The property is required if `True`. - */ - required: boolean; - /** - * The option type. - */ - type: PushOptionType; - validation?: PushValidationInfo | undefined; + /** + * A description of the property. + */ + description?: string | undefined; + /** + * The property's display name. + */ + displayName: string; + options?: Array | null | undefined; + properties?: { [k: string]: PushOptionProperty } | null | undefined; + /** + * The property is required if `True`. + */ + required: boolean; + /** + * The option type. + */ + type: PushOptionType; + validation?: PushValidationInfo | undefined; }; /** @internal */ -export namespace PushOption$ { - export const inboundSchema: z.ZodType = z - .object({ - description: z.string().optional(), - displayName: z.string(), - options: z.nullable(z.array(PushOptionChoice$.inboundSchema)).optional(), - properties: z.nullable(z.record(PushOptionProperty$.inboundSchema)).optional(), - required: z.boolean(), - type: PushOptionType$.inboundSchema, - validation: PushValidationInfo$.inboundSchema.optional(), - }) - .transform((v) => { - return { - ...(v.description === undefined ? null : { description: v.description }), - displayName: v.displayName, - ...(v.options === undefined ? null : { options: v.options }), - ...(v.properties === undefined ? null : { properties: v.properties }), - required: v.required, - type: v.type, - ...(v.validation === undefined ? null : { validation: v.validation }), - }; - }); +export const PushOption$inboundSchema: z.ZodType< + PushOption, + z.ZodTypeDef, + unknown +> = z.object({ + description: z.string().optional(), + displayName: z.string(), + options: z.nullable(z.array(PushOptionChoice$inboundSchema)).optional(), + properties: z.nullable(z.record(PushOptionProperty$inboundSchema)).optional(), + required: z.boolean(), + type: PushOptionType$inboundSchema, + validation: PushValidationInfo$inboundSchema.optional(), +}); - export type Outbound = { - description?: string | undefined; - displayName: string; - options?: Array | null | undefined; - properties?: { [k: string]: PushOptionProperty$.Outbound } | null | undefined; - required: boolean; - type: string; - validation?: PushValidationInfo$.Outbound | undefined; - }; +/** @internal */ +export type PushOption$Outbound = { + description?: string | undefined; + displayName: string; + options?: Array | null | undefined; + properties?: { [k: string]: PushOptionProperty$Outbound } | null | undefined; + required: boolean; + type: string; + validation?: PushValidationInfo$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - description: z.string().optional(), - displayName: z.string(), - options: z.nullable(z.array(PushOptionChoice$.outboundSchema)).optional(), - properties: z.nullable(z.record(PushOptionProperty$.outboundSchema)).optional(), - required: z.boolean(), - type: PushOptionType$.outboundSchema, - validation: PushValidationInfo$.outboundSchema.optional(), - }) - .transform((v) => { - return { - ...(v.description === undefined ? null : { description: v.description }), - displayName: v.displayName, - ...(v.options === undefined ? null : { options: v.options }), - ...(v.properties === undefined ? null : { properties: v.properties }), - required: v.required, - type: v.type, - ...(v.validation === undefined ? null : { validation: v.validation }), - }; - }); +/** @internal */ +export const PushOption$outboundSchema: z.ZodType< + PushOption$Outbound, + z.ZodTypeDef, + PushOption +> = z.object({ + description: z.string().optional(), + displayName: z.string(), + options: z.nullable(z.array(PushOptionChoice$outboundSchema)).optional(), + properties: z.nullable(z.record(PushOptionProperty$outboundSchema)) + .optional(), + required: z.boolean(), + type: PushOptionType$outboundSchema, + validation: PushValidationInfo$outboundSchema.optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PushOption$ { + /** @deprecated use `PushOption$inboundSchema` instead. */ + export const inboundSchema = PushOption$inboundSchema; + /** @deprecated use `PushOption$outboundSchema` instead. */ + export const outboundSchema = PushOption$outboundSchema; + /** @deprecated use `PushOption$Outbound` instead. */ + export type Outbound = PushOption$Outbound; } diff --git a/accounting/src/sdk/models/shared/pushoptionchoice.ts b/accounting/src/sdk/models/shared/pushoptionchoice.ts index 4b98c23d..a97cb11b 100644 --- a/accounting/src/sdk/models/shared/pushoptionchoice.ts +++ b/accounting/src/sdk/models/shared/pushoptionchoice.ts @@ -1,76 +1,81 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { PushOptionType, PushOptionType$ } from "./pushoptiontype"; import * as z from "zod"; +import { + PushOptionType, + PushOptionType$inboundSchema, + PushOptionType$outboundSchema, +} from "./pushoptiontype.js"; export type PushOptionChoice = { - /** - * A description of the property. - */ - description?: string | undefined; - /** - * The property's display name. - */ - displayName?: string | undefined; - /** - * The property is required if `True`. - */ - required?: boolean | undefined; - /** - * The option type. - */ - type?: PushOptionType | undefined; - /** - * Allowed value for field. - */ - value?: string | undefined; + /** + * A description of the property. + */ + description?: string | undefined; + /** + * The property's display name. + */ + displayName?: string | undefined; + /** + * The property is required if `True`. + */ + required?: boolean | undefined; + /** + * The option type. + */ + type?: PushOptionType | undefined; + /** + * Allowed value for field. + */ + value?: string | undefined; }; /** @internal */ -export namespace PushOptionChoice$ { - export const inboundSchema: z.ZodType = z - .object({ - description: z.string().optional(), - displayName: z.string().optional(), - required: z.boolean().optional(), - type: PushOptionType$.inboundSchema.optional(), - value: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.description === undefined ? null : { description: v.description }), - ...(v.displayName === undefined ? null : { displayName: v.displayName }), - ...(v.required === undefined ? null : { required: v.required }), - ...(v.type === undefined ? null : { type: v.type }), - ...(v.value === undefined ? null : { value: v.value }), - }; - }); +export const PushOptionChoice$inboundSchema: z.ZodType< + PushOptionChoice, + z.ZodTypeDef, + unknown +> = z.object({ + description: z.string().optional(), + displayName: z.string().optional(), + required: z.boolean().optional(), + type: PushOptionType$inboundSchema.optional(), + value: z.string().optional(), +}); - export type Outbound = { - description?: string | undefined; - displayName?: string | undefined; - required?: boolean | undefined; - type?: string | undefined; - value?: string | undefined; - }; +/** @internal */ +export type PushOptionChoice$Outbound = { + description?: string | undefined; + displayName?: string | undefined; + required?: boolean | undefined; + type?: string | undefined; + value?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - description: z.string().optional(), - displayName: z.string().optional(), - required: z.boolean().optional(), - type: PushOptionType$.outboundSchema.optional(), - value: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.description === undefined ? null : { description: v.description }), - ...(v.displayName === undefined ? null : { displayName: v.displayName }), - ...(v.required === undefined ? null : { required: v.required }), - ...(v.type === undefined ? null : { type: v.type }), - ...(v.value === undefined ? null : { value: v.value }), - }; - }); +/** @internal */ +export const PushOptionChoice$outboundSchema: z.ZodType< + PushOptionChoice$Outbound, + z.ZodTypeDef, + PushOptionChoice +> = z.object({ + description: z.string().optional(), + displayName: z.string().optional(), + required: z.boolean().optional(), + type: PushOptionType$outboundSchema.optional(), + value: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PushOptionChoice$ { + /** @deprecated use `PushOptionChoice$inboundSchema` instead. */ + export const inboundSchema = PushOptionChoice$inboundSchema; + /** @deprecated use `PushOptionChoice$outboundSchema` instead. */ + export const outboundSchema = PushOptionChoice$outboundSchema; + /** @deprecated use `PushOptionChoice$Outbound` instead. */ + export type Outbound = PushOptionChoice$Outbound; } diff --git a/accounting/src/sdk/models/shared/pushoptionproperty.ts b/accounting/src/sdk/models/shared/pushoptionproperty.ts index 3c7accbd..371fc10e 100644 --- a/accounting/src/sdk/models/shared/pushoptionproperty.ts +++ b/accounting/src/sdk/models/shared/pushoptionproperty.ts @@ -1,91 +1,102 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { PushOptionChoice, PushOptionChoice$ } from "./pushoptionchoice"; -import { PushOptionType, PushOptionType$ } from "./pushoptiontype"; -import { PushValidationInfo, PushValidationInfo$ } from "./pushvalidationinfo"; import * as z from "zod"; +import { + PushOptionChoice, + PushOptionChoice$inboundSchema, + PushOptionChoice$Outbound, + PushOptionChoice$outboundSchema, +} from "./pushoptionchoice.js"; +import { + PushOptionType, + PushOptionType$inboundSchema, + PushOptionType$outboundSchema, +} from "./pushoptiontype.js"; +import { + PushValidationInfo, + PushValidationInfo$inboundSchema, + PushValidationInfo$Outbound, + PushValidationInfo$outboundSchema, +} from "./pushvalidationinfo.js"; export type PushOptionProperty = { - /** - * A description of the property. - */ - description: string; - /** - * The property's display name. - */ - displayName: string; - options?: Array | null | undefined; - properties?: { [k: string]: PushOptionProperty } | null | undefined; - /** - * The property is required if `True`. - */ - required: boolean; - /** - * The option type. - */ - type: PushOptionType; - validation?: PushValidationInfo | undefined; + /** + * A description of the property. + */ + description: string; + /** + * The property's display name. + */ + displayName: string; + options?: Array | null | undefined; + properties?: { [k: string]: PushOptionProperty } | null | undefined; + /** + * The property is required if `True`. + */ + required: boolean; + /** + * The option type. + */ + type: PushOptionType; + validation?: PushValidationInfo | undefined; }; /** @internal */ -export namespace PushOptionProperty$ { - export const inboundSchema: z.ZodType = z - .object({ - description: z.string(), - displayName: z.string(), - options: z.nullable(z.array(PushOptionChoice$.inboundSchema)).optional(), - properties: z - .nullable(z.record(z.lazy(() => PushOptionProperty$.inboundSchema))) - .optional(), - required: z.boolean(), - type: PushOptionType$.inboundSchema, - validation: PushValidationInfo$.inboundSchema.optional(), - }) - .transform((v) => { - return { - description: v.description, - displayName: v.displayName, - ...(v.options === undefined ? null : { options: v.options }), - ...(v.properties === undefined ? null : { properties: v.properties }), - required: v.required, - type: v.type, - ...(v.validation === undefined ? null : { validation: v.validation }), - }; - }); +export const PushOptionProperty$inboundSchema: z.ZodType< + PushOptionProperty, + z.ZodTypeDef, + unknown +> = z.object({ + description: z.string(), + displayName: z.string(), + options: z.nullable(z.array(PushOptionChoice$inboundSchema)).optional(), + properties: z.nullable( + z.record(z.lazy(() => PushOptionProperty$inboundSchema)), + ).optional(), + required: z.boolean(), + type: PushOptionType$inboundSchema, + validation: PushValidationInfo$inboundSchema.optional(), +}); - export type Outbound = { - description: string; - displayName: string; - options?: Array | null | undefined; - properties?: { [k: string]: PushOptionProperty$.Outbound } | null | undefined; - required: boolean; - type: string; - validation?: PushValidationInfo$.Outbound | undefined; - }; +/** @internal */ +export type PushOptionProperty$Outbound = { + description: string; + displayName: string; + options?: Array | null | undefined; + properties?: { [k: string]: PushOptionProperty$Outbound } | null | undefined; + required: boolean; + type: string; + validation?: PushValidationInfo$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - description: z.string(), - displayName: z.string(), - options: z.nullable(z.array(PushOptionChoice$.outboundSchema)).optional(), - properties: z - .nullable(z.record(z.lazy(() => PushOptionProperty$.outboundSchema))) - .optional(), - required: z.boolean(), - type: PushOptionType$.outboundSchema, - validation: PushValidationInfo$.outboundSchema.optional(), - }) - .transform((v) => { - return { - description: v.description, - displayName: v.displayName, - ...(v.options === undefined ? null : { options: v.options }), - ...(v.properties === undefined ? null : { properties: v.properties }), - required: v.required, - type: v.type, - ...(v.validation === undefined ? null : { validation: v.validation }), - }; - }); +/** @internal */ +export const PushOptionProperty$outboundSchema: z.ZodType< + PushOptionProperty$Outbound, + z.ZodTypeDef, + PushOptionProperty +> = z.object({ + description: z.string(), + displayName: z.string(), + options: z.nullable(z.array(PushOptionChoice$outboundSchema)).optional(), + properties: z.nullable( + z.record(z.lazy(() => PushOptionProperty$outboundSchema)), + ).optional(), + required: z.boolean(), + type: PushOptionType$outboundSchema, + validation: PushValidationInfo$outboundSchema.optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PushOptionProperty$ { + /** @deprecated use `PushOptionProperty$inboundSchema` instead. */ + export const inboundSchema = PushOptionProperty$inboundSchema; + /** @deprecated use `PushOptionProperty$outboundSchema` instead. */ + export const outboundSchema = PushOptionProperty$outboundSchema; + /** @deprecated use `PushOptionProperty$Outbound` instead. */ + export type Outbound = PushOptionProperty$Outbound; } diff --git a/accounting/src/sdk/models/shared/pushoptiontype.ts b/accounting/src/sdk/models/shared/pushoptiontype.ts index 78e40c22..0ec7083e 100644 --- a/accounting/src/sdk/models/shared/pushoptiontype.ts +++ b/accounting/src/sdk/models/shared/pushoptiontype.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,18 +8,33 @@ import * as z from "zod"; * The option type. */ export enum PushOptionType { - Array = "Array", - Object = "Object", - String = "String", - Number = "Number", - Boolean = "Boolean", - DateTime = "DateTime", - File = "File", - MultiPart = "MultiPart", + Array = "Array", + Object = "Object", + String = "String", + Number = "Number", + Boolean = "Boolean", + DateTime = "DateTime", + File = "File", + MultiPart = "MultiPart", } /** @internal */ +export const PushOptionType$inboundSchema: z.ZodNativeEnum< + typeof PushOptionType +> = z.nativeEnum(PushOptionType); + +/** @internal */ +export const PushOptionType$outboundSchema: z.ZodNativeEnum< + typeof PushOptionType +> = PushOptionType$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace PushOptionType$ { - export const inboundSchema = z.nativeEnum(PushOptionType); - export const outboundSchema = inboundSchema; + /** @deprecated use `PushOptionType$inboundSchema` instead. */ + export const inboundSchema = PushOptionType$inboundSchema; + /** @deprecated use `PushOptionType$outboundSchema` instead. */ + export const outboundSchema = PushOptionType$outboundSchema; } diff --git a/accounting/src/sdk/models/shared/pushvalidationinfo.ts b/accounting/src/sdk/models/shared/pushvalidationinfo.ts index 482990ce..359842c4 100644 --- a/accounting/src/sdk/models/shared/pushvalidationinfo.ts +++ b/accounting/src/sdk/models/shared/pushvalidationinfo.ts @@ -1,43 +1,57 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { PushFieldValidation, PushFieldValidation$ } from "./pushfieldvalidation"; import * as z from "zod"; +import { + PushFieldValidation, + PushFieldValidation$inboundSchema, + PushFieldValidation$Outbound, + PushFieldValidation$outboundSchema, +} from "./pushfieldvalidation.js"; export type PushValidationInfo = { - information?: Array | null | undefined; - warnings?: Array | null | undefined; + information?: Array | null | undefined; + warnings?: Array | null | undefined; }; /** @internal */ -export namespace PushValidationInfo$ { - export const inboundSchema: z.ZodType = z - .object({ - information: z.nullable(z.array(PushFieldValidation$.inboundSchema)).optional(), - warnings: z.nullable(z.array(PushFieldValidation$.inboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.information === undefined ? null : { information: v.information }), - ...(v.warnings === undefined ? null : { warnings: v.warnings }), - }; - }); +export const PushValidationInfo$inboundSchema: z.ZodType< + PushValidationInfo, + z.ZodTypeDef, + unknown +> = z.object({ + information: z.nullable(z.array(PushFieldValidation$inboundSchema)) + .optional(), + warnings: z.nullable(z.array(PushFieldValidation$inboundSchema)).optional(), +}); - export type Outbound = { - information?: Array | null | undefined; - warnings?: Array | null | undefined; - }; +/** @internal */ +export type PushValidationInfo$Outbound = { + information?: Array | null | undefined; + warnings?: Array | null | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - information: z.nullable(z.array(PushFieldValidation$.outboundSchema)).optional(), - warnings: z.nullable(z.array(PushFieldValidation$.outboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.information === undefined ? null : { information: v.information }), - ...(v.warnings === undefined ? null : { warnings: v.warnings }), - }; - }); +/** @internal */ +export const PushValidationInfo$outboundSchema: z.ZodType< + PushValidationInfo$Outbound, + z.ZodTypeDef, + PushValidationInfo +> = z.object({ + information: z.nullable(z.array(PushFieldValidation$outboundSchema)) + .optional(), + warnings: z.nullable(z.array(PushFieldValidation$outboundSchema)).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PushValidationInfo$ { + /** @deprecated use `PushValidationInfo$inboundSchema` instead. */ + export const inboundSchema = PushValidationInfo$inboundSchema; + /** @deprecated use `PushValidationInfo$outboundSchema` instead. */ + export const outboundSchema = PushValidationInfo$outboundSchema; + /** @deprecated use `PushValidationInfo$Outbound` instead. */ + export type Outbound = PushValidationInfo$Outbound; } diff --git a/accounting/src/sdk/models/shared/security.ts b/accounting/src/sdk/models/shared/security.ts index 73e24f7d..53558d2e 100644 --- a/accounting/src/sdk/models/shared/security.ts +++ b/accounting/src/sdk/models/shared/security.ts @@ -1,36 +1,54 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; export type Security = { - authHeader: string; + authHeader: string; }; /** @internal */ -export namespace Security$ { - export const inboundSchema: z.ZodType = z - .object({ - auth_header: z.string(), - }) - .transform((v) => { - return { - authHeader: v.auth_header, - }; - }); +export const Security$inboundSchema: z.ZodType< + Security, + z.ZodTypeDef, + unknown +> = z.object({ + auth_header: z.string(), +}).transform((v) => { + return remap$(v, { + "auth_header": "authHeader", + }); +}); - export type Outbound = { - auth_header: string; - }; +/** @internal */ +export type Security$Outbound = { + auth_header: string; +}; - export const outboundSchema: z.ZodType = z - .object({ - authHeader: z.string(), - }) - .transform((v) => { - return { - auth_header: v.authHeader, - }; - }); +/** @internal */ +export const Security$outboundSchema: z.ZodType< + Security$Outbound, + z.ZodTypeDef, + Security +> = z.object({ + authHeader: z.string(), +}).transform((v) => { + return remap$(v, { + authHeader: "auth_header", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Security$ { + /** @deprecated use `Security$inboundSchema` instead. */ + export const inboundSchema = Security$inboundSchema; + /** @deprecated use `Security$outboundSchema` instead. */ + export const outboundSchema = Security$outboundSchema; + /** @deprecated use `Security$Outbound` instead. */ + export type Outbound = Security$Outbound; } diff --git a/accounting/src/sdk/models/shared/supplementaldata.ts b/accounting/src/sdk/models/shared/supplementaldata.ts index 45c27300..5b181ca6 100644 --- a/accounting/src/sdk/models/shared/supplementaldata.ts +++ b/accounting/src/sdk/models/shared/supplementaldata.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -12,32 +12,41 @@ import * as z from "zod"; * It is referenced as a configured dynamic key value pair that is unique to the accounting platform. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. */ export type SupplementalData = { - content?: { [k: string]: { [k: string]: any } } | null | undefined; + content?: { [k: string]: { [k: string]: any } } | null | undefined; }; /** @internal */ -export namespace SupplementalData$ { - export const inboundSchema: z.ZodType = z - .object({ - content: z.nullable(z.record(z.record(z.any()))).optional(), - }) - .transform((v) => { - return { - ...(v.content === undefined ? null : { content: v.content }), - }; - }); +export const SupplementalData$inboundSchema: z.ZodType< + SupplementalData, + z.ZodTypeDef, + unknown +> = z.object({ + content: z.nullable(z.record(z.record(z.any()))).optional(), +}); + +/** @internal */ +export type SupplementalData$Outbound = { + content?: { [k: string]: { [k: string]: any } } | null | undefined; +}; - export type Outbound = { - content?: { [k: string]: { [k: string]: any } } | null | undefined; - }; +/** @internal */ +export const SupplementalData$outboundSchema: z.ZodType< + SupplementalData$Outbound, + z.ZodTypeDef, + SupplementalData +> = z.object({ + content: z.nullable(z.record(z.record(z.any()))).optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - content: z.nullable(z.record(z.record(z.any()))).optional(), - }) - .transform((v) => { - return { - ...(v.content === undefined ? null : { content: v.content }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace SupplementalData$ { + /** @deprecated use `SupplementalData$inboundSchema` instead. */ + export const inboundSchema = SupplementalData$inboundSchema; + /** @deprecated use `SupplementalData$outboundSchema` instead. */ + export const outboundSchema = SupplementalData$outboundSchema; + /** @deprecated use `SupplementalData$Outbound` instead. */ + export type Outbound = SupplementalData$Outbound; } diff --git a/accounting/src/sdk/models/shared/validation.ts b/accounting/src/sdk/models/shared/validation.ts index 74e0b99d..70d4dffc 100644 --- a/accounting/src/sdk/models/shared/validation.ts +++ b/accounting/src/sdk/models/shared/validation.ts @@ -1,46 +1,58 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ValidationItem, ValidationItem$ } from "./validationitem"; import * as z from "zod"; +import { + ValidationItem, + ValidationItem$inboundSchema, + ValidationItem$Outbound, + ValidationItem$outboundSchema, +} from "./validationitem.js"; /** * A human-readable object describing validation decisions Codat has made when pushing data into the platform. If a push has failed because of validation errors, they will be detailed here. */ export type Validation = { - errors?: Array | null | undefined; - warnings?: Array | null | undefined; + errors?: Array | null | undefined; + warnings?: Array | null | undefined; }; /** @internal */ -export namespace Validation$ { - export const inboundSchema: z.ZodType = z - .object({ - errors: z.nullable(z.array(ValidationItem$.inboundSchema)).optional(), - warnings: z.nullable(z.array(ValidationItem$.inboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.errors === undefined ? null : { errors: v.errors }), - ...(v.warnings === undefined ? null : { warnings: v.warnings }), - }; - }); +export const Validation$inboundSchema: z.ZodType< + Validation, + z.ZodTypeDef, + unknown +> = z.object({ + errors: z.nullable(z.array(ValidationItem$inboundSchema)).optional(), + warnings: z.nullable(z.array(ValidationItem$inboundSchema)).optional(), +}); + +/** @internal */ +export type Validation$Outbound = { + errors?: Array | null | undefined; + warnings?: Array | null | undefined; +}; - export type Outbound = { - errors?: Array | null | undefined; - warnings?: Array | null | undefined; - }; +/** @internal */ +export const Validation$outboundSchema: z.ZodType< + Validation$Outbound, + z.ZodTypeDef, + Validation +> = z.object({ + errors: z.nullable(z.array(ValidationItem$outboundSchema)).optional(), + warnings: z.nullable(z.array(ValidationItem$outboundSchema)).optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - errors: z.nullable(z.array(ValidationItem$.outboundSchema)).optional(), - warnings: z.nullable(z.array(ValidationItem$.outboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.errors === undefined ? null : { errors: v.errors }), - ...(v.warnings === undefined ? null : { warnings: v.warnings }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Validation$ { + /** @deprecated use `Validation$inboundSchema` instead. */ + export const inboundSchema = Validation$inboundSchema; + /** @deprecated use `Validation$outboundSchema` instead. */ + export const outboundSchema = Validation$outboundSchema; + /** @deprecated use `Validation$Outbound` instead. */ + export type Outbound = Validation$Outbound; } diff --git a/accounting/src/sdk/models/shared/validationitem.ts b/accounting/src/sdk/models/shared/validationitem.ts index ba18654f..827bb4ba 100644 --- a/accounting/src/sdk/models/shared/validationitem.ts +++ b/accounting/src/sdk/models/shared/validationitem.ts @@ -1,57 +1,62 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type ValidationItem = { - /** - * Unique identifier for a validation item. - */ - itemId?: string | null | undefined; - /** - * A message outlining validation item's issue. - */ - message?: string | null | undefined; - /** - * Name of validator. - */ - validatorName?: string | null | undefined; + /** + * Unique identifier for a validation item. + */ + itemId?: string | null | undefined; + /** + * A message outlining validation item's issue. + */ + message?: string | null | undefined; + /** + * Name of validator. + */ + validatorName?: string | null | undefined; }; /** @internal */ -export namespace ValidationItem$ { - export const inboundSchema: z.ZodType = z - .object({ - itemId: z.nullable(z.string()).optional(), - message: z.nullable(z.string()).optional(), - validatorName: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.itemId === undefined ? null : { itemId: v.itemId }), - ...(v.message === undefined ? null : { message: v.message }), - ...(v.validatorName === undefined ? null : { validatorName: v.validatorName }), - }; - }); +export const ValidationItem$inboundSchema: z.ZodType< + ValidationItem, + z.ZodTypeDef, + unknown +> = z.object({ + itemId: z.nullable(z.string()).optional(), + message: z.nullable(z.string()).optional(), + validatorName: z.nullable(z.string()).optional(), +}); - export type Outbound = { - itemId?: string | null | undefined; - message?: string | null | undefined; - validatorName?: string | null | undefined; - }; +/** @internal */ +export type ValidationItem$Outbound = { + itemId?: string | null | undefined; + message?: string | null | undefined; + validatorName?: string | null | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - itemId: z.nullable(z.string()).optional(), - message: z.nullable(z.string()).optional(), - validatorName: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.itemId === undefined ? null : { itemId: v.itemId }), - ...(v.message === undefined ? null : { message: v.message }), - ...(v.validatorName === undefined ? null : { validatorName: v.validatorName }), - }; - }); +/** @internal */ +export const ValidationItem$outboundSchema: z.ZodType< + ValidationItem$Outbound, + z.ZodTypeDef, + ValidationItem +> = z.object({ + itemId: z.nullable(z.string()).optional(), + message: z.nullable(z.string()).optional(), + validatorName: z.nullable(z.string()).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ValidationItem$ { + /** @deprecated use `ValidationItem$inboundSchema` instead. */ + export const inboundSchema = ValidationItem$inboundSchema; + /** @deprecated use `ValidationItem$outboundSchema` instead. */ + export const outboundSchema = ValidationItem$outboundSchema; + /** @deprecated use `ValidationItem$Outbound` instead. */ + export type Outbound = ValidationItem$Outbound; } diff --git a/accounting/src/sdk/models/shared/validdatatypelinks.ts b/accounting/src/sdk/models/shared/validdatatypelinks.ts index efe058c4..1c972d1a 100644 --- a/accounting/src/sdk/models/shared/validdatatypelinks.ts +++ b/accounting/src/sdk/models/shared/validdatatypelinks.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -40,8 +40,6 @@ import * as z from "zod"; * } * ``` * - * - * * ## Support for `validDatatypeLinks` * * Codat currently supports `validDatatypeLinks` for some data types on our Xero, QuickBooks Online, QuickBooks Desktop, Exact (NL), and Sage Business Cloud integrations. @@ -49,44 +47,51 @@ import * as z from "zod"; * If you'd like us to extend support to more data types or integrations, suggest or vote for this on our Product Roadmap. */ export type ValidDataTypeLinks = { - /** - * Supported `dataTypes` that the record can be linked to. - */ - links?: Array | null | undefined; - /** - * The property from the account that can be linked. - */ - property?: string | null | undefined; + /** + * Supported `dataTypes` that the record can be linked to. + */ + links?: Array | null | undefined; + /** + * The property from the account that can be linked. + */ + property?: string | null | undefined; }; /** @internal */ -export namespace ValidDataTypeLinks$ { - export const inboundSchema: z.ZodType = z - .object({ - links: z.nullable(z.array(z.string())).optional(), - property: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.links === undefined ? null : { links: v.links }), - ...(v.property === undefined ? null : { property: v.property }), - }; - }); +export const ValidDataTypeLinks$inboundSchema: z.ZodType< + ValidDataTypeLinks, + z.ZodTypeDef, + unknown +> = z.object({ + links: z.nullable(z.array(z.string())).optional(), + property: z.nullable(z.string()).optional(), +}); + +/** @internal */ +export type ValidDataTypeLinks$Outbound = { + links?: Array | null | undefined; + property?: string | null | undefined; +}; - export type Outbound = { - links?: Array | null | undefined; - property?: string | null | undefined; - }; +/** @internal */ +export const ValidDataTypeLinks$outboundSchema: z.ZodType< + ValidDataTypeLinks$Outbound, + z.ZodTypeDef, + ValidDataTypeLinks +> = z.object({ + links: z.nullable(z.array(z.string())).optional(), + property: z.nullable(z.string()).optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - links: z.nullable(z.array(z.string())).optional(), - property: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.links === undefined ? null : { links: v.links }), - ...(v.property === undefined ? null : { property: v.property }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ValidDataTypeLinks$ { + /** @deprecated use `ValidDataTypeLinks$inboundSchema` instead. */ + export const inboundSchema = ValidDataTypeLinks$inboundSchema; + /** @deprecated use `ValidDataTypeLinks$outboundSchema` instead. */ + export const outboundSchema = ValidDataTypeLinks$outboundSchema; + /** @deprecated use `ValidDataTypeLinks$Outbound` instead. */ + export type Outbound = ValidDataTypeLinks$Outbound; } diff --git a/accounting/src/sdk/sdk.ts b/accounting/src/sdk/sdk.ts index 790e72ff..801b8725 100644 --- a/accounting/src/sdk/sdk.ts +++ b/accounting/src/sdk/sdk.ts @@ -1,48 +1,21 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks"; -import { SDKOptions, serverURLFromOptions } from "../lib/config"; -import { HTTPClient } from "../lib/http"; -import { ClientSDK } from "../lib/sdks"; -import { Accounts } from "./accounts"; -import { AccountTransactions } from "./accounttransactions"; +import { ClientSDK } from "../lib/sdks.js"; +import { Accounts } from "./accounts.js"; +import { AccountTransactions } from "./accounttransactions.js"; export class Accounting extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; + private _accountTransactions?: AccountTransactions; + get accountTransactions(): AccountTransactions { + return (this._accountTransactions ??= new AccountTransactions( + this.options$, + )); + } - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - private _accountTransactions?: AccountTransactions; - get accountTransactions(): AccountTransactions { - return (this._accountTransactions ??= new AccountTransactions(this.options$)); - } - - private _accounts?: Accounts; - get accounts(): Accounts { - return (this._accounts ??= new Accounts(this.options$)); - } + private _accounts?: Accounts; + get accounts(): Accounts { + return (this._accounts ??= new Accounts(this.options$)); + } } diff --git a/accounting/src/sdk/types/blobs.ts b/accounting/src/sdk/types/blobs.ts index cbb8a57f..4ce84602 100644 --- a/accounting/src/sdk/types/blobs.ts +++ b/accounting/src/sdk/types/blobs.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/accounting/src/sdk/types/constdatetime.ts b/accounting/src/sdk/types/constdatetime.ts new file mode 100644 index 00000000..c0a4409c --- /dev/null +++ b/accounting/src/sdk/types/constdatetime.ts @@ -0,0 +1,15 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; + +export function constDateTime( + val: string, +): z.ZodType { + return z.custom((v) => { + return ( + typeof v === "string" && new Date(v).getTime() === new Date(val).getTime() + ); + }, `Value must be equivelant to ${val}`); +} diff --git a/accounting/src/sdk/types/decimal.ts b/accounting/src/sdk/types/decimal.ts index aeba085f..a7895d55 100644 --- a/accounting/src/sdk/types/decimal.ts +++ b/accounting/src/sdk/types/decimal.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "decimal.js"; diff --git a/accounting/src/sdk/types/enums.ts b/accounting/src/sdk/types/enums.ts index 4de0142b..6fb6d910 100644 --- a/accounting/src/sdk/types/enums.ts +++ b/accounting/src/sdk/types/enums.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ declare const __brand: unique symbol; diff --git a/accounting/src/sdk/types/fp.ts b/accounting/src/sdk/types/fp.ts new file mode 100644 index 00000000..ccbe51ea --- /dev/null +++ b/accounting/src/sdk/types/fp.ts @@ -0,0 +1,50 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * A monad that captures the result of a function call or an error if it was not + * successful. Railway programming, enabled by this type, can be a nicer + * alternative to traditional exception throwing because it allows functions to + * declare all _known_ errors with static types and then check for them + * exhaustively in application code. Thrown exception have a type of `unknown` + * and break out of regular control flow of programs making them harder to + * inspect and more verbose work with due to try-catch blocks. + */ +export type Result = + | { ok: true; value: T; error?: never } + | { ok: false; value?: never; error: E }; + +export function OK(value: V): Result { + return { ok: true, value }; +} + +export function ERR(error: E): Result { + return { ok: false, error }; +} + +/** + * unwrap is a convenience function for extracting a value from a result or + * throwing if there was an error. + */ +export function unwrap(r: Result): T { + if (!r.ok) { + throw r.error; + } + return r.value; +} + +/** + * unwrapAsync is a convenience function for resolving a value from a Promise + * of a result or rejecting if an error occurred. + */ +export async function unwrapAsync( + pr: Promise>, +): Promise { + const r = await pr; + if (!r.ok) { + throw r.error; + } + + return r.value; +} diff --git a/accounting/src/sdk/types/index.ts b/accounting/src/sdk/types/index.ts index fd522370..1af7eaa2 100644 --- a/accounting/src/sdk/types/index.ts +++ b/accounting/src/sdk/types/index.ts @@ -1,11 +1,12 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export { RFCDate } from "./rfcdate"; -export { blobLikeSchema, isBlobLike } from "./blobs"; -export type { Paginator, PageIterator } from "./operations"; -export { createPageIterator } from "./operations"; -export { catchUnrecognizedEnum } from "./enums"; -export type { OpenEnum, ClosedEnum, Unrecognized } from "./enums"; -export { Decimal } from "./decimal"; +export { blobLikeSchema, isBlobLike } from "./blobs.js"; +export { Decimal } from "./decimal.js"; +export { catchUnrecognizedEnum } from "./enums.js"; +export type { ClosedEnum, OpenEnum, Unrecognized } from "./enums.js"; +export type { Result } from "./fp.js"; +export type { PageIterator, Paginator } from "./operations.js"; +export { createPageIterator } from "./operations.js"; +export { RFCDate } from "./rfcdate.js"; diff --git a/accounting/src/sdk/types/operations.ts b/accounting/src/sdk/types/operations.ts index 7f833514..0952f6f4 100644 --- a/accounting/src/sdk/types/operations.ts +++ b/accounting/src/sdk/types/operations.ts @@ -1,25 +1,99 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export type Paginator = () => Promise> | null; +import { Result } from "./fp.js"; -export type PageIterator = Result & { - next: Paginator; - [Symbol.asyncIterator]: () => AsyncIterableIterator; +export type Paginator = () => Promise }> | null; + +export type PageIterator = V & { + next: Paginator; + [Symbol.asyncIterator]: () => AsyncIterableIterator; }; -export function createPageIterator( - page: Result & { next: Paginator }, -): { [Symbol.asyncIterator]: () => AsyncIterableIterator } { +export function createPageIterator( + page: V & { next: Paginator }, + halt: (v: V) => boolean, +): { + [Symbol.asyncIterator]: () => AsyncIterableIterator; +} { return { [Symbol.asyncIterator]: async function* paginator() { yield page; + if (halt(page)) { + return; + } let p: typeof page | null = page; for (p = await p.next(); p != null; p = await p.next()) { yield p; + if (halt(p)) { + return; + } } }, }; } + +/** + * This utility create a special iterator that yields a single value and + * terminates. It is useful in paginated SDK functions that have early return + * paths when things go wrong. + */ +export function haltIterator(v: V): PageIterator { + return { + ...v, + next: () => null, + [Symbol.asyncIterator]: async function* paginator() { + yield v; + }, + }; +} + +/** + * Converts an async iterator of `Result` into an async iterator of `V`. + * When error results occur, the underlying error value is thrown. + */ +export async function unwrapResultIterator( + iteratorPromise: Promise>>, +): Promise> { + const resultIter = await iteratorPromise; + + if (!resultIter.ok) { + throw resultIter.error; + } + + return { + ...resultIter.value, + next: unwrapPaginator(resultIter.next), + [Symbol.asyncIterator]: async function* paginator() { + for await (const page of resultIter) { + if (!page.ok) { + throw page.error; + } + yield page.value; + } + }, + }; +} + +function unwrapPaginator( + paginator: Paginator>, +): Paginator { + return () => { + const nextResult = paginator(); + if (nextResult == null) { + return null; + } + return nextResult.then((res) => { + if (!res.ok) { + throw res.error; + } + const out = { + ...res.value, + next: unwrapPaginator(res.next), + }; + return out; + }); + }; +} diff --git a/accounting/src/sdk/types/rfcdate.ts b/accounting/src/sdk/types/rfcdate.ts index e80b6932..c79b3f53 100644 --- a/accounting/src/sdk/types/rfcdate.ts +++ b/accounting/src/sdk/types/rfcdate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ const dateRE = /^\d{4}-\d{2}-\d{2}$/; diff --git a/accounting/src/sdk/types/streams.ts b/accounting/src/sdk/types/streams.ts new file mode 100644 index 00000000..a0163e7a --- /dev/null +++ b/accounting/src/sdk/types/streams.ts @@ -0,0 +1,21 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export function isReadableStream( + val: unknown, +): val is ReadableStream { + if (typeof val !== "object" || val === null) { + return false; + } + + // Check for the presence of methods specific to ReadableStream + const stream = val as ReadableStream; + + // ReadableStream has methods like getReader, cancel, and tee + return ( + typeof stream.getReader === "function" && + typeof stream.cancel === "function" && + typeof stream.tee === "function" + ); +} diff --git a/lending/.eslintrc.js b/lending/.eslintrc.cjs similarity index 100% rename from lending/.eslintrc.js rename to lending/.eslintrc.cjs diff --git a/lending/.gitignore b/lending/.gitignore index 019ca8af..44b9f93c 100755 --- a/lending/.gitignore +++ b/lending/.gitignore @@ -1,3 +1,10 @@ +/funcs +/core.* +/esm +/dist +/.tshy +/.tshy-* +/__tests__ /models /models/errors /types diff --git a/lending/.npmignore b/lending/.npmignore index 709e6847..06cd8abf 100644 --- a/lending/.npmignore +++ b/lending/.npmignore @@ -5,3 +5,6 @@ /.eslintrc.js /cjs +/.tshy +/.tshy-* +/__tests__ diff --git a/lending/.speakeasy/gen.lock b/lending/.speakeasy/gen.lock index b30b29c5..4eec8f1e 100755 --- a/lending/.speakeasy/gen.lock +++ b/lending/.speakeasy/gen.lock @@ -3,22 +3,24 @@ id: 29cfdd98-e13b-4623-b529-885b7ad9a604 management: docChecksum: 48b665753822e4a7157d85cc441e7b3f docVersion: 3.0.0 - speakeasyVersion: 1.296.1 - generationVersion: 2.338.1 - releaseVersion: 0.2.0 - configChecksum: 68bd83ae1170bc99e01db1bdbf82c81a + speakeasyVersion: 1.396.2 + generationVersion: 2.415.0 + releaseVersion: 0.3.0 + configChecksum: 4b1c143572c55d5f0d7a2bff6fc04ed5 repoURL: https://github.com/speakeasy-sdks/template-sdk-monorepo.git repoSubDirectory: lending installationURL: https://gitpkg.now.sh/speakeasy-sdks/template-sdk-monorepo/lending features: typescript: additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.5 - core: 3.9.9 + constsAndDefaults: 0.1.11 + core: 3.17.0 + defaultEnabledRetries: 0.1.0 deprecations: 2.81.1 + envVarSecurityUsage: 0.1.1 examples: 2.81.4 flattening: 2.81.1 - globalSecurity: 2.82.9 + globalSecurity: 2.82.11 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 globalServerURLs: 2.82.4 @@ -27,86 +29,245 @@ features: responseFormat: 0.2.3 retries: 2.83.0 sdkHooks: 0.1.0 + serverEventsSentinels: 0.1.0 generatedFiles: - - src/sdk/companies.ts - - src/sdk/sdk.ts - - .eslintrc.js + - .eslintrc.cjs + - .gitattributes - .npmignore + - CONTRIBUTING.md + - FUNCTIONS.md - RUNTIMES.md + - USAGE.md + - docs/lib/utils/retryconfig.md + - docs/models/components/companies.md + - docs/models/components/company.md + - docs/models/components/companyrequestbody.md + - docs/models/components/connection.md + - docs/models/components/dataconnectionerror.md + - docs/models/components/dataconnectionstatus.md + - docs/models/components/errorvalidation.md + - docs/models/components/errorvalidationitem.md + - docs/models/components/groupreference.md + - docs/models/components/halref.md + - docs/models/components/httpmetadata.md + - docs/models/components/items.md + - docs/models/components/links.md + - docs/models/components/security.md + - docs/models/components/sourcetype.md + - docs/models/errors/errormessage.md + - docs/models/operations/createcompanyresponse.md + - docs/models/operations/deletecompanyrequest.md + - docs/models/operations/deletecompanyresponse.md + - docs/models/operations/getcompanyrequest.md + - docs/models/operations/getcompanyresponse.md + - docs/models/operations/listcompaniesrequest.md + - docs/models/operations/listcompaniesresponse.md + - docs/models/operations/updatecompanyrequest.md + - docs/models/operations/updatecompanyresponse.md + - docs/sdks/companies/README.md + - docs/sdks/lendingts/README.md - jsr.json - package.json + - src/core.ts + - src/funcs/companiesCreate.ts + - src/funcs/companiesDelete.ts + - src/funcs/companiesGet.ts + - src/funcs/companiesList.ts + - src/funcs/companiesUpdate.ts + - src/hooks/hooks.ts + - src/hooks/index.ts + - src/hooks/types.ts - src/index.ts - src/lib/base64.ts - src/lib/config.ts + - src/lib/dlv.ts - src/lib/encodings.ts + - src/lib/files.ts - src/lib/http.ts - src/lib/is-plain-object.ts + - src/lib/logger.ts + - src/lib/matchers.ts + - src/lib/primitives.ts - src/lib/retries.ts - src/lib/schemas.ts - src/lib/sdks.ts - src/lib/security.ts - src/lib/url.ts - - src/sdk/index.ts - - src/models/errors/sdkerror.ts - - src/models/errors/sdkvalidationerror.ts - - src/types/blobs.ts - - src/types/enums.ts - - src/types/index.ts - - src/types/operations.ts - - src/types/rfcdate.ts - - tsconfig.json - - src/models/operations/listcompanies.ts - - src/models/operations/createcompany.ts - - src/models/operations/updatecompany.ts - - src/models/operations/deletecompany.ts - - src/models/operations/getcompany.ts - src/models/components/companies.ts - - src/models/components/links.ts - - src/models/components/halref.ts - src/models/components/company.ts + - src/models/components/companyrequestbody.ts - src/models/components/connection.ts - src/models/components/dataconnectionerror.ts - src/models/components/dataconnectionstatus.ts - - src/models/components/httpmetadata.ts - src/models/components/errorvalidation.ts - src/models/components/errorvalidationitem.ts - - src/models/components/companyrequestbody.ts + - src/models/components/halref.ts + - src/models/components/httpmetadata.ts + - src/models/components/index.ts - src/models/components/items.ts + - src/models/components/links.ts - src/models/components/security.ts - src/models/errors/errormessage.ts + - src/models/errors/httpclienterrors.ts - src/models/errors/index.ts + - src/models/errors/sdkerror.ts + - src/models/errors/sdkvalidationerror.ts + - src/models/operations/createcompany.ts + - src/models/operations/deletecompany.ts + - src/models/operations/getcompany.ts - src/models/operations/index.ts - - src/models/components/index.ts - - docs/models/operations/listcompaniesrequest.md - - docs/models/operations/listcompaniesresponse.md - - docs/models/operations/createcompanyresponse.md - - docs/models/operations/updatecompanyrequest.md - - docs/models/operations/updatecompanyresponse.md - - docs/models/operations/deletecompanyrequest.md - - docs/models/operations/deletecompanyresponse.md - - docs/models/operations/getcompanyrequest.md - - docs/models/operations/getcompanyresponse.md - - docs/models/components/companies.md - - docs/models/components/links.md - - docs/models/components/halref.md - - docs/models/components/groupreference.md - - docs/models/components/company.md - - docs/models/components/sourcetype.md - - docs/models/components/connection.md - - docs/models/components/dataconnectionerror.md - - docs/models/components/dataconnectionstatus.md - - docs/models/components/httpmetadata.md - - docs/models/components/errorvalidation.md - - docs/models/components/errorvalidationitem.md - - docs/models/components/companyrequestbody.md - - docs/models/components/items.md - - docs/models/components/security.md - - docs/models/errors/errormessage.md - - docs/sdks/lendingts/README.md - - docs/lib/utils/retryconfig.md - - docs/sdks/companies/README.md - - USAGE.md - - .gitattributes - - src/hooks/hooks.ts - - src/hooks/types.ts - - src/hooks/index.ts + - src/models/operations/listcompanies.ts + - src/models/operations/updatecompany.ts + - src/sdk/companies.ts + - src/sdk/index.ts + - src/sdk/sdk.ts + - src/types/blobs.ts + - src/types/constdatetime.ts + - src/types/enums.ts + - src/types/fp.ts + - src/types/index.ts + - src/types/operations.ts + - src/types/rfcdate.ts + - src/types/streams.ts + - tsconfig.json +examples: + list-companies: + "": + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "name": "string", "description": "Requested early access to the new financing scheme.", "platform": "string", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "lastSync": "2022-01-01T12:00:00.000Z", "created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []}], "groups": [{"id": "d7a6c4b4-dc87-45f6-b803-62f466398680"}]}], "pageNumber": 1, "pageSize": 10, "totalResults": 1, "_links": {"self": {"href": "/companies/{id}/data/{dataType}"}, "current": {"href": "/companies/{id}/data/{dataType}?page=1&pageSize=10"}}} + "400": {} + One company: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "name": "My Test Company", "description": "My Test Company make testing software", "platform": "", "redirect": "https://link.codat.io/company/3fa85f64-5717-4562-b3fc-2c963f66afa6", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "createdByUserName": "Mike Smith", "dataConnections": [{"id": "51baa045-4836-4317-a42e-3542e991e581", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "platformName": "Pandle", "linkUrl": "https://link-api.codat.io/companies/3fa85f64-5717-4562-b3fc-2c963f66afa6/connections/51baa045-4836-4317-a42e-3542e991e581/start", "status": "Linked", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "dataConnectionErrors": []}], "groups": [{"id": "d7a6c4b4-dc87-45f6-b803-62f466398680"}]}], "pageNumber": 1, "pageSize": 100, "totalResults": 1, "_links": {"self": {"href": "/companies"}, "current": {"href": "/companies?page=1&pageSize=100"}}} + List of Companies: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "d1568dde-adf6-11ed-afa1-0242ac120002", "name": "Technicalium", "description": "Technology services, including web and app design and development", "platform": "", "redirect": "https://link.codat.io/company/d1568dde-adf6-11ed-afa1-0242ac120002", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "createdByUserName": "Joe Bloggs", "dataConnections": [{"id": "51baa045-4836-4317-a42e-3542e991e581", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "platformName": "Pandle", "linkUrl": "https://link-api.codat.io/companies/d1568dde-adf6-11ed-afa1-0242ac120002/connections/51baa045-4836-4317-a42e-3542e991e581/start", "status": "Linked", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "dataConnectionErrors": []}], "groups": []}, {"id": "096db70b-78de-4ff0-aa98-299cb5fe17a0", "name": "Godata", "description": "A new digital agency with a passion for creating amazing digital experiences", "platform": "", "redirect": "https://link.codat.io/company/096db70b-78de-4ff0-aa98-299cb5fe17a0", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "createdByUserName": "Mike Smith", "dataConnections": [{"id": "a70bc148-dc21-46b2-a257-d9c58ac15cbb", "integrationId": "1c312d69-e638-46d4-ad31-72e6c3ba8390", "integrationKey": "vjms", "sourceId": "396c3158-5dd7-481b-a7c4-a795ca31792b", "sourceType": "Accounting", "platformName": "Pandle", "linkUrl": "https://link-api.codat.io/companies/096db70b-78de-4ff0-aa98-299cb5fe17a0/connections/a70bc148-dc21-46b2-a257-d9c58ac15cbb/start", "status": "Linked", "lastSync": "2022-01-01T12:30:00.000Z", "created": "2022-01-01T11:30:00Z", "dataConnectionErrors": []}], "groups": []}], "pageNumber": 1, "pageSize": 100, "totalResults": 2, "_links": {"self": {"href": "/companies"}, "current": {"href": "/companies?page=1&pageSize=100"}}} + Malformed query: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "ClientsApi", "error": "Error parsing query - Malformed query.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + Unresolved property: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "PullApi", "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-company: + With no description: + requestBody: + application/json: {"name": "Technicalium", "description": "Requested early access to the new financing scheme.", "groups": []} + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "Technicalium", "description": "", "platform": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": [], "groups": []} + "400": {} + With a description: + requestBody: + application/json: {"name": "Technicalium", "description": "Technology services, including web and app design and development", "groups": []} + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "Technicalium", "description": "Technology services, including web and app design and development", "platform": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": [], "groups": []} + "400": {} + With a group: + requestBody: + application/json: {"name": "Technicalium", "description": "Requested early access to the new financing scheme.", "groups": [{"id": "d7a6c4b4-dc87-45f6-b803-62f466398680"}]} + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "Technicalium", "description": "", "platform": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18.1950523Z", "createdByUserName": "Dan Tzabar", "dataConnections": [], "groups": [{"id": "f8a6f6ed-9812-4d1e-ba48-4346348403c8"}]} + "400": {} + Malformed query: + requestBody: + application/json: {"name": "Bank of Dave", "description": "Requested early access to the new financing scheme.", "groups": []} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + update-company: + Update name: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"name": "New Name", "description": "Requested early access to the new financing scheme.", "groups": []} + responses: + "200": + application/json: {"id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "name": "string", "description": "Requested early access to the new financing scheme.", "platform": "string", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "lastSync": "2022-01-01T12:00:00.000Z", "created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []}], "groups": [{"id": "d7a6c4b4-dc87-45f6-b803-62f466398680"}]} + "401": {} + Update description: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"name": "Same name", "description": "Additional documents required", "groups": []} + responses: + "200": + application/json: {"id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "name": "string", "description": "Requested early access to the new financing scheme.", "platform": "string", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "lastSync": "2022-01-01T12:00:00.000Z", "created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "dataConnections": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z", "dataConnectionErrors": []}], "groups": [{"id": "d7a6c4b4-dc87-45f6-b803-62f466398680"}]} + "401": {} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"name": "Bank of Dave", "description": "Requested early access to the new financing scheme.", "groups": []} + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + delete-company: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-company: + Simple company: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "My First Company", "description": "", "platform": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18Z", "createdByUserName": "Dan Tzabar", "dataConnections": [], "groups": []} + With groups: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "200": + application/json: {"id": "ab12c58d-a678-4ebf-a159-ae99e1807bd0", "name": "My First Company", "description": "", "platform": "", "redirect": "https://link.codat.io/company/ab12c58d-a678-4ebf-a159-ae99e1807bd0", "lastSync": "2022-10-23T00:00:00Z", "created": "2022-11-10T10:45:18Z", "createdByUserName": "Dan Tzabar", "dataConnections": [], "groups": [{"id": "f8a6f6ed-9812-4d1e-ba48-4346348403c8"}]} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} diff --git a/lending/CONTRIBUTING.md b/lending/CONTRIBUTING.md new file mode 100644 index 00000000..d585717f --- /dev/null +++ b/lending/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to This Repository + +Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. + +## How to Report Issues + +If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: + +- A clear and descriptive title +- Steps to reproduce the issue +- Expected and actual behavior +- Any relevant logs, screenshots, or error messages +- Information about your environment (e.g., operating system, software versions) + - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed + +## Issue Triage and Upstream Fixes + +We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. + +## Contact + +If you have any questions or need further assistance, please feel free to reach out by opening an issue. + +Thank you for your understanding and cooperation! + +The Maintainers diff --git a/lending/FUNCTIONS.md b/lending/FUNCTIONS.md new file mode 100644 index 00000000..f219edbb --- /dev/null +++ b/lending/FUNCTIONS.md @@ -0,0 +1,104 @@ +# Standalone Functions + +> [!NOTE] +> This section is useful if you are using a bundler and targetting browsers and +> runtimes where the size of an application affects performance and load times. + +Every method in this SDK is also available as a standalone function. This +alternative API is suitable when targetting the browser or serverless runtimes +and using a bundler to build your application since all unused functionality +will be tree-shaken away. This includes code for unused methods, Zod schemas, +encoding helpers and response handlers. The result is dramatically smaller +impact on the application's final bundle size which grows very slowly as you use +more and more functionality from this SDK. + +Calling methods through the main SDK class remains a valid and generally more +more ergonomic option. Standalone functions represent an optimisation for a +specific category of applications. + +## Example + +```typescript +import { LendingTsCore } from "@speakeasy-sdks/lending/core.js"; +import { companiesList } from "@speakeasy-sdks/lending/funcs/companiesList.js"; +import { SDKValidationError } from "@speakeasy-sdks/lending/models/errors/sdkvalidationerror.js"; + +// Use `LendingTsCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const lendingTs = new LendingTsCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await companiesList(lendingTs, 1, 100, "id=e3334455-1aed-4e71-ab43-6bccf12092ee", "-modifiedDate"); + + switch (true) { + case res.ok: + // The success case will be handled outside of the switch block + break; + case res.error instanceof SDKValidationError: + // Pretty-print validation errors. + return console.log(res.error.pretty()); + case res.error instanceof Error: + return console.log(res.error); + default: + // TypeScript's type checking will fail on the following line if the above + // cases were not exhaustive. + res.error satisfies never; + throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + } + + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + +## Result types + +Standalone functions differ from SDK methods in that they return a +`Result` type to capture _known errors_ and document them using +the type system. By avoiding throwing errors, application code maintains clear +control flow and error-handling become part of the regular flow of application +code. + +> We use the term "known errors" because standalone functions, and JavaScript +> code in general, can still throw unexpected errors such as `TypeError`s, +> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be +> something this SDK addresses in the future. Nevertheless, there is still a lot +> of benefit from capturing most errors and turning them into values. + +The second reason for this style of programming is because these functions will +typically be used in front-end applications where exception throwing is +sometimes discouraged or considered unidiomatic. React and similar ecosystems +and libraries tend to promote this style of programming so that components +render useful content under all states (loading, success, error and so on). + +The general pattern when calling standalone functions looks like this: + +```typescript +import { Core } from ""; +import { fetchSomething } from "/funcs/fetchSomething.js"; + +const client = new Core(); + +async function run() { + const result = await fetchSomething(client, { id: "123" }); + if (!result.ok) { + // You can throw the error or handle it. It's your choice now. + throw result.error; + } + + console.log(result.value); +} + +run(); +``` + +Notably, `result.error` above will have an explicit type compared to a try-catch +variation where the error in the catch block can only be of type `unknown` (or +`any` depending on your TypeScript settings). \ No newline at end of file diff --git a/lending/README.md b/lending/README.md index 1f7bc8cf..5757fee7 100755 --- a/lending/README.md +++ b/lending/README.md @@ -6,19 +6,84 @@ + +## Summary + +Lending API: Our Lending API helps you make smarter credit decisions on small businesses by enabling you to pull your customers' latest data from accounting, banking, and commerce platforms they are already using. It also includes features to help providers verify the accuracy of data and process it more efficiently. + +The Lending API is built on top of the latest accounting, commerce, and banking data, providing you with the most important data points you need to get a full picture of SMB creditworthiness and make a comprehensive assessment of your customers. + +[Explore product](https://docs.codat.io/lending/overview) | [See OpenAPI spec](https://github.com/codatio/oas) + + +## Endpoints + +| Endpoints | Description | +| :- |:- | +| Companies | Create and manage your SMB users' companies. | +| Connections | Create new and manage existing data connections for a company. | +| Bank statements | Retrieve banking data from linked bank accounts. | +| Sales | Retrieve standardized sales data from a linked commerce platform. | +| Financial statements | Financial data and reports from a linked accounting platform. | +| Liabilities | Debt and other liabilities. | +| Accounts payable | Data from a linked accounting platform representing money the business owes money to its suppliers. | +| Accounts receivable | Data from a linked accounting platform representing money owed to the business for sold goods or services. | +| Transactions | Data from a linked accounting platform representing transactions. | +| Company info | View company information fetched from the source platform. | +| Data integrity | Match mutable accounting data with immutable banking data to increase confidence in financial data. | +| Excel reports | Download reports in Excel format. | +| Manage data | Control how data is retrieved from an integration. | +| File upload | Endpoints to manage uploaded files. | +| Loan writeback | Implement the [loan writeback](https://docs.codat.io/lending/guides/loan-writeback/introduction) procedure in your lending process to maintain an accurate position of a loan during the entire lending cycle. | + + + + +## Table of Contents + +* [SDK Installation](#sdk-installation) +* [Requirements](#requirements) +* [SDK Example Usage](#sdk-example-usage) +* [Available Resources and Operations](#available-resources-and-operations) +* [Standalone functions](#standalone-functions) +* [Retries](#retries) +* [Error Handling](#error-handling) +* [Server Selection](#server-selection) +* [Custom HTTP Client](#custom-http-client) +* [Authentication](#authentication) +* [Debugging](#debugging) + + ## SDK Installation +The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers. + ### NPM ```bash npm add https://gitpkg.now.sh/speakeasy-sdks/template-sdk-monorepo/lending ``` +### PNPM + +```bash +pnpm add https://gitpkg.now.sh/speakeasy-sdks/template-sdk-monorepo/lending +``` + +### Bun + +```bash +bun add https://gitpkg.now.sh/speakeasy-sdks/template-sdk-monorepo/lending +``` + ### Yarn ```bash -yarn add https://gitpkg.now.sh/speakeasy-sdks/template-sdk-monorepo/lending +yarn add https://gitpkg.now.sh/speakeasy-sdks/template-sdk-monorepo/lending zod + +# Note that Yarn does not install peer dependencies automatically. You will need +# to install zod as shown above. ``` @@ -31,19 +96,19 @@ yarn add https://gitpkg.now.sh/speakeasy-sdks/template-sdk-monorepo/lending import { LendingTs } from "@speakeasy-sdks/lending"; const lendingTs = new LendingTs({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await lendingTs.companies.list( - 1, - 100, - "id=e3334455-1aed-4e71-ab43-6bccf12092ee", - "-modifiedDate" - ); - - // Handle the result - console.log(result); + const result = await lendingTs.companies.list( + 1, + 100, + "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + "-modifiedDate", + ); + + // Handle the result + console.log(result); } run(); @@ -69,6 +134,31 @@ run(); For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md). + +## Standalone functions + +All the methods listed above are available as standalone functions. These +functions are ideal for use in applications running in the browser, serverless +runtimes or other environments where application bundle size is a primary +concern. When using a bundler to build your application, all unused +functionality will be either excluded from the final bundle or tree-shaken away. + +To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). + +
+ +Available standalone functions + +- [companiesCreate](docs/sdks/companies/README.md#create) +- [companiesDelete](docs/sdks/companies/README.md#delete) +- [companiesGet](docs/sdks/companies/README.md#get) +- [companiesList](docs/sdks/companies/README.md#list) +- [companiesUpdate](docs/sdks/companies/README.md#update) + + +
+ + ## Retries @@ -79,31 +169,31 @@ To change the default retry strategy for a single API call, simply provide a ret import { LendingTs } from "@speakeasy-sdks/lending"; const lendingTs = new LendingTs({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await lendingTs.companies.list( - 1, - 100, - "id=e3334455-1aed-4e71-ab43-6bccf12092ee", - "-modifiedDate", - { - retries: { - strategy: "backoff", - backoff: { - initialInterval: 1, - maxInterval: 50, - exponent: 1.1, - maxElapsedTime: 100, - }, - retryConnectionErrors: false, - }, - } - ); + const result = await lendingTs.companies.list( + 1, + 100, + "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + "-modifiedDate", + { + retries: { + strategy: "backoff", + backoff: { + initialInterval: 1, + maxInterval: 50, + exponent: 1.1, + maxElapsedTime: 100, + }, + retryConnectionErrors: false, + }, + }, + ); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); @@ -115,29 +205,29 @@ If you'd like to override the default retry strategy for all operations that sup import { LendingTs } from "@speakeasy-sdks/lending"; const lendingTs = new LendingTs({ - retryConfig: { - strategy: "backoff", - backoff: { - initialInterval: 1, - maxInterval: 50, - exponent: 1.1, - maxElapsedTime: 100, - }, - retryConnectionErrors: false, + retryConfig: { + strategy: "backoff", + backoff: { + initialInterval: 1, + maxInterval: 50, + exponent: 1.1, + maxElapsedTime: 100, }, - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + retryConnectionErrors: false, + }, + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await lendingTs.companies.list( - 1, - 100, - "id=e3334455-1aed-4e71-ab43-6bccf12092ee", - "-modifiedDate" - ); - - // Handle the result - console.log(result); + const result = await lendingTs.companies.list( + 1, + 100, + "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + "-modifiedDate", + ); + + // Handle the result + console.log(result); } run(); @@ -160,42 +250,46 @@ Validation errors can also occur when either method arguments or data returned f ```typescript import { LendingTs } from "@speakeasy-sdks/lending"; -import * as errors from "@speakeasy-sdks/lending/models/errors"; +import { + ErrorMessage, + SDKValidationError, +} from "@speakeasy-sdks/lending/models/errors"; const lendingTs = new LendingTs({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - let result; - try { - result = await lendingTs.companies.list( - 1, - 100, - "id=e3334455-1aed-4e71-ab43-6bccf12092ee", - "-modifiedDate" - ); - } catch (err) { - switch (true) { - case err instanceof errors.SDKValidationError: { - // Validation errors can be pretty-printed - console.error(err.pretty()); - // Raw value may also be inspected - console.error(err.rawValue); - return; - } - case err instanceof errors.ErrorMessage: { - console.error(err); // handle exception - return; - } - default: { - throw err; - } - } - } + let result; + try { + result = await lendingTs.companies.list( + 1, + 100, + "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + "-modifiedDate", + ); // Handle the result console.log(result); + } catch (err) { + switch (true) { + case (err instanceof SDKValidationError): { + // Validation errors can be pretty-printed + console.error(err.pretty()); + // Raw value may also be inspected + console.error(err.rawValue); + return; + } + case (err instanceof ErrorMessage): { + // Handle err.data$: ErrorMessageData + console.error(err); + return; + } + default: { + throw err; + } + } + } } run(); @@ -218,20 +312,20 @@ You can override the default server globally by passing a server index to the `s import { LendingTs } from "@speakeasy-sdks/lending"; const lendingTs = new LendingTs({ - serverIdx: 0, - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + serverIdx: 0, + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await lendingTs.companies.list( - 1, - 100, - "id=e3334455-1aed-4e71-ab43-6bccf12092ee", - "-modifiedDate" - ); - - // Handle the result - console.log(result); + const result = await lendingTs.companies.list( + 1, + 100, + "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + "-modifiedDate", + ); + + // Handle the result + console.log(result); } run(); @@ -247,20 +341,20 @@ The default server can also be overridden globally by passing a URL to the `serv import { LendingTs } from "@speakeasy-sdks/lending"; const lendingTs = new LendingTs({ - serverURL: "https://api.codat.io", - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + serverURL: "https://api.codat.io", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await lendingTs.companies.list( - 1, - 100, - "id=e3334455-1aed-4e71-ab43-6bccf12092ee", - "-modifiedDate" - ); - - // Handle the result - console.log(result); + const result = await lendingTs.companies.list( + 1, + 100, + "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + "-modifiedDate", + ); + + // Handle the result + console.log(result); } run(); @@ -333,19 +427,19 @@ To authenticate with the API the `authHeader` parameter must be set when initial import { LendingTs } from "@speakeasy-sdks/lending"; const lendingTs = new LendingTs({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await lendingTs.companies.list( - 1, - 100, - "id=e3334455-1aed-4e71-ab43-6bccf12092ee", - "-modifiedDate" - ); - - // Handle the result - console.log(result); + const result = await lendingTs.companies.list( + 1, + 100, + "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + "-modifiedDate", + ); + + // Handle the result + console.log(result); } run(); @@ -353,6 +447,23 @@ run(); ``` + +## Debugging + +You can setup your SDK to emit debug logs for SDK requests and responses. + +You can pass a logger that matches `console`'s interface as an SDK option. + +> [!WARNING] +> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production. + +```typescript +import { LendingTs } from "@speakeasy-sdks/lending"; + +const sdk = new LendingTs({ debugLogger: console }); +``` + + # Development diff --git a/lending/RUNTIMES.md b/lending/RUNTIMES.md index 71fa3dae..d08a0c07 100644 --- a/lending/RUNTIMES.md +++ b/lending/RUNTIMES.md @@ -3,7 +3,7 @@ This SDK is intended to be used in JavaScript runtimes that support the following features: * [Web Fetch API][web-fetch] -* [Web Streams API](web-streams) and in particular `ReadableStream` +* [Web Streams API][web-streams] and in particular `ReadableStream` * [Async iterables][async-iter] using `Symbol.asyncIterator` [web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API diff --git a/lending/USAGE.md b/lending/USAGE.md index 321fc5c6..1f6e7af1 100644 --- a/lending/USAGE.md +++ b/lending/USAGE.md @@ -3,19 +3,19 @@ import { LendingTs } from "@speakeasy-sdks/lending"; const lendingTs = new LendingTs({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await lendingTs.companies.list( - 1, - 100, - "id=e3334455-1aed-4e71-ab43-6bccf12092ee", - "-modifiedDate" - ); + const result = await lendingTs.companies.list( + 1, + 100, + "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + "-modifiedDate", + ); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); diff --git a/lending/docs/models/components/companies.md b/lending/docs/models/components/companies.md index 8a280b05..f4068826 100644 --- a/lending/docs/models/components/companies.md +++ b/lending/docs/models/components/companies.md @@ -1,5 +1,62 @@ # Companies +## Example Usage + +```typescript +import { Companies, DataConnectionStatus, SourceType } from "@speakeasy-sdks/lending/models/components"; + +let value: Companies = { + results: [ + { + id: "0498e921-9b53-4396-a412-4f2f5983b0a2", + name: "string", + description: "Requested early access to the new financing scheme.", + platform: "string", + redirect: + "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", + lastSync: "2022-01-01T12:00:00.000Z", + created: "2022-01-01T12:00:00.000Z", + createdByUserName: "string", + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: SourceType.Banking, + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: DataConnectionStatus.Linked, + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + dataConnectionErrors: [ + { + erroredOnUtc: "2022-10-23T00:00:00Z", + }, + ], + }, + ], + groups: [ + { + id: "d7a6c4b4-dc87-45f6-b803-62f466398680", + }, + ], + }, + ], + pageNumber: 1, + pageSize: 10, + totalResults: 1, + links: { + self: { + href: "/companies/{id}/data/{dataType}", + }, + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + }, +}; +``` ## Fields diff --git a/lending/docs/models/components/company.md b/lending/docs/models/components/company.md index e765fe2d..83ff881b 100644 --- a/lending/docs/models/components/company.md +++ b/lending/docs/models/components/company.md @@ -6,6 +6,48 @@ Typically each company is one of your customers. When you create a company, you can specify a `name` and we will automatically generate a unique `id` for the company. You can also add a `description` to store any additional information about the company. +## Example Usage + +```typescript +import { Company, DataConnectionStatus, SourceType } from "@speakeasy-sdks/lending/models/components"; + +let value: Company = { + id: "0498e921-9b53-4396-a412-4f2f5983b0a2", + name: "string", + description: "Requested early access to the new financing scheme.", + platform: "string", + redirect: + "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", + lastSync: "2022-01-01T12:00:00.000Z", + created: "2022-01-01T12:00:00.000Z", + createdByUserName: "string", + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: SourceType.Banking, + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: DataConnectionStatus.Linked, + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + dataConnectionErrors: [ + { + erroredOnUtc: "2022-10-23T00:00:00Z", + }, + ], + }, + ], + groups: [ + { + id: "d7a6c4b4-dc87-45f6-b803-62f466398680", + }, + ], +}; +``` ## Fields diff --git a/lending/docs/models/components/companyrequestbody.md b/lending/docs/models/components/companyrequestbody.md index ff65a80e..c7fd32f1 100644 --- a/lending/docs/models/components/companyrequestbody.md +++ b/lending/docs/models/components/companyrequestbody.md @@ -1,5 +1,20 @@ # CompanyRequestBody +## Example Usage + +```typescript +import { CompanyRequestBody } from "@speakeasy-sdks/lending/models/components"; + +let value: CompanyRequestBody = { + name: "Bank of Dave", + description: "Requested early access to the new financing scheme.", + groups: [ + { + id: "60d2fa12-8a04-11ee-b9d1-0242ac120002", + }, + ], +}; +``` ## Fields diff --git a/lending/docs/models/components/connection.md b/lending/docs/models/components/connection.md index 3904e3ee..ce7d97ad 100644 --- a/lending/docs/models/components/connection.md +++ b/lending/docs/models/components/connection.md @@ -11,6 +11,30 @@ Any combination of accounting, banking, and commerce data connections is allowed Before you can use a data connection to pull or push data, the company must grant you access to their business data by [linking the connection](https://docs.codat.io/auth-flow/overview). +## Example Usage + +```typescript +import { Connection, DataConnectionStatus, SourceType } from "@speakeasy-sdks/lending/models/components"; + +let value: Connection = { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: SourceType.Banking, + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: DataConnectionStatus.Linked, + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + dataConnectionErrors: [ + { + erroredOnUtc: "2022-10-23T00:00:00Z", + }, + ], +}; +``` ## Fields diff --git a/lending/docs/models/components/dataconnectionerror.md b/lending/docs/models/components/dataconnectionerror.md index bc0e5cb3..1db8a0ba 100644 --- a/lending/docs/models/components/dataconnectionerror.md +++ b/lending/docs/models/components/dataconnectionerror.md @@ -1,5 +1,14 @@ # DataConnectionError +## Example Usage + +```typescript +import { DataConnectionError } from "@speakeasy-sdks/lending/models/components"; + +let value: DataConnectionError = { + erroredOnUtc: "2022-10-23T00:00:00Z", +}; +``` ## Fields diff --git a/lending/docs/models/components/dataconnectionstatus.md b/lending/docs/models/components/dataconnectionstatus.md index 5d13bea5..f88d20f6 100644 --- a/lending/docs/models/components/dataconnectionstatus.md +++ b/lending/docs/models/components/dataconnectionstatus.md @@ -2,6 +2,13 @@ The current authorization status of the data connection. +## Example Usage + +```typescript +import { DataConnectionStatus } from "@speakeasy-sdks/lending/models/components"; + +let value: DataConnectionStatus = DataConnectionStatus.Linked; +``` ## Values diff --git a/lending/docs/models/components/errorvalidation.md b/lending/docs/models/components/errorvalidation.md index 4497e4ea..7d1d1ef1 100644 --- a/lending/docs/models/components/errorvalidation.md +++ b/lending/docs/models/components/errorvalidation.md @@ -2,6 +2,13 @@ A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. +## Example Usage + +```typescript +import { ErrorValidation } from "@speakeasy-sdks/lending/models/components"; + +let value: ErrorValidation = {}; +``` ## Fields diff --git a/lending/docs/models/components/errorvalidationitem.md b/lending/docs/models/components/errorvalidationitem.md index 257d7818..93766912 100644 --- a/lending/docs/models/components/errorvalidationitem.md +++ b/lending/docs/models/components/errorvalidationitem.md @@ -1,5 +1,12 @@ # ErrorValidationItem +## Example Usage + +```typescript +import { ErrorValidationItem } from "@speakeasy-sdks/lending/models/components"; + +let value: ErrorValidationItem = {}; +``` ## Fields diff --git a/lending/docs/models/components/groupreference.md b/lending/docs/models/components/groupreference.md index 8cf39ba1..a5564ce6 100644 --- a/lending/docs/models/components/groupreference.md +++ b/lending/docs/models/components/groupreference.md @@ -1,5 +1,14 @@ # GroupReference +## Example Usage + +```typescript +import { GroupReference } from "@speakeasy-sdks/lending/models/components"; + +let value: GroupReference = { + id: "60d2fa12-8a04-11ee-b9d1-0242ac120002", +}; +``` ## Fields diff --git a/lending/docs/models/components/halref.md b/lending/docs/models/components/halref.md index a1902370..cf17e41c 100644 --- a/lending/docs/models/components/halref.md +++ b/lending/docs/models/components/halref.md @@ -1,5 +1,12 @@ # HalRef +## Example Usage + +```typescript +import { HalRef } from "@speakeasy-sdks/lending/models/components"; + +let value: HalRef = {}; +``` ## Fields diff --git a/lending/docs/models/components/httpmetadata.md b/lending/docs/models/components/httpmetadata.md index 8ce9328c..c46c8181 100644 --- a/lending/docs/models/components/httpmetadata.md +++ b/lending/docs/models/components/httpmetadata.md @@ -1,5 +1,17 @@ # HTTPMetadata +## Example Usage + +```typescript +import { HTTPMetadata } from "@speakeasy-sdks/lending/models/components"; + +let value: HTTPMetadata = { + response: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), +}; +``` ## Fields diff --git a/lending/docs/models/components/items.md b/lending/docs/models/components/items.md index 0998d985..feb161c9 100644 --- a/lending/docs/models/components/items.md +++ b/lending/docs/models/components/items.md @@ -1,5 +1,14 @@ # Items +## Example Usage + +```typescript +import { Items } from "@speakeasy-sdks/lending/models/components"; + +let value: Items = { + id: "60d2fa12-8a04-11ee-b9d1-0242ac120002", +}; +``` ## Fields diff --git a/lending/docs/models/components/links.md b/lending/docs/models/components/links.md index bfc32b56..72b54d55 100644 --- a/lending/docs/models/components/links.md +++ b/lending/docs/models/components/links.md @@ -1,5 +1,19 @@ # Links +## Example Usage + +```typescript +import { Links } from "@speakeasy-sdks/lending/models/components"; + +let value: Links = { + self: { + href: "/companies", + }, + current: { + href: "/companies?page=1&pageSize=10", + }, +}; +``` ## Fields diff --git a/lending/docs/models/components/security.md b/lending/docs/models/components/security.md index 30160fe1..2026f564 100644 --- a/lending/docs/models/components/security.md +++ b/lending/docs/models/components/security.md @@ -1,5 +1,14 @@ # Security +## Example Usage + +```typescript +import { Security } from "@speakeasy-sdks/lending/models/components"; + +let value: Security = { + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}; +``` ## Fields diff --git a/lending/docs/models/components/sourcetype.md b/lending/docs/models/components/sourcetype.md index 3ddd34f7..f4d1d981 100644 --- a/lending/docs/models/components/sourcetype.md +++ b/lending/docs/models/components/sourcetype.md @@ -2,6 +2,13 @@ The type of platform of the connection. +## Example Usage + +```typescript +import { SourceType } from "@speakeasy-sdks/lending/models/components"; + +let value: SourceType = SourceType.Accounting; +``` ## Values diff --git a/lending/docs/models/errors/errormessage.md b/lending/docs/models/errors/errormessage.md index 14d3faa2..f3923331 100644 --- a/lending/docs/models/errors/errormessage.md +++ b/lending/docs/models/errors/errormessage.md @@ -2,6 +2,13 @@ The request made is not valid. +## Example Usage + +```typescript +import { ErrorMessage } from "@speakeasy-sdks/lending/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/lending/docs/models/operations/createcompanyresponse.md b/lending/docs/models/operations/createcompanyresponse.md index 6e7704ff..2d188883 100644 --- a/lending/docs/models/operations/createcompanyresponse.md +++ b/lending/docs/models/operations/createcompanyresponse.md @@ -1,5 +1,56 @@ # CreateCompanyResponse +## Example Usage + +```typescript +import { DataConnectionStatus, SourceType } from "@speakeasy-sdks/lending/models/components"; +import { CreateCompanyResponse } from "@speakeasy-sdks/lending/models/operations"; + +let value: CreateCompanyResponse = { + httpMeta: { + response: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, + company: { + id: "0498e921-9b53-4396-a412-4f2f5983b0a2", + name: "string", + description: "Requested early access to the new financing scheme.", + platform: "string", + redirect: + "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", + lastSync: "2022-01-01T12:00:00.000Z", + created: "2022-01-01T12:00:00.000Z", + createdByUserName: "string", + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: SourceType.Banking, + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: DataConnectionStatus.Linked, + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + dataConnectionErrors: [ + { + erroredOnUtc: "2022-10-23T00:00:00Z", + }, + ], + }, + ], + groups: [ + { + id: "d7a6c4b4-dc87-45f6-b803-62f466398680", + }, + ], + }, +}; +``` ## Fields diff --git a/lending/docs/models/operations/deletecompanyrequest.md b/lending/docs/models/operations/deletecompanyrequest.md index 98229acf..af84f1d1 100644 --- a/lending/docs/models/operations/deletecompanyrequest.md +++ b/lending/docs/models/operations/deletecompanyrequest.md @@ -1,5 +1,14 @@ # DeleteCompanyRequest +## Example Usage + +```typescript +import { DeleteCompanyRequest } from "@speakeasy-sdks/lending/models/operations"; + +let value: DeleteCompanyRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/lending/docs/models/operations/deletecompanyresponse.md b/lending/docs/models/operations/deletecompanyresponse.md index 3649eef7..26a00d40 100644 --- a/lending/docs/models/operations/deletecompanyresponse.md +++ b/lending/docs/models/operations/deletecompanyresponse.md @@ -1,5 +1,19 @@ # DeleteCompanyResponse +## Example Usage + +```typescript +import { DeleteCompanyResponse } from "@speakeasy-sdks/lending/models/operations"; + +let value: DeleteCompanyResponse = { + httpMeta: { + response: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, +}; +``` ## Fields diff --git a/lending/docs/models/operations/getcompanyrequest.md b/lending/docs/models/operations/getcompanyrequest.md index 7f66ad0c..11d1f3d5 100644 --- a/lending/docs/models/operations/getcompanyrequest.md +++ b/lending/docs/models/operations/getcompanyrequest.md @@ -1,5 +1,14 @@ # GetCompanyRequest +## Example Usage + +```typescript +import { GetCompanyRequest } from "@speakeasy-sdks/lending/models/operations"; + +let value: GetCompanyRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/lending/docs/models/operations/getcompanyresponse.md b/lending/docs/models/operations/getcompanyresponse.md index ce95f1ac..4e211813 100644 --- a/lending/docs/models/operations/getcompanyresponse.md +++ b/lending/docs/models/operations/getcompanyresponse.md @@ -1,5 +1,56 @@ # GetCompanyResponse +## Example Usage + +```typescript +import { DataConnectionStatus, SourceType } from "@speakeasy-sdks/lending/models/components"; +import { GetCompanyResponse } from "@speakeasy-sdks/lending/models/operations"; + +let value: GetCompanyResponse = { + httpMeta: { + response: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, + company: { + id: "0498e921-9b53-4396-a412-4f2f5983b0a2", + name: "string", + description: "Requested early access to the new financing scheme.", + platform: "string", + redirect: + "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", + lastSync: "2022-01-01T12:00:00.000Z", + created: "2022-01-01T12:00:00.000Z", + createdByUserName: "string", + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: SourceType.Banking, + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: DataConnectionStatus.Linked, + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + dataConnectionErrors: [ + { + erroredOnUtc: "2022-10-23T00:00:00Z", + }, + ], + }, + ], + groups: [ + { + id: "d7a6c4b4-dc87-45f6-b803-62f466398680", + }, + ], + }, +}; +``` ## Fields diff --git a/lending/docs/models/operations/listcompaniesrequest.md b/lending/docs/models/operations/listcompaniesrequest.md index fd35ced3..9c5e5863 100644 --- a/lending/docs/models/operations/listcompaniesrequest.md +++ b/lending/docs/models/operations/listcompaniesrequest.md @@ -1,5 +1,17 @@ # ListCompaniesRequest +## Example Usage + +```typescript +import { ListCompaniesRequest } from "@speakeasy-sdks/lending/models/operations"; + +let value: ListCompaniesRequest = { + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + orderBy: "-modifiedDate", +}; +``` ## Fields diff --git a/lending/docs/models/operations/listcompaniesresponse.md b/lending/docs/models/operations/listcompaniesresponse.md index ca7d3b50..73d57226 100644 --- a/lending/docs/models/operations/listcompaniesresponse.md +++ b/lending/docs/models/operations/listcompaniesresponse.md @@ -1,5 +1,71 @@ # ListCompaniesResponse +## Example Usage + +```typescript +import { DataConnectionStatus, SourceType } from "@speakeasy-sdks/lending/models/components"; +import { ListCompaniesResponse } from "@speakeasy-sdks/lending/models/operations"; + +let value: ListCompaniesResponse = { + httpMeta: { + response: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, + companies: { + results: [ + { + id: "0498e921-9b53-4396-a412-4f2f5983b0a2", + name: "string", + description: "Requested early access to the new financing scheme.", + platform: "string", + redirect: + "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", + lastSync: "2022-01-01T12:00:00.000Z", + created: "2022-01-01T12:00:00.000Z", + createdByUserName: "string", + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: SourceType.Banking, + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: DataConnectionStatus.Linked, + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + dataConnectionErrors: [ + { + erroredOnUtc: "2022-10-23T00:00:00Z", + }, + ], + }, + ], + groups: [ + { + id: "d7a6c4b4-dc87-45f6-b803-62f466398680", + }, + ], + }, + ], + pageNumber: 1, + pageSize: 10, + totalResults: 1, + links: { + self: { + href: "/companies/{id}/data/{dataType}", + }, + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + }, + }, +}; +``` ## Fields diff --git a/lending/docs/models/operations/updatecompanyrequest.md b/lending/docs/models/operations/updatecompanyrequest.md index 1d6dee26..01822f7b 100644 --- a/lending/docs/models/operations/updatecompanyrequest.md +++ b/lending/docs/models/operations/updatecompanyrequest.md @@ -1,5 +1,23 @@ # UpdateCompanyRequest +## Example Usage + +```typescript +import { UpdateCompanyRequest } from "@speakeasy-sdks/lending/models/operations"; + +let value: UpdateCompanyRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + companyRequestBody: { + name: "Bank of Dave", + description: "Requested early access to the new financing scheme.", + groups: [ + { + id: "60d2fa12-8a04-11ee-b9d1-0242ac120002", + }, + ], + }, +}; +``` ## Fields diff --git a/lending/docs/models/operations/updatecompanyresponse.md b/lending/docs/models/operations/updatecompanyresponse.md index 31e77619..f6716e78 100644 --- a/lending/docs/models/operations/updatecompanyresponse.md +++ b/lending/docs/models/operations/updatecompanyresponse.md @@ -1,5 +1,56 @@ # UpdateCompanyResponse +## Example Usage + +```typescript +import { DataConnectionStatus, SourceType } from "@speakeasy-sdks/lending/models/components"; +import { UpdateCompanyResponse } from "@speakeasy-sdks/lending/models/operations"; + +let value: UpdateCompanyResponse = { + httpMeta: { + response: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), + request: new Request("https://example.com"), + }, + company: { + id: "0498e921-9b53-4396-a412-4f2f5983b0a2", + name: "string", + description: "Requested early access to the new financing scheme.", + platform: "string", + redirect: + "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", + lastSync: "2022-01-01T12:00:00.000Z", + created: "2022-01-01T12:00:00.000Z", + createdByUserName: "string", + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: SourceType.Banking, + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: DataConnectionStatus.Linked, + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + dataConnectionErrors: [ + { + erroredOnUtc: "2022-10-23T00:00:00Z", + }, + ], + }, + ], + groups: [ + { + id: "d7a6c4b4-dc87-45f6-b803-62f466398680", + }, + ], + }, +}; +``` ## Fields diff --git a/lending/docs/sdks/companies/README.md b/lending/docs/sdks/companies/README.md index bcc3d312..605bd318 100644 --- a/lending/docs/sdks/companies/README.md +++ b/lending/docs/sdks/companies/README.md @@ -31,6 +31,36 @@ const lendingTs = new LendingTs({ async function run() { const result = await lendingTs.companies.list(1, 100, "id=e3334455-1aed-4e71-ab43-6bccf12092ee", "-modifiedDate"); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { LendingTsCore } from "@speakeasy-sdks/lending/core.js"; +import { companiesList } from "@speakeasy-sdks/lending/funcs/companiesList.js"; + +// Use `LendingTsCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const lendingTs = new LendingTsCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await companiesList(lendingTs, 1, 100, "id=e3334455-1aed-4e71-ab43-6bccf12092ee", "-modifiedDate"); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -51,10 +81,10 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.ListCompaniesResponse](../../models/operations/listcompaniesresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | @@ -62,6 +92,7 @@ run(); | errors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | | errors.SDKError | 4xx-5xx | */* | + ## create Use the *Create company* endpoint to create a new [company](https://docs.codat.io/lending-api#/schemas/Company) that represents your customer in Codat. @@ -90,6 +121,44 @@ async function run() { }, ], }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { LendingTsCore } from "@speakeasy-sdks/lending/core.js"; +import { companiesCreate } from "@speakeasy-sdks/lending/funcs/companiesCreate.js"; + +// Use `LendingTsCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const lendingTs = new LendingTsCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await companiesCreate(lendingTs, { + name: "Technicalium", + description: "Requested early access to the new financing scheme.", + groups: [ + { + id: "60d2fa12-8a04-11ee-b9d1-0242ac120002", + }, + ], + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -107,10 +176,10 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.CreateCompanyResponse](../../models/operations/createcompanyresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | @@ -118,6 +187,7 @@ run(); | errors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | | errors.SDKError | 4xx-5xx | */* | + ## update Use the *Update company* endpoint to update both the name and description of the company. @@ -145,6 +215,44 @@ async function run() { }, ], }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { LendingTsCore } from "@speakeasy-sdks/lending/core.js"; +import { companiesUpdate } from "@speakeasy-sdks/lending/funcs/companiesUpdate.js"; + +// Use `LendingTsCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const lendingTs = new LendingTsCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await companiesUpdate(lendingTs, "8a210b68-6988-11ed-a1eb-0242ac120002", { + name: "New Name", + description: "Requested early access to the new financing scheme.", + groups: [ + { + id: "60d2fa12-8a04-11ee-b9d1-0242ac120002", + }, + ], + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -163,10 +271,10 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.UpdateCompanyResponse](../../models/operations/updatecompanyresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | @@ -174,6 +282,7 @@ run(); | errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | | errors.SDKError | 4xx-5xx | */* | + ## delete The *Delete company* endpoint permanently deletes a [company](https://docs.codat.io/lending-api#/schemas/Company), its [connections](https://docs.codat.io/lending-api#/schemas/Connection) and any cached data. This operation is irreversible. @@ -193,6 +302,36 @@ const lendingTs = new LendingTs({ async function run() { const result = await lendingTs.companies.delete("8a210b68-6988-11ed-a1eb-0242ac120002"); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { LendingTsCore } from "@speakeasy-sdks/lending/core.js"; +import { companiesDelete } from "@speakeasy-sdks/lending/funcs/companiesDelete.js"; + +// Use `LendingTsCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const lendingTs = new LendingTsCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await companiesDelete(lendingTs, "8a210b68-6988-11ed-a1eb-0242ac120002"); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -210,10 +349,10 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.DeleteCompanyResponse](../../models/operations/deletecompanyresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | @@ -221,6 +360,7 @@ run(); | errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | | errors.SDKError | 4xx-5xx | */* | + ## get The *Get company* endpoint returns a single company for a given `companyId`. @@ -240,6 +380,36 @@ const lendingTs = new LendingTs({ async function run() { const result = await lendingTs.companies.get("8a210b68-6988-11ed-a1eb-0242ac120002"); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { LendingTsCore } from "@speakeasy-sdks/lending/core.js"; +import { companiesGet } from "@speakeasy-sdks/lending/funcs/companiesGet.js"; + +// Use `LendingTsCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const lendingTs = new LendingTsCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await companiesGet(lendingTs, "8a210b68-6988-11ed-a1eb-0242ac120002"); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -257,10 +427,10 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.GetCompanyResponse](../../models/operations/getcompanyresponse.md)\>** + ### Errors | Error Object | Status Code | Content Type | diff --git a/lending/docs/sdks/lendingts/README.md b/lending/docs/sdks/lendingts/README.md index 6612c5b2..ceb34f40 100644 --- a/lending/docs/sdks/lendingts/README.md +++ b/lending/docs/sdks/lendingts/README.md @@ -1,6 +1,5 @@ # LendingTs SDK - ## Overview Lending API: Our Lending API helps you make smarter credit decisions on small businesses by enabling you to pull your customers' latest data from accounting, banking, and commerce platforms they are already using. It also includes features to help providers verify the accuracy of data and process it more efficiently. @@ -29,7 +28,4 @@ The Lending API is built on top of the latest accounting, commerce, and banking | Manage data | Control how data is retrieved from an integration. | | File upload | Endpoints to manage uploaded files. | | Loan writeback | Implement the [loan writeback](https://docs.codat.io/lending/guides/loan-writeback/introduction) procedure in your lending process to maintain an accurate position of a loan during the entire lending cycle. | - - -### Available Operations - + \ No newline at end of file diff --git a/lending/gen.yaml b/lending/gen.yaml index 15a6effd..33794e8b 100755 --- a/lending/gen.yaml +++ b/lending/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false typescript: - version: 0.2.0 + version: 0.3.0 additionalDependencies: dependencies: {} devDependencies: {} @@ -33,7 +33,9 @@ typescript: inputModelSuffix: input maxMethodParams: 4 methodArguments: require-security-and-request + moduleFormat: commonjs outputModelSuffix: output packageName: '@speakeasy-sdks/lending' responseFormat: envelope-http templateVersion: v2 + useIndexModules: true diff --git a/lending/jsr.json b/lending/jsr.json index b0528d8a..969e9064 100644 --- a/lending/jsr.json +++ b/lending/jsr.json @@ -2,7 +2,7 @@ { "name": "@speakeasy-sdks/lending", - "version": "0.2.0", + "version": "0.3.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/lending/package-lock.json b/lending/package-lock.json index 07dab742..6bc03ed8 100644 --- a/lending/package-lock.json +++ b/lending/package-lock.json @@ -1,14 +1,14 @@ { "name": "@speakeasy-sdks/lending", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@speakeasy-sdks/lending", - "version": "0.2.0", + "version": "0.3.0", "devDependencies": { - "@types/jsonpath": "^0.2.4", + "@types/node": "^18.19.3", "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", "eslint": "^8.57.0", @@ -195,11 +195,15 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, - "node_modules/@types/jsonpath": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@types/jsonpath/-/jsonpath-0.2.4.tgz", - "integrity": "sha512-K3hxB8Blw0qgW6ExKgMbXQv2UPZBoE2GqLpVY+yr7nMD2Pq86lsuIzyAaiQ7eMqFL5B6di6pxSkogLJEyEHoGA==", - "dev": true + "node_modules/@types/node": { + "version": "18.19.50", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.50.tgz", + "integrity": "sha512-xonK+NRrMBRtkL1hVCc3G+uXtjh1Al4opBLjqVmipe5ZAaBYWW6cNAiBVZ1BvmkBhep698rP3UM3aRAdSALuhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.10.0", @@ -2976,6 +2980,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/lending/package.json b/lending/package.json index 6175c201..7b7e0e4b 100644 --- a/lending/package.json +++ b/lending/package.json @@ -1,7 +1,7 @@ { "name": "@speakeasy-sdks/lending", - "version": "0.2.0", - "author": "Speakeasy", + "version": "0.3.0", + "author": "Speakeasy", "main": "./index.js", "sideEffects": false, "repository": { @@ -18,7 +18,7 @@ "zod": ">= 3" }, "devDependencies": { - "@types/jsonpath": "^0.2.4", + "@types/node": "^18.19.3", "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", "eslint": "^8.57.0", diff --git a/lending/src/core.ts b/lending/src/core.ts new file mode 100644 index 00000000..197d2eab --- /dev/null +++ b/lending/src/core.ts @@ -0,0 +1,13 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { ClientSDK } from "./lib/sdks.js"; + +/** + * A minimal client to use when calling standalone SDK functions. Typically, an + * instance of this class would be instantiated once at the start of an + * application and passed around through some dependency injection mechanism to + * parts of an application that need to make SDK calls. + */ +export class LendingTsCore extends ClientSDK {} diff --git a/lending/src/funcs/companiesCreate.ts b/lending/src/funcs/companiesCreate.ts new file mode 100644 index 00000000..e1e78904 --- /dev/null +++ b/lending/src/funcs/companiesCreate.ts @@ -0,0 +1,150 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { LendingTsCore } from "../core.js"; +import { encodeJSON as encodeJSON$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Create company + * + * @remarks + * Use the *Create company* endpoint to create a new [company](https://docs.codat.io/lending-api#/schemas/Company) that represents your customer in Codat. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + * + * If forbidden characters (see `name` pattern) are present in the request, a company will be created with the forbidden characters removed. For example, `Company (Codat[1])` with be created as `Company Codat1`. + */ +export async function companiesCreate( + client$: LendingTsCore, + request?: components.CompanyRequestBody | undefined, + options?: RequestOptions, +): Promise< + Result< + operations.CreateCompanyResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$ = request; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => + components.CompanyRequestBody$outboundSchema.optional().parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = payload$ === undefined + ? null + : encodeJSON$("body", payload$, { explode: true }); + + const path$ = pathToFunc("/companies")(); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "create-company", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + HttpMeta: { Response: response, Request: request$ }, + }; + + const [result$] = await m$.match< + operations.CreateCompanyResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.CreateCompanyResponse$inboundSchema, { + key: "Company", + }), + m$.jsonErr( + [400, 401, 402, 403, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + m$.fail(["4XX", "5XX"]), + )(response, request$, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/lending/src/funcs/companiesDelete.ts b/lending/src/funcs/companiesDelete.ts new file mode 100644 index 00000000..504a1e52 --- /dev/null +++ b/lending/src/funcs/companiesDelete.ts @@ -0,0 +1,150 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { LendingTsCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Delete a company + * + * @remarks + * The *Delete company* endpoint permanently deletes a [company](https://docs.codat.io/lending-api#/schemas/Company), its [connections](https://docs.codat.io/lending-api#/schemas/Connection) and any cached data. This operation is irreversible. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + */ +export async function companiesDelete( + client$: LendingTsCore, + companyId: string, + options?: RequestOptions, +): Promise< + Result< + operations.DeleteCompanyResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.DeleteCompanyRequest = { + companyId: companyId, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.DeleteCompanyRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc("/companies/{companyId}")(pathParams$); + + const headers$ = new Headers({ + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "delete-company", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "DELETE", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + HttpMeta: { Response: response, Request: request$ }, + }; + + const [result$] = await m$.match< + operations.DeleteCompanyResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.nil(204, operations.DeleteCompanyResponse$inboundSchema), + m$.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + m$.fail(["4XX", "5XX"]), + )(response, request$, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/lending/src/funcs/companiesGet.ts b/lending/src/funcs/companiesGet.ts new file mode 100644 index 00000000..6edeb326 --- /dev/null +++ b/lending/src/funcs/companiesGet.ts @@ -0,0 +1,152 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { LendingTsCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Get company + * + * @remarks + * The *Get company* endpoint returns a single company for a given `companyId`. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + */ +export async function companiesGet( + client$: LendingTsCore, + companyId: string, + options?: RequestOptions, +): Promise< + Result< + operations.GetCompanyResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.GetCompanyRequest = { + companyId: companyId, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.GetCompanyRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc("/companies/{companyId}")(pathParams$); + + const headers$ = new Headers({ + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "get-company", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + HttpMeta: { Response: response, Request: request$ }, + }; + + const [result$] = await m$.match< + operations.GetCompanyResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.GetCompanyResponse$inboundSchema, { + key: "Company", + }), + m$.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + m$.fail(["4XX", "5XX"]), + )(response, request$, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/lending/src/funcs/companiesList.ts b/lending/src/funcs/companiesList.ts new file mode 100644 index 00000000..112d0d32 --- /dev/null +++ b/lending/src/funcs/companiesList.ts @@ -0,0 +1,170 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { LendingTsCore } from "../core.js"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * List companies + * + * @remarks + * The *List companies* endpoint returns a list of [companies] associated to your instances. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + */ +export async function companiesList( + client$: LendingTsCore, + page?: number | undefined, + pageSize?: number | undefined, + query?: string | undefined, + orderBy?: string | undefined, + options?: RequestOptions, +): Promise< + Result< + operations.ListCompaniesResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.ListCompaniesRequest = { + page: page, + pageSize: pageSize, + query: query, + orderBy: orderBy, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.ListCompaniesRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const path$ = pathToFunc("/companies")(); + + const query$ = encodeFormQuery$({ + "orderBy": payload$.orderBy, + "page": payload$.page, + "pageSize": payload$.pageSize, + "query": payload$.query, + }); + + const headers$ = new Headers({ + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "list-companies", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + query: query$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: [ + "400", + "401", + "402", + "403", + "404", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + HttpMeta: { Response: response, Request: request$ }, + }; + + const [result$] = await m$.match< + operations.ListCompaniesResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.ListCompaniesResponse$inboundSchema, { + key: "Companies", + }), + m$.jsonErr( + [400, 401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + m$.fail(["4XX", "5XX"]), + )(response, request$, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/lending/src/funcs/companiesUpdate.ts b/lending/src/funcs/companiesUpdate.ts new file mode 100644 index 00000000..12ca81af --- /dev/null +++ b/lending/src/funcs/companiesUpdate.ts @@ -0,0 +1,162 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { LendingTsCore } from "../core.js"; +import { + encodeJSON as encodeJSON$, + encodeSimple as encodeSimple$, +} from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Update company + * + * @remarks + * Use the *Update company* endpoint to update both the name and description of the company. + * If you use [groups](https://docs.codat.io/lending-api#/schemas/Group) to manage a set of companies, use the [Add company](https://docs.codat.io/lending-api#/operations/add-company-to-group) or [Remove company](https://docs.codat.io/lending-api#/operations/remove-company-from-group) endpoints to add or remove a company from a group. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + */ +export async function companiesUpdate( + client$: LendingTsCore, + companyId: string, + companyRequestBody?: components.CompanyRequestBody | undefined, + options?: RequestOptions, +): Promise< + Result< + operations.UpdateCompanyResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.UpdateCompanyRequest = { + companyId: companyId, + companyRequestBody: companyRequestBody, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.UpdateCompanyRequest$outboundSchema.parse(value$), + "Input validation failed", + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$.CompanyRequestBody, { + explode: true, + }); + + const pathParams$ = { + companyId: encodeSimple$("companyId", payload$.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path$ = pathToFunc("/companies/{companyId}")(pathParams$); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const authHeader$ = await extractSecurity(client$.options$.authHeader); + const security$ = authHeader$ == null ? {} : { authHeader: authHeader$ }; + const context = { + operationID: "update-company", + oAuth2Scopes: [], + securitySource: client$.options$.authHeader, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$(context, { + security: securitySettings$, + method: "PUT", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: options?.retries + || client$.options$.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + HttpMeta: { Response: response, Request: request$ }, + }; + + const [result$] = await m$.match< + operations.UpdateCompanyResponse, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.UpdateCompanyResponse$inboundSchema, { + key: "Company", + }), + m$.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + m$.fail(["4XX", "5XX"]), + )(response, request$, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/lending/src/hooks/hooks.ts b/lending/src/hooks/hooks.ts index 8a3db0da..d1b3396f 100644 --- a/lending/src/hooks/hooks.ts +++ b/lending/src/hooks/hooks.ts @@ -1,103 +1,112 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { RequestInput } from "../lib/http"; +import { RequestInput } from "../lib/http.js"; import { - AfterErrorContext, - AfterErrorHook, - AfterSuccessContext, - AfterSuccessHook, - BeforeRequestContext, - BeforeRequestHook, - BeforeCreateRequestHook, - BeforeCreateRequestContext, - Hooks, - SDKInitHook, - SDKInitOptions, -} from "./types"; - -import { initHooks } from "./registration"; + AfterErrorContext, + AfterErrorHook, + AfterSuccessContext, + AfterSuccessHook, + BeforeCreateRequestContext, + BeforeCreateRequestHook, + BeforeRequestContext, + BeforeRequestHook, + Hooks, + SDKInitHook, + SDKInitOptions, +} from "./types.js"; + +import { initHooks } from "./registration.js"; export class SDKHooks implements Hooks { - sdkInitHooks: SDKInitHook[] = []; - beforeCreateRequestHooks: BeforeCreateRequestHook[] = []; - beforeRequestHooks: BeforeRequestHook[] = []; - afterSuccessHooks: AfterSuccessHook[] = []; - afterErrorHooks: AfterErrorHook[] = []; - - constructor() { - initHooks(this); + sdkInitHooks: SDKInitHook[] = []; + beforeCreateRequestHooks: BeforeCreateRequestHook[] = []; + beforeRequestHooks: BeforeRequestHook[] = []; + afterSuccessHooks: AfterSuccessHook[] = []; + afterErrorHooks: AfterErrorHook[] = []; + + constructor() { + initHooks(this); + } + + registerSDKInitHook(hook: SDKInitHook) { + this.sdkInitHooks.push(hook); + } + + registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook) { + this.beforeCreateRequestHooks.push(hook); + } + + registerBeforeRequestHook(hook: BeforeRequestHook) { + this.beforeRequestHooks.push(hook); + } + + registerAfterSuccessHook(hook: AfterSuccessHook) { + this.afterSuccessHooks.push(hook); + } + + registerAfterErrorHook(hook: AfterErrorHook) { + this.afterErrorHooks.push(hook); + } + + sdkInit(opts: SDKInitOptions): SDKInitOptions { + return this.sdkInitHooks.reduce((opts, hook) => hook.sdkInit(opts), opts); + } + + beforeCreateRequest( + hookCtx: BeforeCreateRequestContext, + input: RequestInput, + ): RequestInput { + let inp = input; + + for (const hook of this.beforeCreateRequestHooks) { + inp = hook.beforeCreateRequest(hookCtx, inp); } - registerSDKInitHook(hook: SDKInitHook) { - this.sdkInitHooks.push(hook); - } + return inp; + } - registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook) { - this.beforeCreateRequestHooks.push(hook); - } + async beforeRequest( + hookCtx: BeforeRequestContext, + request: Request, + ): Promise { + let req = request; - registerBeforeRequestHook(hook: BeforeRequestHook) { - this.beforeRequestHooks.push(hook); + for (const hook of this.beforeRequestHooks) { + req = await hook.beforeRequest(hookCtx, req); } - registerAfterSuccessHook(hook: AfterSuccessHook) { - this.afterSuccessHooks.push(hook); - } + return req; + } - registerAfterErrorHook(hook: AfterErrorHook) { - this.afterErrorHooks.push(hook); - } + async afterSuccess( + hookCtx: AfterSuccessContext, + response: Response, + ): Promise { + let res = response; - sdkInit(opts: SDKInitOptions): SDKInitOptions { - return this.sdkInitHooks.reduce((opts, hook) => hook.sdkInit(opts), opts); + for (const hook of this.afterSuccessHooks) { + res = await hook.afterSuccess(hookCtx, res); } - beforeCreateRequest(hookCtx: BeforeCreateRequestContext, input: RequestInput): RequestInput { - let inp = input; - - for (const hook of this.beforeCreateRequestHooks) { - inp = hook.beforeCreateRequest(hookCtx, inp); - } - - return inp; + return res; + } + + async afterError( + hookCtx: AfterErrorContext, + response: Response | null, + error: unknown, + ): Promise<{ response: Response | null; error: unknown }> { + let res = response; + let err = error; + + for (const hook of this.afterErrorHooks) { + const result = await hook.afterError(hookCtx, res, err); + res = result.response; + err = result.error; } - async beforeRequest(hookCtx: BeforeRequestContext, request: Request): Promise { - let req = request; - - for (const hook of this.beforeRequestHooks) { - req = await hook.beforeRequest(hookCtx, req); - } - - return req; - } - - async afterSuccess(hookCtx: AfterSuccessContext, response: Response): Promise { - let res = response; - - for (const hook of this.afterSuccessHooks) { - res = await hook.afterSuccess(hookCtx, res); - } - - return res; - } - - async afterError( - hookCtx: AfterErrorContext, - response: Response | null, - error: unknown - ): Promise<{ response: Response | null; error: unknown }> { - let res = response; - let err = error; - - for (const hook of this.afterErrorHooks) { - const result = await hook.afterError(hookCtx, res, err); - res = result.response; - err = result.error; - } - - return { response: res, error: err }; - } + return { response: res, error: err }; + } } diff --git a/lending/src/hooks/index.ts b/lending/src/hooks/index.ts index 3df03930..f60ec7ac 100644 --- a/lending/src/hooks/index.ts +++ b/lending/src/hooks/index.ts @@ -1,6 +1,6 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./types"; -export * from "./hooks"; +export * from "./hooks.js"; +export * from "./types.js"; diff --git a/lending/src/hooks/types.ts b/lending/src/hooks/types.ts index a5b367a8..656b9e37 100644 --- a/lending/src/hooks/types.ts +++ b/lending/src/hooks/types.ts @@ -1,20 +1,20 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { HTTPClient, RequestInput } from "../lib/http"; +import { HTTPClient, RequestInput } from "../lib/http.js"; export type HookContext = { - operationID: string; - oAuth2Scopes?: string[]; - securitySource?: any | (() => Promise); + operationID: string; + oAuth2Scopes?: string[]; + securitySource?: any | (() => Promise); }; export type Awaitable = T | Promise; export type SDKInitOptions = { - baseURL: URL | null; - client: HTTPClient; + baseURL: URL | null; + client: HTTPClient; }; export type BeforeCreateRequestContext = HookContext & {}; @@ -27,63 +27,72 @@ export type AfterErrorContext = HookContext & {}; * hook can return a new baseURL and HTTP client to be used by the SDK. */ export interface SDKInitHook { - sdkInit: (opts: SDKInitOptions) => SDKInitOptions; + sdkInit: (opts: SDKInitOptions) => SDKInitOptions; } export interface BeforeCreateRequestHook { - /** - * A hook that is called before the SDK creates a `Request` object. The hook - * can modify how a request is constructed since certain modifications, like - * changing the request URL, cannot be done on a request object directly. - */ - beforeCreateRequest: (hookCtx: BeforeCreateRequestContext, input: RequestInput) => RequestInput; + /** + * A hook that is called before the SDK creates a `Request` object. The hook + * can modify how a request is constructed since certain modifications, like + * changing the request URL, cannot be done on a request object directly. + */ + beforeCreateRequest: ( + hookCtx: BeforeCreateRequestContext, + input: RequestInput, + ) => RequestInput; } export interface BeforeRequestHook { - /** - * A hook that is called before the SDK sends a request. The hook can - * introduce instrumentation code such as logging, tracing and metrics or - * replace the request before it is sent or throw an error to stop the - * request from being sent. - */ - beforeRequest: (hookCtx: BeforeRequestContext, request: Request) => Awaitable; + /** + * A hook that is called before the SDK sends a request. The hook can + * introduce instrumentation code such as logging, tracing and metrics or + * replace the request before it is sent or throw an error to stop the + * request from being sent. + */ + beforeRequest: ( + hookCtx: BeforeRequestContext, + request: Request, + ) => Awaitable; } export interface AfterSuccessHook { - /** - * A hook that is called after the SDK receives a response. The hook can - * introduce instrumentation code such as logging, tracing and metrics or - * modify the response before it is handled or throw an error to stop the - * response from being handled. - */ - afterSuccess: (hookCtx: AfterSuccessContext, response: Response) => Awaitable; + /** + * A hook that is called after the SDK receives a response. The hook can + * introduce instrumentation code such as logging, tracing and metrics or + * modify the response before it is handled or throw an error to stop the + * response from being handled. + */ + afterSuccess: ( + hookCtx: AfterSuccessContext, + response: Response, + ) => Awaitable; } export interface AfterErrorHook { - /** - * A hook that is called after the SDK encounters an error, or a - * non-successful response. The hook can introduce instrumentation code such - * as logging, tracing and metrics or modify the response or error values. - */ - afterError: ( - hookCtx: AfterErrorContext, - response: Response | null, - error: unknown - ) => Awaitable<{ - response: Response | null; - error: unknown; - }>; + /** + * A hook that is called after the SDK encounters an error, or a + * non-successful response. The hook can introduce instrumentation code such + * as logging, tracing and metrics or modify the response or error values. + */ + afterError: ( + hookCtx: AfterErrorContext, + response: Response | null, + error: unknown, + ) => Awaitable<{ + response: Response | null; + error: unknown; + }>; } export interface Hooks { - /** Registers a hook to be used by the SDK for initialization event. */ - registerSDKInitHook(hook: SDKInitHook): void; - /** Registers a hook to be used by the SDK for to modify `Request` construction. */ - registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; - /** Registers a hook to be used by the SDK for the before request event. */ - registerBeforeRequestHook(hook: BeforeRequestHook): void; - /** Registers a hook to be used by the SDK for the after success event. */ - registerAfterSuccessHook(hook: AfterSuccessHook): void; - /** Registers a hook to be used by the SDK for the after error event. */ - registerAfterErrorHook(hook: AfterErrorHook): void; + /** Registers a hook to be used by the SDK for initialization event. */ + registerSDKInitHook(hook: SDKInitHook): void; + /** Registers a hook to be used by the SDK for to modify `Request` construction. */ + registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; + /** Registers a hook to be used by the SDK for the before request event. */ + registerBeforeRequestHook(hook: BeforeRequestHook): void; + /** Registers a hook to be used by the SDK for the after success event. */ + registerAfterSuccessHook(hook: AfterSuccessHook): void; + /** Registers a hook to be used by the SDK for the after error event. */ + registerAfterErrorHook(hook: AfterErrorHook): void; } diff --git a/lending/src/index.ts b/lending/src/index.ts index 32044eba..5ddc765e 100644 --- a/lending/src/index.ts +++ b/lending/src/index.ts @@ -1,6 +1,7 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./sdk"; -export * from "./lib/config"; +export * from "./lib/config.js"; +export * as files from "./lib/files.js"; +export * from "./sdk/sdk.js"; diff --git a/lending/src/lib/base64.ts b/lending/src/lib/base64.ts index cda07641..c2d5b389 100644 --- a/lending/src/lib/base64.ts +++ b/lending/src/lib/base64.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/lending/src/lib/config.ts b/lending/src/lib/config.ts index 133925d9..d24f5d70 100644 --- a/lending/src/lib/config.ts +++ b/lending/src/lib/config.ts @@ -1,60 +1,64 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { HTTPClient } from "./http"; -import { RetryConfig } from "./retries"; -import { Params, pathToFunc } from "./url"; +import { HTTPClient } from "./http.js"; +import { Logger } from "./logger.js"; +import { RetryConfig } from "./retries.js"; +import { Params, pathToFunc } from "./url.js"; /** * Contains the list of servers available to the SDK */ export const ServerList = [ - /** - * Production - */ - "https://api.codat.io", + /** + * Production + */ + "https://api.codat.io", ] as const; export type SDKOptions = { - authHeader?: string | (() => Promise); - - httpClient?: HTTPClient; - /** - * Allows overriding the default server used by the SDK - */ - serverIdx?: number; - /** - * Allows overriding the default server URL used by the SDK - */ - serverURL?: string; - /** - * Allows overriding the default retry config used by the SDK - */ - retryConfig?: RetryConfig; + authHeader?: string | (() => Promise); + + httpClient?: HTTPClient; + /** + * Allows overriding the default server used by the SDK + */ + serverIdx?: number; + /** + * Allows overriding the default server URL used by the SDK + */ + serverURL?: string; + /** + * Allows overriding the default retry config used by the SDK + */ + retryConfig?: RetryConfig; + timeoutMs?: number; + debugLogger?: Logger; }; export function serverURLFromOptions(options: SDKOptions): URL | null { - let serverURL = options.serverURL; + let serverURL = options.serverURL; - const params: Params = {}; + const params: Params = {}; - if (!serverURL) { - const serverIdx = options.serverIdx ?? 0; - if (serverIdx < 0 || serverIdx >= ServerList.length) { - throw new Error(`Invalid server index ${serverIdx}`); - } - serverURL = ServerList[serverIdx] || ""; + if (!serverURL) { + const serverIdx = options.serverIdx ?? 0; + if (serverIdx < 0 || serverIdx >= ServerList.length) { + throw new Error(`Invalid server index ${serverIdx}`); } + serverURL = ServerList[serverIdx] || ""; + } - const u = pathToFunc(serverURL)(params); - return new URL(u); + const u = pathToFunc(serverURL)(params); + return new URL(u); } export const SDK_METADATA = { - language: "typescript", - openapiDocVersion: "3.0.0", - sdkVersion: "0.2.0", - genVersion: "2.338.1", - userAgent: "speakeasy-sdk/typescript 0.2.0 2.338.1 3.0.0 @speakeasy-sdks/lending", + language: "typescript", + openapiDocVersion: "3.0.0", + sdkVersion: "0.3.0", + genVersion: "2.415.0", + userAgent: + "speakeasy-sdk/typescript 0.3.0 2.415.0 3.0.0 @speakeasy-sdks/lending", } as const; diff --git a/lending/src/lib/dlv.ts b/lending/src/lib/dlv.ts new file mode 100644 index 00000000..e81091f5 --- /dev/null +++ b/lending/src/lib/dlv.ts @@ -0,0 +1,53 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/* +MIT License + +Copyright (c) 2024 Jason Miller (http://jasonformat.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +/** + * @param obj The object to walk + * @param key The key path to walk the object with + * @param def A default value to return if the result is undefined + * + * @example + * dlv(obj, "a.b.c.d") + * @example + * dlv(object, ["a", "b", "c", "d"]) + * @example + * dlv(object, "foo.bar.baz", "Hello, default value!") + */ +export function dlv( + obj: any, + key: string | string[], + def?: T, + p?: number, + undef?: never, +): T | undefined { + key = Array.isArray(key) ? key : key.split("."); + for (p = 0; p < key.length; p++) { + const k = key[p]; + obj = k != null && obj ? obj[k] : undef; + } + return obj === undef ? def : obj; +} diff --git a/lending/src/lib/encodings.ts b/lending/src/lib/encodings.ts index 8cd50f68..44fa7284 100644 --- a/lending/src/lib/encodings.ts +++ b/lending/src/lib/encodings.ts @@ -1,9 +1,9 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { bytesToBase64 } from "./base64"; -import { isPlainObject } from "./is-plain-object"; +import { bytesToBase64 } from "./base64.js"; +import { isPlainObject } from "./is-plain-object.js"; export class EncodingError extends Error { constructor(message: string) { @@ -212,6 +212,24 @@ export function encodeDeepObject( return ""; } + if (!isPlainObject(value)) { + throw new EncodingError( + `Value of parameter '${key}' which uses deepObject encoding must be an object`, + ); + } + + return encodeDeepObjectObject(key, value, options); +} + +export function encodeDeepObjectObject( + key: string, + value: unknown, + options?: { charEncoding?: "percent" | "none" }, +): string { + if (value == null) { + return ""; + } + let out = ""; const encodeString = (v: string) => { @@ -219,9 +237,7 @@ export function encodeDeepObject( }; if (!isPlainObject(value)) { - throw new EncodingError( - `Value of parameter '${key}' which uses deepObject encoding must be an object`, - ); + throw new EncodingError(`Expected parameter '${key}' to be an object.`); } Object.entries(value).forEach(([ck, cv]) => { @@ -232,9 +248,11 @@ export function encodeDeepObject( const pk = `${key}[${ck}]`; if (isPlainObject(cv)) { - throw new EncodingError( - `Value of parameter field '${pk}' cannot be an array or object.`, - ); + const objOut = encodeDeepObjectObject(pk, cv, options); + + out += `&${objOut}`; + + return; } const pairs: unknown[] = Array.isArray(cv) ? cv : [cv]; @@ -383,3 +401,49 @@ function mapDefinedEntries( return acc; } + +export function queryJoin(...args: string[]): string { + return args.filter(Boolean).join("&"); +} + +type QueryEncoderOptions = { + explode?: boolean; + charEncoding?: "percent" | "none"; +}; + +type QueryEncoder = ( + key: string, + value: unknown, + options?: QueryEncoderOptions, +) => string; + +type BulkQueryEncoder = ( + values: Record, + options?: QueryEncoderOptions, +) => string; + +export function queryEncoder(f: QueryEncoder): BulkQueryEncoder { + const bulkEncode = function ( + values: Record, + options?: QueryEncoderOptions, + ): string { + const opts: QueryEncoderOptions = { + ...options, + explode: options?.explode ?? true, + charEncoding: options?.charEncoding ?? "percent", + }; + + const encoded = Object.entries(values).map(([key, value]) => { + return f(key, value, opts); + }); + return queryJoin(...encoded); + }; + + return bulkEncode; +} + +export const encodeJSONQuery = queryEncoder(encodeJSON); +export const encodeFormQuery = queryEncoder(encodeForm); +export const encodeSpaceDelimitedQuery = queryEncoder(encodeSpaceDelimited); +export const encodePipeDelimitedQuery = queryEncoder(encodePipeDelimited); +export const encodeDeepObjectQuery = queryEncoder(encodeDeepObject); diff --git a/lending/src/lib/files.ts b/lending/src/lib/files.ts new file mode 100644 index 00000000..19e08041 --- /dev/null +++ b/lending/src/lib/files.ts @@ -0,0 +1,40 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * Consumes a stream and returns a concatenated array buffer. Useful in + * situations where we need to read the whole file because it forms part of a + * larger payload containing other fields, and we can't modify the underlying + * request structure. + */ +export async function readableStreamToArrayBuffer( + readable: ReadableStream, +): Promise { + const reader = readable.getReader(); + const chunks: Uint8Array[] = []; + + let totalLength = 0; + let done = false; + + while (!done) { + const { value, done: doneReading } = await reader.read(); + + if (doneReading) { + done = true; + } else { + chunks.push(value); + totalLength += value.length; + } + } + + const concatenatedChunks = new Uint8Array(totalLength); + let offset = 0; + + for (const chunk of chunks) { + concatenatedChunks.set(chunk, offset); + offset += chunk.length; + } + + return concatenatedChunks.buffer; +} diff --git a/lending/src/lib/http.ts b/lending/src/lib/http.ts index 04d111fd..13cf1fd7 100644 --- a/lending/src/lib/http.ts +++ b/lending/src/lib/http.ts @@ -1,41 +1,39 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { never as znever } from "zod"; -import { parse } from "./schemas"; -import { isPlainObject } from "./is-plain-object"; -import * as errors from "../models/errors"; - -export type Fetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise; +export type Fetcher = ( + input: RequestInfo | URL, + init?: RequestInit, +) => Promise; export type Awaitable = T | Promise; const DEFAULT_FETCHER: Fetcher = (input, init) => { - // If input is a Request and init is undefined, Bun will discard the method, - // headers, body and other options that were set on the request object. - // Node.js and browers would ignore an undefined init value. This check is - // therefore needed for interop with Bun. - if (init == null) { - return fetch(input); - } else { - return fetch(input, init); - } + // If input is a Request and init is undefined, Bun will discard the method, + // headers, body and other options that were set on the request object. + // Node.js and browers would ignore an undefined init value. This check is + // therefore needed for interop with Bun. + if (init == null) { + return fetch(input); + } else { + return fetch(input, init); + } }; export type RequestInput = { - /** - * The URL the request will use. - */ - url: URL; - /** - * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). - */ - options?: RequestInit | undefined; + /** + * The URL the request will use. + */ + url: URL; + /** + * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). + */ + options?: RequestInit | undefined; }; export interface HTTPClientOptions { - fetcher?: Fetcher; + fetcher?: Fetcher; } export type BeforeRequestHook = (req: Request) => Awaitable; @@ -43,114 +41,114 @@ export type RequestErrorHook = (err: unknown, req: Request) => Awaitable; export type ResponseHook = (res: Response, req: Request) => Awaitable; export class HTTPClient { - private fetcher: Fetcher; - private requestHooks: BeforeRequestHook[] = []; - private requestErrorHooks: RequestErrorHook[] = []; - private responseHooks: ResponseHook[] = []; - - constructor(private options: HTTPClientOptions = {}) { - this.fetcher = options.fetcher || DEFAULT_FETCHER; + private fetcher: Fetcher; + private requestHooks: BeforeRequestHook[] = []; + private requestErrorHooks: RequestErrorHook[] = []; + private responseHooks: ResponseHook[] = []; + + constructor(private options: HTTPClientOptions = {}) { + this.fetcher = options.fetcher || DEFAULT_FETCHER; + } + + async request(request: Request): Promise { + let req = request; + for (const hook of this.requestHooks) { + const nextRequest = await hook(req); + if (nextRequest) { + req = nextRequest; + } } - async request(request: Request): Promise { - let req = request; - for (const hook of this.requestHooks) { - const nextRequest = await hook(req); - if (nextRequest) { - req = nextRequest; - } - } - - try { - const res = await this.fetcher(req); - - for (const hook of this.responseHooks) { - await hook(res, req); - } - - return res; - } catch (err) { - for (const hook of this.requestErrorHooks) { - await hook(err, req); - } - - throw err; - } - } + try { + const res = await this.fetcher(req); + + for (const hook of this.responseHooks) { + await hook(res, req); + } + + return res; + } catch (err) { + for (const hook of this.requestErrorHooks) { + await hook(err, req); + } - /** - * Registers a hook that is called before a request is made. The hook function - * can mutate the request or return a new request. This may be useful to add - * additional information to request such as request IDs and tracing headers. - */ - addHook(hook: "beforeRequest", fn: BeforeRequestHook): this; - /** - * Registers a hook that is called when a request cannot be made due to a - * network error. - */ - addHook(hook: "requestError", fn: RequestErrorHook): this; - /** - * Registers a hook that is called when a response has been received from the - * server. - */ - addHook(hook: "response", fn: ResponseHook): this; - addHook( - ...args: - | [hook: "beforeRequest", fn: BeforeRequestHook] - | [hook: "requestError", fn: RequestErrorHook] - | [hook: "response", fn: ResponseHook] - ) { - if (args[0] === "beforeRequest") { - this.requestHooks.push(args[1]); - } else if (args[0] === "requestError") { - this.requestErrorHooks.push(args[1]); - } else if (args[0] === "response") { - this.responseHooks.push(args[1]); - } else { - throw new Error(`Invalid hook type: ${args[0]}`); - } - return this; + throw err; + } + } + + /** + * Registers a hook that is called before a request is made. The hook function + * can mutate the request or return a new request. This may be useful to add + * additional information to request such as request IDs and tracing headers. + */ + addHook(hook: "beforeRequest", fn: BeforeRequestHook): this; + /** + * Registers a hook that is called when a request cannot be made due to a + * network error. + */ + addHook(hook: "requestError", fn: RequestErrorHook): this; + /** + * Registers a hook that is called when a response has been received from the + * server. + */ + addHook(hook: "response", fn: ResponseHook): this; + addHook( + ...args: + | [hook: "beforeRequest", fn: BeforeRequestHook] + | [hook: "requestError", fn: RequestErrorHook] + | [hook: "response", fn: ResponseHook] + ) { + if (args[0] === "beforeRequest") { + this.requestHooks.push(args[1]); + } else if (args[0] === "requestError") { + this.requestErrorHooks.push(args[1]); + } else if (args[0] === "response") { + this.responseHooks.push(args[1]); + } else { + throw new Error(`Invalid hook type: ${args[0]}`); + } + return this; + } + + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this; + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "requestError", fn: RequestErrorHook): this; + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "response", fn: ResponseHook): this; + removeHook( + ...args: + | [hook: "beforeRequest", fn: BeforeRequestHook] + | [hook: "requestError", fn: RequestErrorHook] + | [hook: "response", fn: ResponseHook] + ): this { + let target: unknown[]; + if (args[0] === "beforeRequest") { + target = this.requestHooks; + } else if (args[0] === "requestError") { + target = this.requestErrorHooks; + } else if (args[0] === "response") { + target = this.responseHooks; + } else { + throw new Error(`Invalid hook type: ${args[0]}`); } - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this; - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "requestError", fn: RequestErrorHook): this; - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "response", fn: ResponseHook): this; - removeHook( - ...args: - | [hook: "beforeRequest", fn: BeforeRequestHook] - | [hook: "requestError", fn: RequestErrorHook] - | [hook: "response", fn: ResponseHook] - ): this { - let target: unknown[]; - if (args[0] === "beforeRequest") { - target = this.requestHooks; - } else if (args[0] === "requestError") { - target = this.requestErrorHooks; - } else if (args[0] === "response") { - target = this.responseHooks; - } else { - throw new Error(`Invalid hook type: ${args[0]}`); - } - - const index = target.findIndex((v) => v === args[1]); - if (index >= 0) { - target.splice(index, 1); - } - - return this; + const index = target.findIndex((v) => v === args[1]); + if (index >= 0) { + target.splice(index, 1); } - clone(): HTTPClient { - const child = new HTTPClient(this.options); - child.requestHooks = this.requestHooks.slice(); - child.requestErrorHooks = this.requestErrorHooks.slice(); - child.responseHooks = this.responseHooks.slice(); + return this; + } - return child; - } + clone(): HTTPClient { + const child = new HTTPClient(this.options); + child.requestHooks = this.requestHooks.slice(); + child.requestErrorHooks = this.requestErrorHooks.slice(); + child.responseHooks = this.responseHooks.slice(); + + return child; + } } export type StatusCodePredicate = number | string | (number | string)[]; @@ -159,344 +157,167 @@ export type StatusCodePredicate = number | string | (number | string)[]; // segments in a media type string. const mediaParamSeparator = /\s*;\s*/g; -function matchContentType(response: Response, pattern: string): boolean { - // `*` is a special case which means anything is acceptable. - if (pattern === "*") { - return true; +export function matchContentType(response: Response, pattern: string): boolean { + // `*` is a special case which means anything is acceptable. + if (pattern === "*") { + return true; + } + + let contentType = + response.headers.get("content-type")?.trim() || "application/octet-stream"; + contentType = contentType.toLowerCase(); + + const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); + const [wantType = "", ...wantParams] = wantParts; + + if (wantType.split("/").length !== 2) { + return false; + } + + const gotParts = contentType.split(mediaParamSeparator); + const [gotType = "", ...gotParams] = gotParts; + + const [type = "", subtype = ""] = gotType.split("/"); + if (!type || !subtype) { + return false; + } + + if ( + wantType !== "*/*" && + gotType !== wantType && + `${type}/*` !== wantType && + `*/${subtype}` !== wantType + ) { + return false; + } + + if (gotParams.length < wantParams.length) { + return false; + } + + const params = new Set(gotParams); + for (const wantParam of wantParams) { + if (!params.has(wantParam)) { + return false; } + } - let contentType = response.headers.get("content-type")?.trim() || "application/octet-stream"; - contentType = contentType.toLowerCase(); + return true; +} - const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); - const [wantType = "", ...wantParams] = wantParts; +const codeRangeRE = new RegExp("^[0-9]xx$", "i"); - if (wantType.split("/").length !== 2) { - return false; - } +export function matchStatusCode( + response: Response, + codes: StatusCodePredicate, +): boolean { + const actual = `${response.status}`; + const expectedCodes = Array.isArray(codes) ? codes : [codes]; + if (!expectedCodes.length) { + return false; + } - const gotParts = contentType.split(mediaParamSeparator); - const [gotType = "", ...gotParams] = gotParts; + return expectedCodes.some((ec) => { + const code = `${ec}`; - const [type = "", subtype = ""] = gotType.split("/"); - if (!type || !subtype) { - return false; + if (code === "default") { + return true; } - if ( - wantType !== "*/*" && - gotType !== wantType && - `${type}/*` !== wantType && - `*/${subtype}` !== wantType - ) { - return false; + if (!codeRangeRE.test(`${code}`)) { + return code === actual; } - if (gotParams.length < wantParams.length) { - return false; + const expectFamily = code.charAt(0); + if (!expectFamily) { + throw new Error("Invalid status code range"); } - const params = new Set(gotParams); - for (const wantParam of wantParams) { - if (!params.has(wantParam)) { - return false; - } + const actualFamily = actual.charAt(0); + if (!actualFamily) { + throw new Error(`Invalid response status code: ${actual}`); } - return true; -} - -const codeRangeRE = new RegExp("^[0-9]xx$", "i"); - -export function matchStatusCode(response: Response, codes: StatusCodePredicate): boolean { - const actual = `${response.status}`; - const expectedCodes = Array.isArray(codes) ? codes : [codes]; - if (!expectedCodes.length) { - return false; - } - - return expectedCodes.some((ec) => { - const code = `${ec}`; - - if (code === "default") { - return true; - } - - if (!codeRangeRE.test(`${code}`)) { - return code === actual; - } - - const expectFamily = code.charAt(0); - if (!expectFamily) { - throw new Error("Invalid status code range"); - } - - const actualFamily = actual.charAt(0); - if (!actualFamily) { - throw new Error(`Invalid response status code: ${actual}`); - } - - return actualFamily === expectFamily; - }); + return actualFamily === expectFamily; + }); } export function matchResponse( - response: Response, - code: StatusCodePredicate, - contentTypePattern: string + response: Response, + code: StatusCodePredicate, + contentTypePattern: string, ): boolean { - return matchStatusCode(response, code) && matchContentType(response, contentTypePattern); -} - -const headerValRE = /, */; -export function unpackHeaders(headers: Headers): Record { - const out: Record = {}; - - for (const [k, v] of headers.entries()) { - out[k] = v.split(headerValRE); - } - - return out; + return ( + matchStatusCode(response, code) && + matchContentType(response, contentTypePattern) + ); } -type ResponseMatcherSchema = - | { parse: (data: unknown) => T } - | { inboundSchema: { parse: (data: unknown) => T } }; +/** + * Uses various heurisitics to determine if an error is a connection error. + */ +export function isConnectionError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } -type SerializationMethod = "sse" | "json" | "rawBytes" | "rawStream" | "text" | "void" | "fail"; + // Covers fetch in Deno as well + const isBrowserErr = + err instanceof TypeError && + err.message.toLowerCase().startsWith("failed to fetch"); -const defaultContentTypes: Record = { - sse: "text/event-stream", - json: "application/json", - rawBytes: "application/octet-stream", - rawStream: "application/octet-stream", - text: "text/plain", - void: "", - fail: "", -}; + const isNodeErr = + err instanceof TypeError && + err.message.toLowerCase().startsWith("fetch failed"); -type ResponsePredicateMatch = { - method: SerializationMethod; - codes: StatusCodePredicate; - ctype: string; - schema: ResponseMatcherSchema; - hdrs: boolean; - key: string | undefined; - err: boolean; - fail: boolean; -}; + const isBunErr = "name" in err && err.name === "ConnectionError"; -type ResponsePredicateOptions = { - /** Content type to match on. */ - ctype?: string; - /** Pass HTTP headers to deserializer. */ - hdrs?: boolean; -} & ( - | { - /** The result key to store the deserialized value into. */ - key?: string; - fail?: never; - err?: never; - } - | { - /** Indicates the matched response must throw the built-in error. */ - fail: true; - key?: never; - err?: never; - } - | { - /** Indicates the matched response is a custom error. */ - err: true; - key?: never; - fail?: never; - } -); - -export class ResponseMatcher { - private predicates: ResponsePredicateMatch[] = []; - - #any( - method: SerializationMethod, - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ) { - const ctype = opts?.ctype || defaultContentTypes[method]; - const hdrs = !!opts?.hdrs; - const key = opts?.key; - const err = !!opts?.err; - const fail = !!opts?.fail; - this.predicates.push({ - method, - codes, - ctype, - schema, - hdrs, - key, - err, - fail, - }); - return this; - } + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnreset"; - json( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("json", codes, schema, opts); - } - bytes( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("rawBytes", codes, schema, opts); - } - stream( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("rawStream", codes, schema, opts); - } - text( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("text", codes, schema, opts); - } - sse( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: Omit - ): this { - return this.#any("sse", codes, schema, opts); - } - void( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: Pick - ): this { - return this.#any("void", codes, schema, opts); - } - fail(codes: StatusCodePredicate): this { - return this.#any("fail", codes, znever(), { fail: true }); - } - - async match( - response: Response, - // envelope-http - request: Request, - - options?: { - resultKey?: string; - extraFields?: Record; - } - ): Promise<[result: Result, rawData: unknown]> { - let pred: ResponsePredicateMatch | undefined; - for (const predicate of this.predicates) { - const { codes, ctype } = predicate; - if (ctype && matchResponse(response, codes, ctype)) { - pred = predicate; - break; - } else if (!ctype && matchStatusCode(response, codes)) { - pred = predicate; - break; - } - } - if (pred == null) { - await discardResponseBody(response); - throw new errors.SDKError("Unexpected API response status or content-type", { - response, - request, - }); - } - - const { method, schema } = pred; - - let raw: unknown; - switch (method) { - case "json": - raw = await response.json(); - break; - case "rawBytes": - raw = await response.arrayBuffer(); - break; - case "rawStream": - raw = response.body; - break; - case "text": - raw = await response.text(); - break; - case "sse": - raw = response.body; - break; - case "void": - raw = await discardResponseBody(response); - break; - case "fail": - raw = await discardResponseBody(response); - break; - default: - method satisfies never; - throw new Error(`Unsupported response type: ${method}`); - } - - const resultKey = pred.key || options?.resultKey; - let data: unknown; - if (pred.fail) { - throw new errors.SDKError("API error occurred", { response, request }); - } else if (pred.err) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - ...(isPlainObject(raw) ? raw : null), - }; - } else if (resultKey) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - [resultKey]: raw, - }; - } else { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - }; - } - - const parser = "inboundSchema" in schema ? schema.inboundSchema : schema; - const body = parse(data, (v: unknown) => parser.parse(v), "Response validation failed"); - - if (body instanceof Error) { - throw body; - } - - return [body, raw]; - } + return isBrowserErr || isNodeErr || isGenericErr || isBunErr; } /** - * Discards the response body to free up resources. - * - * To learn why this is need, see the undici docs: - * https://undici.nodejs.org/#/?id=garbage-collection + * Uses various heurisitics to determine if an error is a timeout error. */ -export async function discardResponseBody(res: Response) { - const reader = res.body?.getReader(); - if (reader == null) { - return; - } +export function isTimeoutError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } + + // Fetch in browser, Node.js, Bun, Deno + const isNative = "name" in err && err.name === "TimeoutError"; + const isLegacyNative = "code" in err && err.code === 23; + + // Node.js HTTP client and Axios + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnaborted"; + + return isNative || isLegacyNative || isGenericErr; +} - try { - let done = false; - while (!done) { - const res = await reader.read(); - done = res.done; - } - } finally { - reader.releaseLock(); - } +/** + * Uses various heurisitics to determine if an error is a abort error. + */ +export function isAbortError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } + + // Fetch in browser, Node.js, Bun, Deno + const isNative = "name" in err && err.name === "AbortError"; + const isLegacyNative = "code" in err && err.code === 20; + + // Node.js HTTP client and Axios + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnaborted"; + + return isNative || isLegacyNative || isGenericErr; } diff --git a/lending/src/lib/is-plain-object.ts b/lending/src/lib/is-plain-object.ts index af0d6e7e..61070d3d 100644 --- a/lending/src/lib/is-plain-object.ts +++ b/lending/src/lib/is-plain-object.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ /* diff --git a/lending/src/lib/logger.ts b/lending/src/lib/logger.ts new file mode 100644 index 00000000..d181f293 --- /dev/null +++ b/lending/src/lib/logger.ts @@ -0,0 +1,9 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export interface Logger { + group(label?: string): void; + groupEnd(): void; + log(message: any, ...args: any[]): void; +} diff --git a/lending/src/lib/matchers.ts b/lending/src/lib/matchers.ts new file mode 100644 index 00000000..7bf6b59f --- /dev/null +++ b/lending/src/lib/matchers.ts @@ -0,0 +1,316 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import { Result } from "../types/fp.js"; +import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js"; +import { isPlainObject } from "./is-plain-object.js"; +import { safeParse } from "./schemas.js"; + +export type Encoding = + | "json" + | "text" + | "bytes" + | "stream" + | "sse" + | "nil" + | "fail"; + +const DEFAULT_CONTENT_TYPES: Record = { + json: "application/json", + text: "text/plain", + bytes: "application/octet-stream", + stream: "application/octet-stream", + sse: "text/event-stream", + nil: "*", + fail: "*", +}; + +type Schema = { parse(raw: unknown): T }; + +type MatchOptions = { + ctype?: string; + hdrs?: boolean; + key?: string; + sseSentinel?: string; +}; + +export type ValueMatcher = MatchOptions & { + enc: Encoding; + codes: StatusCodePredicate; + schema: Schema; +}; + +export type ErrorMatcher = MatchOptions & { + enc: Encoding; + codes: StatusCodePredicate; + schema: Schema; + err: true; +}; + +export type FailMatcher = { + enc: "fail"; + codes: StatusCodePredicate; +}; + +export type Matcher = ValueMatcher | ErrorMatcher | FailMatcher; + +export function jsonErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "json", codes, schema }; +} +export function json( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "json", codes, schema }; +} + +export function textErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "text", codes, schema }; +} +export function text( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "text", codes, schema }; +} + +export function bytesErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "bytes", codes, schema }; +} +export function bytes( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "bytes", codes, schema }; +} + +export function streamErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "stream", codes, schema }; +} +export function stream( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "stream", codes, schema }; +} + +export function sseErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "sse", codes, schema }; +} +export function sse( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "sse", codes, schema }; +} + +export function nilErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "nil", codes, schema }; +} +export function nil( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "nil", codes, schema }; +} + +export function fail(codes: StatusCodePredicate): FailMatcher { + return { enc: "fail", codes }; +} + +export type MatchedValue = Matchers extends Matcher[] + ? T + : never; +export type MatchedError = Matchers extends Matcher[] + ? E + : never; +export type MatchFunc = ( + response: Response, + request: Request, + options?: { resultKey?: string; extraFields?: Record }, +) => Promise<[result: Result, raw: unknown]>; + +export function match( + ...matchers: Array> +): MatchFunc { + return async function matchFunc( + response: Response, + request: Request, + options?: { resultKey?: string; extraFields?: Record }, + ): Promise< + [result: Result, raw: unknown] + > { + let raw: unknown; + let matcher: Matcher | undefined; + for (const match of matchers) { + const { codes } = match; + const ctpattern = "ctype" in match + ? match.ctype + : DEFAULT_CONTENT_TYPES[match.enc]; + if (ctpattern && matchResponse(response, codes, ctpattern)) { + matcher = match; + break; + } else if (!ctpattern && matchStatusCode(response, codes)) { + matcher = match; + break; + } + } + + if (!matcher) { + await discardResponseBody(response); + return [{ + ok: false, + error: new SDKError("Unexpected API response status or content-type", { + response, + request, + }), + }, raw]; + } + + const encoding = matcher.enc; + switch (encoding) { + case "json": + raw = await response.json(); + break; + case "bytes": + raw = await response.arrayBuffer(); + break; + case "stream": + raw = response.body; + break; + case "text": + raw = await response.text(); + break; + case "sse": + raw = response.body; + break; + case "nil": + raw = await discardResponseBody(response); + break; + case "fail": + raw = await discardResponseBody(response); + break; + default: + encoding satisfies never; + throw new Error(`Unsupported response type: ${encoding}`); + } + + if (matcher.enc === "fail") { + return [{ + ok: false, + error: new SDKError("API error occurred", { response, request }), + }, raw]; + } + + const resultKey = matcher.key || options?.resultKey; + let data: unknown; + + if ("err" in matcher) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + ...(isPlainObject(raw) ? raw : null), + }; + } else if (resultKey) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + [resultKey]: raw, + }; + } else { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + }; + } + + if ("err" in matcher) { + const result = safeParse( + data, + (v: unknown) => matcher.schema.parse(v), + "Response validation failed", + ); + return [result.ok ? { ok: false, error: result.value } : result, raw]; + } else { + return [ + safeParse( + data, + (v: unknown) => matcher.schema.parse(v), + "Response validation failed", + ), + raw, + ]; + } + }; +} + +const headerValRE = /, */; +/** + * Iterates over a Headers object and returns an object with all the header + * entries. Values are represented as an array to account for repeated headers. + */ +export function unpackHeaders(headers: Headers): Record { + const out: Record = {}; + + for (const [k, v] of headers.entries()) { + out[k] = v.split(headerValRE); + } + + return out; +} + +/** + * Discards the response body to free up resources. + * + * To learn why this is need, see the undici docs: + * https://undici.nodejs.org/#/?id=garbage-collection + */ +export async function discardResponseBody(res: Response) { + const reader = res.body?.getReader(); + if (reader == null) { + return; + } + + try { + let done = false; + while (!done) { + const res = await reader.read(); + done = res.done; + } + } finally { + reader.releaseLock(); + } +} diff --git a/lending/src/lib/primitives.ts b/lending/src/lib/primitives.ts new file mode 100644 index 00000000..23794a2b --- /dev/null +++ b/lending/src/lib/primitives.ts @@ -0,0 +1,40 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export type Remap = { + [k in keyof Inp as Mapping[k] extends string /* if we have a string mapping for this key then use it */ + ? Mapping[k] + : Mapping[k] extends null /* if the mapping is to `null` then drop the key */ + ? never + : k /* otherwise keep the key as-is */]: Inp[k]; +}; + +/** + * Converts or omits an object's keys according to a mapping. + * + * @param inp An object whose keys will be remapped + * @param mappings A mapping of original keys to new keys. If a key is not present in the mapping, it will be left as is. If a key is mapped to `null`, it will be removed in the resulting object. + * @returns A new object with keys remapped or omitted according to the mappings + */ +export function remap< + Inp extends Record, + const Mapping extends { [k in keyof Inp]?: string | null }, +>(inp: Inp, mappings: Mapping): Remap { + let out: any = {}; + + if (!Object.keys(mappings).length) { + out = inp; + return out; + } + + for (const [k, v] of Object.entries(inp)) { + const j = mappings[k]; + if (j === null) { + continue; + } + out[j ?? k] = v; + } + + return out; +} diff --git a/lending/src/lib/retries.ts b/lending/src/lib/retries.ts index ed9b4959..df3e0bc2 100644 --- a/lending/src/lib/retries.ts +++ b/lending/src/lib/retries.ts @@ -1,7 +1,9 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { isConnectionError, isTimeoutError } from "./http.js"; + export type BackoffStrategy = { initialInterval: number; maxInterval: number; @@ -99,47 +101,6 @@ function wrapFetcher( }; } -function isConnectionError(err: unknown) { - if (typeof err !== "object" || err == null) { - return false; - } - - // Covers fetch in Deno as well - const isBrowserErr = - err instanceof TypeError && - err.message.toLowerCase().startsWith("failed to fetch"); - - const isNodeErr = - err instanceof TypeError && - err.message.toLowerCase().startsWith("fetch failed"); - - const isBunErr = "name" in err && err.name === "ConnectionError"; - - const isGenericErr = - "code" in err && - typeof err.code === "string" && - err.code.toLowerCase() === "econnreset"; - - return isBrowserErr || isNodeErr || isGenericErr || isBunErr; -} - -function isTimeoutError(err: unknown) { - if (typeof err !== "object" || err == null) { - return false; - } - - // Fetch in browser, Node.js, Bun, Deno - const isNative = "name" in err && err.name === "TimeoutError"; - - // Node.js HTTP client and Axios - const isGenericErr = - "code" in err && - typeof err.code === "string" && - err.code.toLowerCase() === "econnaborted"; - - return isNative || isGenericErr; -} - const codeRangeRE = new RegExp("^[0-9]xx$", "i"); function isRetryableResponse(res: Response, statusCodes: string[]): boolean { diff --git a/lending/src/lib/schemas.ts b/lending/src/lib/schemas.ts index 63ad0ae9..f3856dcb 100644 --- a/lending/src/lib/schemas.ts +++ b/lending/src/lib/schemas.ts @@ -1,22 +1,86 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ZodError } from "zod"; -import * as errors from "../models/errors"; +import { + output, + ZodEffects, + ZodError, + ZodObject, + ZodRawShape, + ZodTypeAny, +} from "zod"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import { ERR, OK, Result } from "../types/fp.js"; /** * Utility function that executes some code which may throw a ZodError. It * intercepts this error and converts it to an SDKValidationError so as to not * leak Zod implementation details to user code. */ -export function parse(rawValue: Inp, fn: (value: Inp) => Out, errorMessage: string): Out { - try { - return fn(rawValue); - } catch (err) { - if (err instanceof ZodError) { - throw new errors.SDKValidationError(errorMessage, err, rawValue); - } - throw err; +export function parse( + rawValue: Inp, + fn: (value: Inp) => Out, + errorMessage: string, +): Out { + try { + return fn(rawValue); + } catch (err) { + if (err instanceof ZodError) { + throw new SDKValidationError(errorMessage, err, rawValue); } + throw err; + } +} + +/** + * Utility function that executes some code which may result in a ZodError. It + * intercepts this error and converts it to an SDKValidationError so as to not + * leak Zod implementation details to user code. + */ +export function safeParse( + rawValue: Inp, + fn: (value: Inp) => Out, + errorMessage: string, +): Result { + try { + return OK(fn(rawValue)); + } catch (err) { + return ERR(new SDKValidationError(errorMessage, err, rawValue)); + } +} + +export function collectExtraKeys< + Shape extends ZodRawShape, + Catchall extends ZodTypeAny, + K extends string, +>( + obj: ZodObject, + extrasKey: K, +): ZodEffects< + typeof obj, + & output> + & { + [k in K]: Record>; + } +> { + return obj.transform((val) => { + const extras: Record> = {}; + const { shape } = obj; + for (const [key] of Object.entries(val)) { + if (key in shape) { + continue; + } + + const v = val[key]; + if (typeof v === "undefined") { + continue; + } + + extras[key] = v; + delete val[key]; + } + + return { ...val, [extrasKey]: extras }; + }); } diff --git a/lending/src/lib/sdks.ts b/lending/src/lib/sdks.ts index 9ec697e7..5e2a8909 100644 --- a/lending/src/lib/sdks.ts +++ b/lending/src/lib/sdks.ts @@ -1,147 +1,384 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ResponseMatcher, HTTPClient, matchStatusCode } from "./http"; -import { SecurityState, resolveSecurity, resolveGlobalSecurity } from "./security"; -import { pathToFunc } from "./url"; -import { encodeForm } from "./encodings"; -import { stringToBase64 } from "./base64"; -import { SDKHooks, HookContext } from "../hooks"; +import { SDKHooks } from "../hooks/hooks.js"; +import { HookContext } from "../hooks/types.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import { ERR, OK, Result } from "../types/fp.js"; +import { stringToBase64 } from "./base64.js"; +import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "./config.js"; +import { encodeForm } from "./encodings.js"; +import { + HTTPClient, + isAbortError, + isConnectionError, + isTimeoutError, + matchContentType, + matchStatusCode, +} from "./http.js"; +import { Logger } from "./logger.js"; +import { retry, RetryConfig } from "./retries.js"; +import { SecurityState } from "./security.js"; export type RequestOptions = { - fetchOptions?: Omit; + /** + * Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If + * `fetchOptions.signal` is set then it will take precedence over this option. + */ + timeoutMs?: number; + /** + * Set or override a retry policy on HTTP calls. + */ + retries?: RetryConfig; + /** + * Specifies the status codes which should be retried using the given retry policy. + */ + retryCodes?: string[]; + /** + * Sets various request options on the `fetch` call made by an SDK method. + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request} + */ + fetchOptions?: Omit; }; type RequestConfig = { - method: string; - path: string; - baseURL?: string | URL; - query?: string; - body?: RequestInit["body"]; - headers?: HeadersInit; - security?: SecurityState | null; + method: string; + path: string; + baseURL?: string | URL; + query?: string; + body?: RequestInit["body"]; + headers?: HeadersInit; + security?: SecurityState | null; + uaHeader?: string; + timeoutMs?: number; }; +const gt: unknown = typeof globalThis === "undefined" ? null : globalThis; +const webWorkerLike = typeof gt === "object" + && gt != null + && "importScripts" in gt + && typeof gt["importScripts"] === "function"; +const isBrowserLike = webWorkerLike + || (typeof navigator !== "undefined" && "serviceWorker" in navigator) + || (typeof window === "object" && typeof window.document !== "undefined"); + export class ClientSDK { - private readonly client: HTTPClient; - protected readonly baseURL: URL | null; - protected readonly hooks$: SDKHooks; - - constructor(init: { client: HTTPClient; baseURL: URL | null; hooks: SDKHooks }) { - const url = init.baseURL; - if (url) { - url.pathname = url.pathname.replace(/\/+$/, "") + "/"; - } + private readonly httpClient: HTTPClient; + protected readonly baseURL: URL | null; + protected readonly hooks$: SDKHooks; + protected readonly logger?: Logger | undefined; + public readonly options$: SDKOptions & { hooks?: SDKHooks }; - this.hooks$ = init.hooks; - const { baseURL, client } = this.hooks$.sdkInit({ baseURL: url, client: init.client }); - this.baseURL = baseURL; - this.client = client; + constructor(options: SDKOptions = {}) { + const opt = options as unknown; + if ( + typeof opt === "object" + && opt != null + && "hooks" in opt + && opt.hooks instanceof SDKHooks + ) { + this.hooks$ = opt.hooks; + } else { + this.hooks$ = new SDKHooks(); } + this.options$ = { ...options, hooks: this.hooks$ }; - protected createRequest$( - context: HookContext, - conf: RequestConfig, - options?: RequestOptions - ): Request { - const { method, path, query, headers: opHeaders, security } = conf; + const url = serverURLFromOptions(options); + if (url) { + url.pathname = url.pathname.replace(/\/+$/, "") + "/"; + } + const { baseURL, client } = this.hooks$.sdkInit({ + baseURL: url, + client: options.httpClient || new HTTPClient(), + }); + this.baseURL = baseURL; + this.httpClient = client; + this.logger = options.debugLogger; + } - const base = conf.baseURL ?? this.baseURL; - if (!base) { - throw new TypeError("No base URL provided for operation"); - } - const reqURL = new URL(base); - const inputURL = new URL(path, reqURL); + public createRequest$( + context: HookContext, + conf: RequestConfig, + options?: RequestOptions, + ): Result { + const { method, path, query, headers: opHeaders, security } = conf; - if (path) { - reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); - } + const base = conf.baseURL ?? this.baseURL; + if (!base) { + return ERR(new InvalidRequestError("No base URL provided for operation")); + } + const reqURL = new URL(base); + const inputURL = new URL(path, reqURL); - let finalQuery = query || ""; + if (path) { + reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); + } - const secQuery: string[] = []; - for (const [k, v] of Object.entries(security?.queryParams || {})) { - secQuery.push(encodeForm(k, v, { charEncoding: "percent" })); - } - if (secQuery.length) { - finalQuery += `&${secQuery.join("&")}`; - } + let finalQuery = query || ""; - if (finalQuery) { - const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery; - reqURL.search = `?${q}`; - } + const secQuery: string[] = []; + for (const [k, v] of Object.entries(security?.queryParams || {})) { + secQuery.push(encodeForm(k, v, { charEncoding: "percent" })); + } + if (secQuery.length) { + finalQuery += `&${secQuery.join("&")}`; + } - const headers = new Headers(opHeaders); + if (finalQuery) { + const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery; + reqURL.search = `?${q}`; + } - const username = security?.basic.username; - const password = security?.basic.password; - if (username != null || password != null) { - const encoded = stringToBase64([username || "", password || ""].join(":")); - headers.set("Authorization", `Basic ${encoded}`); - } + const headers = new Headers(opHeaders); - const securityHeaders = new Headers(security?.headers || {}); - for (const [k, v] of securityHeaders) { - headers.set(k, v); - } + const username = security?.basic.username; + const password = security?.basic.password; + if (username != null || password != null) { + const encoded = stringToBase64( + [username || "", password || ""].join(":"), + ); + headers.set("Authorization", `Basic ${encoded}`); + } - let cookie = headers.get("cookie") || ""; - for (const [k, v] of Object.entries(security?.cookies || {})) { - cookie += `; ${k}=${v}`; - } - cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie; - headers.set("cookie", cookie); + const securityHeaders = new Headers(security?.headers || {}); + for (const [k, v] of securityHeaders) { + headers.set(k, v); + } - const userHeaders = new Headers(options?.fetchOptions?.headers); - for (const [k, v] of userHeaders) { - headers.set(k, v); - } + let cookie = headers.get("cookie") || ""; + for (const [k, v] of Object.entries(security?.cookies || {})) { + cookie += `; ${k}=${v}`; + } + cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie; + headers.set("cookie", cookie); - const input = this.hooks$.beforeCreateRequest(context, { - url: reqURL, - options: { - ...options?.fetchOptions, - body: conf.body ?? null, - headers, - method, - }, - }); + const userHeaders = new Headers(options?.fetchOptions?.headers); + for (const [k, v] of userHeaders) { + headers.set(k, v); + } + + // Only set user agent header in non-browser-like environments since CORS + // policy disallows setting it in browsers e.g. Chrome throws an error. + if (!isBrowserLike) { + headers.set(conf.uaHeader ?? "user-agent", SDK_METADATA.userAgent); + } - return new Request(input.url, input.options); + let fetchOptions = options?.fetchOptions; + if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) { + const timeoutSignal = AbortSignal.timeout(conf.timeoutMs); + if (!fetchOptions) { + fetchOptions = { signal: timeoutSignal }; + } else { + fetchOptions.signal = timeoutSignal; + } } - protected async do$( - req: Request, + if (conf.body instanceof ReadableStream) { + if (!fetchOptions) { + fetchOptions = { + // @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769 + duplex: "half", + }; + } else { + // @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769 + fetchOptions.duplex = "half"; + } + } + + let input; + try { + input = this.hooks$.beforeCreateRequest(context, { + url: reqURL, options: { - context: HookContext; - errorCodes: number | string | (number | string)[]; - } - ): Promise { - const { context, errorCodes } = options; + ...fetchOptions, + body: conf.body ?? null, + headers, + method, + }, + }); + } catch (err: unknown) { + return ERR( + new UnexpectedClientError("Create request hook failed to execute", { + cause: err, + }), + ); + } + + return OK(new Request(input.url, input.options)); + } + + public async do$( + request: Request, + options: { + context: HookContext; + errorCodes: number | string | (number | string)[]; + retryConfig?: RetryConfig | undefined; + retryCodes?: string[] | undefined; + }, + ): Promise< + Result< + Response, + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + | UnexpectedClientError + > + > { + const { context, errorCodes } = options; + const retryConfig = options.retryConfig || { strategy: "none" }; + const retryCodes = options.retryCodes || []; - let response = await this.client.request(await this.hooks$.beforeRequest(context, req)); + return retry( + async () => { + const req = await this.hooks$.beforeRequest(context, request.clone()); + await logRequest(this.logger, req).catch((e) => + this.logger?.log("Failed to log request:", e) + ); + + let response = await this.httpClient.request(req); if (matchStatusCode(response, errorCodes)) { - const result = await this.hooks$.afterError(context, response, null); - if (result.error) { - throw result.error; - } - response = result.response || response; + const result = await this.hooks$.afterError(context, response, null); + if (result.error) { + throw result.error; + } + response = result.response || response; } else { - response = await this.hooks$.afterSuccess(context, response); + response = await this.hooks$.afterSuccess(context, response); } + await logResponse(this.logger, response, req) + .catch(e => this.logger?.log("Failed to log response:", e)); + return response; - } + }, + { config: retryConfig, statusCodes: retryCodes }, + ).then( + (r) => OK(r), + (err) => { + switch (true) { + case isAbortError(err): + return ERR( + new RequestAbortedError("Request aborted by client", { + cause: err, + }), + ); + case isTimeoutError(err): + return ERR( + new RequestTimeoutError("Request timed out", { cause: err }), + ); + case isConnectionError(err): + return ERR( + new ConnectionError("Unable to make request", { cause: err }), + ); + default: + return ERR( + new UnexpectedClientError("Unexpected HTTP client error", { + cause: err, + }), + ); + } + }, + ); + } +} - protected matcher(): ResponseMatcher { - return new ResponseMatcher(); +const jsonLikeContentTypeRE = /^application\/(?:.{0,100}\+)?json/; +async function logRequest(logger: Logger | undefined, req: Request) { + if (!logger) { + return; + } + + const contentType = req.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`> Request: ${req.method} ${req.url}`); + + logger.group("Headers:"); + for (const [k, v] of req.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case jsonLikeContentTypeRE.test(ct): + logger.log(await req.clone().json()); + break; + case ct.startsWith("text/"): + logger.log(await req.clone().text()); + break; + case ct === "multipart/form-data": { + const body = await req.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); + + logger.groupEnd(); +} - protected templateURLComponent = pathToFunc; +async function logResponse( + logger: Logger | undefined, + res: Response, + req: Request, +) { + if (!logger) { + return; + } + + const contentType = res.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`< Response: ${req.method} ${req.url}`); + logger.log("Status Code:", res.status, res.statusText); + + logger.group("Headers:"); + for (const [k, v] of res.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case matchContentType(res, "application/json") + || jsonLikeContentTypeRE.test(ct): + logger.log(await res.clone().json()); + break; + case matchContentType(res, "text/event-stream"): + logger.log(`<${contentType}>`); + break; + case matchContentType(res, "text/*"): + logger.log(await res.clone().text()); + break; + case matchContentType(res, "multipart/form-data"): { + const body = await res.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); - protected resolveSecurity = resolveSecurity; - protected resolveGlobalSecurity = resolveGlobalSecurity; + logger.groupEnd(); } diff --git a/lending/src/lib/security.ts b/lending/src/lib/security.ts index 3f0dc6b7..a59e541b 100644 --- a/lending/src/lib/security.ts +++ b/lending/src/lib/security.ts @@ -1,182 +1,217 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as components from "../models/components"; +import * as components from "../models/components/index.js"; export enum SecurityErrorCode { - Incomplete = "incomplete", - UnrecognisedSecurityType = "unrecognized_security_type", + Incomplete = "incomplete", + UnrecognisedSecurityType = "unrecognized_security_type", } export class SecurityError extends Error { - constructor(public code: SecurityErrorCode, message: string) { - super(message); - this.name = "SecurityError"; - } - - static incomplete(): SecurityError { - return new SecurityError( - SecurityErrorCode.Incomplete, - "Security requirements not met in order to perform the operation" - ); - } - static unrecognizedType(type: string): SecurityError { - return new SecurityError( - SecurityErrorCode.UnrecognisedSecurityType, - `Unrecognised security type: ${type}` - ); - } + constructor( + public code: SecurityErrorCode, + message: string, + ) { + super(message); + this.name = "SecurityError"; + } + + static incomplete(): SecurityError { + return new SecurityError( + SecurityErrorCode.Incomplete, + "Security requirements not met in order to perform the operation", + ); + } + static unrecognizedType(type: string): SecurityError { + return new SecurityError( + SecurityErrorCode.UnrecognisedSecurityType, + `Unrecognised security type: ${type}`, + ); + } } export type SecurityState = { - basic: { username?: string | undefined; password?: string | undefined }; - headers: Record; - queryParams: Record; - cookies: Record; + basic: { username?: string | undefined; password?: string | undefined }; + headers: Record; + queryParams: Record; + cookies: Record; }; type SecurityInputBasic = { - type: "http:basic"; - value: { username?: string | undefined; password?: string | undefined } | null | undefined; + type: "http:basic"; + value: + | { username?: string | undefined; password?: string | undefined } + | null + | undefined; }; type SecurityInputBearer = { - type: "http:bearer"; - value: string | null | undefined; - fieldName: string; + type: "http:bearer"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputAPIKey = { - type: "apiKey:header" | "apiKey:query" | "apiKey:cookie"; - value: string | null | undefined; - fieldName: string; + type: "apiKey:header" | "apiKey:query" | "apiKey:cookie"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOIDC = { - type: "openIdConnect"; - value: string | null | undefined; - fieldName: string; + type: "openIdConnect"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOAuth2 = { - type: "oauth2"; - value: string | null | undefined; - fieldName: string; + type: "oauth2"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOAuth2ClientCredentials = { - type: "oauth2:client_credentials"; - value: string | null | undefined; - fieldName: string; + type: "oauth2:client_credentials"; + value: string | null | undefined; + fieldName: string; +}; + +type SecurityInputCustom = { + type: "http:custom"; + value: any | null | undefined; + fieldName: string; }; export type SecurityInput = - | SecurityInputBasic - | SecurityInputBearer - | SecurityInputAPIKey - | SecurityInputOAuth2 - | SecurityInputOAuth2ClientCredentials - | SecurityInputOIDC; - -export function resolveSecurity(...options: SecurityInput[][]): SecurityState | null { - const state: SecurityState = { - basic: { username: "", password: "" }, - headers: {}, - queryParams: {}, - cookies: {}, - }; - - const option = options.find((opts) => { - return opts.every((o) => { - if (o.value == null) { - return false; - } else if (o.type === "http:basic") { - return o.value.username != null || o.value.password != null; - } else if (typeof o.value === "string") { - return !!o.value; - } else { - throw new Error( - `Unrecognized security type: ${o.type} (value type: ${typeof o.value})` - ); - } - }); - }); - if (option == null) { + | SecurityInputBasic + | SecurityInputBearer + | SecurityInputAPIKey + | SecurityInputOAuth2 + | SecurityInputOAuth2ClientCredentials + | SecurityInputOIDC + | SecurityInputCustom; + +export function resolveSecurity( + ...options: SecurityInput[][] +): SecurityState | null { + const state: SecurityState = { + basic: { username: "", password: "" }, + headers: {}, + queryParams: {}, + cookies: {}, + }; + + const option = options.find((opts) => { + return opts.every((o) => { + if (o.value == null) { + return false; + } else if (o.type === "http:basic") { + return o.value.username != null || o.value.password != null; + } else if (o.type === "http:custom") { return null; + } else if (typeof o.value === "string") { + return !!o.value; + } else { + throw new Error( + `Unrecognized security type: ${o.type} (value type: ${typeof o + .value})`, + ); + } + }); + }); + if (option == null) { + return null; + } + + option.forEach((spec) => { + if (spec.value == null) { + return; } - option.forEach((spec) => { - if (spec.value == null) { - return; - } - - const { type } = spec; - - switch (type) { - case "apiKey:header": - state.headers[spec.fieldName] = spec.value; - break; - case "apiKey:query": - state.queryParams[spec.fieldName] = spec.value; - break; - case "apiKey:cookie": - state.cookies[spec.fieldName] = spec.value; - break; - case "http:basic": - applyBasic(state, spec); - break; - case "http:bearer": - applyBearer(state, spec); - break; - case "oauth2": - applyBearer(state, spec); - break; - case "oauth2:client_credentials": - break; - case "openIdConnect": - applyBearer(state, spec); - break; - default: - spec satisfies never; - throw SecurityError.unrecognizedType(type); - } - }); + const { type } = spec; + + switch (type) { + case "apiKey:header": + state.headers[spec.fieldName] = spec.value; + break; + case "apiKey:query": + state.queryParams[spec.fieldName] = spec.value; + break; + case "apiKey:cookie": + state.cookies[spec.fieldName] = spec.value; + break; + case "http:basic": + applyBasic(state, spec); + break; + case "http:custom": + break; + case "http:bearer": + applyBearer(state, spec); + break; + case "oauth2": + applyBearer(state, spec); + break; + case "oauth2:client_credentials": + break; + case "openIdConnect": + applyBearer(state, spec); + break; + default: + spec satisfies never; + throw SecurityError.unrecognizedType(type); + } + }); - return state; + return state; } -function applyBasic(state: SecurityState, spec: SecurityInputBasic) { - if (spec.value == null) { - return; - } +function applyBasic( + state: SecurityState, + spec: SecurityInputBasic, +) { + if (spec.value == null) { + return; + } - state.basic = spec.value; + state.basic = spec.value; } function applyBearer( - state: SecurityState, - spec: SecurityInputBearer | SecurityInputOAuth2 | SecurityInputOIDC + state: SecurityState, + spec: SecurityInputBearer | SecurityInputOAuth2 | SecurityInputOIDC, ) { - if (spec.value == null) { - return; - } + if (spec.value == null) { + return; + } - let value = spec.value; - if (value.slice(0, 7).toLowerCase() !== "bearer ") { - value = `Bearer ${value}`; - } + let value = spec.value; + if (value.slice(0, 7).toLowerCase() !== "bearer ") { + value = `Bearer ${value}`; + } - state.headers[spec.fieldName] = value; + state.headers[spec.fieldName] = value; } export function resolveGlobalSecurity( - security: Partial | null | undefined + security: Partial | null | undefined, ): SecurityState | null { - return resolveSecurity([ - { - fieldName: "Authorization", - type: "apiKey:header", - value: security?.authHeader, - }, - ]); + return resolveSecurity( + [ + { + fieldName: "Authorization", + type: "apiKey:header", + value: security?.authHeader, + }, + ], + ); +} + +export async function extractSecurity< + T extends string | Record, +>(sec: T | (() => Promise) | undefined): Promise { + if (sec == null) { + return; + } + + return typeof sec === "function" ? sec() : sec; } diff --git a/lending/src/lib/url.ts b/lending/src/lib/url.ts index df58acbb..6bc6356e 100644 --- a/lending/src/lib/url.ts +++ b/lending/src/lib/url.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ const hasOwn = Object.prototype.hasOwnProperty; diff --git a/lending/src/models/components/companies.ts b/lending/src/models/components/companies.ts index f857b026..92c48414 100644 --- a/lending/src/models/components/companies.ts +++ b/lending/src/models/components/companies.ts @@ -1,71 +1,91 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Company, Company$ } from "./company"; -import { Links, Links$ } from "./links"; import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; +import { + Company, + Company$inboundSchema, + Company$Outbound, + Company$outboundSchema, +} from "./company.js"; +import { + Links, + Links$inboundSchema, + Links$Outbound, + Links$outboundSchema, +} from "./links.js"; export type Companies = { - results?: Array | undefined; - /** - * Current page number. - */ - pageNumber: number; - /** - * Number of items to return in results array. - */ - pageSize: number; - /** - * Total number of items. - */ - totalResults: number; - links: Links; + results?: Array | undefined; + /** + * Current page number. + */ + pageNumber: number; + /** + * Number of items to return in results array. + */ + pageSize: number; + /** + * Total number of items. + */ + totalResults: number; + links: Links; }; /** @internal */ -export namespace Companies$ { - export const inboundSchema: z.ZodType = z - .object({ - results: z.array(Company$.inboundSchema).optional(), - pageNumber: z.number().int(), - pageSize: z.number().int(), - totalResults: z.number().int(), - _links: Links$.inboundSchema, - }) - .transform((v) => { - return { - ...(v.results === undefined ? null : { results: v.results }), - pageNumber: v.pageNumber, - pageSize: v.pageSize, - totalResults: v.totalResults, - links: v._links, - }; - }); +export const Companies$inboundSchema: z.ZodType< + Companies, + z.ZodTypeDef, + unknown +> = z.object({ + results: z.array(Company$inboundSchema).optional(), + pageNumber: z.number().int(), + pageSize: z.number().int(), + totalResults: z.number().int(), + _links: Links$inboundSchema, +}).transform((v) => { + return remap$(v, { + "_links": "links", + }); +}); - export type Outbound = { - results?: Array | undefined; - pageNumber: number; - pageSize: number; - totalResults: number; - _links: Links$.Outbound; - }; +/** @internal */ +export type Companies$Outbound = { + results?: Array | undefined; + pageNumber: number; + pageSize: number; + totalResults: number; + _links: Links$Outbound; +}; - export const outboundSchema: z.ZodType = z - .object({ - results: z.array(Company$.outboundSchema).optional(), - pageNumber: z.number().int(), - pageSize: z.number().int(), - totalResults: z.number().int(), - links: Links$.outboundSchema, - }) - .transform((v) => { - return { - ...(v.results === undefined ? null : { results: v.results }), - pageNumber: v.pageNumber, - pageSize: v.pageSize, - totalResults: v.totalResults, - _links: v.links, - }; - }); +/** @internal */ +export const Companies$outboundSchema: z.ZodType< + Companies$Outbound, + z.ZodTypeDef, + Companies +> = z.object({ + results: z.array(Company$outboundSchema).optional(), + pageNumber: z.number().int(), + pageSize: z.number().int(), + totalResults: z.number().int(), + links: Links$outboundSchema, +}).transform((v) => { + return remap$(v, { + links: "_links", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Companies$ { + /** @deprecated use `Companies$inboundSchema` instead. */ + export const inboundSchema = Companies$inboundSchema; + /** @deprecated use `Companies$outboundSchema` instead. */ + export const outboundSchema = Companies$outboundSchema; + /** @deprecated use `Companies$Outbound` instead. */ + export type Outbound = Companies$Outbound; } diff --git a/lending/src/models/components/company.ts b/lending/src/models/components/company.ts index 5cd7a761..16cc6d38 100644 --- a/lending/src/models/components/company.ts +++ b/lending/src/models/components/company.ts @@ -1,15 +1,20 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Connection, Connection$ } from "./connection"; import * as z from "zod"; +import { + Connection, + Connection$inboundSchema, + Connection$Outbound, + Connection$outboundSchema, +} from "./connection.js"; export type GroupReference = { - /** - * Unique identifier for the group. - */ - id?: string | undefined; + /** + * Unique identifier for the group. + */ + id?: string | undefined; }; /** @@ -22,190 +27,175 @@ export type GroupReference = { * When you create a company, you can specify a `name` and we will automatically generate a unique `id` for the company. You can also add a `description` to store any additional information about the company. */ export type Company = { - /** - * Unique identifier for your SMB in Codat. - */ - id: string; - /** - * The name of the company - */ - name: string; - /** - * Additional information about the company. This can be used to store foreign IDs, references, etc. - */ - description?: string | undefined; - /** - * `platformKeys` name used when creating the company. - * - * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. - */ - platform?: string | undefined; - /** - * The `redirect` [Link URL](https://docs.codat.io/auth-flow/authorize-hosted-link) enabling the customer to start their auth flow journey for the company. - */ - redirect: string; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - lastSync?: string | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - created?: string | undefined; - /** - * Name of user that created the company in Codat. - */ - createdByUserName?: string | undefined; - dataConnections?: Array | undefined; - /** - * An array of groups the company has been assigned to. - */ - groups?: Array | undefined; + /** + * Unique identifier for your SMB in Codat. + */ + id: string; + /** + * The name of the company + */ + name: string; + /** + * Additional information about the company. This can be used to store foreign IDs, references, etc. + */ + description?: string | undefined; + /** + * `platformKeys` name used when creating the company. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + platform?: string | undefined; + /** + * The `redirect` [Link URL](https://docs.codat.io/auth-flow/authorize-hosted-link) enabling the customer to start their auth flow journey for the company. + */ + redirect: string; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + lastSync?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + created?: string | undefined; + /** + * Name of user that created the company in Codat. + */ + createdByUserName?: string | undefined; + dataConnections?: Array | undefined; + /** + * An array of groups the company has been assigned to. + */ + groups?: Array | undefined; }; /** @internal */ -export namespace GroupReference$ { - export const inboundSchema: z.ZodType = z - .object({ - id: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.id === undefined ? null : { id: v.id }), - }; - }); +export const GroupReference$inboundSchema: z.ZodType< + GroupReference, + z.ZodTypeDef, + unknown +> = z.object({ + id: z.string().optional(), +}); + +/** @internal */ +export type GroupReference$Outbound = { + id?: string | undefined; +}; - export type Outbound = { - id?: string | undefined; - }; +/** @internal */ +export const GroupReference$outboundSchema: z.ZodType< + GroupReference$Outbound, + z.ZodTypeDef, + GroupReference +> = z.object({ + id: z.string().optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - id: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.id === undefined ? null : { id: v.id }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GroupReference$ { + /** @deprecated use `GroupReference$inboundSchema` instead. */ + export const inboundSchema = GroupReference$inboundSchema; + /** @deprecated use `GroupReference$outboundSchema` instead. */ + export const outboundSchema = GroupReference$outboundSchema; + /** @deprecated use `GroupReference$Outbound` instead. */ + export type Outbound = GroupReference$Outbound; } /** @internal */ -export namespace Company$ { - export const inboundSchema: z.ZodType = z - .object({ - id: z.string(), - name: z.string(), - description: z.string().optional(), - platform: z.string().optional(), - redirect: z.string(), - lastSync: z.string().optional(), - created: z.string().optional(), - createdByUserName: z.string().optional(), - dataConnections: z.array(Connection$.inboundSchema).optional(), - groups: z.array(z.lazy(() => GroupReference$.inboundSchema)).optional(), - }) - .transform((v) => { - return { - id: v.id, - name: v.name, - ...(v.description === undefined ? null : { description: v.description }), - ...(v.platform === undefined ? null : { platform: v.platform }), - redirect: v.redirect, - ...(v.lastSync === undefined ? null : { lastSync: v.lastSync }), - ...(v.created === undefined ? null : { created: v.created }), - ...(v.createdByUserName === undefined - ? null - : { createdByUserName: v.createdByUserName }), - ...(v.dataConnections === undefined - ? null - : { dataConnections: v.dataConnections }), - ...(v.groups === undefined ? null : { groups: v.groups }), - }; - }); +export const Company$inboundSchema: z.ZodType = + z.object({ + id: z.string(), + name: z.string(), + description: z.string().optional(), + platform: z.string().optional(), + redirect: z.string(), + lastSync: z.string().optional(), + created: z.string().optional(), + createdByUserName: z.string().optional(), + dataConnections: z.array(Connection$inboundSchema).optional(), + groups: z.array(z.lazy(() => GroupReference$inboundSchema)).optional(), + }); + +/** @internal */ +export type Company$Outbound = { + id: string; + name: string; + description?: string | undefined; + platform?: string | undefined; + redirect: string; + lastSync?: string | undefined; + created?: string | undefined; + createdByUserName?: string | undefined; + dataConnections?: Array | undefined; + groups?: Array | undefined; +}; - export type Outbound = { - id: string; - name: string; - description?: string | undefined; - platform?: string | undefined; - redirect: string; - lastSync?: string | undefined; - created?: string | undefined; - createdByUserName?: string | undefined; - dataConnections?: Array | undefined; - groups?: Array | undefined; - }; +/** @internal */ +export const Company$outboundSchema: z.ZodType< + Company$Outbound, + z.ZodTypeDef, + Company +> = z.object({ + id: z.string(), + name: z.string(), + description: z.string().optional(), + platform: z.string().optional(), + redirect: z.string(), + lastSync: z.string().optional(), + created: z.string().optional(), + createdByUserName: z.string().optional(), + dataConnections: z.array(Connection$outboundSchema).optional(), + groups: z.array(z.lazy(() => GroupReference$outboundSchema)).optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - id: z.string(), - name: z.string(), - description: z.string().optional(), - platform: z.string().optional(), - redirect: z.string(), - lastSync: z.string().optional(), - created: z.string().optional(), - createdByUserName: z.string().optional(), - dataConnections: z.array(Connection$.outboundSchema).optional(), - groups: z.array(z.lazy(() => GroupReference$.outboundSchema)).optional(), - }) - .transform((v) => { - return { - id: v.id, - name: v.name, - ...(v.description === undefined ? null : { description: v.description }), - ...(v.platform === undefined ? null : { platform: v.platform }), - redirect: v.redirect, - ...(v.lastSync === undefined ? null : { lastSync: v.lastSync }), - ...(v.created === undefined ? null : { created: v.created }), - ...(v.createdByUserName === undefined - ? null - : { createdByUserName: v.createdByUserName }), - ...(v.dataConnections === undefined - ? null - : { dataConnections: v.dataConnections }), - ...(v.groups === undefined ? null : { groups: v.groups }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Company$ { + /** @deprecated use `Company$inboundSchema` instead. */ + export const inboundSchema = Company$inboundSchema; + /** @deprecated use `Company$outboundSchema` instead. */ + export const outboundSchema = Company$outboundSchema; + /** @deprecated use `Company$Outbound` instead. */ + export type Outbound = Company$Outbound; } diff --git a/lending/src/models/components/companyrequestbody.ts b/lending/src/models/components/companyrequestbody.ts index 449fc89a..a0a30b94 100644 --- a/lending/src/models/components/companyrequestbody.ts +++ b/lending/src/models/components/companyrequestbody.ts @@ -1,58 +1,68 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Items, Items$ } from "./items"; import * as z from "zod"; +import { + Items, + Items$inboundSchema, + Items$Outbound, + Items$outboundSchema, +} from "./items.js"; export type CompanyRequestBody = { - /** - * Name of company being connected. - */ - name: string; - /** - * Additional information about the company. This can be used to store foreign IDs, references, etc. - */ - description?: string | undefined; - /** - * Reference to the groups that the company is assigned to. - */ - groups?: Array | undefined; + /** + * Name of company being connected. + */ + name: string; + /** + * Additional information about the company. This can be used to store foreign IDs, references, etc. + */ + description?: string | undefined; + /** + * Reference to the groups that the company is assigned to. + */ + groups?: Array | undefined; }; /** @internal */ -export namespace CompanyRequestBody$ { - export const inboundSchema: z.ZodType = z - .object({ - name: z.string(), - description: z.string().optional(), - groups: z.array(Items$.inboundSchema).optional(), - }) - .transform((v) => { - return { - name: v.name, - ...(v.description === undefined ? null : { description: v.description }), - ...(v.groups === undefined ? null : { groups: v.groups }), - }; - }); +export const CompanyRequestBody$inboundSchema: z.ZodType< + CompanyRequestBody, + z.ZodTypeDef, + unknown +> = z.object({ + name: z.string(), + description: z.string().optional(), + groups: z.array(Items$inboundSchema).optional(), +}); - export type Outbound = { - name: string; - description?: string | undefined; - groups?: Array | undefined; - }; +/** @internal */ +export type CompanyRequestBody$Outbound = { + name: string; + description?: string | undefined; + groups?: Array | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - name: z.string(), - description: z.string().optional(), - groups: z.array(Items$.outboundSchema).optional(), - }) - .transform((v) => { - return { - name: v.name, - ...(v.description === undefined ? null : { description: v.description }), - ...(v.groups === undefined ? null : { groups: v.groups }), - }; - }); +/** @internal */ +export const CompanyRequestBody$outboundSchema: z.ZodType< + CompanyRequestBody$Outbound, + z.ZodTypeDef, + CompanyRequestBody +> = z.object({ + name: z.string(), + description: z.string().optional(), + groups: z.array(Items$outboundSchema).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace CompanyRequestBody$ { + /** @deprecated use `CompanyRequestBody$inboundSchema` instead. */ + export const inboundSchema = CompanyRequestBody$inboundSchema; + /** @deprecated use `CompanyRequestBody$outboundSchema` instead. */ + export const outboundSchema = CompanyRequestBody$outboundSchema; + /** @deprecated use `CompanyRequestBody$Outbound` instead. */ + export type Outbound = CompanyRequestBody$Outbound; } diff --git a/lending/src/models/components/connection.ts b/lending/src/models/components/connection.ts index 438a497c..d9265dbf 100644 --- a/lending/src/models/components/connection.ts +++ b/lending/src/models/components/connection.ts @@ -1,22 +1,31 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { DataConnectionError, DataConnectionError$ } from "./dataconnectionerror"; -import { DataConnectionStatus, DataConnectionStatus$ } from "./dataconnectionstatus"; import * as z from "zod"; +import { + DataConnectionError, + DataConnectionError$inboundSchema, + DataConnectionError$Outbound, + DataConnectionError$outboundSchema, +} from "./dataconnectionerror.js"; +import { + DataConnectionStatus, + DataConnectionStatus$inboundSchema, + DataConnectionStatus$outboundSchema, +} from "./dataconnectionstatus.js"; /** * The type of platform of the connection. */ export enum SourceType { - Accounting = "Accounting", - Banking = "Banking", - BankFeed = "BankFeed", - Commerce = "Commerce", - Expense = "Expense", - Other = "Other", - Unknown = "Unknown", + Accounting = "Accounting", + Banking = "Banking", + BankFeed = "BankFeed", + Commerce = "Commerce", + Expense = "Expense", + Other = "Other", + Unknown = "Unknown", } /** @@ -34,188 +43,174 @@ export enum SourceType { * Before you can use a data connection to pull or push data, the company must grant you access to their business data by [linking the connection](https://docs.codat.io/auth-flow/overview). */ export type Connection = { - /** - * Unique identifier for a company's data connection. - */ - id: string; - /** - * A Codat ID representing the integration. - */ - integrationId: string; - /** - * A unique four-character ID that identifies the platform of the company's data connection. This ensures continuity if the platform changes its name in the future. - */ - integrationKey: string; - /** - * A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. - */ - sourceId: string; - /** - * The type of platform of the connection. - */ - sourceType: SourceType; - /** - * Name of integration connected to company. - */ - platformName: string; - /** - * The link URL your customers can use to authorize access to their business application. - */ - linkUrl: string; - /** - * The current authorization status of the data connection. - */ - status: DataConnectionStatus; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - lastSync?: string | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - created: string; - dataConnectionErrors?: Array | undefined; - connectionInfo?: { [k: string]: string } | undefined; - additionalProperties?: any | undefined; + /** + * Unique identifier for a company's data connection. + */ + id: string; + /** + * A Codat ID representing the integration. + */ + integrationId: string; + /** + * A unique four-character ID that identifies the platform of the company's data connection. This ensures continuity if the platform changes its name in the future. + */ + integrationKey: string; + /** + * A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. + */ + sourceId: string; + /** + * The type of platform of the connection. + */ + sourceType: SourceType; + /** + * Name of integration connected to company. + */ + platformName: string; + /** + * The link URL your customers can use to authorize access to their business application. + */ + linkUrl: string; + /** + * The current authorization status of the data connection. + */ + status: DataConnectionStatus; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + lastSync?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + created: string; + dataConnectionErrors?: Array | undefined; + connectionInfo?: { [k: string]: string } | undefined; + additionalProperties?: any | undefined; }; /** @internal */ +export const SourceType$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(SourceType); + +/** @internal */ +export const SourceType$outboundSchema: z.ZodNativeEnum = + SourceType$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace SourceType$ { - export const inboundSchema = z.nativeEnum(SourceType); - export const outboundSchema = inboundSchema; + /** @deprecated use `SourceType$inboundSchema` instead. */ + export const inboundSchema = SourceType$inboundSchema; + /** @deprecated use `SourceType$outboundSchema` instead. */ + export const outboundSchema = SourceType$outboundSchema; } /** @internal */ -export namespace Connection$ { - export const inboundSchema: z.ZodType = z - .object({ - id: z.string(), - integrationId: z.string(), - integrationKey: z.string(), - sourceId: z.string(), - sourceType: SourceType$.inboundSchema, - platformName: z.string(), - linkUrl: z.string(), - status: DataConnectionStatus$.inboundSchema, - lastSync: z.string().optional(), - created: z.string(), - dataConnectionErrors: z.array(DataConnectionError$.inboundSchema).optional(), - connectionInfo: z.record(z.string()).optional(), - additionalProperties: z.any().optional(), - }) - .transform((v) => { - return { - id: v.id, - integrationId: v.integrationId, - integrationKey: v.integrationKey, - sourceId: v.sourceId, - sourceType: v.sourceType, - platformName: v.platformName, - linkUrl: v.linkUrl, - status: v.status, - ...(v.lastSync === undefined ? null : { lastSync: v.lastSync }), - created: v.created, - ...(v.dataConnectionErrors === undefined - ? null - : { dataConnectionErrors: v.dataConnectionErrors }), - ...(v.connectionInfo === undefined ? null : { connectionInfo: v.connectionInfo }), - ...(v.additionalProperties === undefined - ? null - : { additionalProperties: v.additionalProperties }), - }; - }); +export const Connection$inboundSchema: z.ZodType< + Connection, + z.ZodTypeDef, + unknown +> = z.object({ + id: z.string(), + integrationId: z.string(), + integrationKey: z.string(), + sourceId: z.string(), + sourceType: SourceType$inboundSchema, + platformName: z.string(), + linkUrl: z.string(), + status: DataConnectionStatus$inboundSchema, + lastSync: z.string().optional(), + created: z.string(), + dataConnectionErrors: z.array(DataConnectionError$inboundSchema).optional(), + connectionInfo: z.record(z.string()).optional(), + additionalProperties: z.any().optional(), +}); - export type Outbound = { - id: string; - integrationId: string; - integrationKey: string; - sourceId: string; - sourceType: string; - platformName: string; - linkUrl: string; - status: string; - lastSync?: string | undefined; - created: string; - dataConnectionErrors?: Array | undefined; - connectionInfo?: { [k: string]: string } | undefined; - additionalProperties?: any | undefined; - }; +/** @internal */ +export type Connection$Outbound = { + id: string; + integrationId: string; + integrationKey: string; + sourceId: string; + sourceType: string; + platformName: string; + linkUrl: string; + status: string; + lastSync?: string | undefined; + created: string; + dataConnectionErrors?: Array | undefined; + connectionInfo?: { [k: string]: string } | undefined; + additionalProperties?: any | undefined; +}; + +/** @internal */ +export const Connection$outboundSchema: z.ZodType< + Connection$Outbound, + z.ZodTypeDef, + Connection +> = z.object({ + id: z.string(), + integrationId: z.string(), + integrationKey: z.string(), + sourceId: z.string(), + sourceType: SourceType$outboundSchema, + platformName: z.string(), + linkUrl: z.string(), + status: DataConnectionStatus$outboundSchema, + lastSync: z.string().optional(), + created: z.string(), + dataConnectionErrors: z.array(DataConnectionError$outboundSchema).optional(), + connectionInfo: z.record(z.string()).optional(), + additionalProperties: z.any().optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - id: z.string(), - integrationId: z.string(), - integrationKey: z.string(), - sourceId: z.string(), - sourceType: SourceType$.outboundSchema, - platformName: z.string(), - linkUrl: z.string(), - status: DataConnectionStatus$.outboundSchema, - lastSync: z.string().optional(), - created: z.string(), - dataConnectionErrors: z.array(DataConnectionError$.outboundSchema).optional(), - connectionInfo: z.record(z.string()).optional(), - additionalProperties: z.any().optional(), - }) - .transform((v) => { - return { - id: v.id, - integrationId: v.integrationId, - integrationKey: v.integrationKey, - sourceId: v.sourceId, - sourceType: v.sourceType, - platformName: v.platformName, - linkUrl: v.linkUrl, - status: v.status, - ...(v.lastSync === undefined ? null : { lastSync: v.lastSync }), - created: v.created, - ...(v.dataConnectionErrors === undefined - ? null - : { dataConnectionErrors: v.dataConnectionErrors }), - ...(v.connectionInfo === undefined ? null : { connectionInfo: v.connectionInfo }), - ...(v.additionalProperties === undefined - ? null - : { additionalProperties: v.additionalProperties }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Connection$ { + /** @deprecated use `Connection$inboundSchema` instead. */ + export const inboundSchema = Connection$inboundSchema; + /** @deprecated use `Connection$outboundSchema` instead. */ + export const outboundSchema = Connection$outboundSchema; + /** @deprecated use `Connection$Outbound` instead. */ + export type Outbound = Connection$Outbound; } diff --git a/lending/src/models/components/dataconnectionerror.ts b/lending/src/models/components/dataconnectionerror.ts index 9a57d93b..463559e5 100644 --- a/lending/src/models/components/dataconnectionerror.ts +++ b/lending/src/models/components/dataconnectionerror.ts @@ -1,86 +1,87 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type DataConnectionError = { - /** - * The HTTP status code returned by the error. - */ - statusCode?: string | undefined; - /** - * A non-numeric status code/text. - */ - statusText?: string | undefined; - /** - * A brief message about the error. - */ - errorMessage?: string | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - erroredOnUtc?: string | undefined; + /** + * The HTTP status code returned by the error. + */ + statusCode?: string | undefined; + /** + * A non-numeric status code/text. + */ + statusText?: string | undefined; + /** + * A brief message about the error. + */ + errorMessage?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + erroredOnUtc?: string | undefined; }; /** @internal */ -export namespace DataConnectionError$ { - export const inboundSchema: z.ZodType = z - .object({ - statusCode: z.string().optional(), - statusText: z.string().optional(), - errorMessage: z.string().optional(), - erroredOnUtc: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.statusCode === undefined ? null : { statusCode: v.statusCode }), - ...(v.statusText === undefined ? null : { statusText: v.statusText }), - ...(v.errorMessage === undefined ? null : { errorMessage: v.errorMessage }), - ...(v.erroredOnUtc === undefined ? null : { erroredOnUtc: v.erroredOnUtc }), - }; - }); +export const DataConnectionError$inboundSchema: z.ZodType< + DataConnectionError, + z.ZodTypeDef, + unknown +> = z.object({ + statusCode: z.string().optional(), + statusText: z.string().optional(), + errorMessage: z.string().optional(), + erroredOnUtc: z.string().optional(), +}); - export type Outbound = { - statusCode?: string | undefined; - statusText?: string | undefined; - errorMessage?: string | undefined; - erroredOnUtc?: string | undefined; - }; +/** @internal */ +export type DataConnectionError$Outbound = { + statusCode?: string | undefined; + statusText?: string | undefined; + errorMessage?: string | undefined; + erroredOnUtc?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - statusCode: z.string().optional(), - statusText: z.string().optional(), - errorMessage: z.string().optional(), - erroredOnUtc: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.statusCode === undefined ? null : { statusCode: v.statusCode }), - ...(v.statusText === undefined ? null : { statusText: v.statusText }), - ...(v.errorMessage === undefined ? null : { errorMessage: v.errorMessage }), - ...(v.erroredOnUtc === undefined ? null : { erroredOnUtc: v.erroredOnUtc }), - }; - }); +/** @internal */ +export const DataConnectionError$outboundSchema: z.ZodType< + DataConnectionError$Outbound, + z.ZodTypeDef, + DataConnectionError +> = z.object({ + statusCode: z.string().optional(), + statusText: z.string().optional(), + errorMessage: z.string().optional(), + erroredOnUtc: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace DataConnectionError$ { + /** @deprecated use `DataConnectionError$inboundSchema` instead. */ + export const inboundSchema = DataConnectionError$inboundSchema; + /** @deprecated use `DataConnectionError$outboundSchema` instead. */ + export const outboundSchema = DataConnectionError$outboundSchema; + /** @deprecated use `DataConnectionError$Outbound` instead. */ + export type Outbound = DataConnectionError$Outbound; } diff --git a/lending/src/models/components/dataconnectionstatus.ts b/lending/src/models/components/dataconnectionstatus.ts index b8407895..b0a7f684 100644 --- a/lending/src/models/components/dataconnectionstatus.ts +++ b/lending/src/models/components/dataconnectionstatus.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -8,14 +8,29 @@ import * as z from "zod"; * The current authorization status of the data connection. */ export enum DataConnectionStatus { - PendingAuth = "PendingAuth", - Linked = "Linked", - Unlinked = "Unlinked", - Deauthorized = "Deauthorized", + PendingAuth = "PendingAuth", + Linked = "Linked", + Unlinked = "Unlinked", + Deauthorized = "Deauthorized", } /** @internal */ +export const DataConnectionStatus$inboundSchema: z.ZodNativeEnum< + typeof DataConnectionStatus +> = z.nativeEnum(DataConnectionStatus); + +/** @internal */ +export const DataConnectionStatus$outboundSchema: z.ZodNativeEnum< + typeof DataConnectionStatus +> = DataConnectionStatus$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace DataConnectionStatus$ { - export const inboundSchema = z.nativeEnum(DataConnectionStatus); - export const outboundSchema = inboundSchema; + /** @deprecated use `DataConnectionStatus$inboundSchema` instead. */ + export const inboundSchema = DataConnectionStatus$inboundSchema; + /** @deprecated use `DataConnectionStatus$outboundSchema` instead. */ + export const outboundSchema = DataConnectionStatus$outboundSchema; } diff --git a/lending/src/models/components/errorvalidation.ts b/lending/src/models/components/errorvalidation.ts index 9f1a7806..c79e9490 100644 --- a/lending/src/models/components/errorvalidation.ts +++ b/lending/src/models/components/errorvalidation.ts @@ -1,46 +1,58 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ErrorValidationItem, ErrorValidationItem$ } from "./errorvalidationitem"; import * as z from "zod"; +import { + ErrorValidationItem, + ErrorValidationItem$inboundSchema, + ErrorValidationItem$Outbound, + ErrorValidationItem$outboundSchema, +} from "./errorvalidationitem.js"; /** * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. */ export type ErrorValidation = { - errors?: Array | null | undefined; - warnings?: Array | null | undefined; + errors?: Array | null | undefined; + warnings?: Array | null | undefined; }; /** @internal */ -export namespace ErrorValidation$ { - export const inboundSchema: z.ZodType = z - .object({ - errors: z.nullable(z.array(ErrorValidationItem$.inboundSchema)).optional(), - warnings: z.nullable(z.array(ErrorValidationItem$.inboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.errors === undefined ? null : { errors: v.errors }), - ...(v.warnings === undefined ? null : { warnings: v.warnings }), - }; - }); +export const ErrorValidation$inboundSchema: z.ZodType< + ErrorValidation, + z.ZodTypeDef, + unknown +> = z.object({ + errors: z.nullable(z.array(ErrorValidationItem$inboundSchema)).optional(), + warnings: z.nullable(z.array(ErrorValidationItem$inboundSchema)).optional(), +}); + +/** @internal */ +export type ErrorValidation$Outbound = { + errors?: Array | null | undefined; + warnings?: Array | null | undefined; +}; - export type Outbound = { - errors?: Array | null | undefined; - warnings?: Array | null | undefined; - }; +/** @internal */ +export const ErrorValidation$outboundSchema: z.ZodType< + ErrorValidation$Outbound, + z.ZodTypeDef, + ErrorValidation +> = z.object({ + errors: z.nullable(z.array(ErrorValidationItem$outboundSchema)).optional(), + warnings: z.nullable(z.array(ErrorValidationItem$outboundSchema)).optional(), +}); - export const outboundSchema: z.ZodType = z - .object({ - errors: z.nullable(z.array(ErrorValidationItem$.outboundSchema)).optional(), - warnings: z.nullable(z.array(ErrorValidationItem$.outboundSchema)).optional(), - }) - .transform((v) => { - return { - ...(v.errors === undefined ? null : { errors: v.errors }), - ...(v.warnings === undefined ? null : { warnings: v.warnings }), - }; - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ErrorValidation$ { + /** @deprecated use `ErrorValidation$inboundSchema` instead. */ + export const inboundSchema = ErrorValidation$inboundSchema; + /** @deprecated use `ErrorValidation$outboundSchema` instead. */ + export const outboundSchema = ErrorValidation$outboundSchema; + /** @deprecated use `ErrorValidation$Outbound` instead. */ + export type Outbound = ErrorValidation$Outbound; } diff --git a/lending/src/models/components/errorvalidationitem.ts b/lending/src/models/components/errorvalidationitem.ts index e5eb3946..ec4d7aac 100644 --- a/lending/src/models/components/errorvalidationitem.ts +++ b/lending/src/models/components/errorvalidationitem.ts @@ -1,57 +1,62 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type ErrorValidationItem = { - /** - * Unique identifier for a validation item. - */ - itemId?: string | null | undefined; - /** - * A message outlining validation item's issue. - */ - message?: string | null | undefined; - /** - * Name of validator. - */ - validatorName?: string | null | undefined; + /** + * Unique identifier for a validation item. + */ + itemId?: string | null | undefined; + /** + * A message outlining validation item's issue. + */ + message?: string | null | undefined; + /** + * Name of validator. + */ + validatorName?: string | null | undefined; }; /** @internal */ -export namespace ErrorValidationItem$ { - export const inboundSchema: z.ZodType = z - .object({ - itemId: z.nullable(z.string()).optional(), - message: z.nullable(z.string()).optional(), - validatorName: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.itemId === undefined ? null : { itemId: v.itemId }), - ...(v.message === undefined ? null : { message: v.message }), - ...(v.validatorName === undefined ? null : { validatorName: v.validatorName }), - }; - }); +export const ErrorValidationItem$inboundSchema: z.ZodType< + ErrorValidationItem, + z.ZodTypeDef, + unknown +> = z.object({ + itemId: z.nullable(z.string()).optional(), + message: z.nullable(z.string()).optional(), + validatorName: z.nullable(z.string()).optional(), +}); - export type Outbound = { - itemId?: string | null | undefined; - message?: string | null | undefined; - validatorName?: string | null | undefined; - }; +/** @internal */ +export type ErrorValidationItem$Outbound = { + itemId?: string | null | undefined; + message?: string | null | undefined; + validatorName?: string | null | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - itemId: z.nullable(z.string()).optional(), - message: z.nullable(z.string()).optional(), - validatorName: z.nullable(z.string()).optional(), - }) - .transform((v) => { - return { - ...(v.itemId === undefined ? null : { itemId: v.itemId }), - ...(v.message === undefined ? null : { message: v.message }), - ...(v.validatorName === undefined ? null : { validatorName: v.validatorName }), - }; - }); +/** @internal */ +export const ErrorValidationItem$outboundSchema: z.ZodType< + ErrorValidationItem$Outbound, + z.ZodTypeDef, + ErrorValidationItem +> = z.object({ + itemId: z.nullable(z.string()).optional(), + message: z.nullable(z.string()).optional(), + validatorName: z.nullable(z.string()).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ErrorValidationItem$ { + /** @deprecated use `ErrorValidationItem$inboundSchema` instead. */ + export const inboundSchema = ErrorValidationItem$inboundSchema; + /** @deprecated use `ErrorValidationItem$outboundSchema` instead. */ + export const outboundSchema = ErrorValidationItem$outboundSchema; + /** @deprecated use `ErrorValidationItem$Outbound` instead. */ + export type Outbound = ErrorValidationItem$Outbound; } diff --git a/lending/src/models/components/halref.ts b/lending/src/models/components/halref.ts index 1d335538..322dda69 100644 --- a/lending/src/models/components/halref.ts +++ b/lending/src/models/components/halref.ts @@ -1,39 +1,45 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type HalRef = { - /** - * Uri hypertext reference. - */ - href?: string | undefined; + /** + * Uri hypertext reference. + */ + href?: string | undefined; }; /** @internal */ -export namespace HalRef$ { - export const inboundSchema: z.ZodType = z - .object({ - href: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.href === undefined ? null : { href: v.href }), - }; - }); +export const HalRef$inboundSchema: z.ZodType = z + .object({ + href: z.string().optional(), + }); - export type Outbound = { - href?: string | undefined; - }; +/** @internal */ +export type HalRef$Outbound = { + href?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - href: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.href === undefined ? null : { href: v.href }), - }; - }); +/** @internal */ +export const HalRef$outboundSchema: z.ZodType< + HalRef$Outbound, + z.ZodTypeDef, + HalRef +> = z.object({ + href: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace HalRef$ { + /** @deprecated use `HalRef$inboundSchema` instead. */ + export const inboundSchema = HalRef$inboundSchema; + /** @deprecated use `HalRef$outboundSchema` instead. */ + export const outboundSchema = HalRef$outboundSchema; + /** @deprecated use `HalRef$Outbound` instead. */ + export type Outbound = HalRef$Outbound; } diff --git a/lending/src/models/components/httpmetadata.ts b/lending/src/models/components/httpmetadata.ts index 3b51f1ef..9f2d2e2b 100644 --- a/lending/src/models/components/httpmetadata.ts +++ b/lending/src/models/components/httpmetadata.ts @@ -1,52 +1,70 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; export type HTTPMetadata = { - /** - * Raw HTTP response; suitable for custom response parsing - */ - response: Response; - /** - * Raw HTTP request; suitable for debugging - */ - request: Request; + /** + * Raw HTTP response; suitable for custom response parsing + */ + response: Response; + /** + * Raw HTTP request; suitable for debugging + */ + request: Request; }; /** @internal */ -export namespace HTTPMetadata$ { - export const inboundSchema: z.ZodType = z - .object({ - Response: z.instanceof(Response), - Request: z.instanceof(Request), - }) - .transform((v) => { - return { - response: v.Response, - request: v.Request, - }; - }); +export const HTTPMetadata$inboundSchema: z.ZodType< + HTTPMetadata, + z.ZodTypeDef, + unknown +> = z.object({ + Response: z.instanceof(Response), + Request: z.instanceof(Request), +}).transform((v) => { + return remap$(v, { + "Response": "response", + "Request": "request", + }); +}); - export type Outbound = { - Response: never; - Request: never; - }; +/** @internal */ +export type HTTPMetadata$Outbound = { + Response: never; + Request: never; +}; - export const outboundSchema: z.ZodType = z - .object({ - response: z.instanceof(Response).transform(() => { - throw new Error("Response cannot be serialized"); - }), - request: z.instanceof(Request).transform(() => { - throw new Error("Response cannot be serialized"); - }), - }) - .transform((v) => { - return { - Response: v.response, - Request: v.request, - }; - }); +/** @internal */ +export const HTTPMetadata$outboundSchema: z.ZodType< + HTTPMetadata$Outbound, + z.ZodTypeDef, + HTTPMetadata +> = z.object({ + response: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), + request: z.instanceof(Request).transform(() => { + throw new Error("Response cannot be serialized"); + }), +}).transform((v) => { + return remap$(v, { + response: "Response", + request: "Request", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace HTTPMetadata$ { + /** @deprecated use `HTTPMetadata$inboundSchema` instead. */ + export const inboundSchema = HTTPMetadata$inboundSchema; + /** @deprecated use `HTTPMetadata$outboundSchema` instead. */ + export const outboundSchema = HTTPMetadata$outboundSchema; + /** @deprecated use `HTTPMetadata$Outbound` instead. */ + export type Outbound = HTTPMetadata$Outbound; } diff --git a/lending/src/models/components/index.ts b/lending/src/models/components/index.ts index 6b30630f..fa8cacf4 100644 --- a/lending/src/models/components/index.ts +++ b/lending/src/models/components/index.ts @@ -1,17 +1,17 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./companies"; -export * from "./company"; -export * from "./companyrequestbody"; -export * from "./connection"; -export * from "./dataconnectionerror"; -export * from "./dataconnectionstatus"; -export * from "./errorvalidation"; -export * from "./errorvalidationitem"; -export * from "./halref"; -export * from "./httpmetadata"; -export * from "./items"; -export * from "./links"; -export * from "./security"; +export * from "./companies.js"; +export * from "./company.js"; +export * from "./companyrequestbody.js"; +export * from "./connection.js"; +export * from "./dataconnectionerror.js"; +export * from "./dataconnectionstatus.js"; +export * from "./errorvalidation.js"; +export * from "./errorvalidationitem.js"; +export * from "./halref.js"; +export * from "./httpmetadata.js"; +export * from "./items.js"; +export * from "./links.js"; +export * from "./security.js"; diff --git a/lending/src/models/components/items.ts b/lending/src/models/components/items.ts index e8b6ee60..282618c2 100644 --- a/lending/src/models/components/items.ts +++ b/lending/src/models/components/items.ts @@ -1,39 +1,45 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; export type Items = { - /** - * Unique identifier for the group. - */ - id?: string | undefined; + /** + * Unique identifier for the group. + */ + id?: string | undefined; }; /** @internal */ -export namespace Items$ { - export const inboundSchema: z.ZodType = z - .object({ - id: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.id === undefined ? null : { id: v.id }), - }; - }); +export const Items$inboundSchema: z.ZodType = z + .object({ + id: z.string().optional(), + }); - export type Outbound = { - id?: string | undefined; - }; +/** @internal */ +export type Items$Outbound = { + id?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - id: z.string().optional(), - }) - .transform((v) => { - return { - ...(v.id === undefined ? null : { id: v.id }), - }; - }); +/** @internal */ +export const Items$outboundSchema: z.ZodType< + Items$Outbound, + z.ZodTypeDef, + Items +> = z.object({ + id: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Items$ { + /** @deprecated use `Items$inboundSchema` instead. */ + export const inboundSchema = Items$inboundSchema; + /** @deprecated use `Items$outboundSchema` instead. */ + export const outboundSchema = Items$outboundSchema; + /** @deprecated use `Items$Outbound` instead. */ + export type Outbound = Items$Outbound; } diff --git a/lending/src/models/components/links.ts b/lending/src/models/components/links.ts index 90030c0e..31ddfc07 100644 --- a/lending/src/models/components/links.ts +++ b/lending/src/models/components/links.ts @@ -1,55 +1,60 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { HalRef, HalRef$ } from "./halref"; import * as z from "zod"; +import { + HalRef, + HalRef$inboundSchema, + HalRef$Outbound, + HalRef$outboundSchema, +} from "./halref.js"; export type Links = { - self: HalRef; - current: HalRef; - next?: HalRef | undefined; - previous?: HalRef | undefined; + self: HalRef; + current: HalRef; + next?: HalRef | undefined; + previous?: HalRef | undefined; }; /** @internal */ -export namespace Links$ { - export const inboundSchema: z.ZodType = z - .object({ - self: HalRef$.inboundSchema, - current: HalRef$.inboundSchema, - next: HalRef$.inboundSchema.optional(), - previous: HalRef$.inboundSchema.optional(), - }) - .transform((v) => { - return { - self: v.self, - current: v.current, - ...(v.next === undefined ? null : { next: v.next }), - ...(v.previous === undefined ? null : { previous: v.previous }), - }; - }); +export const Links$inboundSchema: z.ZodType = z + .object({ + self: HalRef$inboundSchema, + current: HalRef$inboundSchema, + next: HalRef$inboundSchema.optional(), + previous: HalRef$inboundSchema.optional(), + }); - export type Outbound = { - self: HalRef$.Outbound; - current: HalRef$.Outbound; - next?: HalRef$.Outbound | undefined; - previous?: HalRef$.Outbound | undefined; - }; +/** @internal */ +export type Links$Outbound = { + self: HalRef$Outbound; + current: HalRef$Outbound; + next?: HalRef$Outbound | undefined; + previous?: HalRef$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - self: HalRef$.outboundSchema, - current: HalRef$.outboundSchema, - next: HalRef$.outboundSchema.optional(), - previous: HalRef$.outboundSchema.optional(), - }) - .transform((v) => { - return { - self: v.self, - current: v.current, - ...(v.next === undefined ? null : { next: v.next }), - ...(v.previous === undefined ? null : { previous: v.previous }), - }; - }); +/** @internal */ +export const Links$outboundSchema: z.ZodType< + Links$Outbound, + z.ZodTypeDef, + Links +> = z.object({ + self: HalRef$outboundSchema, + current: HalRef$outboundSchema, + next: HalRef$outboundSchema.optional(), + previous: HalRef$outboundSchema.optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Links$ { + /** @deprecated use `Links$inboundSchema` instead. */ + export const inboundSchema = Links$inboundSchema; + /** @deprecated use `Links$outboundSchema` instead. */ + export const outboundSchema = Links$outboundSchema; + /** @deprecated use `Links$Outbound` instead. */ + export type Outbound = Links$Outbound; } diff --git a/lending/src/models/components/security.ts b/lending/src/models/components/security.ts index 73e24f7d..525f2c2f 100644 --- a/lending/src/models/components/security.ts +++ b/lending/src/models/components/security.ts @@ -1,36 +1,54 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; export type Security = { - authHeader: string; + authHeader: string; }; /** @internal */ -export namespace Security$ { - export const inboundSchema: z.ZodType = z - .object({ - auth_header: z.string(), - }) - .transform((v) => { - return { - authHeader: v.auth_header, - }; - }); +export const Security$inboundSchema: z.ZodType< + Security, + z.ZodTypeDef, + unknown +> = z.object({ + auth_header: z.string(), +}).transform((v) => { + return remap$(v, { + "auth_header": "authHeader", + }); +}); - export type Outbound = { - auth_header: string; - }; +/** @internal */ +export type Security$Outbound = { + auth_header: string; +}; - export const outboundSchema: z.ZodType = z - .object({ - authHeader: z.string(), - }) - .transform((v) => { - return { - auth_header: v.authHeader, - }; - }); +/** @internal */ +export const Security$outboundSchema: z.ZodType< + Security$Outbound, + z.ZodTypeDef, + Security +> = z.object({ + authHeader: z.string(), +}).transform((v) => { + return remap$(v, { + authHeader: "auth_header", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Security$ { + /** @deprecated use `Security$inboundSchema` instead. */ + export const inboundSchema = Security$inboundSchema; + /** @deprecated use `Security$outboundSchema` instead. */ + export const outboundSchema = Security$outboundSchema; + /** @deprecated use `Security$Outbound` instead. */ + export type Outbound = Security$Outbound; } diff --git a/lending/src/models/errors/errormessage.ts b/lending/src/models/errors/errormessage.ts index 8b383ac6..7a2810a9 100644 --- a/lending/src/models/errors/errormessage.ts +++ b/lending/src/models/errors/errormessage.ts @@ -1,179 +1,157 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as components from "../components"; import * as z from "zod"; +import * as components from "../components/index.js"; /** * The request made is not valid. */ export type ErrorMessageData = { - /** - * The HTTP status code returned by the error. - */ - statusCode?: number | undefined; - /** - * Codat's service the returned the error. - */ - service?: string | undefined; - /** - * A brief description of the error. - */ - error?: string | undefined; - /** - * Unique identifier used to propagate to all downstream services and determine the source of the error. - */ - correlationId?: string | undefined; - /** - * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. - */ - validation?: components.ErrorValidation | null | undefined; - /** - * `True` if the error occurred transiently and can be retried. - */ - canBeRetried?: string | undefined; - /** - * Machine readable error code used to automate processes based on the code returned. - */ - detailedErrorCode?: number | undefined; + /** + * The HTTP status code returned by the error. + */ + statusCode?: number | undefined; + /** + * Codat's service the returned the error. + */ + service?: string | undefined; + /** + * A brief description of the error. + */ + error?: string | undefined; + /** + * Unique identifier used to propagate to all downstream services and determine the source of the error. + */ + correlationId?: string | undefined; + /** + * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. + */ + validation?: components.ErrorValidation | null | undefined; + /** + * `True` if the error occurred transiently and can be retried. + */ + canBeRetried?: string | undefined; + /** + * Machine readable error code used to automate processes based on the code returned. + */ + detailedErrorCode?: number | undefined; }; /** * The request made is not valid. */ export class ErrorMessage extends Error { - /** - * The HTTP status code returned by the error. - */ - statusCode?: number | undefined; - /** - * Codat's service the returned the error. - */ - service?: string | undefined; - /** - * A brief description of the error. - */ - error?: string | undefined; - /** - * Unique identifier used to propagate to all downstream services and determine the source of the error. - */ - correlationId?: string | undefined; - /** - * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. - */ - validation?: components.ErrorValidation | null | undefined; - /** - * `True` if the error occurred transiently and can be retried. - */ - canBeRetried?: string | undefined; - /** - * Machine readable error code used to automate processes based on the code returned. - */ - detailedErrorCode?: number | undefined; + /** + * The HTTP status code returned by the error. + */ + statusCode?: number | undefined; + /** + * Codat's service the returned the error. + */ + service?: string | undefined; + /** + * A brief description of the error. + */ + error?: string | undefined; + /** + * Unique identifier used to propagate to all downstream services and determine the source of the error. + */ + correlationId?: string | undefined; + /** + * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. + */ + validation?: components.ErrorValidation | null | undefined; + /** + * `True` if the error occurred transiently and can be retried. + */ + canBeRetried?: string | undefined; + /** + * Machine readable error code used to automate processes based on the code returned. + */ + detailedErrorCode?: number | undefined; - /** The original data that was passed to this error instance. */ - data$: ErrorMessageData; + /** The original data that was passed to this error instance. */ + data$: ErrorMessageData; - constructor(err: ErrorMessageData) { - super(""); - this.data$ = err; + constructor(err: ErrorMessageData) { + const message = "message" in err && typeof err.message === "string" + ? err.message + : `API error occurred: ${JSON.stringify(err)}`; + super(message); + this.data$ = err; - if (err.statusCode != null) { - this.statusCode = err.statusCode; - } - if (err.service != null) { - this.service = err.service; - } - if (err.error != null) { - this.error = err.error; - } - if (err.correlationId != null) { - this.correlationId = err.correlationId; - } - if (err.validation != null) { - this.validation = err.validation; - } - if (err.canBeRetried != null) { - this.canBeRetried = err.canBeRetried; - } - if (err.detailedErrorCode != null) { - this.detailedErrorCode = err.detailedErrorCode; - } - - this.message = - "message" in err && typeof err.message === "string" - ? err.message - : "API error occurred"; - - this.name = "ErrorMessage"; + if (err.statusCode != null) this.statusCode = err.statusCode; + if (err.service != null) this.service = err.service; + if (err.error != null) this.error = err.error; + if (err.correlationId != null) this.correlationId = err.correlationId; + if (err.validation != null) this.validation = err.validation; + if (err.canBeRetried != null) this.canBeRetried = err.canBeRetried; + if (err.detailedErrorCode != null) { + this.detailedErrorCode = err.detailedErrorCode; } + + this.name = "ErrorMessage"; + } } /** @internal */ -export namespace ErrorMessage$ { - export const inboundSchema: z.ZodType = z - .object({ - statusCode: z.number().int().optional(), - service: z.string().optional(), - error: z.string().optional(), - correlationId: z.string().optional(), - validation: z.nullable(components.ErrorValidation$.inboundSchema).optional(), - canBeRetried: z.string().optional(), - detailedErrorCode: z.number().int().optional(), - }) - .transform((v) => { - return new ErrorMessage({ - ...(v.statusCode === undefined ? null : { statusCode: v.statusCode }), - ...(v.service === undefined ? null : { service: v.service }), - ...(v.error === undefined ? null : { error: v.error }), - ...(v.correlationId === undefined ? null : { correlationId: v.correlationId }), - ...(v.validation === undefined ? null : { validation: v.validation }), - ...(v.canBeRetried === undefined ? null : { canBeRetried: v.canBeRetried }), - ...(v.detailedErrorCode === undefined - ? null - : { detailedErrorCode: v.detailedErrorCode }), - }); - }); +export const ErrorMessage$inboundSchema: z.ZodType< + ErrorMessage, + z.ZodTypeDef, + unknown +> = z.object({ + statusCode: z.number().int().optional(), + service: z.string().optional(), + error: z.string().optional(), + correlationId: z.string().optional(), + validation: z.nullable(components.ErrorValidation$inboundSchema).optional(), + canBeRetried: z.string().optional(), + detailedErrorCode: z.number().int().optional(), +}) + .transform((v) => { + return new ErrorMessage(v); + }); - export type Outbound = { - statusCode?: number | undefined; - service?: string | undefined; - error?: string | undefined; - correlationId?: string | undefined; - validation?: components.ErrorValidation$.Outbound | null | undefined; - canBeRetried?: string | undefined; - detailedErrorCode?: number | undefined; - }; +/** @internal */ +export type ErrorMessage$Outbound = { + statusCode?: number | undefined; + service?: string | undefined; + error?: string | undefined; + correlationId?: string | undefined; + validation?: components.ErrorValidation$Outbound | null | undefined; + canBeRetried?: string | undefined; + detailedErrorCode?: number | undefined; +}; - export const outboundSchema: z.ZodType = z - .instanceof(ErrorMessage) - .transform((v) => v.data$) - .pipe( - z - .object({ - statusCode: z.number().int().optional(), - service: z.string().optional(), - error: z.string().optional(), - correlationId: z.string().optional(), - validation: z.nullable(components.ErrorValidation$.outboundSchema).optional(), - canBeRetried: z.string().optional(), - detailedErrorCode: z.number().int().optional(), - }) - .transform((v) => { - return { - ...(v.statusCode === undefined ? null : { statusCode: v.statusCode }), - ...(v.service === undefined ? null : { service: v.service }), - ...(v.error === undefined ? null : { error: v.error }), - ...(v.correlationId === undefined - ? null - : { correlationId: v.correlationId }), - ...(v.validation === undefined ? null : { validation: v.validation }), - ...(v.canBeRetried === undefined ? null : { canBeRetried: v.canBeRetried }), - ...(v.detailedErrorCode === undefined - ? null - : { detailedErrorCode: v.detailedErrorCode }), - }; - }) - ); +/** @internal */ +export const ErrorMessage$outboundSchema: z.ZodType< + ErrorMessage$Outbound, + z.ZodTypeDef, + ErrorMessage +> = z.instanceof(ErrorMessage) + .transform(v => v.data$) + .pipe(z.object({ + statusCode: z.number().int().optional(), + service: z.string().optional(), + error: z.string().optional(), + correlationId: z.string().optional(), + validation: z.nullable(components.ErrorValidation$outboundSchema) + .optional(), + canBeRetried: z.string().optional(), + detailedErrorCode: z.number().int().optional(), + })); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ErrorMessage$ { + /** @deprecated use `ErrorMessage$inboundSchema` instead. */ + export const inboundSchema = ErrorMessage$inboundSchema; + /** @deprecated use `ErrorMessage$outboundSchema` instead. */ + export const outboundSchema = ErrorMessage$outboundSchema; + /** @deprecated use `ErrorMessage$Outbound` instead. */ + export type Outbound = ErrorMessage$Outbound; } diff --git a/lending/src/models/errors/httpclienterrors.ts b/lending/src/models/errors/httpclienterrors.ts new file mode 100644 index 00000000..b34f6121 --- /dev/null +++ b/lending/src/models/errors/httpclienterrors.ts @@ -0,0 +1,62 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * Base class for all HTTP errors. + */ +export class HTTPClientError extends Error { + /** The underlying cause of the error. */ + override readonly cause: unknown; + override name = "HTTPClientError"; + constructor(message: string, opts?: { cause?: unknown }) { + let msg = message; + if (opts?.cause) { + msg += `: ${opts.cause}`; + } + + super(msg, opts); + // In older runtimes, the cause field would not have been assigned through + // the super() call. + if (typeof this.cause === "undefined") { + this.cause = opts?.cause; + } + } +} + +/** + * An error to capture unrecognised or unexpected errors when making HTTP calls. + */ +export class UnexpectedClientError extends HTTPClientError { + override name = "UnexpectedClientError"; +} + +/** + * An error that is raised when any inputs used to create a request are invalid. + */ +export class InvalidRequestError extends HTTPClientError { + override name = "InvalidRequestError"; +} + +/** + * An error that is raised when a HTTP request was aborted by the client error. + */ +export class RequestAbortedError extends HTTPClientError { + override readonly name = "RequestAbortedError"; +} + +/** + * An error that is raised when a HTTP request timed out due to an AbortSignal + * signal timeout. + */ +export class RequestTimeoutError extends HTTPClientError { + override readonly name = "RequestTimeoutError"; +} + +/** + * An error that is raised when a HTTP client is unable to make a request to + * a server. + */ +export class ConnectionError extends HTTPClientError { + override readonly name = "ConnectionError"; +} diff --git a/lending/src/models/errors/index.ts b/lending/src/models/errors/index.ts index 1b6fc0d0..615a5157 100644 --- a/lending/src/models/errors/index.ts +++ b/lending/src/models/errors/index.ts @@ -1,7 +1,8 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./errormessage"; -export * from "./sdkerror"; -export * from "./sdkvalidationerror"; +export * from "./errormessage.js"; +export * from "./httpclienterrors.js"; +export * from "./sdkerror.js"; +export * from "./sdkvalidationerror.js"; diff --git a/lending/src/models/errors/sdkerror.ts b/lending/src/models/errors/sdkerror.ts index b7261372..1c2adb2d 100644 --- a/lending/src/models/errors/sdkerror.ts +++ b/lending/src/models/errors/sdkerror.ts @@ -1,21 +1,21 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export class SDKError extends Error { - constructor( - message: string, - public readonly httpMeta: { - response: Response; - request: Request; - } - ) { - super( - `${message}: Status ${httpMeta.response.status} Content-Type ${ - httpMeta.response.headers.get("content-type") || "" - }` - ); + constructor( + message: string, + public readonly httpMeta: { + response: Response; + request: Request; + }, + ) { + super( + `${message}: Status ${httpMeta.response.status} Content-Type ${ + httpMeta.response.headers.get("content-type") || "" + }`, + ); - this.name = "SDKError"; - } + this.name = "SDKError"; + } } diff --git a/lending/src/models/errors/sdkvalidationerror.ts b/lending/src/models/errors/sdkvalidationerror.ts index 5eb92182..16929b9e 100644 --- a/lending/src/models/errors/sdkvalidationerror.ts +++ b/lending/src/models/errors/sdkvalidationerror.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -10,15 +10,17 @@ export class SDKValidationError extends Error { */ public readonly rawValue: unknown; + /** + * The raw message that failed validation. + */ + public readonly rawMessage: unknown; + constructor(message: string, cause: unknown, rawValue: unknown) { - super(message); + super(`${message}: ${cause}`); this.name = "SDKValidationError"; this.cause = cause; this.rawValue = rawValue; - } - - public override toString(): string { - return `${this.message}: ${this.cause}`; + this.rawMessage = message; } /** @@ -28,7 +30,7 @@ export class SDKValidationError extends Error { */ public pretty(): string { if (this.cause instanceof z.ZodError) { - return `${this.message}\n${formatZodError(this.cause)}`; + return `${this.rawMessage}\n${formatZodError(this.cause)}`; } else { return this.toString(); } diff --git a/lending/src/models/operations/createcompany.ts b/lending/src/models/operations/createcompany.ts index d77f9b76..9e3a4bb9 100644 --- a/lending/src/models/operations/createcompany.ts +++ b/lending/src/models/operations/createcompany.ts @@ -1,46 +1,64 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as components from "../components"; import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as components from "../components/index.js"; export type CreateCompanyResponse = { - httpMeta: components.HTTPMetadata; - /** - * OK - */ - company?: components.Company | undefined; + httpMeta: components.HTTPMetadata; + /** + * OK + */ + company?: components.Company | undefined; }; /** @internal */ -export namespace CreateCompanyResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - HttpMeta: components.HTTPMetadata$.inboundSchema, - Company: components.Company$.inboundSchema.optional(), - }) - .transform((v) => { - return { - httpMeta: v.HttpMeta, - ...(v.Company === undefined ? null : { company: v.Company }), - }; - }); +export const CreateCompanyResponse$inboundSchema: z.ZodType< + CreateCompanyResponse, + z.ZodTypeDef, + unknown +> = z.object({ + HttpMeta: components.HTTPMetadata$inboundSchema, + Company: components.Company$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "HttpMeta": "httpMeta", + "Company": "company", + }); +}); - export type Outbound = { - HttpMeta: components.HTTPMetadata$.Outbound; - Company?: components.Company$.Outbound | undefined; - }; +/** @internal */ +export type CreateCompanyResponse$Outbound = { + HttpMeta: components.HTTPMetadata$Outbound; + Company?: components.Company$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - httpMeta: components.HTTPMetadata$.outboundSchema, - company: components.Company$.outboundSchema.optional(), - }) - .transform((v) => { - return { - HttpMeta: v.httpMeta, - ...(v.company === undefined ? null : { Company: v.company }), - }; - }); +/** @internal */ +export const CreateCompanyResponse$outboundSchema: z.ZodType< + CreateCompanyResponse$Outbound, + z.ZodTypeDef, + CreateCompanyResponse +> = z.object({ + httpMeta: components.HTTPMetadata$outboundSchema, + company: components.Company$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + httpMeta: "HttpMeta", + company: "Company", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace CreateCompanyResponse$ { + /** @deprecated use `CreateCompanyResponse$inboundSchema` instead. */ + export const inboundSchema = CreateCompanyResponse$inboundSchema; + /** @deprecated use `CreateCompanyResponse$outboundSchema` instead. */ + export const outboundSchema = CreateCompanyResponse$outboundSchema; + /** @deprecated use `CreateCompanyResponse$Outbound` instead. */ + export type Outbound = CreateCompanyResponse$Outbound; } diff --git a/lending/src/models/operations/deletecompany.ts b/lending/src/models/operations/deletecompany.ts index 65e76ccd..408e8245 100644 --- a/lending/src/models/operations/deletecompany.ts +++ b/lending/src/models/operations/deletecompany.ts @@ -1,71 +1,98 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as components from "../components"; import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as components from "../components/index.js"; export type DeleteCompanyRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; export type DeleteCompanyResponse = { - httpMeta: components.HTTPMetadata; + httpMeta: components.HTTPMetadata; }; /** @internal */ -export namespace DeleteCompanyRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - }) - .transform((v) => { - return { - companyId: v.companyId, - }; - }); +export const DeleteCompanyRequest$inboundSchema: z.ZodType< + DeleteCompanyRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), +}); - export type Outbound = { - companyId: string; - }; +/** @internal */ +export type DeleteCompanyRequest$Outbound = { + companyId: string; +}; - export const outboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - }) - .transform((v) => { - return { - companyId: v.companyId, - }; - }); +/** @internal */ +export const DeleteCompanyRequest$outboundSchema: z.ZodType< + DeleteCompanyRequest$Outbound, + z.ZodTypeDef, + DeleteCompanyRequest +> = z.object({ + companyId: z.string(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace DeleteCompanyRequest$ { + /** @deprecated use `DeleteCompanyRequest$inboundSchema` instead. */ + export const inboundSchema = DeleteCompanyRequest$inboundSchema; + /** @deprecated use `DeleteCompanyRequest$outboundSchema` instead. */ + export const outboundSchema = DeleteCompanyRequest$outboundSchema; + /** @deprecated use `DeleteCompanyRequest$Outbound` instead. */ + export type Outbound = DeleteCompanyRequest$Outbound; } /** @internal */ -export namespace DeleteCompanyResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - HttpMeta: components.HTTPMetadata$.inboundSchema, - }) - .transform((v) => { - return { - httpMeta: v.HttpMeta, - }; - }); +export const DeleteCompanyResponse$inboundSchema: z.ZodType< + DeleteCompanyResponse, + z.ZodTypeDef, + unknown +> = z.object({ + HttpMeta: components.HTTPMetadata$inboundSchema, +}).transform((v) => { + return remap$(v, { + "HttpMeta": "httpMeta", + }); +}); - export type Outbound = { - HttpMeta: components.HTTPMetadata$.Outbound; - }; +/** @internal */ +export type DeleteCompanyResponse$Outbound = { + HttpMeta: components.HTTPMetadata$Outbound; +}; - export const outboundSchema: z.ZodType = z - .object({ - httpMeta: components.HTTPMetadata$.outboundSchema, - }) - .transform((v) => { - return { - HttpMeta: v.httpMeta, - }; - }); +/** @internal */ +export const DeleteCompanyResponse$outboundSchema: z.ZodType< + DeleteCompanyResponse$Outbound, + z.ZodTypeDef, + DeleteCompanyResponse +> = z.object({ + httpMeta: components.HTTPMetadata$outboundSchema, +}).transform((v) => { + return remap$(v, { + httpMeta: "HttpMeta", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace DeleteCompanyResponse$ { + /** @deprecated use `DeleteCompanyResponse$inboundSchema` instead. */ + export const inboundSchema = DeleteCompanyResponse$inboundSchema; + /** @deprecated use `DeleteCompanyResponse$outboundSchema` instead. */ + export const outboundSchema = DeleteCompanyResponse$outboundSchema; + /** @deprecated use `DeleteCompanyResponse$Outbound` instead. */ + export type Outbound = DeleteCompanyResponse$Outbound; } diff --git a/lending/src/models/operations/getcompany.ts b/lending/src/models/operations/getcompany.ts index 6e9e112a..a3ca73fe 100644 --- a/lending/src/models/operations/getcompany.ts +++ b/lending/src/models/operations/getcompany.ts @@ -1,80 +1,107 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as components from "../components"; import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as components from "../components/index.js"; export type GetCompanyRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; export type GetCompanyResponse = { - httpMeta: components.HTTPMetadata; - /** - * OK - */ - company?: components.Company | undefined; + httpMeta: components.HTTPMetadata; + /** + * OK + */ + company?: components.Company | undefined; }; /** @internal */ -export namespace GetCompanyRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - }) - .transform((v) => { - return { - companyId: v.companyId, - }; - }); +export const GetCompanyRequest$inboundSchema: z.ZodType< + GetCompanyRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), +}); - export type Outbound = { - companyId: string; - }; +/** @internal */ +export type GetCompanyRequest$Outbound = { + companyId: string; +}; - export const outboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - }) - .transform((v) => { - return { - companyId: v.companyId, - }; - }); +/** @internal */ +export const GetCompanyRequest$outboundSchema: z.ZodType< + GetCompanyRequest$Outbound, + z.ZodTypeDef, + GetCompanyRequest +> = z.object({ + companyId: z.string(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetCompanyRequest$ { + /** @deprecated use `GetCompanyRequest$inboundSchema` instead. */ + export const inboundSchema = GetCompanyRequest$inboundSchema; + /** @deprecated use `GetCompanyRequest$outboundSchema` instead. */ + export const outboundSchema = GetCompanyRequest$outboundSchema; + /** @deprecated use `GetCompanyRequest$Outbound` instead. */ + export type Outbound = GetCompanyRequest$Outbound; } /** @internal */ -export namespace GetCompanyResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - HttpMeta: components.HTTPMetadata$.inboundSchema, - Company: components.Company$.inboundSchema.optional(), - }) - .transform((v) => { - return { - httpMeta: v.HttpMeta, - ...(v.Company === undefined ? null : { company: v.Company }), - }; - }); +export const GetCompanyResponse$inboundSchema: z.ZodType< + GetCompanyResponse, + z.ZodTypeDef, + unknown +> = z.object({ + HttpMeta: components.HTTPMetadata$inboundSchema, + Company: components.Company$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "HttpMeta": "httpMeta", + "Company": "company", + }); +}); - export type Outbound = { - HttpMeta: components.HTTPMetadata$.Outbound; - Company?: components.Company$.Outbound | undefined; - }; +/** @internal */ +export type GetCompanyResponse$Outbound = { + HttpMeta: components.HTTPMetadata$Outbound; + Company?: components.Company$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - httpMeta: components.HTTPMetadata$.outboundSchema, - company: components.Company$.outboundSchema.optional(), - }) - .transform((v) => { - return { - HttpMeta: v.httpMeta, - ...(v.company === undefined ? null : { Company: v.company }), - }; - }); +/** @internal */ +export const GetCompanyResponse$outboundSchema: z.ZodType< + GetCompanyResponse$Outbound, + z.ZodTypeDef, + GetCompanyResponse +> = z.object({ + httpMeta: components.HTTPMetadata$outboundSchema, + company: components.Company$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + httpMeta: "HttpMeta", + company: "Company", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetCompanyResponse$ { + /** @deprecated use `GetCompanyResponse$inboundSchema` instead. */ + export const inboundSchema = GetCompanyResponse$inboundSchema; + /** @deprecated use `GetCompanyResponse$outboundSchema` instead. */ + export const outboundSchema = GetCompanyResponse$outboundSchema; + /** @deprecated use `GetCompanyResponse$Outbound` instead. */ + export type Outbound = GetCompanyResponse$Outbound; } diff --git a/lending/src/models/operations/index.ts b/lending/src/models/operations/index.ts index 3e96553e..50eeef78 100644 --- a/lending/src/models/operations/index.ts +++ b/lending/src/models/operations/index.ts @@ -1,9 +1,9 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./createcompany"; -export * from "./deletecompany"; -export * from "./getcompany"; -export * from "./listcompanies"; -export * from "./updatecompany"; +export * from "./createcompany.js"; +export * from "./deletecompany.js"; +export * from "./getcompany.js"; +export * from "./listcompanies.js"; +export * from "./updatecompany.js"; diff --git a/lending/src/models/operations/listcompanies.ts b/lending/src/models/operations/listcompanies.ts index 0e193325..d0d63668 100644 --- a/lending/src/models/operations/listcompanies.ts +++ b/lending/src/models/operations/listcompanies.ts @@ -1,107 +1,128 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as components from "../components"; import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as components from "../components/index.js"; export type ListCompaniesRequest = { - /** - * Page number. [Read more](https://docs.codat.io/using-the-api/paging). - */ - page?: number | undefined; - /** - * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). - */ - pageSize?: number | undefined; - /** - * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). - */ - query?: string | undefined; - /** - * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). - */ - orderBy?: string | undefined; + /** + * Page number. [Read more](https://docs.codat.io/using-the-api/paging). + */ + page?: number | undefined; + /** + * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). + */ + pageSize?: number | undefined; + /** + * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). + */ + query?: string | undefined; + /** + * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). + */ + orderBy?: string | undefined; }; export type ListCompaniesResponse = { - httpMeta: components.HTTPMetadata; - /** - * OK - */ - companies?: components.Companies | undefined; + httpMeta: components.HTTPMetadata; + /** + * OK + */ + companies?: components.Companies | undefined; }; /** @internal */ -export namespace ListCompaniesRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - orderBy: z.string().optional(), - }) - .transform((v) => { - return { - page: v.page, - pageSize: v.pageSize, - ...(v.query === undefined ? null : { query: v.query }), - ...(v.orderBy === undefined ? null : { orderBy: v.orderBy }), - }; - }); +export const ListCompaniesRequest$inboundSchema: z.ZodType< + ListCompaniesRequest, + z.ZodTypeDef, + unknown +> = z.object({ + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), + orderBy: z.string().optional(), +}); - export type Outbound = { - page: number; - pageSize: number; - query?: string | undefined; - orderBy?: string | undefined; - }; +/** @internal */ +export type ListCompaniesRequest$Outbound = { + page: number; + pageSize: number; + query?: string | undefined; + orderBy?: string | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - orderBy: z.string().optional(), - }) - .transform((v) => { - return { - page: v.page, - pageSize: v.pageSize, - ...(v.query === undefined ? null : { query: v.query }), - ...(v.orderBy === undefined ? null : { orderBy: v.orderBy }), - }; - }); +/** @internal */ +export const ListCompaniesRequest$outboundSchema: z.ZodType< + ListCompaniesRequest$Outbound, + z.ZodTypeDef, + ListCompaniesRequest +> = z.object({ + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), + orderBy: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ListCompaniesRequest$ { + /** @deprecated use `ListCompaniesRequest$inboundSchema` instead. */ + export const inboundSchema = ListCompaniesRequest$inboundSchema; + /** @deprecated use `ListCompaniesRequest$outboundSchema` instead. */ + export const outboundSchema = ListCompaniesRequest$outboundSchema; + /** @deprecated use `ListCompaniesRequest$Outbound` instead. */ + export type Outbound = ListCompaniesRequest$Outbound; } /** @internal */ -export namespace ListCompaniesResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - HttpMeta: components.HTTPMetadata$.inboundSchema, - Companies: components.Companies$.inboundSchema.optional(), - }) - .transform((v) => { - return { - httpMeta: v.HttpMeta, - ...(v.Companies === undefined ? null : { companies: v.Companies }), - }; - }); +export const ListCompaniesResponse$inboundSchema: z.ZodType< + ListCompaniesResponse, + z.ZodTypeDef, + unknown +> = z.object({ + HttpMeta: components.HTTPMetadata$inboundSchema, + Companies: components.Companies$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "HttpMeta": "httpMeta", + "Companies": "companies", + }); +}); - export type Outbound = { - HttpMeta: components.HTTPMetadata$.Outbound; - Companies?: components.Companies$.Outbound | undefined; - }; +/** @internal */ +export type ListCompaniesResponse$Outbound = { + HttpMeta: components.HTTPMetadata$Outbound; + Companies?: components.Companies$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - httpMeta: components.HTTPMetadata$.outboundSchema, - companies: components.Companies$.outboundSchema.optional(), - }) - .transform((v) => { - return { - HttpMeta: v.httpMeta, - ...(v.companies === undefined ? null : { Companies: v.companies }), - }; - }); +/** @internal */ +export const ListCompaniesResponse$outboundSchema: z.ZodType< + ListCompaniesResponse$Outbound, + z.ZodTypeDef, + ListCompaniesResponse +> = z.object({ + httpMeta: components.HTTPMetadata$outboundSchema, + companies: components.Companies$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + httpMeta: "HttpMeta", + companies: "Companies", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ListCompaniesResponse$ { + /** @deprecated use `ListCompaniesResponse$inboundSchema` instead. */ + export const inboundSchema = ListCompaniesResponse$inboundSchema; + /** @deprecated use `ListCompaniesResponse$outboundSchema` instead. */ + export const outboundSchema = ListCompaniesResponse$outboundSchema; + /** @deprecated use `ListCompaniesResponse$Outbound` instead. */ + export type Outbound = ListCompaniesResponse$Outbound; } diff --git a/lending/src/models/operations/updatecompany.ts b/lending/src/models/operations/updatecompany.ts index 86e6c9b9..1ad8681d 100644 --- a/lending/src/models/operations/updatecompany.ts +++ b/lending/src/models/operations/updatecompany.ts @@ -1,90 +1,119 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as components from "../components"; import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as components from "../components/index.js"; export type UpdateCompanyRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - companyRequestBody?: components.CompanyRequestBody | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + companyRequestBody?: components.CompanyRequestBody | undefined; }; export type UpdateCompanyResponse = { - httpMeta: components.HTTPMetadata; - /** - * OK - */ - company?: components.Company | undefined; + httpMeta: components.HTTPMetadata; + /** + * OK + */ + company?: components.Company | undefined; }; /** @internal */ -export namespace UpdateCompanyRequest$ { - export const inboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - CompanyRequestBody: components.CompanyRequestBody$.inboundSchema.optional(), - }) - .transform((v) => { - return { - companyId: v.companyId, - ...(v.CompanyRequestBody === undefined - ? null - : { companyRequestBody: v.CompanyRequestBody }), - }; - }); +export const UpdateCompanyRequest$inboundSchema: z.ZodType< + UpdateCompanyRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + CompanyRequestBody: components.CompanyRequestBody$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "CompanyRequestBody": "companyRequestBody", + }); +}); - export type Outbound = { - companyId: string; - CompanyRequestBody?: components.CompanyRequestBody$.Outbound | undefined; - }; +/** @internal */ +export type UpdateCompanyRequest$Outbound = { + companyId: string; + CompanyRequestBody?: components.CompanyRequestBody$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - companyId: z.string(), - companyRequestBody: components.CompanyRequestBody$.outboundSchema.optional(), - }) - .transform((v) => { - return { - companyId: v.companyId, - ...(v.companyRequestBody === undefined - ? null - : { CompanyRequestBody: v.companyRequestBody }), - }; - }); +/** @internal */ +export const UpdateCompanyRequest$outboundSchema: z.ZodType< + UpdateCompanyRequest$Outbound, + z.ZodTypeDef, + UpdateCompanyRequest +> = z.object({ + companyId: z.string(), + companyRequestBody: components.CompanyRequestBody$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + companyRequestBody: "CompanyRequestBody", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace UpdateCompanyRequest$ { + /** @deprecated use `UpdateCompanyRequest$inboundSchema` instead. */ + export const inboundSchema = UpdateCompanyRequest$inboundSchema; + /** @deprecated use `UpdateCompanyRequest$outboundSchema` instead. */ + export const outboundSchema = UpdateCompanyRequest$outboundSchema; + /** @deprecated use `UpdateCompanyRequest$Outbound` instead. */ + export type Outbound = UpdateCompanyRequest$Outbound; } /** @internal */ -export namespace UpdateCompanyResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - HttpMeta: components.HTTPMetadata$.inboundSchema, - Company: components.Company$.inboundSchema.optional(), - }) - .transform((v) => { - return { - httpMeta: v.HttpMeta, - ...(v.Company === undefined ? null : { company: v.Company }), - }; - }); +export const UpdateCompanyResponse$inboundSchema: z.ZodType< + UpdateCompanyResponse, + z.ZodTypeDef, + unknown +> = z.object({ + HttpMeta: components.HTTPMetadata$inboundSchema, + Company: components.Company$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "HttpMeta": "httpMeta", + "Company": "company", + }); +}); - export type Outbound = { - HttpMeta: components.HTTPMetadata$.Outbound; - Company?: components.Company$.Outbound | undefined; - }; +/** @internal */ +export type UpdateCompanyResponse$Outbound = { + HttpMeta: components.HTTPMetadata$Outbound; + Company?: components.Company$Outbound | undefined; +}; - export const outboundSchema: z.ZodType = z - .object({ - httpMeta: components.HTTPMetadata$.outboundSchema, - company: components.Company$.outboundSchema.optional(), - }) - .transform((v) => { - return { - HttpMeta: v.httpMeta, - ...(v.company === undefined ? null : { Company: v.company }), - }; - }); +/** @internal */ +export const UpdateCompanyResponse$outboundSchema: z.ZodType< + UpdateCompanyResponse$Outbound, + z.ZodTypeDef, + UpdateCompanyResponse +> = z.object({ + httpMeta: components.HTTPMetadata$outboundSchema, + company: components.Company$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + httpMeta: "HttpMeta", + company: "Company", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace UpdateCompanyResponse$ { + /** @deprecated use `UpdateCompanyResponse$inboundSchema` instead. */ + export const inboundSchema = UpdateCompanyResponse$inboundSchema; + /** @deprecated use `UpdateCompanyResponse$outboundSchema` instead. */ + export const outboundSchema = UpdateCompanyResponse$outboundSchema; + /** @deprecated use `UpdateCompanyResponse$Outbound` instead. */ + export type Outbound = UpdateCompanyResponse$Outbound; } diff --git a/lending/src/sdk/companies.ts b/lending/src/sdk/companies.ts index 9f3678dc..8954cfb8 100644 --- a/lending/src/sdk/companies.ts +++ b/lending/src/sdk/companies.ts @@ -1,567 +1,126 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks"; -import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; -import { HTTPClient } from "../lib/http"; -import * as retries$ from "../lib/retries"; -import * as schemas$ from "../lib/schemas"; -import { ClientSDK, RequestOptions } from "../lib/sdks"; -import * as components from "../models/components"; -import * as errors from "../models/errors"; -import * as operations from "../models/operations"; +import { companiesCreate } from "../funcs/companiesCreate.js"; +import { companiesDelete } from "../funcs/companiesDelete.js"; +import { companiesGet } from "../funcs/companiesGet.js"; +import { companiesList } from "../funcs/companiesList.js"; +import { companiesUpdate } from "../funcs/companiesUpdate.js"; +import { ClientSDK, RequestOptions } from "../lib/sdks.js"; +import * as components from "../models/components/index.js"; +import * as operations from "../models/operations/index.js"; +import { unwrapAsync } from "../types/fp.js"; export class Companies extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - /** - * List companies - * - * @remarks - * The *List companies* endpoint returns a list of [companies] associated to your instances. - * - * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. - * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. - */ - async list( - page?: number | undefined, - pageSize?: number | undefined, - query?: string | undefined, - orderBy?: string | undefined, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$: operations.ListCompaniesRequest = { - page: page, - pageSize: pageSize, - query: query, - orderBy: orderBy, - }; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.ListCompaniesRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const path$ = this.templateURLComponent("/companies")(); - - const query$ = [ - enc$.encodeForm("orderBy", payload$.orderBy, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("page", payload$.page, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("pageSize", payload$.pageSize, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("query", payload$.query, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "list-companies", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { - context, - errorCodes: ["400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, operations.ListCompaniesResponse$, { key: "Companies" }) - .json([400, 401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$, { err: true }) - .fail(["4XX", "5XX"]) - .match(response, request$, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Create company - * - * @remarks - * Use the *Create company* endpoint to create a new [company](https://docs.codat.io/lending-api#/schemas/Company) that represents your customer in Codat. - * - * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. - * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. - * - * If forbidden characters (see `name` pattern) are present in the request, a company will be created with the forbidden characters removed. For example, `Company (Codat[1])` with be created as `Company Codat1`. - */ - async create( - request?: components.CompanyRequestBody | undefined, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$ = request; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Content-Type", "application/json"); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => components.CompanyRequestBody$.outboundSchema.optional().parse(value$), - "Input validation failed" - ); - const body$ = - payload$ === undefined ? null : enc$.encodeJSON("body", payload$, { explode: true }); - - const path$ = this.templateURLComponent("/companies")(); - - const query$ = ""; - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "create-company", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { - context, - errorCodes: ["400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"], - }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, operations.CreateCompanyResponse$, { key: "Company" }) - .json([400, 401, 402, 403, 429, 500, 503], errors.ErrorMessage$, { err: true }) - .fail(["4XX", "5XX"]) - .match(response, request$, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Update company - * - * @remarks - * Use the *Update company* endpoint to update both the name and description of the company. - * If you use [groups](https://docs.codat.io/lending-api#/schemas/Group) to manage a set of companies, use the [Add company](https://docs.codat.io/lending-api#/operations/add-company-to-group) or [Remove company](https://docs.codat.io/lending-api#/operations/remove-company-from-group) endpoints to add or remove a company from a group. - * - * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. - * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. - */ - async update( - companyId: string, - companyRequestBody?: components.CompanyRequestBody | undefined, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$: operations.UpdateCompanyRequest = { - companyId: companyId, - companyRequestBody: companyRequestBody, - }; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Content-Type", "application/json"); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.UpdateCompanyRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = enc$.encodeJSON("body", payload$.CompanyRequestBody, { explode: true }); - - const pathParams$ = { - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/companies/{companyId}")(pathParams$); - - const query$ = ""; - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "update-company", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "PUT", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, operations.UpdateCompanyResponse$, { key: "Company" }) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$, { err: true }) - .fail(["4XX", "5XX"]) - .match(response, request$, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Delete a company - * - * @remarks - * The *Delete company* endpoint permanently deletes a [company](https://docs.codat.io/lending-api#/schemas/Company), its [connections](https://docs.codat.io/lending-api#/schemas/Connection) and any cached data. This operation is irreversible. - * - * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. - * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. - * - */ - async delete( - companyId: string, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$: operations.DeleteCompanyRequest = { - companyId: companyId, - }; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.DeleteCompanyRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/companies/{companyId}")(pathParams$); - - const query$ = ""; - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "delete-company", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "DELETE", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .void(204, operations.DeleteCompanyResponse$) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$, { err: true }) - .fail(["4XX", "5XX"]) - .match(response, request$, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Get company - * - * @remarks - * The *Get company* endpoint returns a single company for a given `companyId`. - * - * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. - * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. - * - */ - async get( - companyId: string, - options?: RequestOptions & { retries?: retries$.RetryConfig } - ): Promise { - const input$: operations.GetCompanyRequest = { - companyId: companyId, - }; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetCompanyRequest$.outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: enc$.encodeSimple("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/companies/{companyId}")(pathParams$); - - const query$ = ""; - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-company", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const doOptions = { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - }; - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - }, - options - ); - - const retryConfig = options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }; - - const response = await retries$.retry( - () => { - const cloned = request$.clone(); - return this.do$(cloned, doOptions); - }, - { config: retryConfig, statusCodes: ["408", "429", "5XX"] } - ); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, operations.GetCompanyResponse$, { key: "Company" }) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$, { err: true }) - .fail(["4XX", "5XX"]) - .match(response, request$, { extraFields: responseFields$ }); - - return result$; - } + /** + * List companies + * + * @remarks + * The *List companies* endpoint returns a list of [companies] associated to your instances. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + */ + async list( + page?: number | undefined, + pageSize?: number | undefined, + query?: string | undefined, + orderBy?: string | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(companiesList( + this, + page, + pageSize, + query, + orderBy, + options, + )); + } + + /** + * Create company + * + * @remarks + * Use the *Create company* endpoint to create a new [company](https://docs.codat.io/lending-api#/schemas/Company) that represents your customer in Codat. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + * + * If forbidden characters (see `name` pattern) are present in the request, a company will be created with the forbidden characters removed. For example, `Company (Codat[1])` with be created as `Company Codat1`. + */ + async create( + request?: components.CompanyRequestBody | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(companiesCreate( + this, + request, + options, + )); + } + + /** + * Update company + * + * @remarks + * Use the *Update company* endpoint to update both the name and description of the company. + * If you use [groups](https://docs.codat.io/lending-api#/schemas/Group) to manage a set of companies, use the [Add company](https://docs.codat.io/lending-api#/operations/add-company-to-group) or [Remove company](https://docs.codat.io/lending-api#/operations/remove-company-from-group) endpoints to add or remove a company from a group. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + */ + async update( + companyId: string, + companyRequestBody?: components.CompanyRequestBody | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(companiesUpdate( + this, + companyId, + companyRequestBody, + options, + )); + } + + /** + * Delete a company + * + * @remarks + * The *Delete company* endpoint permanently deletes a [company](https://docs.codat.io/lending-api#/schemas/Company), its [connections](https://docs.codat.io/lending-api#/schemas/Connection) and any cached data. This operation is irreversible. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + */ + async delete( + companyId: string, + options?: RequestOptions, + ): Promise { + return unwrapAsync(companiesDelete( + this, + companyId, + options, + )); + } + + /** + * Get company + * + * @remarks + * The *Get company* endpoint returns a single company for a given `companyId`. + * + * A [company](https://docs.codat.io/lending-api#/schemas/Company) represents a business sharing access to their data. + * Each company can have multiple [connections](https://docs.codat.io/lending-api#/schemas/Connection) to different data sources, such as one connection to Xero for accounting data, two connections to Plaid for two bank accounts, and a connection to Zettle for POS data. + */ + async get( + companyId: string, + options?: RequestOptions, + ): Promise { + return unwrapAsync(companiesGet( + this, + companyId, + options, + )); + } } diff --git a/lending/src/sdk/index.ts b/lending/src/sdk/index.ts index 31303148..ecac2264 100644 --- a/lending/src/sdk/index.ts +++ b/lending/src/sdk/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./sdk"; +export * from "./sdk.js"; diff --git a/lending/src/sdk/sdk.ts b/lending/src/sdk/sdk.ts index 4dd21800..0167ce5d 100644 --- a/lending/src/sdk/sdk.ts +++ b/lending/src/sdk/sdk.ts @@ -1,42 +1,13 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks"; -import { SDKOptions, serverURLFromOptions } from "../lib/config"; -import { HTTPClient } from "../lib/http"; -import { ClientSDK } from "../lib/sdks"; -import { Companies } from "./companies"; +import { ClientSDK } from "../lib/sdks.js"; +import { Companies } from "./companies.js"; export class LendingTs extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - private _companies?: Companies; - get companies(): Companies { - return (this._companies ??= new Companies(this.options$)); - } + private _companies?: Companies; + get companies(): Companies { + return (this._companies ??= new Companies(this.options$)); + } } diff --git a/lending/src/types/blobs.ts b/lending/src/types/blobs.ts index cbb8a57f..4ce84602 100644 --- a/lending/src/types/blobs.ts +++ b/lending/src/types/blobs.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/lending/src/types/constdatetime.ts b/lending/src/types/constdatetime.ts new file mode 100644 index 00000000..c0a4409c --- /dev/null +++ b/lending/src/types/constdatetime.ts @@ -0,0 +1,15 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; + +export function constDateTime( + val: string, +): z.ZodType { + return z.custom((v) => { + return ( + typeof v === "string" && new Date(v).getTime() === new Date(val).getTime() + ); + }, `Value must be equivelant to ${val}`); +} diff --git a/lending/src/types/enums.ts b/lending/src/types/enums.ts index 4de0142b..6fb6d910 100644 --- a/lending/src/types/enums.ts +++ b/lending/src/types/enums.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ declare const __brand: unique symbol; diff --git a/lending/src/types/fp.ts b/lending/src/types/fp.ts new file mode 100644 index 00000000..ccbe51ea --- /dev/null +++ b/lending/src/types/fp.ts @@ -0,0 +1,50 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * A monad that captures the result of a function call or an error if it was not + * successful. Railway programming, enabled by this type, can be a nicer + * alternative to traditional exception throwing because it allows functions to + * declare all _known_ errors with static types and then check for them + * exhaustively in application code. Thrown exception have a type of `unknown` + * and break out of regular control flow of programs making them harder to + * inspect and more verbose work with due to try-catch blocks. + */ +export type Result = + | { ok: true; value: T; error?: never } + | { ok: false; value?: never; error: E }; + +export function OK(value: V): Result { + return { ok: true, value }; +} + +export function ERR(error: E): Result { + return { ok: false, error }; +} + +/** + * unwrap is a convenience function for extracting a value from a result or + * throwing if there was an error. + */ +export function unwrap(r: Result): T { + if (!r.ok) { + throw r.error; + } + return r.value; +} + +/** + * unwrapAsync is a convenience function for resolving a value from a Promise + * of a result or rejecting if an error occurred. + */ +export async function unwrapAsync( + pr: Promise>, +): Promise { + const r = await pr; + if (!r.ok) { + throw r.error; + } + + return r.value; +} diff --git a/lending/src/types/index.ts b/lending/src/types/index.ts index 42fcfd24..e124e817 100644 --- a/lending/src/types/index.ts +++ b/lending/src/types/index.ts @@ -1,10 +1,11 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export { RFCDate } from "./rfcdate"; -export { blobLikeSchema, isBlobLike } from "./blobs"; -export type { Paginator, PageIterator } from "./operations"; -export { createPageIterator } from "./operations"; -export { catchUnrecognizedEnum } from "./enums"; -export type { OpenEnum, ClosedEnum, Unrecognized } from "./enums"; +export { blobLikeSchema, isBlobLike } from "./blobs.js"; +export { catchUnrecognizedEnum } from "./enums.js"; +export type { ClosedEnum, OpenEnum, Unrecognized } from "./enums.js"; +export type { Result } from "./fp.js"; +export type { PageIterator, Paginator } from "./operations.js"; +export { createPageIterator } from "./operations.js"; +export { RFCDate } from "./rfcdate.js"; diff --git a/lending/src/types/operations.ts b/lending/src/types/operations.ts index 7f833514..0952f6f4 100644 --- a/lending/src/types/operations.ts +++ b/lending/src/types/operations.ts @@ -1,25 +1,99 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export type Paginator = () => Promise> | null; +import { Result } from "./fp.js"; -export type PageIterator = Result & { - next: Paginator; - [Symbol.asyncIterator]: () => AsyncIterableIterator; +export type Paginator = () => Promise }> | null; + +export type PageIterator = V & { + next: Paginator; + [Symbol.asyncIterator]: () => AsyncIterableIterator; }; -export function createPageIterator( - page: Result & { next: Paginator }, -): { [Symbol.asyncIterator]: () => AsyncIterableIterator } { +export function createPageIterator( + page: V & { next: Paginator }, + halt: (v: V) => boolean, +): { + [Symbol.asyncIterator]: () => AsyncIterableIterator; +} { return { [Symbol.asyncIterator]: async function* paginator() { yield page; + if (halt(page)) { + return; + } let p: typeof page | null = page; for (p = await p.next(); p != null; p = await p.next()) { yield p; + if (halt(p)) { + return; + } } }, }; } + +/** + * This utility create a special iterator that yields a single value and + * terminates. It is useful in paginated SDK functions that have early return + * paths when things go wrong. + */ +export function haltIterator(v: V): PageIterator { + return { + ...v, + next: () => null, + [Symbol.asyncIterator]: async function* paginator() { + yield v; + }, + }; +} + +/** + * Converts an async iterator of `Result` into an async iterator of `V`. + * When error results occur, the underlying error value is thrown. + */ +export async function unwrapResultIterator( + iteratorPromise: Promise>>, +): Promise> { + const resultIter = await iteratorPromise; + + if (!resultIter.ok) { + throw resultIter.error; + } + + return { + ...resultIter.value, + next: unwrapPaginator(resultIter.next), + [Symbol.asyncIterator]: async function* paginator() { + for await (const page of resultIter) { + if (!page.ok) { + throw page.error; + } + yield page.value; + } + }, + }; +} + +function unwrapPaginator( + paginator: Paginator>, +): Paginator { + return () => { + const nextResult = paginator(); + if (nextResult == null) { + return null; + } + return nextResult.then((res) => { + if (!res.ok) { + throw res.error; + } + const out = { + ...res.value, + next: unwrapPaginator(res.next), + }; + return out; + }); + }; +} diff --git a/lending/src/types/rfcdate.ts b/lending/src/types/rfcdate.ts index e80b6932..c79b3f53 100644 --- a/lending/src/types/rfcdate.ts +++ b/lending/src/types/rfcdate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ const dateRE = /^\d{4}-\d{2}-\d{2}$/; diff --git a/lending/src/types/streams.ts b/lending/src/types/streams.ts new file mode 100644 index 00000000..a0163e7a --- /dev/null +++ b/lending/src/types/streams.ts @@ -0,0 +1,21 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export function isReadableStream( + val: unknown, +): val is ReadableStream { + if (typeof val !== "object" || val === null) { + return false; + } + + // Check for the presence of methods specific to ReadableStream + const stream = val as ReadableStream; + + // ReadableStream has methods like getReader, cancel, and tee + return ( + typeof stream.getReader === "function" && + typeof stream.cancel === "function" && + typeof stream.tee === "function" + ); +}