From 8f96c069c19c50107d602b2051c48bf9b9f0a417 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:37:34 +0000 Subject: [PATCH 01/15] chore(internal): refactor scripts (#390) --- bin/check-test-server | 50 ------------------- package.json | 6 +-- scripts/bootstrap | 9 ++++ build => scripts/build | 15 +++--- scripts/lint | 7 +++ scripts/mock | 10 ++-- scripts/test | 36 ++++++++++--- .../{ => utils}/check-is-in-git-install.sh | 0 scripts/{ => utils}/check-version.cjs | 4 +- scripts/{ => utils}/fix-index-exports.cjs | 2 +- .../{ => utils}/make-dist-package-json.cjs | 2 +- scripts/{ => utils}/postprocess-files.cjs | 6 +-- 12 files changed, 72 insertions(+), 75 deletions(-) delete mode 100755 bin/check-test-server create mode 100755 scripts/bootstrap rename build => scripts/build (85%) create mode 100755 scripts/lint rename scripts/{ => utils}/check-is-in-git-install.sh (100%) rename scripts/{ => utils}/check-version.cjs (82%) rename scripts/{ => utils}/fix-index-exports.cjs (86%) rename scripts/{ => utils}/make-dist-package-json.cjs (87%) rename scripts/{ => utils}/postprocess-files.cjs (97%) diff --git a/bin/check-test-server b/bin/check-test-server deleted file mode 100755 index a6fa3495..00000000 --- a/bin/check-test-server +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color - -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if is_overriding_api_base_url ; then - # If someone is running the tests against the live API, we can trust they know - # what they're doing and exit early. - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - - exit 0 -elif prism_is_running ; then - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo - - exit 0 -else - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "${YELLOW}To fix:${NC}" - echo - echo -e "1. Install Prism (requires Node 16+):" - echo - echo -e " With npm:" - echo -e " \$ ${YELLOW}npm install -g @stoplight/prism-cli${NC}" - echo - echo -e " With yarn:" - echo -e " \$ ${YELLOW}yarn global add @stoplight/prism-cli${NC}" - echo - echo -e "2. Run the mock server" - echo - echo -e " To run the server, pass in the path of your OpenAPI" - echo -e " spec to the prism command:" - echo - echo -e " \$ ${YELLOW}prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -fi diff --git a/package.json b/package.json index c9c9123f..844c2294 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,13 @@ "private": false, "scripts": { "test": "./scripts/test", - "build": "bash ./build", + "build": "./scripts/build", "prepack": "echo 'to pack, run yarn build && (cd dist; yarn pack)' && exit 1", "prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1", "format": "prettier --write --cache --cache-strategy metadata . !dist", - "prepare": "if ./scripts/check-is-in-git-install.sh; then npm run build; fi", + "prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi", "tsn": "ts-node -r tsconfig-paths/register", - "lint": "eslint --ext ts,js .", + "lint": "./scripts/lint", "fix": "eslint --fix --ext ts,js ." }, "dependencies": { diff --git a/scripts/bootstrap b/scripts/bootstrap new file mode 100755 index 00000000..6752d0e6 --- /dev/null +++ b/scripts/bootstrap @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +PACKAGE_MANAGER=$(command -v yarn >/dev/null 2>&1 && echo "yarn" || echo "npm") + +$PACKAGE_MANAGER install diff --git a/build b/scripts/build similarity index 85% rename from build rename to scripts/build index 0a835c34..6176247c 100755 --- a/build +++ b/scripts/build @@ -1,7 +1,10 @@ #!/usr/bin/env bash + set -exuo pipefail -node scripts/check-version.cjs +cd "$(dirname "$0")/.." + +node scripts/utils/check-version.cjs # Build into dist and will publish the package from there, # so that src/resources/foo.ts becomes /resources/foo.js @@ -22,7 +25,7 @@ if [ -e "bin/cli" ]; then fi # this converts the export map paths for the dist directory # and does a few other minor things -node scripts/make-dist-package-json.cjs > dist/package.json +node scripts/utils/make-dist-package-json.cjs > dist/package.json # build to .js/.mjs/.d.ts files npm exec tsc-multi @@ -32,7 +35,7 @@ cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto # we need to add exports = module.exports = Modern Treasury Node to index.js; # No way to get that from index.ts because it would cause compile errors # when building .mjs -node scripts/fix-index-exports.cjs +node scripts/utils/fix-index-exports.cjs # with "moduleResolution": "nodenext", if ESM resolves to index.d.ts, # it'll have TS errors on the default import. But if it resolves to # index.d.mts the default import will work (even though both files have @@ -40,14 +43,14 @@ node scripts/fix-index-exports.cjs cp dist/index.d.ts dist/index.d.mts cp tsconfig.dist-src.json dist/src/tsconfig.json -node scripts/postprocess-files.cjs +node scripts/utils/postprocess-files.cjs # make sure that nothing crashes when we require the output CJS or # import the output ESM (cd dist && node -e 'require("modern-treasury")') (cd dist && node -e 'import("modern-treasury")' --input-type=module) -if command -v deno &> /dev/null && [ -e ./build-deno ] +if command -v deno &> /dev/null && [ -e ./scripts/build-deno ] then - ./build-deno + ./scripts/build-deno fi diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..4f05d660 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +./node_modules/.bin/eslint --ext ts,js . diff --git a/scripts/mock b/scripts/mock index 61c6988a..2bba2272 100755 --- a/scripts/mock +++ b/scripts/mock @@ -1,6 +1,10 @@ #!/usr/bin/env bash -if [ -z "$1" ]; then +set -e + +cd "$(dirname "$0")/.." + +if [ -n "$1" ]; then URL="$1" shift else @@ -15,7 +19,7 @@ fi # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec prism mock "$URL" &> .prism.log & + npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log & # Wait for server to come online while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do @@ -30,5 +34,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec prism mock "$URL" + npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" fi diff --git a/scripts/test b/scripts/test index f01384e6..48b637a4 100755 --- a/scripts/test +++ b/scripts/test @@ -1,5 +1,14 @@ #!/usr/bin/env bash +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + function prism_is_running() { curl --silent "http://localhost:4010" >/dev/null 2>&1 } @@ -12,17 +21,32 @@ kill_server_on_port() { fi } -if ! prism_is_running; then +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then # When we exit this script, make sure to kill the background mock server process trap 'kill_server_on_port 4010' EXIT # Start the dev server - ./scripts/mock --daemon + ./scripts/mock --daemon &> /dev/null +fi - # Sanity check and print a nice error message - if ! ./bin/check-test-server; then - exit - fi +if ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo fi # Run tests diff --git a/scripts/check-is-in-git-install.sh b/scripts/utils/check-is-in-git-install.sh similarity index 100% rename from scripts/check-is-in-git-install.sh rename to scripts/utils/check-is-in-git-install.sh diff --git a/scripts/check-version.cjs b/scripts/utils/check-version.cjs similarity index 82% rename from scripts/check-version.cjs rename to scripts/utils/check-version.cjs index 50a85669..86c56dfd 100644 --- a/scripts/check-version.cjs +++ b/scripts/utils/check-version.cjs @@ -2,14 +2,14 @@ const fs = require('fs'); const path = require('path'); const main = () => { - const pkg = require('../package.json'); + const pkg = require('../../package.json'); const version = pkg['version']; if (!version) throw 'The version property is not set in the package.json file'; if (typeof version !== 'string') { throw `Unexpected type for the package.json version field; got ${typeof version}, expected string`; } - const versionFile = path.resolve(__dirname, '..', 'src', 'version.ts'); + const versionFile = path.resolve(__dirname, '..', '..', 'src', 'version.ts'); const contents = fs.readFileSync(versionFile, 'utf8'); const output = contents.replace(/(export const VERSION = ')(.*)(')/g, `$1${version}$3`); fs.writeFileSync(versionFile, output); diff --git a/scripts/fix-index-exports.cjs b/scripts/utils/fix-index-exports.cjs similarity index 86% rename from scripts/fix-index-exports.cjs rename to scripts/utils/fix-index-exports.cjs index b61b2ea3..72b0b8fd 100644 --- a/scripts/fix-index-exports.cjs +++ b/scripts/utils/fix-index-exports.cjs @@ -4,7 +4,7 @@ const path = require('path'); const indexJs = process.env['DIST_PATH'] ? path.resolve(process.env['DIST_PATH'], 'index.js') - : path.resolve(__dirname, '..', 'dist', 'index.js'); + : path.resolve(__dirname, '..', '..', 'dist', 'index.js'); let before = fs.readFileSync(indexJs, 'utf8'); let after = before.replace( diff --git a/scripts/make-dist-package-json.cjs b/scripts/utils/make-dist-package-json.cjs similarity index 87% rename from scripts/make-dist-package-json.cjs rename to scripts/utils/make-dist-package-json.cjs index d4a0a69b..7c24f56e 100644 --- a/scripts/make-dist-package-json.cjs +++ b/scripts/utils/make-dist-package-json.cjs @@ -1,4 +1,4 @@ -const pkgJson = require(process.env['PKG_JSON_PATH'] || '../package.json'); +const pkgJson = require(process.env['PKG_JSON_PATH'] || '../../package.json'); function processExportMap(m) { for (const key in m) { diff --git a/scripts/postprocess-files.cjs b/scripts/utils/postprocess-files.cjs similarity index 97% rename from scripts/postprocess-files.cjs rename to scripts/utils/postprocess-files.cjs index cda99efc..75d39ce4 100644 --- a/scripts/postprocess-files.cjs +++ b/scripts/utils/postprocess-files.cjs @@ -2,12 +2,12 @@ const fs = require('fs'); const path = require('path'); const { parse } = require('@typescript-eslint/parser'); -const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'modern-treasury/' +const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'modern-treasury/'; const distDir = process.env['DIST_PATH'] ? path.resolve(process.env['DIST_PATH']) - : path.resolve(__dirname, '..', 'dist'); + : path.resolve(__dirname, '..', '..', 'dist'); const distSrcDir = path.join(distDir, 'src'); /** @@ -103,7 +103,7 @@ async function* walk(dir) { } async function postprocess() { - for await (const file of walk(path.resolve(__dirname, '..', 'dist'))) { + for await (const file of walk(path.resolve(__dirname, '..', '..', 'dist'))) { if (!/\.([cm]?js|(\.d)?[cm]?ts)$/.test(file)) continue; const code = await fs.promises.readFile(file, 'utf8'); From 272d79431c4901b9677b58b03b9ea04e828a15eb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:06:35 +0000 Subject: [PATCH 02/15] chore(internal): add link to openapi spec (#392) --- .stats.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.stats.yml b/.stats.yml index 7c3c0bae..254b39b8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1,2 @@ configured_endpoints: 162 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-8e9975cfba00d068bd09ffca9b07eb9f439cd99c0aa6e7454001d50848957dba.yml From 315be57cb1f4206000e6986123a63789672ec8b4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 22:20:12 +0000 Subject: [PATCH 03/15] chore(internal): add scripts/test, scripts/mock and add ci job (#393) --- .github/workflows/ci.yml | 19 ++++++++++++++++++- .gitignore | 1 + Brewfile | 1 + scripts/bootstrap | 9 +++++++++ scripts/mock | 5 ++++- scripts/test | 10 +++++++--- 6 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 Brewfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6045ef09..c1b4ca47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,5 +28,22 @@ jobs: - name: Check types run: | yarn build + test: + name: test + runs-on: ubuntu-latest + if: github.repository == 'Modern-Treasury/modern-treasury-node' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Bootstrap + run: ./scripts/bootstrap + + - name: Run tests + run: ./scripts/test - diff --git a/.gitignore b/.gitignore index 425a0113..9a5858a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules yarn-error.log codegen.log +Brewfile.lock.json dist /deno /*.tgz diff --git a/Brewfile b/Brewfile new file mode 100644 index 00000000..e4feee60 --- /dev/null +++ b/Brewfile @@ -0,0 +1 @@ +brew "node" diff --git a/scripts/bootstrap b/scripts/bootstrap index 6752d0e6..05dd47a6 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,6 +4,15 @@ set -e cd "$(dirname "$0")/.." +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then + brew bundle check >/dev/null 2>&1 || { + echo "==> Installing Homebrew dependencies…" + brew bundle + } +fi + +echo "==> Installing Node dependencies…" + PACKAGE_MANAGER=$(command -v yarn >/dev/null 2>&1 && echo "yarn" || echo "npm") $PACKAGE_MANAGER install diff --git a/scripts/mock b/scripts/mock index 2bba2272..5a8c35b7 100755 --- a/scripts/mock +++ b/scripts/mock @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -n "$1" ]; then +if [[ -n "$1" && "$1" != '--'* ]]; then URL="$1" shift else @@ -17,11 +17,14 @@ if [ -z "$URL" ]; then exit 1 fi +echo "==> Starting mock server with URL ${URL}" + # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log & # Wait for server to come online + echo -n "Waiting for server" while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do echo -n "." sleep 0.1 diff --git a/scripts/test b/scripts/test index 48b637a4..aa94b72d 100755 --- a/scripts/test +++ b/scripts/test @@ -30,17 +30,20 @@ if ! is_overriding_api_base_url && ! prism_is_running ; then trap 'kill_server_on_port 4010' EXIT # Start the dev server - ./scripts/mock --daemon &> /dev/null + ./scripts/mock --daemon fi -if ! prism_is_running ; then +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" echo -e "running against your OpenAPI spec." echo echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the prism command:" echo - echo -e " \$ ${YELLOW}npm exec prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" echo exit 1 @@ -50,4 +53,5 @@ else fi # Run tests +echo "==> Running tests" ./node_modules/.bin/jest From f583eafab9e417a1760ab077ee041c9b1d5bb237 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 17:49:27 +0000 Subject: [PATCH 04/15] chore(internal): forward arguments in scripts/test (#394) --- scripts/mock | 4 ++-- scripts/test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mock b/scripts/mock index 5a8c35b7..fe89a1d0 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" fi diff --git a/scripts/test b/scripts/test index aa94b72d..b62a7ccc 100755 --- a/scripts/test +++ b/scripts/test @@ -54,4 +54,4 @@ fi # Run tests echo "==> Running tests" -./node_modules/.bin/jest +./node_modules/.bin/jest "$@" From d6279508016f41e6c4e095ea555313508ff64314 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 20:39:05 +0000 Subject: [PATCH 05/15] feat(api): updates (#395) --- .stats.yml | 2 +- src/resources/ledger-account-settlements.ts | 2 ++ tests/api-resources/ledger-account-settlements.test.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 254b39b8..70a26313 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 162 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-8e9975cfba00d068bd09ffca9b07eb9f439cd99c0aa6e7454001d50848957dba.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-21d8d8be5e3219420b523ac5670a79f8dcc6e2602fcd13dca12209271db2170e.yml diff --git a/src/resources/ledger-account-settlements.ts b/src/resources/ledger-account-settlements.ts index 5d02ff16..99d5e837 100644 --- a/src/resources/ledger-account-settlements.ts +++ b/src/resources/ledger-account-settlements.ts @@ -240,6 +240,8 @@ export interface LedgerAccountSettlementListParams extends PageParams { */ id?: Array; + ledger_id?: string; + ledger_transaction_id?: string; /** diff --git a/tests/api-resources/ledger-account-settlements.test.ts b/tests/api-resources/ledger-account-settlements.test.ts index 4fc63ac3..b3afff2e 100644 --- a/tests/api-resources/ledger-account-settlements.test.ts +++ b/tests/api-resources/ledger-account-settlements.test.ts @@ -113,6 +113,7 @@ describe('resource ledgerAccountSettlements', () => { { id: ['string', 'string', 'string'], after_cursor: 'string', + ledger_id: 'string', ledger_transaction_id: 'string', metadata: { foo: 'string' }, per_page: 0, From 88770139e5265bfc08e7bf7bc142b54bfb9b21bd Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Thu, 2 May 2024 08:42:27 +0000 Subject: [PATCH 06/15] chore(internal): move client class to separate file (#396) --- src/client.ts | 510 +++++++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 514 +------------------------------------------------- 2 files changed, 516 insertions(+), 508 deletions(-) create mode 100644 src/client.ts diff --git a/src/client.ts b/src/client.ts new file mode 100644 index 00000000..14f79fd8 --- /dev/null +++ b/src/client.ts @@ -0,0 +1,510 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import * as Core from './core'; +import * as Errors from './error'; +import { type Agent } from './_shims/index'; +import * as Uploads from './uploads'; +import * as qs from 'qs'; +import * as Pagination from 'modern-treasury/pagination'; +import * as API from 'modern-treasury/resources/index'; +import * as TopLevelAPI from 'modern-treasury/resources/top-level'; + +export interface ClientOptions { + /** + * Defaults to process.env['MODERN_TREASURY_API_KEY']. + */ + apiKey?: string | undefined; + + /** + * Defaults to process.env['MODERN_TREASURY_ORGANIZATION_ID']. + */ + organizationId?: string | undefined; + + /** + * Defaults to process.env['MODERN_TREASURY_WEBHOOK_KEY']. + */ + webhookKey?: string | null | undefined; + + /** + * Override the default base URL for the API, e.g., "https://api.example.com/v2/" + * + * Defaults to process.env['MODERN_TREASURY_BASE_URL']. + */ + baseURL?: string | null | undefined; + + /** + * The maximum amount of time (in milliseconds) that the client should wait for a response + * from the server before timing out a single request. + * + * Note that request timeouts are retried by default, so in a worst-case scenario you may wait + * much longer than this timeout before the promise succeeds or fails. + */ + timeout?: number; + + /** + * An HTTP agent used to manage HTTP(S) connections. + * + * If not provided, an agent will be constructed by default in the Node.js environment, + * otherwise no agent is used. + */ + httpAgent?: Agent; + + /** + * Specify a custom `fetch` function implementation. + * + * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is + * defined globally. + */ + fetch?: Core.Fetch | undefined; + + /** + * The maximum number of times that the client will retry a request in case of a + * temporary failure, like a network error or a 5XX error from the server. + * + * @default 2 + */ + maxRetries?: number; + + /** + * Default headers to include with every request to the API. + * + * These can be removed in individual requests by explicitly setting the + * header to `undefined` or `null` in request options. + */ + defaultHeaders?: Core.Headers; + + /** + * Default query parameters to include with every request to the API. + * + * These can be removed in individual requests by explicitly setting the + * param to `undefined` in request options. + */ + defaultQuery?: Core.DefaultQuery; +} + +/** API Client for interfacing with the Modern Treasury API. */ +export class ModernTreasury extends Core.APIClient { + apiKey: string; + organizationId: string; + webhookKey: string | null; + + private _options: ClientOptions; + + /** + * API Client for interfacing with the Modern Treasury API. + * + * @param {string | undefined} [opts.apiKey=process.env['MODERN_TREASURY_API_KEY'] ?? undefined] + * @param {string | undefined} [opts.organizationId=process.env['MODERN_TREASURY_ORGANIZATION_ID'] ?? undefined] + * @param {string | null | undefined} [opts.webhookKey=process.env['MODERN_TREASURY_WEBHOOK_KEY'] ?? null] + * @param {string} [opts.baseURL=process.env['MODERN_TREASURY_BASE_URL'] ?? https://app.moderntreasury.com] - Override the default base URL for the API. + * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. + * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. + * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. + * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. + * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API. + * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API. + */ + constructor({ + baseURL = Core.readEnv('MODERN_TREASURY_BASE_URL'), + apiKey = Core.readEnv('MODERN_TREASURY_API_KEY'), + organizationId = Core.readEnv('MODERN_TREASURY_ORGANIZATION_ID'), + webhookKey = Core.readEnv('MODERN_TREASURY_WEBHOOK_KEY') ?? null, + ...opts + }: ClientOptions = {}) { + if (apiKey === undefined) { + throw new Errors.ModernTreasuryError( + "The MODERN_TREASURY_API_KEY environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an apiKey option, like new ModernTreasury({ apiKey: 'My API Key' }).", + ); + } + if (organizationId === undefined) { + throw new Errors.ModernTreasuryError( + "The MODERN_TREASURY_ORGANIZATION_ID environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an organizationId option, like new ModernTreasury({ organizationId: 'my-organization-ID' }).", + ); + } + + const options: ClientOptions = { + apiKey, + organizationId, + webhookKey, + ...opts, + baseURL: baseURL || `https://app.moderntreasury.com`, + }; + + super({ + baseURL: options.baseURL!, + timeout: options.timeout ?? 60000 /* 1 minute */, + httpAgent: options.httpAgent, + maxRetries: options.maxRetries, + fetch: options.fetch, + }); + this._options = options; + this.idempotencyHeader = 'Idempotency-Key'; + + this.apiKey = apiKey; + this.organizationId = organizationId; + this.webhookKey = webhookKey; + } + + connections: API.Connections = new API.Connections(this); + counterparties: API.Counterparties = new API.Counterparties(this); + events: API.Events = new API.Events(this); + expectedPayments: API.ExpectedPayments = new API.ExpectedPayments(this); + externalAccounts: API.ExternalAccounts = new API.ExternalAccounts(this); + incomingPaymentDetails: API.IncomingPaymentDetails = new API.IncomingPaymentDetails(this); + invoices: API.Invoices = new API.Invoices(this); + documents: API.Documents = new API.Documents(this); + accountCollectionFlows: API.AccountCollectionFlows = new API.AccountCollectionFlows(this); + accountDetails: API.AccountDetails = new API.AccountDetails(this); + routingDetails: API.RoutingDetails = new API.RoutingDetails(this); + internalAccounts: API.InternalAccounts = new API.InternalAccounts(this); + ledgers: API.Ledgers = new API.Ledgers(this); + ledgerableEvents: API.LedgerableEvents = new API.LedgerableEvents(this); + ledgerAccountCategories: API.LedgerAccountCategories = new API.LedgerAccountCategories(this); + ledgerAccounts: API.LedgerAccounts = new API.LedgerAccounts(this); + ledgerAccountBalanceMonitors: API.LedgerAccountBalanceMonitors = new API.LedgerAccountBalanceMonitors(this); + ledgerAccountPayouts: API.LedgerAccountPayouts = new API.LedgerAccountPayouts(this); + ledgerAccountStatements: API.LedgerAccountStatements = new API.LedgerAccountStatements(this); + ledgerEntries: API.LedgerEntries = new API.LedgerEntries(this); + ledgerEventHandlers: API.LedgerEventHandlers = new API.LedgerEventHandlers(this); + ledgerTransactions: API.LedgerTransactions = new API.LedgerTransactions(this); + lineItems: API.LineItems = new API.LineItems(this); + paymentFlows: API.PaymentFlows = new API.PaymentFlows(this); + paymentOrders: API.PaymentOrders = new API.PaymentOrders(this); + paymentReferences: API.PaymentReferences = new API.PaymentReferences(this); + returns: API.Returns = new API.Returns(this); + transactions: API.Transactions = new API.Transactions(this); + validations: API.Validations = new API.Validations(this); + paperItems: API.PaperItems = new API.PaperItems(this); + webhooks: API.Webhooks = new API.Webhooks(this); + virtualAccounts: API.VirtualAccounts = new API.VirtualAccounts(this); + bulkRequests: API.BulkRequests = new API.BulkRequests(this); + bulkResults: API.BulkResults = new API.BulkResults(this); + ledgerAccountSettlements: API.LedgerAccountSettlements = new API.LedgerAccountSettlements(this); + foreignExchangeQuotes: API.ForeignExchangeQuotes = new API.ForeignExchangeQuotes(this); + connectionLegalEntities: API.ConnectionLegalEntities = new API.ConnectionLegalEntities(this); + legalEntities: API.LegalEntities = new API.LegalEntities(this); + legalEntityAssociations: API.LegalEntityAssociations = new API.LegalEntityAssociations(this); + + /** + * A test endpoint often used to confirm credentials and headers are being passed + * in correctly. + */ + ping(options?: Core.RequestOptions): Core.APIPromise { + return this.get('/api/ping', options); + } + + protected override defaultQuery(): Core.DefaultQuery | undefined { + return this._options.defaultQuery; + } + + protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers { + return { + ...super.defaultHeaders(opts), + ...this._options.defaultHeaders, + }; + } + + protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers { + if (!this.organizationId) { + return {}; + } + + if (!this.apiKey) { + return {}; + } + + const credentials = `${this.organizationId}:${this.apiKey}`; + const Authorization = `Basic ${Core.toBase64(credentials)}`; + return { Authorization }; + } + + protected override stringifyQuery(query: Record): string { + return qs.stringify(query, { arrayFormat: 'brackets' }); + } + + static ModernTreasury = this; + + static ModernTreasuryError = Errors.ModernTreasuryError; + static APIError = Errors.APIError; + static APIConnectionError = Errors.APIConnectionError; + static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError; + static APIUserAbortError = Errors.APIUserAbortError; + static NotFoundError = Errors.NotFoundError; + static ConflictError = Errors.ConflictError; + static RateLimitError = Errors.RateLimitError; + static BadRequestError = Errors.BadRequestError; + static AuthenticationError = Errors.AuthenticationError; + static InternalServerError = Errors.InternalServerError; + static PermissionDeniedError = Errors.PermissionDeniedError; + static UnprocessableEntityError = Errors.UnprocessableEntityError; + + static toFile = Uploads.toFile; + static fileFromPath = Uploads.fileFromPath; +} + +export namespace ModernTreasury { + export import RequestOptions = Core.RequestOptions; + + export import Page = Pagination.Page; + export import PageParams = Pagination.PageParams; + export import PageResponse = Pagination.PageResponse; + + export import PingResponse = API.PingResponse; + + export import Connections = API.Connections; + export import Connection = API.Connection; + export import ConnectionsPage = API.ConnectionsPage; + export import ConnectionListParams = API.ConnectionListParams; + + export import Counterparties = API.Counterparties; + export import Counterparty = API.Counterparty; + export import CounterpartyCollectAccountResponse = API.CounterpartyCollectAccountResponse; + export import CounterpartiesPage = API.CounterpartiesPage; + export import CounterpartyCreateParams = API.CounterpartyCreateParams; + export import CounterpartyUpdateParams = API.CounterpartyUpdateParams; + export import CounterpartyListParams = API.CounterpartyListParams; + export import CounterpartyCollectAccountParams = API.CounterpartyCollectAccountParams; + + export import Events = API.Events; + export import Event = API.Event; + export import EventsPage = API.EventsPage; + export import EventListParams = API.EventListParams; + + export import ExpectedPayments = API.ExpectedPayments; + export import ExpectedPayment = API.ExpectedPayment; + export import ExpectedPaymentType = API.ExpectedPaymentType; + export import ExpectedPaymentsPage = API.ExpectedPaymentsPage; + export import ExpectedPaymentCreateParams = API.ExpectedPaymentCreateParams; + export import ExpectedPaymentUpdateParams = API.ExpectedPaymentUpdateParams; + export import ExpectedPaymentListParams = API.ExpectedPaymentListParams; + + export import ExternalAccounts = API.ExternalAccounts; + export import ExternalAccount = API.ExternalAccount; + export import ExternalAccountType = API.ExternalAccountType; + export import ExternalAccountsPage = API.ExternalAccountsPage; + export import ExternalAccountCreateParams = API.ExternalAccountCreateParams; + export import ExternalAccountUpdateParams = API.ExternalAccountUpdateParams; + export import ExternalAccountListParams = API.ExternalAccountListParams; + export import ExternalAccountCompleteVerificationParams = API.ExternalAccountCompleteVerificationParams; + export import ExternalAccountVerifyParams = API.ExternalAccountVerifyParams; + + export import IncomingPaymentDetails = API.IncomingPaymentDetails; + export import IncomingPaymentDetail = API.IncomingPaymentDetail; + export import IncomingPaymentDetailsPage = API.IncomingPaymentDetailsPage; + export import IncomingPaymentDetailUpdateParams = API.IncomingPaymentDetailUpdateParams; + export import IncomingPaymentDetailListParams = API.IncomingPaymentDetailListParams; + export import IncomingPaymentDetailCreateAsyncParams = API.IncomingPaymentDetailCreateAsyncParams; + + export import Invoices = API.Invoices; + export import Invoice = API.Invoice; + export import InvoicesPage = API.InvoicesPage; + export import InvoiceCreateParams = API.InvoiceCreateParams; + export import InvoiceUpdateParams = API.InvoiceUpdateParams; + export import InvoiceListParams = API.InvoiceListParams; + + export import Documents = API.Documents; + export import Document = API.Document; + export import DocumentsPage = API.DocumentsPage; + export import DocumentCreateParams = API.DocumentCreateParams; + export import DocumentListParams = API.DocumentListParams; + + export import AccountCollectionFlows = API.AccountCollectionFlows; + export import AccountCollectionFlow = API.AccountCollectionFlow; + export import AccountCollectionFlowsPage = API.AccountCollectionFlowsPage; + export import AccountCollectionFlowCreateParams = API.AccountCollectionFlowCreateParams; + export import AccountCollectionFlowUpdateParams = API.AccountCollectionFlowUpdateParams; + export import AccountCollectionFlowListParams = API.AccountCollectionFlowListParams; + + export import AccountDetails = API.AccountDetails; + export import AccountDetail = API.AccountDetail; + export import AccountDetailsPage = API.AccountDetailsPage; + export import AccountDetailCreateParams = API.AccountDetailCreateParams; + export import AccountDetailListParams = API.AccountDetailListParams; + + export import RoutingDetails = API.RoutingDetails; + export import RoutingDetail = API.RoutingDetail; + export import RoutingDetailsPage = API.RoutingDetailsPage; + export import RoutingDetailCreateParams = API.RoutingDetailCreateParams; + export import RoutingDetailListParams = API.RoutingDetailListParams; + + export import InternalAccounts = API.InternalAccounts; + export import InternalAccount = API.InternalAccount; + export import InternalAccountsPage = API.InternalAccountsPage; + export import InternalAccountCreateParams = API.InternalAccountCreateParams; + export import InternalAccountUpdateParams = API.InternalAccountUpdateParams; + export import InternalAccountListParams = API.InternalAccountListParams; + + export import Ledgers = API.Ledgers; + export import Ledger = API.Ledger; + export import LedgersPage = API.LedgersPage; + export import LedgerCreateParams = API.LedgerCreateParams; + export import LedgerUpdateParams = API.LedgerUpdateParams; + export import LedgerListParams = API.LedgerListParams; + + export import LedgerableEvents = API.LedgerableEvents; + export import LedgerableEvent = API.LedgerableEvent; + export import LedgerableEventCreateParams = API.LedgerableEventCreateParams; + + export import LedgerAccountCategories = API.LedgerAccountCategories; + export import LedgerAccountCategory = API.LedgerAccountCategory; + export import LedgerAccountCategoriesPage = API.LedgerAccountCategoriesPage; + export import LedgerAccountCategoryCreateParams = API.LedgerAccountCategoryCreateParams; + export import LedgerAccountCategoryRetrieveParams = API.LedgerAccountCategoryRetrieveParams; + export import LedgerAccountCategoryUpdateParams = API.LedgerAccountCategoryUpdateParams; + export import LedgerAccountCategoryListParams = API.LedgerAccountCategoryListParams; + + export import LedgerAccounts = API.LedgerAccounts; + export import LedgerAccount = API.LedgerAccount; + export import LedgerAccountsPage = API.LedgerAccountsPage; + export import LedgerAccountCreateParams = API.LedgerAccountCreateParams; + export import LedgerAccountRetrieveParams = API.LedgerAccountRetrieveParams; + export import LedgerAccountUpdateParams = API.LedgerAccountUpdateParams; + export import LedgerAccountListParams = API.LedgerAccountListParams; + + export import LedgerAccountBalanceMonitors = API.LedgerAccountBalanceMonitors; + export import LedgerAccountBalanceMonitor = API.LedgerAccountBalanceMonitor; + export import LedgerAccountBalanceMonitorsPage = API.LedgerAccountBalanceMonitorsPage; + export import LedgerAccountBalanceMonitorCreateParams = API.LedgerAccountBalanceMonitorCreateParams; + export import LedgerAccountBalanceMonitorUpdateParams = API.LedgerAccountBalanceMonitorUpdateParams; + export import LedgerAccountBalanceMonitorListParams = API.LedgerAccountBalanceMonitorListParams; + + export import LedgerAccountPayouts = API.LedgerAccountPayouts; + export import LedgerAccountPayout = API.LedgerAccountPayout; + export import LedgerAccountPayoutsPage = API.LedgerAccountPayoutsPage; + export import LedgerAccountPayoutCreateParams = API.LedgerAccountPayoutCreateParams; + export import LedgerAccountPayoutUpdateParams = API.LedgerAccountPayoutUpdateParams; + export import LedgerAccountPayoutListParams = API.LedgerAccountPayoutListParams; + + export import LedgerAccountStatements = API.LedgerAccountStatements; + export import LedgerAccountStatementCreateResponse = API.LedgerAccountStatementCreateResponse; + export import LedgerAccountStatementRetrieveResponse = API.LedgerAccountStatementRetrieveResponse; + export import LedgerAccountStatementCreateParams = API.LedgerAccountStatementCreateParams; + + export import LedgerEntries = API.LedgerEntries; + export import LedgerEntry = API.LedgerEntry; + export import LedgerEntriesPage = API.LedgerEntriesPage; + export import LedgerEntryRetrieveParams = API.LedgerEntryRetrieveParams; + export import LedgerEntryUpdateParams = API.LedgerEntryUpdateParams; + export import LedgerEntryListParams = API.LedgerEntryListParams; + + export import LedgerEventHandlers = API.LedgerEventHandlers; + export import LedgerEventHandler = API.LedgerEventHandler; + export import LedgerEventHandlerVariable = API.LedgerEventHandlerVariable; + export import LedgerEventHandlersPage = API.LedgerEventHandlersPage; + export import LedgerEventHandlerCreateParams = API.LedgerEventHandlerCreateParams; + export import LedgerEventHandlerListParams = API.LedgerEventHandlerListParams; + + export import LedgerTransactions = API.LedgerTransactions; + export import LedgerTransaction = API.LedgerTransaction; + export import LedgerTransactionsPage = API.LedgerTransactionsPage; + export import LedgerTransactionCreateParams = API.LedgerTransactionCreateParams; + export import LedgerTransactionUpdateParams = API.LedgerTransactionUpdateParams; + export import LedgerTransactionListParams = API.LedgerTransactionListParams; + export import LedgerTransactionCreateReversalParams = API.LedgerTransactionCreateReversalParams; + + export import LineItems = API.LineItems; + export import LineItem = API.LineItem; + export import LineItemsPage = API.LineItemsPage; + export import LineItemUpdateParams = API.LineItemUpdateParams; + export import LineItemListParams = API.LineItemListParams; + + export import PaymentFlows = API.PaymentFlows; + export import PaymentFlow = API.PaymentFlow; + export import PaymentFlowsPage = API.PaymentFlowsPage; + export import PaymentFlowCreateParams = API.PaymentFlowCreateParams; + export import PaymentFlowUpdateParams = API.PaymentFlowUpdateParams; + export import PaymentFlowListParams = API.PaymentFlowListParams; + + export import PaymentOrders = API.PaymentOrders; + export import PaymentOrder = API.PaymentOrder; + export import PaymentOrderSubtype = API.PaymentOrderSubtype; + export import PaymentOrderType = API.PaymentOrderType; + export import PaymentOrdersPage = API.PaymentOrdersPage; + export import PaymentOrderCreateParams = API.PaymentOrderCreateParams; + export import PaymentOrderUpdateParams = API.PaymentOrderUpdateParams; + export import PaymentOrderListParams = API.PaymentOrderListParams; + export import PaymentOrderCreateAsyncParams = API.PaymentOrderCreateAsyncParams; + + export import PaymentReferences = API.PaymentReferences; + export import PaymentReference = API.PaymentReference; + export import PaymentReferencesPage = API.PaymentReferencesPage; + export import PaymentReferenceListParams = API.PaymentReferenceListParams; + + export import Returns = API.Returns; + export import ReturnObject = API.ReturnObject; + export import ReturnObjectsPage = API.ReturnObjectsPage; + export import ReturnCreateParams = API.ReturnCreateParams; + export import ReturnListParams = API.ReturnListParams; + + export import Transactions = API.Transactions; + export import Transaction = API.Transaction; + export import TransactionsPage = API.TransactionsPage; + export import TransactionCreateParams = API.TransactionCreateParams; + export import TransactionUpdateParams = API.TransactionUpdateParams; + export import TransactionListParams = API.TransactionListParams; + + export import Validations = API.Validations; + export import RoutingNumberLookupRequest = API.RoutingNumberLookupRequest; + export import ValidationValidateRoutingNumberParams = API.ValidationValidateRoutingNumberParams; + + export import PaperItems = API.PaperItems; + export import PaperItem = API.PaperItem; + export import PaperItemsPage = API.PaperItemsPage; + export import PaperItemListParams = API.PaperItemListParams; + + export import Webhooks = API.Webhooks; + + export import VirtualAccounts = API.VirtualAccounts; + export import VirtualAccount = API.VirtualAccount; + export import VirtualAccountsPage = API.VirtualAccountsPage; + export import VirtualAccountCreateParams = API.VirtualAccountCreateParams; + export import VirtualAccountUpdateParams = API.VirtualAccountUpdateParams; + export import VirtualAccountListParams = API.VirtualAccountListParams; + + export import BulkRequests = API.BulkRequests; + export import BulkRequest = API.BulkRequest; + export import BulkRequestsPage = API.BulkRequestsPage; + export import BulkRequestCreateParams = API.BulkRequestCreateParams; + export import BulkRequestListParams = API.BulkRequestListParams; + + export import BulkResults = API.BulkResults; + export import BulkResult = API.BulkResult; + export import BulkResultsPage = API.BulkResultsPage; + export import BulkResultListParams = API.BulkResultListParams; + + export import LedgerAccountSettlements = API.LedgerAccountSettlements; + export import LedgerAccountSettlement = API.LedgerAccountSettlement; + export import LedgerAccountSettlementsPage = API.LedgerAccountSettlementsPage; + export import LedgerAccountSettlementCreateParams = API.LedgerAccountSettlementCreateParams; + export import LedgerAccountSettlementUpdateParams = API.LedgerAccountSettlementUpdateParams; + export import LedgerAccountSettlementListParams = API.LedgerAccountSettlementListParams; + + export import ForeignExchangeQuotes = API.ForeignExchangeQuotes; + export import ForeignExchangeQuote = API.ForeignExchangeQuote; + export import ForeignExchangeQuotesPage = API.ForeignExchangeQuotesPage; + export import ForeignExchangeQuoteCreateParams = API.ForeignExchangeQuoteCreateParams; + export import ForeignExchangeQuoteListParams = API.ForeignExchangeQuoteListParams; + + export import ConnectionLegalEntities = API.ConnectionLegalEntities; + export import ConnectionLegalEntity = API.ConnectionLegalEntity; + export import ConnectionLegalEntitiesPage = API.ConnectionLegalEntitiesPage; + export import ConnectionLegalEntityCreateParams = API.ConnectionLegalEntityCreateParams; + export import ConnectionLegalEntityUpdateParams = API.ConnectionLegalEntityUpdateParams; + export import ConnectionLegalEntityListParams = API.ConnectionLegalEntityListParams; + + export import LegalEntities = API.LegalEntities; + export import LegalEntity = API.LegalEntity; + export import LegalEntitiesPage = API.LegalEntitiesPage; + export import LegalEntityCreateParams = API.LegalEntityCreateParams; + export import LegalEntityUpdateParams = API.LegalEntityUpdateParams; + export import LegalEntityListParams = API.LegalEntityListParams; + + export import LegalEntityAssociations = API.LegalEntityAssociations; + export import LegalEntityAssociation = API.LegalEntityAssociation; + export import LegalEntityAssociationCreateParams = API.LegalEntityAssociationCreateParams; + + export import AccountsType = API.AccountsType; + export import AsyncResponse = API.AsyncResponse; + export import Currency = API.Currency; + export import TransactionDirection = API.TransactionDirection; +} diff --git a/src/index.ts b/src/index.ts index ac6b452d..3af1aa37 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,246 +1,14 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from './core'; import * as Errors from './error'; -import { type Agent } from './_shims/index'; import * as Uploads from './uploads'; -import * as qs from 'qs'; -import * as Pagination from 'modern-treasury/pagination'; -import * as API from 'modern-treasury/resources/index'; -import * as TopLevelAPI from 'modern-treasury/resources/top-level'; +import { ModernTreasury } from './client'; -export interface ClientOptions { - /** - * Defaults to process.env['MODERN_TREASURY_API_KEY']. - */ - apiKey?: string | undefined; - - /** - * Defaults to process.env['MODERN_TREASURY_ORGANIZATION_ID']. - */ - organizationId?: string | undefined; - - /** - * Defaults to process.env['MODERN_TREASURY_WEBHOOK_KEY']. - */ - webhookKey?: string | null | undefined; - - /** - * Override the default base URL for the API, e.g., "https://api.example.com/v2/" - * - * Defaults to process.env['MODERN_TREASURY_BASE_URL']. - */ - baseURL?: string | null | undefined; - - /** - * The maximum amount of time (in milliseconds) that the client should wait for a response - * from the server before timing out a single request. - * - * Note that request timeouts are retried by default, so in a worst-case scenario you may wait - * much longer than this timeout before the promise succeeds or fails. - */ - timeout?: number; - - /** - * An HTTP agent used to manage HTTP(S) connections. - * - * If not provided, an agent will be constructed by default in the Node.js environment, - * otherwise no agent is used. - */ - httpAgent?: Agent; - - /** - * Specify a custom `fetch` function implementation. - * - * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is - * defined globally. - */ - fetch?: Core.Fetch | undefined; - - /** - * The maximum number of times that the client will retry a request in case of a - * temporary failure, like a network error or a 5XX error from the server. - * - * @default 2 - */ - maxRetries?: number; - - /** - * Default headers to include with every request to the API. - * - * These can be removed in individual requests by explicitly setting the - * header to `undefined` or `null` in request options. - */ - defaultHeaders?: Core.Headers; - - /** - * Default query parameters to include with every request to the API. - * - * These can be removed in individual requests by explicitly setting the - * param to `undefined` in request options. - */ - defaultQuery?: Core.DefaultQuery; -} - -/** API Client for interfacing with the Modern Treasury API. */ -export class ModernTreasury extends Core.APIClient { - apiKey: string; - organizationId: string; - webhookKey: string | null; - - private _options: ClientOptions; - - /** - * API Client for interfacing with the Modern Treasury API. - * - * @param {string | undefined} [opts.apiKey=process.env['MODERN_TREASURY_API_KEY'] ?? undefined] - * @param {string | undefined} [opts.organizationId=process.env['MODERN_TREASURY_ORGANIZATION_ID'] ?? undefined] - * @param {string | null | undefined} [opts.webhookKey=process.env['MODERN_TREASURY_WEBHOOK_KEY'] ?? null] - * @param {string} [opts.baseURL=process.env['MODERN_TREASURY_BASE_URL'] ?? https://app.moderntreasury.com] - Override the default base URL for the API. - * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. - * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. - * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. - * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. - * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API. - * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API. - */ - constructor({ - baseURL = Core.readEnv('MODERN_TREASURY_BASE_URL'), - apiKey = Core.readEnv('MODERN_TREASURY_API_KEY'), - organizationId = Core.readEnv('MODERN_TREASURY_ORGANIZATION_ID'), - webhookKey = Core.readEnv('MODERN_TREASURY_WEBHOOK_KEY') ?? null, - ...opts - }: ClientOptions = {}) { - if (apiKey === undefined) { - throw new Errors.ModernTreasuryError( - "The MODERN_TREASURY_API_KEY environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an apiKey option, like new ModernTreasury({ apiKey: 'My API Key' }).", - ); - } - if (organizationId === undefined) { - throw new Errors.ModernTreasuryError( - "The MODERN_TREASURY_ORGANIZATION_ID environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an organizationId option, like new ModernTreasury({ organizationId: 'my-organization-ID' }).", - ); - } - - const options: ClientOptions = { - apiKey, - organizationId, - webhookKey, - ...opts, - baseURL: baseURL || `https://app.moderntreasury.com`, - }; - - super({ - baseURL: options.baseURL!, - timeout: options.timeout ?? 60000 /* 1 minute */, - httpAgent: options.httpAgent, - maxRetries: options.maxRetries, - fetch: options.fetch, - }); - this._options = options; - this.idempotencyHeader = 'Idempotency-Key'; - - this.apiKey = apiKey; - this.organizationId = organizationId; - this.webhookKey = webhookKey; - } - - connections: API.Connections = new API.Connections(this); - counterparties: API.Counterparties = new API.Counterparties(this); - events: API.Events = new API.Events(this); - expectedPayments: API.ExpectedPayments = new API.ExpectedPayments(this); - externalAccounts: API.ExternalAccounts = new API.ExternalAccounts(this); - incomingPaymentDetails: API.IncomingPaymentDetails = new API.IncomingPaymentDetails(this); - invoices: API.Invoices = new API.Invoices(this); - documents: API.Documents = new API.Documents(this); - accountCollectionFlows: API.AccountCollectionFlows = new API.AccountCollectionFlows(this); - accountDetails: API.AccountDetails = new API.AccountDetails(this); - routingDetails: API.RoutingDetails = new API.RoutingDetails(this); - internalAccounts: API.InternalAccounts = new API.InternalAccounts(this); - ledgers: API.Ledgers = new API.Ledgers(this); - ledgerableEvents: API.LedgerableEvents = new API.LedgerableEvents(this); - ledgerAccountCategories: API.LedgerAccountCategories = new API.LedgerAccountCategories(this); - ledgerAccounts: API.LedgerAccounts = new API.LedgerAccounts(this); - ledgerAccountBalanceMonitors: API.LedgerAccountBalanceMonitors = new API.LedgerAccountBalanceMonitors(this); - ledgerAccountPayouts: API.LedgerAccountPayouts = new API.LedgerAccountPayouts(this); - ledgerAccountStatements: API.LedgerAccountStatements = new API.LedgerAccountStatements(this); - ledgerEntries: API.LedgerEntries = new API.LedgerEntries(this); - ledgerEventHandlers: API.LedgerEventHandlers = new API.LedgerEventHandlers(this); - ledgerTransactions: API.LedgerTransactions = new API.LedgerTransactions(this); - lineItems: API.LineItems = new API.LineItems(this); - paymentFlows: API.PaymentFlows = new API.PaymentFlows(this); - paymentOrders: API.PaymentOrders = new API.PaymentOrders(this); - paymentReferences: API.PaymentReferences = new API.PaymentReferences(this); - returns: API.Returns = new API.Returns(this); - transactions: API.Transactions = new API.Transactions(this); - validations: API.Validations = new API.Validations(this); - paperItems: API.PaperItems = new API.PaperItems(this); - webhooks: API.Webhooks = new API.Webhooks(this); - virtualAccounts: API.VirtualAccounts = new API.VirtualAccounts(this); - bulkRequests: API.BulkRequests = new API.BulkRequests(this); - bulkResults: API.BulkResults = new API.BulkResults(this); - ledgerAccountSettlements: API.LedgerAccountSettlements = new API.LedgerAccountSettlements(this); - foreignExchangeQuotes: API.ForeignExchangeQuotes = new API.ForeignExchangeQuotes(this); - connectionLegalEntities: API.ConnectionLegalEntities = new API.ConnectionLegalEntities(this); - legalEntities: API.LegalEntities = new API.LegalEntities(this); - legalEntityAssociations: API.LegalEntityAssociations = new API.LegalEntityAssociations(this); - - /** - * A test endpoint often used to confirm credentials and headers are being passed - * in correctly. - */ - ping(options?: Core.RequestOptions): Core.APIPromise { - return this.get('/api/ping', options); - } - - protected override defaultQuery(): Core.DefaultQuery | undefined { - return this._options.defaultQuery; - } - - protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers { - return { - ...super.defaultHeaders(opts), - ...this._options.defaultHeaders, - }; - } - - protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers { - if (!this.organizationId) { - return {}; - } - - if (!this.apiKey) { - return {}; - } - - const credentials = `${this.organizationId}:${this.apiKey}`; - const Authorization = `Basic ${Core.toBase64(credentials)}`; - return { Authorization }; - } - - protected override stringifyQuery(query: Record): string { - return qs.stringify(query, { arrayFormat: 'brackets' }); - } - - static ModernTreasury = this; - - static ModernTreasuryError = Errors.ModernTreasuryError; - static APIError = Errors.APIError; - static APIConnectionError = Errors.APIConnectionError; - static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError; - static APIUserAbortError = Errors.APIUserAbortError; - static NotFoundError = Errors.NotFoundError; - static ConflictError = Errors.ConflictError; - static RateLimitError = Errors.RateLimitError; - static BadRequestError = Errors.BadRequestError; - static AuthenticationError = Errors.AuthenticationError; - static InternalServerError = Errors.InternalServerError; - static PermissionDeniedError = Errors.PermissionDeniedError; - static UnprocessableEntityError = Errors.UnprocessableEntityError; +export { ModernTreasury }; +export default ModernTreasury; - static toFile = Uploads.toFile; - static fileFromPath = Uploads.fileFromPath; -} +export import toFile = Uploads.toFile; +export import fileFromPath = Uploads.fileFromPath; export const { ModernTreasuryError, @@ -258,274 +26,4 @@ export const { UnprocessableEntityError, } = Errors; -export import toFile = Uploads.toFile; -export import fileFromPath = Uploads.fileFromPath; - -export namespace ModernTreasury { - export import RequestOptions = Core.RequestOptions; - - export import Page = Pagination.Page; - export import PageParams = Pagination.PageParams; - export import PageResponse = Pagination.PageResponse; - - export import PingResponse = API.PingResponse; - - export import Connections = API.Connections; - export import Connection = API.Connection; - export import ConnectionsPage = API.ConnectionsPage; - export import ConnectionListParams = API.ConnectionListParams; - - export import Counterparties = API.Counterparties; - export import Counterparty = API.Counterparty; - export import CounterpartyCollectAccountResponse = API.CounterpartyCollectAccountResponse; - export import CounterpartiesPage = API.CounterpartiesPage; - export import CounterpartyCreateParams = API.CounterpartyCreateParams; - export import CounterpartyUpdateParams = API.CounterpartyUpdateParams; - export import CounterpartyListParams = API.CounterpartyListParams; - export import CounterpartyCollectAccountParams = API.CounterpartyCollectAccountParams; - - export import Events = API.Events; - export import Event = API.Event; - export import EventsPage = API.EventsPage; - export import EventListParams = API.EventListParams; - - export import ExpectedPayments = API.ExpectedPayments; - export import ExpectedPayment = API.ExpectedPayment; - export import ExpectedPaymentType = API.ExpectedPaymentType; - export import ExpectedPaymentsPage = API.ExpectedPaymentsPage; - export import ExpectedPaymentCreateParams = API.ExpectedPaymentCreateParams; - export import ExpectedPaymentUpdateParams = API.ExpectedPaymentUpdateParams; - export import ExpectedPaymentListParams = API.ExpectedPaymentListParams; - - export import ExternalAccounts = API.ExternalAccounts; - export import ExternalAccount = API.ExternalAccount; - export import ExternalAccountType = API.ExternalAccountType; - export import ExternalAccountsPage = API.ExternalAccountsPage; - export import ExternalAccountCreateParams = API.ExternalAccountCreateParams; - export import ExternalAccountUpdateParams = API.ExternalAccountUpdateParams; - export import ExternalAccountListParams = API.ExternalAccountListParams; - export import ExternalAccountCompleteVerificationParams = API.ExternalAccountCompleteVerificationParams; - export import ExternalAccountVerifyParams = API.ExternalAccountVerifyParams; - - export import IncomingPaymentDetails = API.IncomingPaymentDetails; - export import IncomingPaymentDetail = API.IncomingPaymentDetail; - export import IncomingPaymentDetailsPage = API.IncomingPaymentDetailsPage; - export import IncomingPaymentDetailUpdateParams = API.IncomingPaymentDetailUpdateParams; - export import IncomingPaymentDetailListParams = API.IncomingPaymentDetailListParams; - export import IncomingPaymentDetailCreateAsyncParams = API.IncomingPaymentDetailCreateAsyncParams; - - export import Invoices = API.Invoices; - export import Invoice = API.Invoice; - export import InvoicesPage = API.InvoicesPage; - export import InvoiceCreateParams = API.InvoiceCreateParams; - export import InvoiceUpdateParams = API.InvoiceUpdateParams; - export import InvoiceListParams = API.InvoiceListParams; - - export import Documents = API.Documents; - export import Document = API.Document; - export import DocumentsPage = API.DocumentsPage; - export import DocumentCreateParams = API.DocumentCreateParams; - export import DocumentListParams = API.DocumentListParams; - - export import AccountCollectionFlows = API.AccountCollectionFlows; - export import AccountCollectionFlow = API.AccountCollectionFlow; - export import AccountCollectionFlowsPage = API.AccountCollectionFlowsPage; - export import AccountCollectionFlowCreateParams = API.AccountCollectionFlowCreateParams; - export import AccountCollectionFlowUpdateParams = API.AccountCollectionFlowUpdateParams; - export import AccountCollectionFlowListParams = API.AccountCollectionFlowListParams; - - export import AccountDetails = API.AccountDetails; - export import AccountDetail = API.AccountDetail; - export import AccountDetailsPage = API.AccountDetailsPage; - export import AccountDetailCreateParams = API.AccountDetailCreateParams; - export import AccountDetailListParams = API.AccountDetailListParams; - - export import RoutingDetails = API.RoutingDetails; - export import RoutingDetail = API.RoutingDetail; - export import RoutingDetailsPage = API.RoutingDetailsPage; - export import RoutingDetailCreateParams = API.RoutingDetailCreateParams; - export import RoutingDetailListParams = API.RoutingDetailListParams; - - export import InternalAccounts = API.InternalAccounts; - export import InternalAccount = API.InternalAccount; - export import InternalAccountsPage = API.InternalAccountsPage; - export import InternalAccountCreateParams = API.InternalAccountCreateParams; - export import InternalAccountUpdateParams = API.InternalAccountUpdateParams; - export import InternalAccountListParams = API.InternalAccountListParams; - - export import Ledgers = API.Ledgers; - export import Ledger = API.Ledger; - export import LedgersPage = API.LedgersPage; - export import LedgerCreateParams = API.LedgerCreateParams; - export import LedgerUpdateParams = API.LedgerUpdateParams; - export import LedgerListParams = API.LedgerListParams; - - export import LedgerableEvents = API.LedgerableEvents; - export import LedgerableEvent = API.LedgerableEvent; - export import LedgerableEventCreateParams = API.LedgerableEventCreateParams; - - export import LedgerAccountCategories = API.LedgerAccountCategories; - export import LedgerAccountCategory = API.LedgerAccountCategory; - export import LedgerAccountCategoriesPage = API.LedgerAccountCategoriesPage; - export import LedgerAccountCategoryCreateParams = API.LedgerAccountCategoryCreateParams; - export import LedgerAccountCategoryRetrieveParams = API.LedgerAccountCategoryRetrieveParams; - export import LedgerAccountCategoryUpdateParams = API.LedgerAccountCategoryUpdateParams; - export import LedgerAccountCategoryListParams = API.LedgerAccountCategoryListParams; - - export import LedgerAccounts = API.LedgerAccounts; - export import LedgerAccount = API.LedgerAccount; - export import LedgerAccountsPage = API.LedgerAccountsPage; - export import LedgerAccountCreateParams = API.LedgerAccountCreateParams; - export import LedgerAccountRetrieveParams = API.LedgerAccountRetrieveParams; - export import LedgerAccountUpdateParams = API.LedgerAccountUpdateParams; - export import LedgerAccountListParams = API.LedgerAccountListParams; - - export import LedgerAccountBalanceMonitors = API.LedgerAccountBalanceMonitors; - export import LedgerAccountBalanceMonitor = API.LedgerAccountBalanceMonitor; - export import LedgerAccountBalanceMonitorsPage = API.LedgerAccountBalanceMonitorsPage; - export import LedgerAccountBalanceMonitorCreateParams = API.LedgerAccountBalanceMonitorCreateParams; - export import LedgerAccountBalanceMonitorUpdateParams = API.LedgerAccountBalanceMonitorUpdateParams; - export import LedgerAccountBalanceMonitorListParams = API.LedgerAccountBalanceMonitorListParams; - - export import LedgerAccountPayouts = API.LedgerAccountPayouts; - export import LedgerAccountPayout = API.LedgerAccountPayout; - export import LedgerAccountPayoutsPage = API.LedgerAccountPayoutsPage; - export import LedgerAccountPayoutCreateParams = API.LedgerAccountPayoutCreateParams; - export import LedgerAccountPayoutUpdateParams = API.LedgerAccountPayoutUpdateParams; - export import LedgerAccountPayoutListParams = API.LedgerAccountPayoutListParams; - - export import LedgerAccountStatements = API.LedgerAccountStatements; - export import LedgerAccountStatementCreateResponse = API.LedgerAccountStatementCreateResponse; - export import LedgerAccountStatementRetrieveResponse = API.LedgerAccountStatementRetrieveResponse; - export import LedgerAccountStatementCreateParams = API.LedgerAccountStatementCreateParams; - - export import LedgerEntries = API.LedgerEntries; - export import LedgerEntry = API.LedgerEntry; - export import LedgerEntriesPage = API.LedgerEntriesPage; - export import LedgerEntryRetrieveParams = API.LedgerEntryRetrieveParams; - export import LedgerEntryUpdateParams = API.LedgerEntryUpdateParams; - export import LedgerEntryListParams = API.LedgerEntryListParams; - - export import LedgerEventHandlers = API.LedgerEventHandlers; - export import LedgerEventHandler = API.LedgerEventHandler; - export import LedgerEventHandlerVariable = API.LedgerEventHandlerVariable; - export import LedgerEventHandlersPage = API.LedgerEventHandlersPage; - export import LedgerEventHandlerCreateParams = API.LedgerEventHandlerCreateParams; - export import LedgerEventHandlerListParams = API.LedgerEventHandlerListParams; - - export import LedgerTransactions = API.LedgerTransactions; - export import LedgerTransaction = API.LedgerTransaction; - export import LedgerTransactionsPage = API.LedgerTransactionsPage; - export import LedgerTransactionCreateParams = API.LedgerTransactionCreateParams; - export import LedgerTransactionUpdateParams = API.LedgerTransactionUpdateParams; - export import LedgerTransactionListParams = API.LedgerTransactionListParams; - export import LedgerTransactionCreateReversalParams = API.LedgerTransactionCreateReversalParams; - - export import LineItems = API.LineItems; - export import LineItem = API.LineItem; - export import LineItemsPage = API.LineItemsPage; - export import LineItemUpdateParams = API.LineItemUpdateParams; - export import LineItemListParams = API.LineItemListParams; - - export import PaymentFlows = API.PaymentFlows; - export import PaymentFlow = API.PaymentFlow; - export import PaymentFlowsPage = API.PaymentFlowsPage; - export import PaymentFlowCreateParams = API.PaymentFlowCreateParams; - export import PaymentFlowUpdateParams = API.PaymentFlowUpdateParams; - export import PaymentFlowListParams = API.PaymentFlowListParams; - - export import PaymentOrders = API.PaymentOrders; - export import PaymentOrder = API.PaymentOrder; - export import PaymentOrderSubtype = API.PaymentOrderSubtype; - export import PaymentOrderType = API.PaymentOrderType; - export import PaymentOrdersPage = API.PaymentOrdersPage; - export import PaymentOrderCreateParams = API.PaymentOrderCreateParams; - export import PaymentOrderUpdateParams = API.PaymentOrderUpdateParams; - export import PaymentOrderListParams = API.PaymentOrderListParams; - export import PaymentOrderCreateAsyncParams = API.PaymentOrderCreateAsyncParams; - - export import PaymentReferences = API.PaymentReferences; - export import PaymentReference = API.PaymentReference; - export import PaymentReferencesPage = API.PaymentReferencesPage; - export import PaymentReferenceListParams = API.PaymentReferenceListParams; - - export import Returns = API.Returns; - export import ReturnObject = API.ReturnObject; - export import ReturnObjectsPage = API.ReturnObjectsPage; - export import ReturnCreateParams = API.ReturnCreateParams; - export import ReturnListParams = API.ReturnListParams; - - export import Transactions = API.Transactions; - export import Transaction = API.Transaction; - export import TransactionsPage = API.TransactionsPage; - export import TransactionCreateParams = API.TransactionCreateParams; - export import TransactionUpdateParams = API.TransactionUpdateParams; - export import TransactionListParams = API.TransactionListParams; - - export import Validations = API.Validations; - export import RoutingNumberLookupRequest = API.RoutingNumberLookupRequest; - export import ValidationValidateRoutingNumberParams = API.ValidationValidateRoutingNumberParams; - - export import PaperItems = API.PaperItems; - export import PaperItem = API.PaperItem; - export import PaperItemsPage = API.PaperItemsPage; - export import PaperItemListParams = API.PaperItemListParams; - - export import Webhooks = API.Webhooks; - - export import VirtualAccounts = API.VirtualAccounts; - export import VirtualAccount = API.VirtualAccount; - export import VirtualAccountsPage = API.VirtualAccountsPage; - export import VirtualAccountCreateParams = API.VirtualAccountCreateParams; - export import VirtualAccountUpdateParams = API.VirtualAccountUpdateParams; - export import VirtualAccountListParams = API.VirtualAccountListParams; - - export import BulkRequests = API.BulkRequests; - export import BulkRequest = API.BulkRequest; - export import BulkRequestsPage = API.BulkRequestsPage; - export import BulkRequestCreateParams = API.BulkRequestCreateParams; - export import BulkRequestListParams = API.BulkRequestListParams; - - export import BulkResults = API.BulkResults; - export import BulkResult = API.BulkResult; - export import BulkResultsPage = API.BulkResultsPage; - export import BulkResultListParams = API.BulkResultListParams; - - export import LedgerAccountSettlements = API.LedgerAccountSettlements; - export import LedgerAccountSettlement = API.LedgerAccountSettlement; - export import LedgerAccountSettlementsPage = API.LedgerAccountSettlementsPage; - export import LedgerAccountSettlementCreateParams = API.LedgerAccountSettlementCreateParams; - export import LedgerAccountSettlementUpdateParams = API.LedgerAccountSettlementUpdateParams; - export import LedgerAccountSettlementListParams = API.LedgerAccountSettlementListParams; - - export import ForeignExchangeQuotes = API.ForeignExchangeQuotes; - export import ForeignExchangeQuote = API.ForeignExchangeQuote; - export import ForeignExchangeQuotesPage = API.ForeignExchangeQuotesPage; - export import ForeignExchangeQuoteCreateParams = API.ForeignExchangeQuoteCreateParams; - export import ForeignExchangeQuoteListParams = API.ForeignExchangeQuoteListParams; - - export import ConnectionLegalEntities = API.ConnectionLegalEntities; - export import ConnectionLegalEntity = API.ConnectionLegalEntity; - export import ConnectionLegalEntitiesPage = API.ConnectionLegalEntitiesPage; - export import ConnectionLegalEntityCreateParams = API.ConnectionLegalEntityCreateParams; - export import ConnectionLegalEntityUpdateParams = API.ConnectionLegalEntityUpdateParams; - export import ConnectionLegalEntityListParams = API.ConnectionLegalEntityListParams; - - export import LegalEntities = API.LegalEntities; - export import LegalEntity = API.LegalEntity; - export import LegalEntitiesPage = API.LegalEntitiesPage; - export import LegalEntityCreateParams = API.LegalEntityCreateParams; - export import LegalEntityUpdateParams = API.LegalEntityUpdateParams; - export import LegalEntityListParams = API.LegalEntityListParams; - - export import LegalEntityAssociations = API.LegalEntityAssociations; - export import LegalEntityAssociation = API.LegalEntityAssociation; - export import LegalEntityAssociationCreateParams = API.LegalEntityAssociationCreateParams; - - export import AccountsType = API.AccountsType; - export import AsyncResponse = API.AsyncResponse; - export import Currency = API.Currency; - export import TransactionDirection = API.TransactionDirection; -} - -export default ModernTreasury; +export * from './client'; From e25a0fab22a47c779aac58d14d87cec0a3768442 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Fri, 3 May 2024 15:18:37 +0000 Subject: [PATCH 07/15] fix(package): revert recent client file change (#398) this subtly broke some setups that we didn't have tests for --- src/client.ts | 510 ------------------------------------------------- src/index.ts | 514 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 508 insertions(+), 516 deletions(-) delete mode 100644 src/client.ts diff --git a/src/client.ts b/src/client.ts deleted file mode 100644 index 14f79fd8..00000000 --- a/src/client.ts +++ /dev/null @@ -1,510 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import * as Core from './core'; -import * as Errors from './error'; -import { type Agent } from './_shims/index'; -import * as Uploads from './uploads'; -import * as qs from 'qs'; -import * as Pagination from 'modern-treasury/pagination'; -import * as API from 'modern-treasury/resources/index'; -import * as TopLevelAPI from 'modern-treasury/resources/top-level'; - -export interface ClientOptions { - /** - * Defaults to process.env['MODERN_TREASURY_API_KEY']. - */ - apiKey?: string | undefined; - - /** - * Defaults to process.env['MODERN_TREASURY_ORGANIZATION_ID']. - */ - organizationId?: string | undefined; - - /** - * Defaults to process.env['MODERN_TREASURY_WEBHOOK_KEY']. - */ - webhookKey?: string | null | undefined; - - /** - * Override the default base URL for the API, e.g., "https://api.example.com/v2/" - * - * Defaults to process.env['MODERN_TREASURY_BASE_URL']. - */ - baseURL?: string | null | undefined; - - /** - * The maximum amount of time (in milliseconds) that the client should wait for a response - * from the server before timing out a single request. - * - * Note that request timeouts are retried by default, so in a worst-case scenario you may wait - * much longer than this timeout before the promise succeeds or fails. - */ - timeout?: number; - - /** - * An HTTP agent used to manage HTTP(S) connections. - * - * If not provided, an agent will be constructed by default in the Node.js environment, - * otherwise no agent is used. - */ - httpAgent?: Agent; - - /** - * Specify a custom `fetch` function implementation. - * - * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is - * defined globally. - */ - fetch?: Core.Fetch | undefined; - - /** - * The maximum number of times that the client will retry a request in case of a - * temporary failure, like a network error or a 5XX error from the server. - * - * @default 2 - */ - maxRetries?: number; - - /** - * Default headers to include with every request to the API. - * - * These can be removed in individual requests by explicitly setting the - * header to `undefined` or `null` in request options. - */ - defaultHeaders?: Core.Headers; - - /** - * Default query parameters to include with every request to the API. - * - * These can be removed in individual requests by explicitly setting the - * param to `undefined` in request options. - */ - defaultQuery?: Core.DefaultQuery; -} - -/** API Client for interfacing with the Modern Treasury API. */ -export class ModernTreasury extends Core.APIClient { - apiKey: string; - organizationId: string; - webhookKey: string | null; - - private _options: ClientOptions; - - /** - * API Client for interfacing with the Modern Treasury API. - * - * @param {string | undefined} [opts.apiKey=process.env['MODERN_TREASURY_API_KEY'] ?? undefined] - * @param {string | undefined} [opts.organizationId=process.env['MODERN_TREASURY_ORGANIZATION_ID'] ?? undefined] - * @param {string | null | undefined} [opts.webhookKey=process.env['MODERN_TREASURY_WEBHOOK_KEY'] ?? null] - * @param {string} [opts.baseURL=process.env['MODERN_TREASURY_BASE_URL'] ?? https://app.moderntreasury.com] - Override the default base URL for the API. - * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. - * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. - * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. - * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. - * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API. - * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API. - */ - constructor({ - baseURL = Core.readEnv('MODERN_TREASURY_BASE_URL'), - apiKey = Core.readEnv('MODERN_TREASURY_API_KEY'), - organizationId = Core.readEnv('MODERN_TREASURY_ORGANIZATION_ID'), - webhookKey = Core.readEnv('MODERN_TREASURY_WEBHOOK_KEY') ?? null, - ...opts - }: ClientOptions = {}) { - if (apiKey === undefined) { - throw new Errors.ModernTreasuryError( - "The MODERN_TREASURY_API_KEY environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an apiKey option, like new ModernTreasury({ apiKey: 'My API Key' }).", - ); - } - if (organizationId === undefined) { - throw new Errors.ModernTreasuryError( - "The MODERN_TREASURY_ORGANIZATION_ID environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an organizationId option, like new ModernTreasury({ organizationId: 'my-organization-ID' }).", - ); - } - - const options: ClientOptions = { - apiKey, - organizationId, - webhookKey, - ...opts, - baseURL: baseURL || `https://app.moderntreasury.com`, - }; - - super({ - baseURL: options.baseURL!, - timeout: options.timeout ?? 60000 /* 1 minute */, - httpAgent: options.httpAgent, - maxRetries: options.maxRetries, - fetch: options.fetch, - }); - this._options = options; - this.idempotencyHeader = 'Idempotency-Key'; - - this.apiKey = apiKey; - this.organizationId = organizationId; - this.webhookKey = webhookKey; - } - - connections: API.Connections = new API.Connections(this); - counterparties: API.Counterparties = new API.Counterparties(this); - events: API.Events = new API.Events(this); - expectedPayments: API.ExpectedPayments = new API.ExpectedPayments(this); - externalAccounts: API.ExternalAccounts = new API.ExternalAccounts(this); - incomingPaymentDetails: API.IncomingPaymentDetails = new API.IncomingPaymentDetails(this); - invoices: API.Invoices = new API.Invoices(this); - documents: API.Documents = new API.Documents(this); - accountCollectionFlows: API.AccountCollectionFlows = new API.AccountCollectionFlows(this); - accountDetails: API.AccountDetails = new API.AccountDetails(this); - routingDetails: API.RoutingDetails = new API.RoutingDetails(this); - internalAccounts: API.InternalAccounts = new API.InternalAccounts(this); - ledgers: API.Ledgers = new API.Ledgers(this); - ledgerableEvents: API.LedgerableEvents = new API.LedgerableEvents(this); - ledgerAccountCategories: API.LedgerAccountCategories = new API.LedgerAccountCategories(this); - ledgerAccounts: API.LedgerAccounts = new API.LedgerAccounts(this); - ledgerAccountBalanceMonitors: API.LedgerAccountBalanceMonitors = new API.LedgerAccountBalanceMonitors(this); - ledgerAccountPayouts: API.LedgerAccountPayouts = new API.LedgerAccountPayouts(this); - ledgerAccountStatements: API.LedgerAccountStatements = new API.LedgerAccountStatements(this); - ledgerEntries: API.LedgerEntries = new API.LedgerEntries(this); - ledgerEventHandlers: API.LedgerEventHandlers = new API.LedgerEventHandlers(this); - ledgerTransactions: API.LedgerTransactions = new API.LedgerTransactions(this); - lineItems: API.LineItems = new API.LineItems(this); - paymentFlows: API.PaymentFlows = new API.PaymentFlows(this); - paymentOrders: API.PaymentOrders = new API.PaymentOrders(this); - paymentReferences: API.PaymentReferences = new API.PaymentReferences(this); - returns: API.Returns = new API.Returns(this); - transactions: API.Transactions = new API.Transactions(this); - validations: API.Validations = new API.Validations(this); - paperItems: API.PaperItems = new API.PaperItems(this); - webhooks: API.Webhooks = new API.Webhooks(this); - virtualAccounts: API.VirtualAccounts = new API.VirtualAccounts(this); - bulkRequests: API.BulkRequests = new API.BulkRequests(this); - bulkResults: API.BulkResults = new API.BulkResults(this); - ledgerAccountSettlements: API.LedgerAccountSettlements = new API.LedgerAccountSettlements(this); - foreignExchangeQuotes: API.ForeignExchangeQuotes = new API.ForeignExchangeQuotes(this); - connectionLegalEntities: API.ConnectionLegalEntities = new API.ConnectionLegalEntities(this); - legalEntities: API.LegalEntities = new API.LegalEntities(this); - legalEntityAssociations: API.LegalEntityAssociations = new API.LegalEntityAssociations(this); - - /** - * A test endpoint often used to confirm credentials and headers are being passed - * in correctly. - */ - ping(options?: Core.RequestOptions): Core.APIPromise { - return this.get('/api/ping', options); - } - - protected override defaultQuery(): Core.DefaultQuery | undefined { - return this._options.defaultQuery; - } - - protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers { - return { - ...super.defaultHeaders(opts), - ...this._options.defaultHeaders, - }; - } - - protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers { - if (!this.organizationId) { - return {}; - } - - if (!this.apiKey) { - return {}; - } - - const credentials = `${this.organizationId}:${this.apiKey}`; - const Authorization = `Basic ${Core.toBase64(credentials)}`; - return { Authorization }; - } - - protected override stringifyQuery(query: Record): string { - return qs.stringify(query, { arrayFormat: 'brackets' }); - } - - static ModernTreasury = this; - - static ModernTreasuryError = Errors.ModernTreasuryError; - static APIError = Errors.APIError; - static APIConnectionError = Errors.APIConnectionError; - static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError; - static APIUserAbortError = Errors.APIUserAbortError; - static NotFoundError = Errors.NotFoundError; - static ConflictError = Errors.ConflictError; - static RateLimitError = Errors.RateLimitError; - static BadRequestError = Errors.BadRequestError; - static AuthenticationError = Errors.AuthenticationError; - static InternalServerError = Errors.InternalServerError; - static PermissionDeniedError = Errors.PermissionDeniedError; - static UnprocessableEntityError = Errors.UnprocessableEntityError; - - static toFile = Uploads.toFile; - static fileFromPath = Uploads.fileFromPath; -} - -export namespace ModernTreasury { - export import RequestOptions = Core.RequestOptions; - - export import Page = Pagination.Page; - export import PageParams = Pagination.PageParams; - export import PageResponse = Pagination.PageResponse; - - export import PingResponse = API.PingResponse; - - export import Connections = API.Connections; - export import Connection = API.Connection; - export import ConnectionsPage = API.ConnectionsPage; - export import ConnectionListParams = API.ConnectionListParams; - - export import Counterparties = API.Counterparties; - export import Counterparty = API.Counterparty; - export import CounterpartyCollectAccountResponse = API.CounterpartyCollectAccountResponse; - export import CounterpartiesPage = API.CounterpartiesPage; - export import CounterpartyCreateParams = API.CounterpartyCreateParams; - export import CounterpartyUpdateParams = API.CounterpartyUpdateParams; - export import CounterpartyListParams = API.CounterpartyListParams; - export import CounterpartyCollectAccountParams = API.CounterpartyCollectAccountParams; - - export import Events = API.Events; - export import Event = API.Event; - export import EventsPage = API.EventsPage; - export import EventListParams = API.EventListParams; - - export import ExpectedPayments = API.ExpectedPayments; - export import ExpectedPayment = API.ExpectedPayment; - export import ExpectedPaymentType = API.ExpectedPaymentType; - export import ExpectedPaymentsPage = API.ExpectedPaymentsPage; - export import ExpectedPaymentCreateParams = API.ExpectedPaymentCreateParams; - export import ExpectedPaymentUpdateParams = API.ExpectedPaymentUpdateParams; - export import ExpectedPaymentListParams = API.ExpectedPaymentListParams; - - export import ExternalAccounts = API.ExternalAccounts; - export import ExternalAccount = API.ExternalAccount; - export import ExternalAccountType = API.ExternalAccountType; - export import ExternalAccountsPage = API.ExternalAccountsPage; - export import ExternalAccountCreateParams = API.ExternalAccountCreateParams; - export import ExternalAccountUpdateParams = API.ExternalAccountUpdateParams; - export import ExternalAccountListParams = API.ExternalAccountListParams; - export import ExternalAccountCompleteVerificationParams = API.ExternalAccountCompleteVerificationParams; - export import ExternalAccountVerifyParams = API.ExternalAccountVerifyParams; - - export import IncomingPaymentDetails = API.IncomingPaymentDetails; - export import IncomingPaymentDetail = API.IncomingPaymentDetail; - export import IncomingPaymentDetailsPage = API.IncomingPaymentDetailsPage; - export import IncomingPaymentDetailUpdateParams = API.IncomingPaymentDetailUpdateParams; - export import IncomingPaymentDetailListParams = API.IncomingPaymentDetailListParams; - export import IncomingPaymentDetailCreateAsyncParams = API.IncomingPaymentDetailCreateAsyncParams; - - export import Invoices = API.Invoices; - export import Invoice = API.Invoice; - export import InvoicesPage = API.InvoicesPage; - export import InvoiceCreateParams = API.InvoiceCreateParams; - export import InvoiceUpdateParams = API.InvoiceUpdateParams; - export import InvoiceListParams = API.InvoiceListParams; - - export import Documents = API.Documents; - export import Document = API.Document; - export import DocumentsPage = API.DocumentsPage; - export import DocumentCreateParams = API.DocumentCreateParams; - export import DocumentListParams = API.DocumentListParams; - - export import AccountCollectionFlows = API.AccountCollectionFlows; - export import AccountCollectionFlow = API.AccountCollectionFlow; - export import AccountCollectionFlowsPage = API.AccountCollectionFlowsPage; - export import AccountCollectionFlowCreateParams = API.AccountCollectionFlowCreateParams; - export import AccountCollectionFlowUpdateParams = API.AccountCollectionFlowUpdateParams; - export import AccountCollectionFlowListParams = API.AccountCollectionFlowListParams; - - export import AccountDetails = API.AccountDetails; - export import AccountDetail = API.AccountDetail; - export import AccountDetailsPage = API.AccountDetailsPage; - export import AccountDetailCreateParams = API.AccountDetailCreateParams; - export import AccountDetailListParams = API.AccountDetailListParams; - - export import RoutingDetails = API.RoutingDetails; - export import RoutingDetail = API.RoutingDetail; - export import RoutingDetailsPage = API.RoutingDetailsPage; - export import RoutingDetailCreateParams = API.RoutingDetailCreateParams; - export import RoutingDetailListParams = API.RoutingDetailListParams; - - export import InternalAccounts = API.InternalAccounts; - export import InternalAccount = API.InternalAccount; - export import InternalAccountsPage = API.InternalAccountsPage; - export import InternalAccountCreateParams = API.InternalAccountCreateParams; - export import InternalAccountUpdateParams = API.InternalAccountUpdateParams; - export import InternalAccountListParams = API.InternalAccountListParams; - - export import Ledgers = API.Ledgers; - export import Ledger = API.Ledger; - export import LedgersPage = API.LedgersPage; - export import LedgerCreateParams = API.LedgerCreateParams; - export import LedgerUpdateParams = API.LedgerUpdateParams; - export import LedgerListParams = API.LedgerListParams; - - export import LedgerableEvents = API.LedgerableEvents; - export import LedgerableEvent = API.LedgerableEvent; - export import LedgerableEventCreateParams = API.LedgerableEventCreateParams; - - export import LedgerAccountCategories = API.LedgerAccountCategories; - export import LedgerAccountCategory = API.LedgerAccountCategory; - export import LedgerAccountCategoriesPage = API.LedgerAccountCategoriesPage; - export import LedgerAccountCategoryCreateParams = API.LedgerAccountCategoryCreateParams; - export import LedgerAccountCategoryRetrieveParams = API.LedgerAccountCategoryRetrieveParams; - export import LedgerAccountCategoryUpdateParams = API.LedgerAccountCategoryUpdateParams; - export import LedgerAccountCategoryListParams = API.LedgerAccountCategoryListParams; - - export import LedgerAccounts = API.LedgerAccounts; - export import LedgerAccount = API.LedgerAccount; - export import LedgerAccountsPage = API.LedgerAccountsPage; - export import LedgerAccountCreateParams = API.LedgerAccountCreateParams; - export import LedgerAccountRetrieveParams = API.LedgerAccountRetrieveParams; - export import LedgerAccountUpdateParams = API.LedgerAccountUpdateParams; - export import LedgerAccountListParams = API.LedgerAccountListParams; - - export import LedgerAccountBalanceMonitors = API.LedgerAccountBalanceMonitors; - export import LedgerAccountBalanceMonitor = API.LedgerAccountBalanceMonitor; - export import LedgerAccountBalanceMonitorsPage = API.LedgerAccountBalanceMonitorsPage; - export import LedgerAccountBalanceMonitorCreateParams = API.LedgerAccountBalanceMonitorCreateParams; - export import LedgerAccountBalanceMonitorUpdateParams = API.LedgerAccountBalanceMonitorUpdateParams; - export import LedgerAccountBalanceMonitorListParams = API.LedgerAccountBalanceMonitorListParams; - - export import LedgerAccountPayouts = API.LedgerAccountPayouts; - export import LedgerAccountPayout = API.LedgerAccountPayout; - export import LedgerAccountPayoutsPage = API.LedgerAccountPayoutsPage; - export import LedgerAccountPayoutCreateParams = API.LedgerAccountPayoutCreateParams; - export import LedgerAccountPayoutUpdateParams = API.LedgerAccountPayoutUpdateParams; - export import LedgerAccountPayoutListParams = API.LedgerAccountPayoutListParams; - - export import LedgerAccountStatements = API.LedgerAccountStatements; - export import LedgerAccountStatementCreateResponse = API.LedgerAccountStatementCreateResponse; - export import LedgerAccountStatementRetrieveResponse = API.LedgerAccountStatementRetrieveResponse; - export import LedgerAccountStatementCreateParams = API.LedgerAccountStatementCreateParams; - - export import LedgerEntries = API.LedgerEntries; - export import LedgerEntry = API.LedgerEntry; - export import LedgerEntriesPage = API.LedgerEntriesPage; - export import LedgerEntryRetrieveParams = API.LedgerEntryRetrieveParams; - export import LedgerEntryUpdateParams = API.LedgerEntryUpdateParams; - export import LedgerEntryListParams = API.LedgerEntryListParams; - - export import LedgerEventHandlers = API.LedgerEventHandlers; - export import LedgerEventHandler = API.LedgerEventHandler; - export import LedgerEventHandlerVariable = API.LedgerEventHandlerVariable; - export import LedgerEventHandlersPage = API.LedgerEventHandlersPage; - export import LedgerEventHandlerCreateParams = API.LedgerEventHandlerCreateParams; - export import LedgerEventHandlerListParams = API.LedgerEventHandlerListParams; - - export import LedgerTransactions = API.LedgerTransactions; - export import LedgerTransaction = API.LedgerTransaction; - export import LedgerTransactionsPage = API.LedgerTransactionsPage; - export import LedgerTransactionCreateParams = API.LedgerTransactionCreateParams; - export import LedgerTransactionUpdateParams = API.LedgerTransactionUpdateParams; - export import LedgerTransactionListParams = API.LedgerTransactionListParams; - export import LedgerTransactionCreateReversalParams = API.LedgerTransactionCreateReversalParams; - - export import LineItems = API.LineItems; - export import LineItem = API.LineItem; - export import LineItemsPage = API.LineItemsPage; - export import LineItemUpdateParams = API.LineItemUpdateParams; - export import LineItemListParams = API.LineItemListParams; - - export import PaymentFlows = API.PaymentFlows; - export import PaymentFlow = API.PaymentFlow; - export import PaymentFlowsPage = API.PaymentFlowsPage; - export import PaymentFlowCreateParams = API.PaymentFlowCreateParams; - export import PaymentFlowUpdateParams = API.PaymentFlowUpdateParams; - export import PaymentFlowListParams = API.PaymentFlowListParams; - - export import PaymentOrders = API.PaymentOrders; - export import PaymentOrder = API.PaymentOrder; - export import PaymentOrderSubtype = API.PaymentOrderSubtype; - export import PaymentOrderType = API.PaymentOrderType; - export import PaymentOrdersPage = API.PaymentOrdersPage; - export import PaymentOrderCreateParams = API.PaymentOrderCreateParams; - export import PaymentOrderUpdateParams = API.PaymentOrderUpdateParams; - export import PaymentOrderListParams = API.PaymentOrderListParams; - export import PaymentOrderCreateAsyncParams = API.PaymentOrderCreateAsyncParams; - - export import PaymentReferences = API.PaymentReferences; - export import PaymentReference = API.PaymentReference; - export import PaymentReferencesPage = API.PaymentReferencesPage; - export import PaymentReferenceListParams = API.PaymentReferenceListParams; - - export import Returns = API.Returns; - export import ReturnObject = API.ReturnObject; - export import ReturnObjectsPage = API.ReturnObjectsPage; - export import ReturnCreateParams = API.ReturnCreateParams; - export import ReturnListParams = API.ReturnListParams; - - export import Transactions = API.Transactions; - export import Transaction = API.Transaction; - export import TransactionsPage = API.TransactionsPage; - export import TransactionCreateParams = API.TransactionCreateParams; - export import TransactionUpdateParams = API.TransactionUpdateParams; - export import TransactionListParams = API.TransactionListParams; - - export import Validations = API.Validations; - export import RoutingNumberLookupRequest = API.RoutingNumberLookupRequest; - export import ValidationValidateRoutingNumberParams = API.ValidationValidateRoutingNumberParams; - - export import PaperItems = API.PaperItems; - export import PaperItem = API.PaperItem; - export import PaperItemsPage = API.PaperItemsPage; - export import PaperItemListParams = API.PaperItemListParams; - - export import Webhooks = API.Webhooks; - - export import VirtualAccounts = API.VirtualAccounts; - export import VirtualAccount = API.VirtualAccount; - export import VirtualAccountsPage = API.VirtualAccountsPage; - export import VirtualAccountCreateParams = API.VirtualAccountCreateParams; - export import VirtualAccountUpdateParams = API.VirtualAccountUpdateParams; - export import VirtualAccountListParams = API.VirtualAccountListParams; - - export import BulkRequests = API.BulkRequests; - export import BulkRequest = API.BulkRequest; - export import BulkRequestsPage = API.BulkRequestsPage; - export import BulkRequestCreateParams = API.BulkRequestCreateParams; - export import BulkRequestListParams = API.BulkRequestListParams; - - export import BulkResults = API.BulkResults; - export import BulkResult = API.BulkResult; - export import BulkResultsPage = API.BulkResultsPage; - export import BulkResultListParams = API.BulkResultListParams; - - export import LedgerAccountSettlements = API.LedgerAccountSettlements; - export import LedgerAccountSettlement = API.LedgerAccountSettlement; - export import LedgerAccountSettlementsPage = API.LedgerAccountSettlementsPage; - export import LedgerAccountSettlementCreateParams = API.LedgerAccountSettlementCreateParams; - export import LedgerAccountSettlementUpdateParams = API.LedgerAccountSettlementUpdateParams; - export import LedgerAccountSettlementListParams = API.LedgerAccountSettlementListParams; - - export import ForeignExchangeQuotes = API.ForeignExchangeQuotes; - export import ForeignExchangeQuote = API.ForeignExchangeQuote; - export import ForeignExchangeQuotesPage = API.ForeignExchangeQuotesPage; - export import ForeignExchangeQuoteCreateParams = API.ForeignExchangeQuoteCreateParams; - export import ForeignExchangeQuoteListParams = API.ForeignExchangeQuoteListParams; - - export import ConnectionLegalEntities = API.ConnectionLegalEntities; - export import ConnectionLegalEntity = API.ConnectionLegalEntity; - export import ConnectionLegalEntitiesPage = API.ConnectionLegalEntitiesPage; - export import ConnectionLegalEntityCreateParams = API.ConnectionLegalEntityCreateParams; - export import ConnectionLegalEntityUpdateParams = API.ConnectionLegalEntityUpdateParams; - export import ConnectionLegalEntityListParams = API.ConnectionLegalEntityListParams; - - export import LegalEntities = API.LegalEntities; - export import LegalEntity = API.LegalEntity; - export import LegalEntitiesPage = API.LegalEntitiesPage; - export import LegalEntityCreateParams = API.LegalEntityCreateParams; - export import LegalEntityUpdateParams = API.LegalEntityUpdateParams; - export import LegalEntityListParams = API.LegalEntityListParams; - - export import LegalEntityAssociations = API.LegalEntityAssociations; - export import LegalEntityAssociation = API.LegalEntityAssociation; - export import LegalEntityAssociationCreateParams = API.LegalEntityAssociationCreateParams; - - export import AccountsType = API.AccountsType; - export import AsyncResponse = API.AsyncResponse; - export import Currency = API.Currency; - export import TransactionDirection = API.TransactionDirection; -} diff --git a/src/index.ts b/src/index.ts index 3af1aa37..ac6b452d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,246 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +import * as Core from './core'; import * as Errors from './error'; +import { type Agent } from './_shims/index'; import * as Uploads from './uploads'; -import { ModernTreasury } from './client'; +import * as qs from 'qs'; +import * as Pagination from 'modern-treasury/pagination'; +import * as API from 'modern-treasury/resources/index'; +import * as TopLevelAPI from 'modern-treasury/resources/top-level'; -export { ModernTreasury }; -export default ModernTreasury; +export interface ClientOptions { + /** + * Defaults to process.env['MODERN_TREASURY_API_KEY']. + */ + apiKey?: string | undefined; -export import toFile = Uploads.toFile; -export import fileFromPath = Uploads.fileFromPath; + /** + * Defaults to process.env['MODERN_TREASURY_ORGANIZATION_ID']. + */ + organizationId?: string | undefined; + + /** + * Defaults to process.env['MODERN_TREASURY_WEBHOOK_KEY']. + */ + webhookKey?: string | null | undefined; + + /** + * Override the default base URL for the API, e.g., "https://api.example.com/v2/" + * + * Defaults to process.env['MODERN_TREASURY_BASE_URL']. + */ + baseURL?: string | null | undefined; + + /** + * The maximum amount of time (in milliseconds) that the client should wait for a response + * from the server before timing out a single request. + * + * Note that request timeouts are retried by default, so in a worst-case scenario you may wait + * much longer than this timeout before the promise succeeds or fails. + */ + timeout?: number; + + /** + * An HTTP agent used to manage HTTP(S) connections. + * + * If not provided, an agent will be constructed by default in the Node.js environment, + * otherwise no agent is used. + */ + httpAgent?: Agent; + + /** + * Specify a custom `fetch` function implementation. + * + * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is + * defined globally. + */ + fetch?: Core.Fetch | undefined; + + /** + * The maximum number of times that the client will retry a request in case of a + * temporary failure, like a network error or a 5XX error from the server. + * + * @default 2 + */ + maxRetries?: number; + + /** + * Default headers to include with every request to the API. + * + * These can be removed in individual requests by explicitly setting the + * header to `undefined` or `null` in request options. + */ + defaultHeaders?: Core.Headers; + + /** + * Default query parameters to include with every request to the API. + * + * These can be removed in individual requests by explicitly setting the + * param to `undefined` in request options. + */ + defaultQuery?: Core.DefaultQuery; +} + +/** API Client for interfacing with the Modern Treasury API. */ +export class ModernTreasury extends Core.APIClient { + apiKey: string; + organizationId: string; + webhookKey: string | null; + + private _options: ClientOptions; + + /** + * API Client for interfacing with the Modern Treasury API. + * + * @param {string | undefined} [opts.apiKey=process.env['MODERN_TREASURY_API_KEY'] ?? undefined] + * @param {string | undefined} [opts.organizationId=process.env['MODERN_TREASURY_ORGANIZATION_ID'] ?? undefined] + * @param {string | null | undefined} [opts.webhookKey=process.env['MODERN_TREASURY_WEBHOOK_KEY'] ?? null] + * @param {string} [opts.baseURL=process.env['MODERN_TREASURY_BASE_URL'] ?? https://app.moderntreasury.com] - Override the default base URL for the API. + * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. + * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. + * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. + * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. + * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API. + * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API. + */ + constructor({ + baseURL = Core.readEnv('MODERN_TREASURY_BASE_URL'), + apiKey = Core.readEnv('MODERN_TREASURY_API_KEY'), + organizationId = Core.readEnv('MODERN_TREASURY_ORGANIZATION_ID'), + webhookKey = Core.readEnv('MODERN_TREASURY_WEBHOOK_KEY') ?? null, + ...opts + }: ClientOptions = {}) { + if (apiKey === undefined) { + throw new Errors.ModernTreasuryError( + "The MODERN_TREASURY_API_KEY environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an apiKey option, like new ModernTreasury({ apiKey: 'My API Key' }).", + ); + } + if (organizationId === undefined) { + throw new Errors.ModernTreasuryError( + "The MODERN_TREASURY_ORGANIZATION_ID environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an organizationId option, like new ModernTreasury({ organizationId: 'my-organization-ID' }).", + ); + } + + const options: ClientOptions = { + apiKey, + organizationId, + webhookKey, + ...opts, + baseURL: baseURL || `https://app.moderntreasury.com`, + }; + + super({ + baseURL: options.baseURL!, + timeout: options.timeout ?? 60000 /* 1 minute */, + httpAgent: options.httpAgent, + maxRetries: options.maxRetries, + fetch: options.fetch, + }); + this._options = options; + this.idempotencyHeader = 'Idempotency-Key'; + + this.apiKey = apiKey; + this.organizationId = organizationId; + this.webhookKey = webhookKey; + } + + connections: API.Connections = new API.Connections(this); + counterparties: API.Counterparties = new API.Counterparties(this); + events: API.Events = new API.Events(this); + expectedPayments: API.ExpectedPayments = new API.ExpectedPayments(this); + externalAccounts: API.ExternalAccounts = new API.ExternalAccounts(this); + incomingPaymentDetails: API.IncomingPaymentDetails = new API.IncomingPaymentDetails(this); + invoices: API.Invoices = new API.Invoices(this); + documents: API.Documents = new API.Documents(this); + accountCollectionFlows: API.AccountCollectionFlows = new API.AccountCollectionFlows(this); + accountDetails: API.AccountDetails = new API.AccountDetails(this); + routingDetails: API.RoutingDetails = new API.RoutingDetails(this); + internalAccounts: API.InternalAccounts = new API.InternalAccounts(this); + ledgers: API.Ledgers = new API.Ledgers(this); + ledgerableEvents: API.LedgerableEvents = new API.LedgerableEvents(this); + ledgerAccountCategories: API.LedgerAccountCategories = new API.LedgerAccountCategories(this); + ledgerAccounts: API.LedgerAccounts = new API.LedgerAccounts(this); + ledgerAccountBalanceMonitors: API.LedgerAccountBalanceMonitors = new API.LedgerAccountBalanceMonitors(this); + ledgerAccountPayouts: API.LedgerAccountPayouts = new API.LedgerAccountPayouts(this); + ledgerAccountStatements: API.LedgerAccountStatements = new API.LedgerAccountStatements(this); + ledgerEntries: API.LedgerEntries = new API.LedgerEntries(this); + ledgerEventHandlers: API.LedgerEventHandlers = new API.LedgerEventHandlers(this); + ledgerTransactions: API.LedgerTransactions = new API.LedgerTransactions(this); + lineItems: API.LineItems = new API.LineItems(this); + paymentFlows: API.PaymentFlows = new API.PaymentFlows(this); + paymentOrders: API.PaymentOrders = new API.PaymentOrders(this); + paymentReferences: API.PaymentReferences = new API.PaymentReferences(this); + returns: API.Returns = new API.Returns(this); + transactions: API.Transactions = new API.Transactions(this); + validations: API.Validations = new API.Validations(this); + paperItems: API.PaperItems = new API.PaperItems(this); + webhooks: API.Webhooks = new API.Webhooks(this); + virtualAccounts: API.VirtualAccounts = new API.VirtualAccounts(this); + bulkRequests: API.BulkRequests = new API.BulkRequests(this); + bulkResults: API.BulkResults = new API.BulkResults(this); + ledgerAccountSettlements: API.LedgerAccountSettlements = new API.LedgerAccountSettlements(this); + foreignExchangeQuotes: API.ForeignExchangeQuotes = new API.ForeignExchangeQuotes(this); + connectionLegalEntities: API.ConnectionLegalEntities = new API.ConnectionLegalEntities(this); + legalEntities: API.LegalEntities = new API.LegalEntities(this); + legalEntityAssociations: API.LegalEntityAssociations = new API.LegalEntityAssociations(this); + + /** + * A test endpoint often used to confirm credentials and headers are being passed + * in correctly. + */ + ping(options?: Core.RequestOptions): Core.APIPromise { + return this.get('/api/ping', options); + } + + protected override defaultQuery(): Core.DefaultQuery | undefined { + return this._options.defaultQuery; + } + + protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers { + return { + ...super.defaultHeaders(opts), + ...this._options.defaultHeaders, + }; + } + + protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers { + if (!this.organizationId) { + return {}; + } + + if (!this.apiKey) { + return {}; + } + + const credentials = `${this.organizationId}:${this.apiKey}`; + const Authorization = `Basic ${Core.toBase64(credentials)}`; + return { Authorization }; + } + + protected override stringifyQuery(query: Record): string { + return qs.stringify(query, { arrayFormat: 'brackets' }); + } + + static ModernTreasury = this; + + static ModernTreasuryError = Errors.ModernTreasuryError; + static APIError = Errors.APIError; + static APIConnectionError = Errors.APIConnectionError; + static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError; + static APIUserAbortError = Errors.APIUserAbortError; + static NotFoundError = Errors.NotFoundError; + static ConflictError = Errors.ConflictError; + static RateLimitError = Errors.RateLimitError; + static BadRequestError = Errors.BadRequestError; + static AuthenticationError = Errors.AuthenticationError; + static InternalServerError = Errors.InternalServerError; + static PermissionDeniedError = Errors.PermissionDeniedError; + static UnprocessableEntityError = Errors.UnprocessableEntityError; + + static toFile = Uploads.toFile; + static fileFromPath = Uploads.fileFromPath; +} export const { ModernTreasuryError, @@ -26,4 +258,274 @@ export const { UnprocessableEntityError, } = Errors; -export * from './client'; +export import toFile = Uploads.toFile; +export import fileFromPath = Uploads.fileFromPath; + +export namespace ModernTreasury { + export import RequestOptions = Core.RequestOptions; + + export import Page = Pagination.Page; + export import PageParams = Pagination.PageParams; + export import PageResponse = Pagination.PageResponse; + + export import PingResponse = API.PingResponse; + + export import Connections = API.Connections; + export import Connection = API.Connection; + export import ConnectionsPage = API.ConnectionsPage; + export import ConnectionListParams = API.ConnectionListParams; + + export import Counterparties = API.Counterparties; + export import Counterparty = API.Counterparty; + export import CounterpartyCollectAccountResponse = API.CounterpartyCollectAccountResponse; + export import CounterpartiesPage = API.CounterpartiesPage; + export import CounterpartyCreateParams = API.CounterpartyCreateParams; + export import CounterpartyUpdateParams = API.CounterpartyUpdateParams; + export import CounterpartyListParams = API.CounterpartyListParams; + export import CounterpartyCollectAccountParams = API.CounterpartyCollectAccountParams; + + export import Events = API.Events; + export import Event = API.Event; + export import EventsPage = API.EventsPage; + export import EventListParams = API.EventListParams; + + export import ExpectedPayments = API.ExpectedPayments; + export import ExpectedPayment = API.ExpectedPayment; + export import ExpectedPaymentType = API.ExpectedPaymentType; + export import ExpectedPaymentsPage = API.ExpectedPaymentsPage; + export import ExpectedPaymentCreateParams = API.ExpectedPaymentCreateParams; + export import ExpectedPaymentUpdateParams = API.ExpectedPaymentUpdateParams; + export import ExpectedPaymentListParams = API.ExpectedPaymentListParams; + + export import ExternalAccounts = API.ExternalAccounts; + export import ExternalAccount = API.ExternalAccount; + export import ExternalAccountType = API.ExternalAccountType; + export import ExternalAccountsPage = API.ExternalAccountsPage; + export import ExternalAccountCreateParams = API.ExternalAccountCreateParams; + export import ExternalAccountUpdateParams = API.ExternalAccountUpdateParams; + export import ExternalAccountListParams = API.ExternalAccountListParams; + export import ExternalAccountCompleteVerificationParams = API.ExternalAccountCompleteVerificationParams; + export import ExternalAccountVerifyParams = API.ExternalAccountVerifyParams; + + export import IncomingPaymentDetails = API.IncomingPaymentDetails; + export import IncomingPaymentDetail = API.IncomingPaymentDetail; + export import IncomingPaymentDetailsPage = API.IncomingPaymentDetailsPage; + export import IncomingPaymentDetailUpdateParams = API.IncomingPaymentDetailUpdateParams; + export import IncomingPaymentDetailListParams = API.IncomingPaymentDetailListParams; + export import IncomingPaymentDetailCreateAsyncParams = API.IncomingPaymentDetailCreateAsyncParams; + + export import Invoices = API.Invoices; + export import Invoice = API.Invoice; + export import InvoicesPage = API.InvoicesPage; + export import InvoiceCreateParams = API.InvoiceCreateParams; + export import InvoiceUpdateParams = API.InvoiceUpdateParams; + export import InvoiceListParams = API.InvoiceListParams; + + export import Documents = API.Documents; + export import Document = API.Document; + export import DocumentsPage = API.DocumentsPage; + export import DocumentCreateParams = API.DocumentCreateParams; + export import DocumentListParams = API.DocumentListParams; + + export import AccountCollectionFlows = API.AccountCollectionFlows; + export import AccountCollectionFlow = API.AccountCollectionFlow; + export import AccountCollectionFlowsPage = API.AccountCollectionFlowsPage; + export import AccountCollectionFlowCreateParams = API.AccountCollectionFlowCreateParams; + export import AccountCollectionFlowUpdateParams = API.AccountCollectionFlowUpdateParams; + export import AccountCollectionFlowListParams = API.AccountCollectionFlowListParams; + + export import AccountDetails = API.AccountDetails; + export import AccountDetail = API.AccountDetail; + export import AccountDetailsPage = API.AccountDetailsPage; + export import AccountDetailCreateParams = API.AccountDetailCreateParams; + export import AccountDetailListParams = API.AccountDetailListParams; + + export import RoutingDetails = API.RoutingDetails; + export import RoutingDetail = API.RoutingDetail; + export import RoutingDetailsPage = API.RoutingDetailsPage; + export import RoutingDetailCreateParams = API.RoutingDetailCreateParams; + export import RoutingDetailListParams = API.RoutingDetailListParams; + + export import InternalAccounts = API.InternalAccounts; + export import InternalAccount = API.InternalAccount; + export import InternalAccountsPage = API.InternalAccountsPage; + export import InternalAccountCreateParams = API.InternalAccountCreateParams; + export import InternalAccountUpdateParams = API.InternalAccountUpdateParams; + export import InternalAccountListParams = API.InternalAccountListParams; + + export import Ledgers = API.Ledgers; + export import Ledger = API.Ledger; + export import LedgersPage = API.LedgersPage; + export import LedgerCreateParams = API.LedgerCreateParams; + export import LedgerUpdateParams = API.LedgerUpdateParams; + export import LedgerListParams = API.LedgerListParams; + + export import LedgerableEvents = API.LedgerableEvents; + export import LedgerableEvent = API.LedgerableEvent; + export import LedgerableEventCreateParams = API.LedgerableEventCreateParams; + + export import LedgerAccountCategories = API.LedgerAccountCategories; + export import LedgerAccountCategory = API.LedgerAccountCategory; + export import LedgerAccountCategoriesPage = API.LedgerAccountCategoriesPage; + export import LedgerAccountCategoryCreateParams = API.LedgerAccountCategoryCreateParams; + export import LedgerAccountCategoryRetrieveParams = API.LedgerAccountCategoryRetrieveParams; + export import LedgerAccountCategoryUpdateParams = API.LedgerAccountCategoryUpdateParams; + export import LedgerAccountCategoryListParams = API.LedgerAccountCategoryListParams; + + export import LedgerAccounts = API.LedgerAccounts; + export import LedgerAccount = API.LedgerAccount; + export import LedgerAccountsPage = API.LedgerAccountsPage; + export import LedgerAccountCreateParams = API.LedgerAccountCreateParams; + export import LedgerAccountRetrieveParams = API.LedgerAccountRetrieveParams; + export import LedgerAccountUpdateParams = API.LedgerAccountUpdateParams; + export import LedgerAccountListParams = API.LedgerAccountListParams; + + export import LedgerAccountBalanceMonitors = API.LedgerAccountBalanceMonitors; + export import LedgerAccountBalanceMonitor = API.LedgerAccountBalanceMonitor; + export import LedgerAccountBalanceMonitorsPage = API.LedgerAccountBalanceMonitorsPage; + export import LedgerAccountBalanceMonitorCreateParams = API.LedgerAccountBalanceMonitorCreateParams; + export import LedgerAccountBalanceMonitorUpdateParams = API.LedgerAccountBalanceMonitorUpdateParams; + export import LedgerAccountBalanceMonitorListParams = API.LedgerAccountBalanceMonitorListParams; + + export import LedgerAccountPayouts = API.LedgerAccountPayouts; + export import LedgerAccountPayout = API.LedgerAccountPayout; + export import LedgerAccountPayoutsPage = API.LedgerAccountPayoutsPage; + export import LedgerAccountPayoutCreateParams = API.LedgerAccountPayoutCreateParams; + export import LedgerAccountPayoutUpdateParams = API.LedgerAccountPayoutUpdateParams; + export import LedgerAccountPayoutListParams = API.LedgerAccountPayoutListParams; + + export import LedgerAccountStatements = API.LedgerAccountStatements; + export import LedgerAccountStatementCreateResponse = API.LedgerAccountStatementCreateResponse; + export import LedgerAccountStatementRetrieveResponse = API.LedgerAccountStatementRetrieveResponse; + export import LedgerAccountStatementCreateParams = API.LedgerAccountStatementCreateParams; + + export import LedgerEntries = API.LedgerEntries; + export import LedgerEntry = API.LedgerEntry; + export import LedgerEntriesPage = API.LedgerEntriesPage; + export import LedgerEntryRetrieveParams = API.LedgerEntryRetrieveParams; + export import LedgerEntryUpdateParams = API.LedgerEntryUpdateParams; + export import LedgerEntryListParams = API.LedgerEntryListParams; + + export import LedgerEventHandlers = API.LedgerEventHandlers; + export import LedgerEventHandler = API.LedgerEventHandler; + export import LedgerEventHandlerVariable = API.LedgerEventHandlerVariable; + export import LedgerEventHandlersPage = API.LedgerEventHandlersPage; + export import LedgerEventHandlerCreateParams = API.LedgerEventHandlerCreateParams; + export import LedgerEventHandlerListParams = API.LedgerEventHandlerListParams; + + export import LedgerTransactions = API.LedgerTransactions; + export import LedgerTransaction = API.LedgerTransaction; + export import LedgerTransactionsPage = API.LedgerTransactionsPage; + export import LedgerTransactionCreateParams = API.LedgerTransactionCreateParams; + export import LedgerTransactionUpdateParams = API.LedgerTransactionUpdateParams; + export import LedgerTransactionListParams = API.LedgerTransactionListParams; + export import LedgerTransactionCreateReversalParams = API.LedgerTransactionCreateReversalParams; + + export import LineItems = API.LineItems; + export import LineItem = API.LineItem; + export import LineItemsPage = API.LineItemsPage; + export import LineItemUpdateParams = API.LineItemUpdateParams; + export import LineItemListParams = API.LineItemListParams; + + export import PaymentFlows = API.PaymentFlows; + export import PaymentFlow = API.PaymentFlow; + export import PaymentFlowsPage = API.PaymentFlowsPage; + export import PaymentFlowCreateParams = API.PaymentFlowCreateParams; + export import PaymentFlowUpdateParams = API.PaymentFlowUpdateParams; + export import PaymentFlowListParams = API.PaymentFlowListParams; + + export import PaymentOrders = API.PaymentOrders; + export import PaymentOrder = API.PaymentOrder; + export import PaymentOrderSubtype = API.PaymentOrderSubtype; + export import PaymentOrderType = API.PaymentOrderType; + export import PaymentOrdersPage = API.PaymentOrdersPage; + export import PaymentOrderCreateParams = API.PaymentOrderCreateParams; + export import PaymentOrderUpdateParams = API.PaymentOrderUpdateParams; + export import PaymentOrderListParams = API.PaymentOrderListParams; + export import PaymentOrderCreateAsyncParams = API.PaymentOrderCreateAsyncParams; + + export import PaymentReferences = API.PaymentReferences; + export import PaymentReference = API.PaymentReference; + export import PaymentReferencesPage = API.PaymentReferencesPage; + export import PaymentReferenceListParams = API.PaymentReferenceListParams; + + export import Returns = API.Returns; + export import ReturnObject = API.ReturnObject; + export import ReturnObjectsPage = API.ReturnObjectsPage; + export import ReturnCreateParams = API.ReturnCreateParams; + export import ReturnListParams = API.ReturnListParams; + + export import Transactions = API.Transactions; + export import Transaction = API.Transaction; + export import TransactionsPage = API.TransactionsPage; + export import TransactionCreateParams = API.TransactionCreateParams; + export import TransactionUpdateParams = API.TransactionUpdateParams; + export import TransactionListParams = API.TransactionListParams; + + export import Validations = API.Validations; + export import RoutingNumberLookupRequest = API.RoutingNumberLookupRequest; + export import ValidationValidateRoutingNumberParams = API.ValidationValidateRoutingNumberParams; + + export import PaperItems = API.PaperItems; + export import PaperItem = API.PaperItem; + export import PaperItemsPage = API.PaperItemsPage; + export import PaperItemListParams = API.PaperItemListParams; + + export import Webhooks = API.Webhooks; + + export import VirtualAccounts = API.VirtualAccounts; + export import VirtualAccount = API.VirtualAccount; + export import VirtualAccountsPage = API.VirtualAccountsPage; + export import VirtualAccountCreateParams = API.VirtualAccountCreateParams; + export import VirtualAccountUpdateParams = API.VirtualAccountUpdateParams; + export import VirtualAccountListParams = API.VirtualAccountListParams; + + export import BulkRequests = API.BulkRequests; + export import BulkRequest = API.BulkRequest; + export import BulkRequestsPage = API.BulkRequestsPage; + export import BulkRequestCreateParams = API.BulkRequestCreateParams; + export import BulkRequestListParams = API.BulkRequestListParams; + + export import BulkResults = API.BulkResults; + export import BulkResult = API.BulkResult; + export import BulkResultsPage = API.BulkResultsPage; + export import BulkResultListParams = API.BulkResultListParams; + + export import LedgerAccountSettlements = API.LedgerAccountSettlements; + export import LedgerAccountSettlement = API.LedgerAccountSettlement; + export import LedgerAccountSettlementsPage = API.LedgerAccountSettlementsPage; + export import LedgerAccountSettlementCreateParams = API.LedgerAccountSettlementCreateParams; + export import LedgerAccountSettlementUpdateParams = API.LedgerAccountSettlementUpdateParams; + export import LedgerAccountSettlementListParams = API.LedgerAccountSettlementListParams; + + export import ForeignExchangeQuotes = API.ForeignExchangeQuotes; + export import ForeignExchangeQuote = API.ForeignExchangeQuote; + export import ForeignExchangeQuotesPage = API.ForeignExchangeQuotesPage; + export import ForeignExchangeQuoteCreateParams = API.ForeignExchangeQuoteCreateParams; + export import ForeignExchangeQuoteListParams = API.ForeignExchangeQuoteListParams; + + export import ConnectionLegalEntities = API.ConnectionLegalEntities; + export import ConnectionLegalEntity = API.ConnectionLegalEntity; + export import ConnectionLegalEntitiesPage = API.ConnectionLegalEntitiesPage; + export import ConnectionLegalEntityCreateParams = API.ConnectionLegalEntityCreateParams; + export import ConnectionLegalEntityUpdateParams = API.ConnectionLegalEntityUpdateParams; + export import ConnectionLegalEntityListParams = API.ConnectionLegalEntityListParams; + + export import LegalEntities = API.LegalEntities; + export import LegalEntity = API.LegalEntity; + export import LegalEntitiesPage = API.LegalEntitiesPage; + export import LegalEntityCreateParams = API.LegalEntityCreateParams; + export import LegalEntityUpdateParams = API.LegalEntityUpdateParams; + export import LegalEntityListParams = API.LegalEntityListParams; + + export import LegalEntityAssociations = API.LegalEntityAssociations; + export import LegalEntityAssociation = API.LegalEntityAssociation; + export import LegalEntityAssociationCreateParams = API.LegalEntityAssociationCreateParams; + + export import AccountsType = API.AccountsType; + export import AsyncResponse = API.AsyncResponse; + export import Currency = API.Currency; + export import TransactionDirection = API.TransactionDirection; +} + +export default ModernTreasury; From 7da6a8304155395bc5c0d0984df76d665306350e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 19:30:50 +0000 Subject: [PATCH 08/15] chore(docs): add SECURITY.md (#401) --- SECURITY.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..d7977608 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainlessapi.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Modern Treasury please follow the respective company's security reporting guidelines. + +### Modern Treasury Terms and Policies + +Please contact sdk-feedback@moderntreasury.com for any questions or concerns regarding security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. From d816b926e4891f4ff0a0da3c64742e87bd0c1348 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 21:29:50 +0000 Subject: [PATCH 09/15] chore(docs): streamline payment purpose and vendor failure handling (#402) --- .stats.yml | 2 +- src/resources/bulk-requests.ts | 10 ++++---- .../payment-orders/payment-orders.ts | 24 ++++++++----------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/.stats.yml b/.stats.yml index 70a26313..5b868858 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 162 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-21d8d8be5e3219420b523ac5670a79f8dcc6e2602fcd13dca12209271db2170e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-aaacc072bfbc4cfb94152b18ca831ca6fce6ed9b64a28341107063386e611a7f.yml diff --git a/src/resources/bulk-requests.ts b/src/resources/bulk-requests.ts index 02efbf61..25bab52c 100644 --- a/src/resources/bulk-requests.ts +++ b/src/resources/bulk-requests.ts @@ -295,9 +295,8 @@ export namespace BulkRequestCreateParams { /** * For `wire`, this is usually the purpose which is transmitted via the - * "InstrForDbtrAgt" field in the ISO20022 file. If you are using Currencycloud, - * this is the `payment.purpose_code` field. For `eft`, this field is the 3 digit - * CPA Code that will be attached to the payment. + * "InstrForDbtrAgt" field in the ISO20022 file. For `eft`, this field is the 3 + * digit CPA Code that will be attached to the payment. */ purpose?: string | null; @@ -1401,9 +1400,8 @@ export namespace BulkRequestCreateParams { /** * For `wire`, this is usually the purpose which is transmitted via the - * "InstrForDbtrAgt" field in the ISO20022 file. If you are using Currencycloud, - * this is the `payment.purpose_code` field. For `eft`, this field is the 3 digit - * CPA Code that will be attached to the payment. + * "InstrForDbtrAgt" field in the ISO20022 file. For `eft`, this field is the 3 + * digit CPA Code that will be attached to the payment. */ purpose?: string | null; diff --git a/src/resources/payment-orders/payment-orders.ts b/src/resources/payment-orders/payment-orders.ts index 16d32e04..d070395d 100644 --- a/src/resources/payment-orders/payment-orders.ts +++ b/src/resources/payment-orders/payment-orders.ts @@ -266,9 +266,8 @@ export interface PaymentOrder { /** * For `wire`, this is usually the purpose which is transmitted via the - * "InstrForDbtrAgt" field in the ISO20022 file. If you are using Currencycloud, - * this is the `payment.purpose_code` field. For `eft`, this field is the 3 digit - * CPA Code that will be attached to the payment. + * "InstrForDbtrAgt" field in the ISO20022 file. For `eft`, this field is the 3 + * digit CPA Code that will be attached to the payment. */ purpose: string | null; @@ -383,8 +382,8 @@ export interface PaymentOrder { updated_at: string; /** - * This field will be populated if a vendor (e.g. Currencycloud) failure occurs. - * Logic shouldn't be built on its value as it is free-form. + * This field will be populated if a vendor failure occurs. Logic shouldn't be + * built on its value as it is free-form. */ vendor_failure_reason: string | null; } @@ -751,9 +750,8 @@ export interface PaymentOrderCreateParams { /** * For `wire`, this is usually the purpose which is transmitted via the - * "InstrForDbtrAgt" field in the ISO20022 file. If you are using Currencycloud, - * this is the `payment.purpose_code` field. For `eft`, this field is the 3 digit - * CPA Code that will be attached to the payment. + * "InstrForDbtrAgt" field in the ISO20022 file. For `eft`, this field is the 3 + * digit CPA Code that will be attached to the payment. */ purpose?: string | null; @@ -1387,9 +1385,8 @@ export interface PaymentOrderUpdateParams { /** * For `wire`, this is usually the purpose which is transmitted via the - * "InstrForDbtrAgt" field in the ISO20022 file. If you are using Currencycloud, - * this is the `payment.purpose_code` field. For `eft`, this field is the 3 digit - * CPA Code that will be attached to the payment. + * "InstrForDbtrAgt" field in the ISO20022 file. For `eft`, this field is the 3 + * digit CPA Code that will be attached to the payment. */ purpose?: string | null; @@ -2016,9 +2013,8 @@ export interface PaymentOrderCreateAsyncParams { /** * For `wire`, this is usually the purpose which is transmitted via the - * "InstrForDbtrAgt" field in the ISO20022 file. If you are using Currencycloud, - * this is the `payment.purpose_code` field. For `eft`, this field is the 3 digit - * CPA Code that will be attached to the payment. + * "InstrForDbtrAgt" field in the ISO20022 file. For `eft`, this field is the 3 + * digit CPA Code that will be attached to the payment. */ purpose?: string | null; From 00e1c3a68fac93d65ea7bfcf1293c79381f6ac46 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 19:02:19 +0000 Subject: [PATCH 10/15] refactor: change import paths to be relative (#403) --- src/index.ts | 6 ++--- src/pagination.ts | 2 +- src/resources/account-collection-flows.ts | 10 ++++---- src/resources/account-details.ts | 12 +++++----- src/resources/bulk-requests.ts | 18 +++++++------- src/resources/bulk-results.ts | 18 +++++++------- src/resources/connection-legal-entities.ts | 10 ++++---- src/resources/connections.ts | 10 ++++---- src/resources/counterparties.ts | 18 +++++++------- src/resources/documents.ts | 12 +++++----- src/resources/events.ts | 10 ++++---- src/resources/expected-payments.ts | 12 +++++----- src/resources/external-accounts.ts | 16 ++++++------- src/resources/foreign-exchange-quotes.ts | 12 +++++----- src/resources/incoming-payment-details.ts | 14 +++++------ .../internal-accounts/balance-reports.ts | 12 +++++----- .../internal-accounts/internal-accounts.ts | 20 ++++++++-------- src/resources/invoices/invoices.ts | 18 +++++++------- src/resources/invoices/line-items.ts | 10 ++++---- .../ledger-account-balance-monitors.ts | 10 ++++---- src/resources/ledger-account-categories.ts | 12 +++++----- src/resources/ledger-account-payouts.ts | 10 ++++---- src/resources/ledger-account-settlements.ts | 10 ++++---- src/resources/ledger-account-statements.ts | 8 +++---- src/resources/ledger-accounts.ts | 12 +++++----- src/resources/ledger-entries.ts | 12 +++++----- src/resources/ledger-event-handlers.ts | 10 ++++---- .../ledger-transactions.ts | 16 ++++++------- src/resources/ledger-transactions/versions.ts | 12 +++++----- src/resources/ledgerable-events.ts | 6 ++--- src/resources/ledgers.ts | 10 ++++---- src/resources/legal-entities.ts | 12 +++++----- src/resources/legal-entity-associations.ts | 6 ++--- src/resources/line-items.ts | 10 ++++---- src/resources/paper-items.ts | 12 +++++----- src/resources/payment-flows.ts | 10 ++++---- .../payment-orders/payment-orders.ts | 24 +++++++++---------- src/resources/payment-orders/reversals.ts | 12 +++++----- src/resources/payment-references.ts | 10 ++++---- src/resources/returns.ts | 12 +++++----- src/resources/routing-details.ts | 12 +++++----- src/resources/top-level.ts | 2 +- src/resources/transactions/line-items.ts | 10 ++++---- src/resources/transactions/transactions.ts | 14 +++++------ src/resources/validations.ts | 6 ++--- src/resources/virtual-accounts.ts | 16 ++++++------- 46 files changed, 268 insertions(+), 268 deletions(-) diff --git a/src/index.ts b/src/index.ts index ac6b452d..bdd3dcd8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,9 +5,9 @@ import * as Errors from './error'; import { type Agent } from './_shims/index'; import * as Uploads from './uploads'; import * as qs from 'qs'; -import * as Pagination from 'modern-treasury/pagination'; -import * as API from 'modern-treasury/resources/index'; -import * as TopLevelAPI from 'modern-treasury/resources/top-level'; +import * as Pagination from './pagination'; +import * as API from './resources/index'; +import * as TopLevelAPI from './resources/top-level'; export interface ClientOptions { /** diff --git a/src/pagination.ts b/src/pagination.ts index f9497956..ffea8284 100644 --- a/src/pagination.ts +++ b/src/pagination.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core'; -import * as Core from 'modern-treasury/core'; +import * as Core from './core'; export type PageResponse = Item[]; diff --git a/src/resources/account-collection-flows.ts b/src/resources/account-collection-flows.ts index e70fab02..3283d03e 100644 --- a/src/resources/account-collection-flows.ts +++ b/src/resources/account-collection-flows.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as AccountCollectionFlowsAPI from 'modern-treasury/resources/account-collection-flows'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as AccountCollectionFlowsAPI from './account-collection-flows'; +import { Page, type PageParams } from '../pagination'; export class AccountCollectionFlows extends APIResource { /** diff --git a/src/resources/account-details.ts b/src/resources/account-details.ts index e5906c63..7113760f 100644 --- a/src/resources/account-details.ts +++ b/src/resources/account-details.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as AccountDetailsAPI from 'modern-treasury/resources/account-details'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as AccountDetailsAPI from './account-details'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class AccountDetails extends APIResource { /** diff --git a/src/resources/bulk-requests.ts b/src/resources/bulk-requests.ts index 25bab52c..1a35143e 100644 --- a/src/resources/bulk-requests.ts +++ b/src/resources/bulk-requests.ts @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as BulkRequestsAPI from 'modern-treasury/resources/bulk-requests'; -import * as ExpectedPaymentsAPI from 'modern-treasury/resources/expected-payments'; -import * as ExternalAccountsAPI from 'modern-treasury/resources/external-accounts'; -import * as Shared from 'modern-treasury/resources/shared'; -import * as PaymentOrdersAPI from 'modern-treasury/resources/payment-orders/payment-orders'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as BulkRequestsAPI from './bulk-requests'; +import * as ExpectedPaymentsAPI from './expected-payments'; +import * as ExternalAccountsAPI from './external-accounts'; +import * as Shared from './shared'; +import * as PaymentOrdersAPI from './payment-orders/payment-orders'; +import { Page, type PageParams } from '../pagination'; export class BulkRequests extends APIResource { /** diff --git a/src/resources/bulk-results.ts b/src/resources/bulk-results.ts index 0594528a..1f2650d4 100644 --- a/src/resources/bulk-results.ts +++ b/src/resources/bulk-results.ts @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as BulkResultsAPI from 'modern-treasury/resources/bulk-results'; -import * as ExpectedPaymentsAPI from 'modern-treasury/resources/expected-payments'; -import * as LedgerTransactionsAPI from 'modern-treasury/resources/ledger-transactions/ledger-transactions'; -import * as PaymentOrdersAPI from 'modern-treasury/resources/payment-orders/payment-orders'; -import * as TransactionsAPI from 'modern-treasury/resources/transactions/transactions'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as BulkResultsAPI from './bulk-results'; +import * as ExpectedPaymentsAPI from './expected-payments'; +import * as LedgerTransactionsAPI from './ledger-transactions/ledger-transactions'; +import * as PaymentOrdersAPI from './payment-orders/payment-orders'; +import * as TransactionsAPI from './transactions/transactions'; +import { Page, type PageParams } from '../pagination'; export class BulkResults extends APIResource { /** diff --git a/src/resources/connection-legal-entities.ts b/src/resources/connection-legal-entities.ts index cd9f0f7b..4f30d8d0 100644 --- a/src/resources/connection-legal-entities.ts +++ b/src/resources/connection-legal-entities.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as ConnectionLegalEntitiesAPI from 'modern-treasury/resources/connection-legal-entities'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as ConnectionLegalEntitiesAPI from './connection-legal-entities'; +import { Page, type PageParams } from '../pagination'; export class ConnectionLegalEntities extends APIResource { /** diff --git a/src/resources/connections.ts b/src/resources/connections.ts index 36b9abf8..607dd17d 100644 --- a/src/resources/connections.ts +++ b/src/resources/connections.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as ConnectionsAPI from 'modern-treasury/resources/connections'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as ConnectionsAPI from './connections'; +import { Page, type PageParams } from '../pagination'; export class Connections extends APIResource { /** diff --git a/src/resources/counterparties.ts b/src/resources/counterparties.ts index 47775cba..bebee664 100644 --- a/src/resources/counterparties.ts +++ b/src/resources/counterparties.ts @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as CounterpartiesAPI from 'modern-treasury/resources/counterparties'; -import * as AccountDetailsAPI from 'modern-treasury/resources/account-details'; -import * as ExternalAccountsAPI from 'modern-treasury/resources/external-accounts'; -import * as RoutingDetailsAPI from 'modern-treasury/resources/routing-details'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as CounterpartiesAPI from './counterparties'; +import * as AccountDetailsAPI from './account-details'; +import * as ExternalAccountsAPI from './external-accounts'; +import * as RoutingDetailsAPI from './routing-details'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class Counterparties extends APIResource { /** diff --git a/src/resources/documents.ts b/src/resources/documents.ts index b972ca6f..bb09bfde 100644 --- a/src/resources/documents.ts +++ b/src/resources/documents.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as DocumentsAPI from 'modern-treasury/resources/documents'; -import { type Uploadable, multipartFormRequestOptions } from 'modern-treasury/core'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as DocumentsAPI from './documents'; +import { type Uploadable, multipartFormRequestOptions } from '../core'; +import { Page, type PageParams } from '../pagination'; export class Documents extends APIResource { /** diff --git a/src/resources/events.ts b/src/resources/events.ts index a08353cc..bab686d1 100644 --- a/src/resources/events.ts +++ b/src/resources/events.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as EventsAPI from 'modern-treasury/resources/events'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as EventsAPI from './events'; +import { Page, type PageParams } from '../pagination'; export class Events extends APIResource { /** diff --git a/src/resources/expected-payments.ts b/src/resources/expected-payments.ts index 17f977be..4dcafd25 100644 --- a/src/resources/expected-payments.ts +++ b/src/resources/expected-payments.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as ExpectedPaymentsAPI from 'modern-treasury/resources/expected-payments'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as ExpectedPaymentsAPI from './expected-payments'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class ExpectedPayments extends APIResource { /** diff --git a/src/resources/external-accounts.ts b/src/resources/external-accounts.ts index 5dcda785..da99ec33 100644 --- a/src/resources/external-accounts.ts +++ b/src/resources/external-accounts.ts @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as ExternalAccountsAPI from 'modern-treasury/resources/external-accounts'; -import * as AccountDetailsAPI from 'modern-treasury/resources/account-details'; -import * as RoutingDetailsAPI from 'modern-treasury/resources/routing-details'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as ExternalAccountsAPI from './external-accounts'; +import * as AccountDetailsAPI from './account-details'; +import * as RoutingDetailsAPI from './routing-details'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class ExternalAccounts extends APIResource { /** diff --git a/src/resources/foreign-exchange-quotes.ts b/src/resources/foreign-exchange-quotes.ts index 8082ac92..47553ce8 100644 --- a/src/resources/foreign-exchange-quotes.ts +++ b/src/resources/foreign-exchange-quotes.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as ForeignExchangeQuotesAPI from 'modern-treasury/resources/foreign-exchange-quotes'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as ForeignExchangeQuotesAPI from './foreign-exchange-quotes'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class ForeignExchangeQuotes extends APIResource { /** diff --git a/src/resources/incoming-payment-details.ts b/src/resources/incoming-payment-details.ts index 0c0d5971..e4e6b7b6 100644 --- a/src/resources/incoming-payment-details.ts +++ b/src/resources/incoming-payment-details.ts @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as IncomingPaymentDetailsAPI from 'modern-treasury/resources/incoming-payment-details'; -import * as Shared from 'modern-treasury/resources/shared'; -import * as VirtualAccountsAPI from 'modern-treasury/resources/virtual-accounts'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as IncomingPaymentDetailsAPI from './incoming-payment-details'; +import * as Shared from './shared'; +import * as VirtualAccountsAPI from './virtual-accounts'; +import { Page, type PageParams } from '../pagination'; export class IncomingPaymentDetails extends APIResource { /** diff --git a/src/resources/internal-accounts/balance-reports.ts b/src/resources/internal-accounts/balance-reports.ts index 3dce992f..34ff98b0 100644 --- a/src/resources/internal-accounts/balance-reports.ts +++ b/src/resources/internal-accounts/balance-reports.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as BalanceReportsAPI from 'modern-treasury/resources/internal-accounts/balance-reports'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as BalanceReportsAPI from './balance-reports'; +import * as Shared from '../shared'; +import { Page, type PageParams } from '../../pagination'; export class BalanceReports extends APIResource { /** diff --git a/src/resources/internal-accounts/internal-accounts.ts b/src/resources/internal-accounts/internal-accounts.ts index a7c62db5..5cc964b4 100644 --- a/src/resources/internal-accounts/internal-accounts.ts +++ b/src/resources/internal-accounts/internal-accounts.ts @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as InternalAccountsAPI from 'modern-treasury/resources/internal-accounts/internal-accounts'; -import * as AccountDetailsAPI from 'modern-treasury/resources/account-details'; -import * as ConnectionsAPI from 'modern-treasury/resources/connections'; -import * as RoutingDetailsAPI from 'modern-treasury/resources/routing-details'; -import * as Shared from 'modern-treasury/resources/shared'; -import * as BalanceReportsAPI from 'modern-treasury/resources/internal-accounts/balance-reports'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as InternalAccountsAPI from './internal-accounts'; +import * as AccountDetailsAPI from '../account-details'; +import * as ConnectionsAPI from '../connections'; +import * as RoutingDetailsAPI from '../routing-details'; +import * as Shared from '../shared'; +import * as BalanceReportsAPI from './balance-reports'; +import { Page, type PageParams } from '../../pagination'; export class InternalAccounts extends APIResource { balanceReports: BalanceReportsAPI.BalanceReports = new BalanceReportsAPI.BalanceReports(this._client); diff --git a/src/resources/invoices/invoices.ts b/src/resources/invoices/invoices.ts index 9b116e51..d6901cf5 100644 --- a/src/resources/invoices/invoices.ts +++ b/src/resources/invoices/invoices.ts @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as InvoicesAPI from 'modern-treasury/resources/invoices/invoices'; -import * as ExpectedPaymentsAPI from 'modern-treasury/resources/expected-payments'; -import * as Shared from 'modern-treasury/resources/shared'; -import * as LineItemsAPI from 'modern-treasury/resources/invoices/line-items'; -import * as PaymentOrdersAPI from 'modern-treasury/resources/payment-orders/payment-orders'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as InvoicesAPI from './invoices'; +import * as ExpectedPaymentsAPI from '../expected-payments'; +import * as Shared from '../shared'; +import * as LineItemsAPI from './line-items'; +import * as PaymentOrdersAPI from '../payment-orders/payment-orders'; +import { Page, type PageParams } from '../../pagination'; export class Invoices extends APIResource { lineItems: LineItemsAPI.LineItems = new LineItemsAPI.LineItems(this._client); diff --git a/src/resources/invoices/line-items.ts b/src/resources/invoices/line-items.ts index 6242734e..16a9c223 100644 --- a/src/resources/invoices/line-items.ts +++ b/src/resources/invoices/line-items.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LineItemsAPI from 'modern-treasury/resources/invoices/line-items'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as LineItemsAPI from './line-items'; +import { Page, type PageParams } from '../../pagination'; export class LineItems extends APIResource { /** diff --git a/src/resources/ledger-account-balance-monitors.ts b/src/resources/ledger-account-balance-monitors.ts index 71fac37f..e740dacb 100644 --- a/src/resources/ledger-account-balance-monitors.ts +++ b/src/resources/ledger-account-balance-monitors.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgerAccountBalanceMonitorsAPI from 'modern-treasury/resources/ledger-account-balance-monitors'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LedgerAccountBalanceMonitorsAPI from './ledger-account-balance-monitors'; +import { Page, type PageParams } from '../pagination'; export class LedgerAccountBalanceMonitors extends APIResource { /** diff --git a/src/resources/ledger-account-categories.ts b/src/resources/ledger-account-categories.ts index 9aedaf51..464db3ea 100644 --- a/src/resources/ledger-account-categories.ts +++ b/src/resources/ledger-account-categories.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgerAccountCategoriesAPI from 'modern-treasury/resources/ledger-account-categories'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LedgerAccountCategoriesAPI from './ledger-account-categories'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class LedgerAccountCategories extends APIResource { /** diff --git a/src/resources/ledger-account-payouts.ts b/src/resources/ledger-account-payouts.ts index bc81947b..3db63819 100644 --- a/src/resources/ledger-account-payouts.ts +++ b/src/resources/ledger-account-payouts.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgerAccountPayoutsAPI from 'modern-treasury/resources/ledger-account-payouts'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LedgerAccountPayoutsAPI from './ledger-account-payouts'; +import { Page, type PageParams } from '../pagination'; export class LedgerAccountPayouts extends APIResource { /** diff --git a/src/resources/ledger-account-settlements.ts b/src/resources/ledger-account-settlements.ts index 99d5e837..48ebd193 100644 --- a/src/resources/ledger-account-settlements.ts +++ b/src/resources/ledger-account-settlements.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgerAccountSettlementsAPI from 'modern-treasury/resources/ledger-account-settlements'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LedgerAccountSettlementsAPI from './ledger-account-settlements'; +import { Page, type PageParams } from '../pagination'; export class LedgerAccountSettlements extends APIResource { /** diff --git a/src/resources/ledger-account-statements.ts b/src/resources/ledger-account-statements.ts index e220c28e..7f6a7884 100644 --- a/src/resources/ledger-account-statements.ts +++ b/src/resources/ledger-account-statements.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import * as LedgerAccountStatementsAPI from 'modern-treasury/resources/ledger-account-statements'; -import * as Shared from 'modern-treasury/resources/shared'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import * as LedgerAccountStatementsAPI from './ledger-account-statements'; +import * as Shared from './shared'; export class LedgerAccountStatements extends APIResource { /** diff --git a/src/resources/ledger-accounts.ts b/src/resources/ledger-accounts.ts index d42e8d5d..c944c964 100644 --- a/src/resources/ledger-accounts.ts +++ b/src/resources/ledger-accounts.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgerAccountsAPI from 'modern-treasury/resources/ledger-accounts'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LedgerAccountsAPI from './ledger-accounts'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class LedgerAccounts extends APIResource { /** diff --git a/src/resources/ledger-entries.ts b/src/resources/ledger-entries.ts index 42f48a46..a0c273ed 100644 --- a/src/resources/ledger-entries.ts +++ b/src/resources/ledger-entries.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgerEntriesAPI from 'modern-treasury/resources/ledger-entries'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LedgerEntriesAPI from './ledger-entries'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class LedgerEntries extends APIResource { /** diff --git a/src/resources/ledger-event-handlers.ts b/src/resources/ledger-event-handlers.ts index 08196e86..9a9069d9 100644 --- a/src/resources/ledger-event-handlers.ts +++ b/src/resources/ledger-event-handlers.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgerEventHandlersAPI from 'modern-treasury/resources/ledger-event-handlers'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LedgerEventHandlersAPI from './ledger-event-handlers'; +import { Page, type PageParams } from '../pagination'; export class LedgerEventHandlers extends APIResource { /** diff --git a/src/resources/ledger-transactions/ledger-transactions.ts b/src/resources/ledger-transactions/ledger-transactions.ts index 59d7d09d..e158ac2a 100644 --- a/src/resources/ledger-transactions/ledger-transactions.ts +++ b/src/resources/ledger-transactions/ledger-transactions.ts @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgerTransactionsAPI from 'modern-treasury/resources/ledger-transactions/ledger-transactions'; -import * as LedgerEntriesAPI from 'modern-treasury/resources/ledger-entries'; -import * as Shared from 'modern-treasury/resources/shared'; -import * as VersionsAPI from 'modern-treasury/resources/ledger-transactions/versions'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as LedgerTransactionsAPI from './ledger-transactions'; +import * as LedgerEntriesAPI from '../ledger-entries'; +import * as Shared from '../shared'; +import * as VersionsAPI from './versions'; +import { Page, type PageParams } from '../../pagination'; export class LedgerTransactions extends APIResource { versions: VersionsAPI.Versions = new VersionsAPI.Versions(this._client); diff --git a/src/resources/ledger-transactions/versions.ts b/src/resources/ledger-transactions/versions.ts index 1cd3bbb5..a7efc99b 100644 --- a/src/resources/ledger-transactions/versions.ts +++ b/src/resources/ledger-transactions/versions.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as VersionsAPI from 'modern-treasury/resources/ledger-transactions/versions'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as VersionsAPI from './versions'; +import * as Shared from '../shared'; +import { Page, type PageParams } from '../../pagination'; export class Versions extends APIResource { /** diff --git a/src/resources/ledgerable-events.ts b/src/resources/ledgerable-events.ts index cd88b7d5..7e7c1cb7 100644 --- a/src/resources/ledgerable-events.ts +++ b/src/resources/ledgerable-events.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import * as LedgerableEventsAPI from 'modern-treasury/resources/ledgerable-events'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import * as LedgerableEventsAPI from './ledgerable-events'; export class LedgerableEvents extends APIResource { /** diff --git a/src/resources/ledgers.ts b/src/resources/ledgers.ts index 14614ee2..00b181fe 100644 --- a/src/resources/ledgers.ts +++ b/src/resources/ledgers.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LedgersAPI from 'modern-treasury/resources/ledgers'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LedgersAPI from './ledgers'; +import { Page, type PageParams } from '../pagination'; export class Ledgers extends APIResource { /** diff --git a/src/resources/legal-entities.ts b/src/resources/legal-entities.ts index 1d9fd14d..a8ed4de3 100644 --- a/src/resources/legal-entities.ts +++ b/src/resources/legal-entities.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LegalEntitiesAPI from 'modern-treasury/resources/legal-entities'; -import * as LegalEntityAssociationsAPI from 'modern-treasury/resources/legal-entity-associations'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LegalEntitiesAPI from './legal-entities'; +import * as LegalEntityAssociationsAPI from './legal-entity-associations'; +import { Page, type PageParams } from '../pagination'; export class LegalEntities extends APIResource { /** diff --git a/src/resources/legal-entity-associations.ts b/src/resources/legal-entity-associations.ts index dbcf4dc5..4cf1680f 100644 --- a/src/resources/legal-entity-associations.ts +++ b/src/resources/legal-entity-associations.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import * as LegalEntityAssociationsAPI from 'modern-treasury/resources/legal-entity-associations'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import * as LegalEntityAssociationsAPI from './legal-entity-associations'; export class LegalEntityAssociations extends APIResource { /** diff --git a/src/resources/line-items.ts b/src/resources/line-items.ts index 7b45db41..876b35c6 100644 --- a/src/resources/line-items.ts +++ b/src/resources/line-items.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LineItemsAPI from 'modern-treasury/resources/line-items'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as LineItemsAPI from './line-items'; +import { Page, type PageParams } from '../pagination'; export class LineItems extends APIResource { /** diff --git a/src/resources/paper-items.ts b/src/resources/paper-items.ts index 490042c0..18f72bef 100644 --- a/src/resources/paper-items.ts +++ b/src/resources/paper-items.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as PaperItemsAPI from 'modern-treasury/resources/paper-items'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as PaperItemsAPI from './paper-items'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class PaperItems extends APIResource { /** diff --git a/src/resources/payment-flows.ts b/src/resources/payment-flows.ts index 84deecad..08a3e551 100644 --- a/src/resources/payment-flows.ts +++ b/src/resources/payment-flows.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as PaymentFlowsAPI from 'modern-treasury/resources/payment-flows'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as PaymentFlowsAPI from './payment-flows'; +import { Page, type PageParams } from '../pagination'; export class PaymentFlows extends APIResource { /** diff --git a/src/resources/payment-orders/payment-orders.ts b/src/resources/payment-orders/payment-orders.ts index d070395d..4bb91b14 100644 --- a/src/resources/payment-orders/payment-orders.ts +++ b/src/resources/payment-orders/payment-orders.ts @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as PaymentOrdersAPI from 'modern-treasury/resources/payment-orders/payment-orders'; -import * as ExternalAccountsAPI from 'modern-treasury/resources/external-accounts'; -import * as ReturnsAPI from 'modern-treasury/resources/returns'; -import * as Shared from 'modern-treasury/resources/shared'; -import * as VirtualAccountsAPI from 'modern-treasury/resources/virtual-accounts'; -import * as InternalAccountsAPI from 'modern-treasury/resources/internal-accounts/internal-accounts'; -import * as ReversalsAPI from 'modern-treasury/resources/payment-orders/reversals'; -import { type Uploadable, maybeMultipartFormRequestOptions } from 'modern-treasury/core'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as PaymentOrdersAPI from './payment-orders'; +import * as ExternalAccountsAPI from '../external-accounts'; +import * as ReturnsAPI from '../returns'; +import * as Shared from '../shared'; +import * as VirtualAccountsAPI from '../virtual-accounts'; +import * as InternalAccountsAPI from '../internal-accounts/internal-accounts'; +import * as ReversalsAPI from './reversals'; +import { type Uploadable, maybeMultipartFormRequestOptions } from '../../core'; +import { Page, type PageParams } from '../../pagination'; export class PaymentOrders extends APIResource { reversals: ReversalsAPI.Reversals = new ReversalsAPI.Reversals(this._client); diff --git a/src/resources/payment-orders/reversals.ts b/src/resources/payment-orders/reversals.ts index 875685b6..172096a0 100644 --- a/src/resources/payment-orders/reversals.ts +++ b/src/resources/payment-orders/reversals.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as ReversalsAPI from 'modern-treasury/resources/payment-orders/reversals'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as ReversalsAPI from './reversals'; +import * as Shared from '../shared'; +import { Page, type PageParams } from '../../pagination'; export class Reversals extends APIResource { /** diff --git a/src/resources/payment-references.ts b/src/resources/payment-references.ts index ea5f4963..2b3409c6 100644 --- a/src/resources/payment-references.ts +++ b/src/resources/payment-references.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as PaymentReferencesAPI from 'modern-treasury/resources/payment-references'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as PaymentReferencesAPI from './payment-references'; +import { Page, type PageParams } from '../pagination'; export class PaymentReferences extends APIResource { /** diff --git a/src/resources/returns.ts b/src/resources/returns.ts index 7ea90580..4a68d1e3 100644 --- a/src/resources/returns.ts +++ b/src/resources/returns.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as ReturnsAPI from 'modern-treasury/resources/returns'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as ReturnsAPI from './returns'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class Returns extends APIResource { /** diff --git a/src/resources/routing-details.ts b/src/resources/routing-details.ts index cfa06bd1..2ddb0639 100644 --- a/src/resources/routing-details.ts +++ b/src/resources/routing-details.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as RoutingDetailsAPI from 'modern-treasury/resources/routing-details'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as RoutingDetailsAPI from './routing-details'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class RoutingDetails extends APIResource { /** diff --git a/src/resources/top-level.ts b/src/resources/top-level.ts index 03951d78..1de4074e 100644 --- a/src/resources/top-level.ts +++ b/src/resources/top-level.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as TopLevelAPI from 'modern-treasury/resources/top-level'; +import * as TopLevelAPI from './top-level'; export interface PingResponse { ping: string; diff --git a/src/resources/transactions/line-items.ts b/src/resources/transactions/line-items.ts index 50aa5411..4a9c8ae2 100644 --- a/src/resources/transactions/line-items.ts +++ b/src/resources/transactions/line-items.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as LineItemsAPI from 'modern-treasury/resources/transactions/line-items'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as LineItemsAPI from './line-items'; +import { Page, type PageParams } from '../../pagination'; export class LineItems extends APIResource { /** diff --git a/src/resources/transactions/transactions.ts b/src/resources/transactions/transactions.ts index dd0e0e98..83c0f042 100644 --- a/src/resources/transactions/transactions.ts +++ b/src/resources/transactions/transactions.ts @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as TransactionsAPI from 'modern-treasury/resources/transactions/transactions'; -import * as Shared from 'modern-treasury/resources/shared'; -import * as LineItemsAPI from 'modern-treasury/resources/transactions/line-items'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../../core'; +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as TransactionsAPI from './transactions'; +import * as Shared from '../shared'; +import * as LineItemsAPI from './line-items'; +import { Page, type PageParams } from '../../pagination'; export class Transactions extends APIResource { lineItems: LineItemsAPI.LineItems = new LineItemsAPI.LineItems(this._client); diff --git a/src/resources/validations.ts b/src/resources/validations.ts index 124e4144..491b3416 100644 --- a/src/resources/validations.ts +++ b/src/resources/validations.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import * as ValidationsAPI from 'modern-treasury/resources/validations'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import * as ValidationsAPI from './validations'; export class Validations extends APIResource { /** diff --git a/src/resources/virtual-accounts.ts b/src/resources/virtual-accounts.ts index fa68b37b..ad6dbaa5 100644 --- a/src/resources/virtual-accounts.ts +++ b/src/resources/virtual-accounts.ts @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from 'modern-treasury/core'; -import { APIResource } from 'modern-treasury/resource'; -import { isRequestOptions } from 'modern-treasury/core'; -import * as VirtualAccountsAPI from 'modern-treasury/resources/virtual-accounts'; -import * as AccountDetailsAPI from 'modern-treasury/resources/account-details'; -import * as RoutingDetailsAPI from 'modern-treasury/resources/routing-details'; -import * as Shared from 'modern-treasury/resources/shared'; -import { Page, type PageParams } from 'modern-treasury/pagination'; +import * as Core from '../core'; +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as VirtualAccountsAPI from './virtual-accounts'; +import * as AccountDetailsAPI from './account-details'; +import * as RoutingDetailsAPI from './routing-details'; +import * as Shared from './shared'; +import { Page, type PageParams } from '../pagination'; export class VirtualAccounts extends APIResource { /** From 27e0062215d71db39b8dd840e1e359487c19745d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 14:47:49 +0000 Subject: [PATCH 11/15] chore(internal): add slightly better logging to scripts (#404) --- .github/workflows/ci.yml | 6 ++---- scripts/format | 8 ++++++++ scripts/lint | 1 + scripts/test | 1 - 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100755 scripts/format diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1b4ca47..8efbd2cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,12 +22,10 @@ jobs: node-version: '18' - name: Install dependencies - run: | - yarn install + run: yarn install - name: Check types - run: | - yarn build + run: ./scripts/lint test: name: test runs-on: ubuntu-latest diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..d297e762 --- /dev/null +++ b/scripts/format @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running eslint --fix" +./node_modules/.bin/eslint --fix --ext ts,js . diff --git a/scripts/lint b/scripts/lint index 4f05d660..6b0e5dc3 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,4 +4,5 @@ set -e cd "$(dirname "$0")/.." +echo "==> Running eslint" ./node_modules/.bin/eslint --ext ts,js . diff --git a/scripts/test b/scripts/test index b62a7ccc..2049e31b 100755 --- a/scripts/test +++ b/scripts/test @@ -52,6 +52,5 @@ else echo fi -# Run tests echo "==> Running tests" ./node_modules/.bin/jest "$@" From 84bc4a0f89ba2abd4c232cd346a0978d9f437bda Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 09:58:04 +0000 Subject: [PATCH 12/15] feat(api): add currency to ledger account categories (#405) --- .stats.yml | 2 +- src/resources/ledger-account-categories.ts | 2 ++ src/resources/payment-orders/payment-orders.ts | 6 ++++++ tests/api-resources/ledger-account-categories.test.ts | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5b868858..f635e4ab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 162 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-aaacc072bfbc4cfb94152b18ca831ca6fce6ed9b64a28341107063386e611a7f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-0d96e401c358af911b14ce409d7fec4bdd075933679edf97f44409f76d749353.yml diff --git a/src/resources/ledger-account-categories.ts b/src/resources/ledger-account-categories.ts index 464db3ea..2cfa3abe 100644 --- a/src/resources/ledger-account-categories.ts +++ b/src/resources/ledger-account-categories.ts @@ -394,6 +394,8 @@ export interface LedgerAccountCategoryListParams extends PageParams { */ balances?: LedgerAccountCategoryListParams.Balances; + currency?: string; + /** * Query categories which contain a ledger account directly or through child * categories. diff --git a/src/resources/payment-orders/payment-orders.ts b/src/resources/payment-orders/payment-orders.ts index 4bb91b14..f6d4bf09 100644 --- a/src/resources/payment-orders/payment-orders.ts +++ b/src/resources/payment-orders/payment-orders.ts @@ -381,6 +381,12 @@ export interface PaymentOrder { updated_at: string; + /** + * Additional vendor specific fields for this payment. Data must be represented as + * key-value pairs. + */ + vendor_attributes: unknown | null; + /** * This field will be populated if a vendor failure occurs. Logic shouldn't be * built on its value as it is free-form. diff --git a/tests/api-resources/ledger-account-categories.test.ts b/tests/api-resources/ledger-account-categories.test.ts index ead097c2..61355fc6 100644 --- a/tests/api-resources/ledger-account-categories.test.ts +++ b/tests/api-resources/ledger-account-categories.test.ts @@ -122,6 +122,7 @@ describe('resource ledgerAccountCategories', () => { id: ['string', 'string', 'string'], after_cursor: 'string', balances: { effective_at: '2019-12-27T18:11:19.117Z' }, + currency: 'string', ledger_account_id: 'string', ledger_id: 'string', metadata: { foo: 'string' }, From 59e36383759b57f7c30277a1bb4eda746720a8f7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 12:50:29 +0000 Subject: [PATCH 13/15] feat(api): remove deprecated ledger account payouts (#406) feat(api): invoice overdue reminders --- .stats.yml | 4 +- api.md | 13 - src/index.ts | 8 - src/resources/index.ts | 8 - src/resources/invoices/invoices.ts | 18 ++ src/resources/ledger-account-payouts.ts | 263 ------------------ .../ledger-transactions.ts | 2 - tests/api-resources/invoices/invoices.test.ts | 2 + .../ledger-account-payouts.test.ts | 143 ---------- .../ledger-transactions.test.ts | 1 - 10 files changed, 22 insertions(+), 440 deletions(-) delete mode 100644 src/resources/ledger-account-payouts.ts delete mode 100644 tests/api-resources/ledger-account-payouts.test.ts diff --git a/.stats.yml b/.stats.yml index f635e4ab..9055d0eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 162 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-0d96e401c358af911b14ce409d7fec4bdd075933679edf97f44409f76d749353.yml +configured_endpoints: 158 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-83d243745498afb4f6e8661829a75db0064ac47220203b90f299be128c18a818.yml diff --git a/api.md b/api.md index 86cfe289..d2eb993c 100644 --- a/api.md +++ b/api.md @@ -275,19 +275,6 @@ Methods: - client.ledgerAccountBalanceMonitors.list({ ...params }) -> LedgerAccountBalanceMonitorsPage - client.ledgerAccountBalanceMonitors.del(id) -> LedgerAccountBalanceMonitor -# LedgerAccountPayouts - -Types: - -- LedgerAccountPayout - -Methods: - -- client.ledgerAccountPayouts.create({ ...params }) -> LedgerAccountPayout -- client.ledgerAccountPayouts.retrieve(id) -> LedgerAccountPayout -- client.ledgerAccountPayouts.update(id, { ...params }) -> LedgerAccountPayout -- client.ledgerAccountPayouts.list({ ...params }) -> LedgerAccountPayoutsPage - # LedgerAccountStatements Types: diff --git a/src/index.ts b/src/index.ts index bdd3dcd8..6233c48e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -162,7 +162,6 @@ export class ModernTreasury extends Core.APIClient { ledgerAccountCategories: API.LedgerAccountCategories = new API.LedgerAccountCategories(this); ledgerAccounts: API.LedgerAccounts = new API.LedgerAccounts(this); ledgerAccountBalanceMonitors: API.LedgerAccountBalanceMonitors = new API.LedgerAccountBalanceMonitors(this); - ledgerAccountPayouts: API.LedgerAccountPayouts = new API.LedgerAccountPayouts(this); ledgerAccountStatements: API.LedgerAccountStatements = new API.LedgerAccountStatements(this); ledgerEntries: API.LedgerEntries = new API.LedgerEntries(this); ledgerEventHandlers: API.LedgerEventHandlers = new API.LedgerEventHandlers(this); @@ -387,13 +386,6 @@ export namespace ModernTreasury { export import LedgerAccountBalanceMonitorUpdateParams = API.LedgerAccountBalanceMonitorUpdateParams; export import LedgerAccountBalanceMonitorListParams = API.LedgerAccountBalanceMonitorListParams; - export import LedgerAccountPayouts = API.LedgerAccountPayouts; - export import LedgerAccountPayout = API.LedgerAccountPayout; - export import LedgerAccountPayoutsPage = API.LedgerAccountPayoutsPage; - export import LedgerAccountPayoutCreateParams = API.LedgerAccountPayoutCreateParams; - export import LedgerAccountPayoutUpdateParams = API.LedgerAccountPayoutUpdateParams; - export import LedgerAccountPayoutListParams = API.LedgerAccountPayoutListParams; - export import LedgerAccountStatements = API.LedgerAccountStatements; export import LedgerAccountStatementCreateResponse = API.LedgerAccountStatementCreateResponse; export import LedgerAccountStatementRetrieveResponse = API.LedgerAccountStatementRetrieveResponse; diff --git a/src/resources/index.ts b/src/resources/index.ts index a01d0003..32e76389 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -130,14 +130,6 @@ export { LedgerAccountCategoriesPage, LedgerAccountCategories, } from './ledger-account-categories'; -export { - LedgerAccountPayout, - LedgerAccountPayoutCreateParams, - LedgerAccountPayoutUpdateParams, - LedgerAccountPayoutListParams, - LedgerAccountPayoutsPage, - LedgerAccountPayouts, -} from './ledger-account-payouts'; export { LedgerAccountSettlement, LedgerAccountSettlementCreateParams, diff --git a/src/resources/invoices/invoices.ts b/src/resources/invoices/invoices.ts index d6901cf5..fde69538 100644 --- a/src/resources/invoices/invoices.ts +++ b/src/resources/invoices/invoices.ts @@ -243,6 +243,12 @@ export interface Invoice { */ recipient_name: string | null; + /** + * Number of days after due date when overdue reminder emails will be sent out to + * invoice recipients. + */ + remind_after_overdue_days: Array | null; + /** * The status of the invoice. */ @@ -533,6 +539,12 @@ export interface InvoiceCreateParams { */ recipient_name?: string | null; + /** + * Number of days after due date when overdue reminder emails will be sent out to + * invoice recipients. + */ + remind_after_overdue_days?: Array | null; + /** * The ID of the virtual account the invoice should be paid to. */ @@ -849,6 +861,12 @@ export interface InvoiceUpdateParams { */ recipient_name?: string | null; + /** + * Number of days after due date when overdue reminder emails will be sent out to + * invoice recipients. + */ + remind_after_overdue_days?: Array | null; + /** * Invoice status must be updated in a `PATCH` request that does not modify any * other invoice attributes. Valid state transitions are `draft` to `unpaid`, diff --git a/src/resources/ledger-account-payouts.ts b/src/resources/ledger-account-payouts.ts deleted file mode 100644 index 3db63819..00000000 --- a/src/resources/ledger-account-payouts.ts +++ /dev/null @@ -1,263 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import * as Core from '../core'; -import { APIResource } from '../resource'; -import { isRequestOptions } from '../core'; -import * as LedgerAccountPayoutsAPI from './ledger-account-payouts'; -import { Page, type PageParams } from '../pagination'; - -export class LedgerAccountPayouts extends APIResource { - /** - * Create a ledger account payout. - */ - create( - params: LedgerAccountPayoutCreateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - // @ts-expect-error idempotency key header isn't defined anymore but is included here for back-compat - const { 'Idempotency-Key': idempotencyKey, ...body } = params; - if (idempotencyKey) { - console.warn( - "The Idempotency-Key request param is deprecated, the 'idempotencyToken' option should be set instead", - ); - } - return this._client.post('/api/ledger_account_payouts', { - body, - ...options, - headers: { 'Idempotency-Key': idempotencyKey, ...options?.headers }, - }); - } - - /** - * Get details on a single ledger account payout. - */ - retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise { - return this._client.get(`/api/ledger_account_payouts/${id}`, options); - } - - /** - * Update the details of a ledger account payout. - */ - update( - id: string, - body?: LedgerAccountPayoutUpdateParams, - options?: Core.RequestOptions, - ): Core.APIPromise; - update(id: string, options?: Core.RequestOptions): Core.APIPromise; - update( - id: string, - body: LedgerAccountPayoutUpdateParams | Core.RequestOptions = {}, - options?: Core.RequestOptions, - ): Core.APIPromise { - if (isRequestOptions(body)) { - return this.update(id, {}, body); - } - return this._client.patch(`/api/ledger_account_payouts/${id}`, { body, ...options }); - } - - /** - * Get a list of ledger account payouts. - */ - list( - query?: LedgerAccountPayoutListParams, - options?: Core.RequestOptions, - ): Core.PagePromise; - list(options?: Core.RequestOptions): Core.PagePromise; - list( - query: LedgerAccountPayoutListParams | Core.RequestOptions = {}, - options?: Core.RequestOptions, - ): Core.PagePromise { - if (isRequestOptions(query)) { - return this.list({}, query); - } - return this._client.getAPIList('/api/ledger_account_payouts', LedgerAccountPayoutsPage, { - query, - ...options, - }); - } - - /** - * @deprecated use `retrieve` instead - */ - retireve = this.retrieve; -} - -export class LedgerAccountPayoutsPage extends Page {} - -export interface LedgerAccountPayout { - id: string; - - /** - * The amount of the ledger account payout. - */ - amount: number | null; - - created_at: string; - - /** - * The currency of the ledger account payout. - */ - currency: string; - - /** - * The currency exponent of the ledger account payout. - */ - currency_exponent: number | null; - - /** - * The description of the ledger account payout. - */ - description: string | null; - - /** - * The exclusive upper bound of the effective_at timestamp of the ledger entries to - * be included in the ledger account payout. The default value is the created_at - * timestamp of the ledger account payout. - */ - effective_at_upper_bound: string; - - /** - * The id of the funding ledger account that sends to or receives funds from the - * payout ledger account. - */ - funding_ledger_account_id: string; - - /** - * The id of the ledger that this ledger account payout belongs to. - */ - ledger_id: string; - - /** - * The id of the ledger transaction that this payout is associated with. - */ - ledger_transaction_id: string | null; - - /** - * This field will be true if this object exists in the live environment or false - * if it exists in the test environment. - */ - live_mode: boolean; - - /** - * Additional data represented as key-value pairs. Both the key and value must be - * strings. - */ - metadata: Record; - - object: string; - - /** - * The direction of the ledger entry with the payout_ledger_account. - */ - payout_entry_direction: string | null; - - /** - * The id of the payout ledger account whose ledger entries are queried against, - * and its balance is reduced as a result. - */ - payout_ledger_account_id: string; - - /** - * The status of the ledger account payout. One of `processing`, `pending`, - * `posted`, `archiving`, `archived`. - */ - status: 'archived' | 'archiving' | 'pending' | 'posted' | 'processing'; - - updated_at: string; -} - -export interface LedgerAccountPayoutCreateParams { - /** - * The id of the funding ledger account that sends to or receives funds from the - * payout ledger account. - */ - funding_ledger_account_id: string; - - /** - * The id of the payout ledger account whose ledger entries are queried against, - * and its balance is reduced as a result. - */ - payout_ledger_account_id: string; - - /** - * If true, the payout amount and payout_entry_direction will bring the payout - * ledger account's balance closer to zero, even if the balance is negative. - */ - allow_either_direction?: boolean | null; - - /** - * The description of the ledger account payout. - */ - description?: string | null; - - /** - * The exclusive upper bound of the effective_at timestamp of the ledger entries to - * be included in the ledger account payout. The default value is the created_at - * timestamp of the ledger account payout. - */ - effective_at_upper_bound?: string | null; - - /** - * Additional data represented as key-value pairs. Both the key and value must be - * strings. - */ - metadata?: Record; - - /** - * It is set to `false` by default. It should be set to `true` when migrating - * existing payouts. - */ - skip_payout_ledger_transaction?: boolean | null; - - /** - * The status of the ledger account payout. It is set to `pending` by default. To - * post a ledger account payout at creation, use `posted`. - */ - status?: 'pending' | 'posted' | null; -} - -export interface LedgerAccountPayoutUpdateParams { - /** - * The description of the ledger account payout. - */ - description?: string | null; - - /** - * Additional data represented as key-value pairs. Both the key and value must be - * strings. - */ - metadata?: Record; - - /** - * To post a pending ledger account payout, use `posted`. To archive a pending - * ledger transaction, use `archived`. - */ - status?: 'posted' | 'archived'; -} - -export interface LedgerAccountPayoutListParams extends PageParams { - /** - * If you have specific IDs to retrieve in bulk, you can pass them as query - * parameters delimited with `id[]=`, for example `?id[]=123&id[]=abc`. - */ - id?: Array; - - /** - * For example, if you want to query for records with metadata key `Type` and value - * `Loan`, the query would be `metadata%5BType%5D=Loan`. This encodes the query - * parameters. - */ - metadata?: Record; - - payout_entry_direction?: string; - - payout_ledger_account_id?: string; -} - -export namespace LedgerAccountPayouts { - export import LedgerAccountPayout = LedgerAccountPayoutsAPI.LedgerAccountPayout; - export import LedgerAccountPayoutsPage = LedgerAccountPayoutsAPI.LedgerAccountPayoutsPage; - export import LedgerAccountPayoutCreateParams = LedgerAccountPayoutsAPI.LedgerAccountPayoutCreateParams; - export import LedgerAccountPayoutUpdateParams = LedgerAccountPayoutsAPI.LedgerAccountPayoutUpdateParams; - export import LedgerAccountPayoutListParams = LedgerAccountPayoutsAPI.LedgerAccountPayoutListParams; -} diff --git a/src/resources/ledger-transactions/ledger-transactions.ts b/src/resources/ledger-transactions/ledger-transactions.ts index e158ac2a..c0d9c876 100644 --- a/src/resources/ledger-transactions/ledger-transactions.ts +++ b/src/resources/ledger-transactions/ledger-transactions.ts @@ -463,8 +463,6 @@ export interface LedgerTransactionListParams extends PageParams { ledger_account_id?: string; - ledger_account_payout_id?: string; - ledger_account_settlement_id?: string; ledger_id?: string; diff --git a/tests/api-resources/invoices/invoices.test.ts b/tests/api-resources/invoices/invoices.test.ts index 6ea5662c..662aa0bc 100644 --- a/tests/api-resources/invoices/invoices.test.ts +++ b/tests/api-resources/invoices/invoices.test.ts @@ -128,6 +128,7 @@ describe('resource invoices', () => { receiving_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', recipient_email: 'string', recipient_name: 'string', + remind_after_overdue_days: [0, 0, 0], virtual_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', }); }); @@ -275,6 +276,7 @@ describe('resource invoices', () => { receiving_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', recipient_email: 'string', recipient_name: 'string', + remind_after_overdue_days: [0, 0, 0], status: 'string', virtual_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', }, diff --git a/tests/api-resources/ledger-account-payouts.test.ts b/tests/api-resources/ledger-account-payouts.test.ts deleted file mode 100644 index 78caa6bb..00000000 --- a/tests/api-resources/ledger-account-payouts.test.ts +++ /dev/null @@ -1,143 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import ModernTreasury from 'modern-treasury'; -import { Response } from 'node-fetch'; - -const modernTreasury = new ModernTreasury({ - apiKey: 'My API Key', - organizationId: 'my-organization-ID', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource ledgerAccountPayouts', () => { - test('create: only required params', async () => { - const responsePromise = modernTreasury.ledgerAccountPayouts.create({ - funding_ledger_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - payout_ledger_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('create: required and optional params', async () => { - const response = await modernTreasury.ledgerAccountPayouts.create({ - funding_ledger_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - payout_ledger_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - allow_either_direction: true, - description: 'string', - effective_at_upper_bound: '2019-12-27T18:11:19.117Z', - metadata: { key: 'value', foo: 'bar', modern: 'treasury' }, - skip_payout_ledger_transaction: true, - status: 'pending', - }); - }); - - test('retrieve', async () => { - const responsePromise = modernTreasury.ledgerAccountPayouts.retrieve('string'); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('retrieve: request options instead of params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - modernTreasury.ledgerAccountPayouts.retrieve('string', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(ModernTreasury.NotFoundError); - }); - - test('update', async () => { - const responsePromise = modernTreasury.ledgerAccountPayouts.update('string'); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('update: request options instead of params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - modernTreasury.ledgerAccountPayouts.update('string', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(ModernTreasury.NotFoundError); - }); - - test('update: request options and params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - modernTreasury.ledgerAccountPayouts.update( - 'string', - { - description: 'string', - metadata: { key: 'value', foo: 'bar', modern: 'treasury' }, - status: 'posted', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(ModernTreasury.NotFoundError); - }); - - test('list', async () => { - const responsePromise = modernTreasury.ledgerAccountPayouts.list(); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('list: request options instead of params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - modernTreasury.ledgerAccountPayouts.list({ path: '/_stainless_unknown_path' }), - ).rejects.toThrow(ModernTreasury.NotFoundError); - }); - - test('list: request options and params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - modernTreasury.ledgerAccountPayouts.list( - { - id: ['string', 'string', 'string'], - after_cursor: 'string', - metadata: { foo: 'string' }, - payout_entry_direction: 'string', - payout_ledger_account_id: 'string', - per_page: 0, - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(ModernTreasury.NotFoundError); - }); - - test('retireve', async () => { - const responsePromise = modernTreasury.ledgerAccountPayouts.retireve('string'); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('retireve: request options instead of params are passed correctly', async () => { - // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - modernTreasury.ledgerAccountPayouts.retireve('string', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(ModernTreasury.NotFoundError); - }); -}); diff --git a/tests/api-resources/ledger-transactions/ledger-transactions.test.ts b/tests/api-resources/ledger-transactions/ledger-transactions.test.ts index 13026e78..4882c164 100644 --- a/tests/api-resources/ledger-transactions/ledger-transactions.test.ts +++ b/tests/api-resources/ledger-transactions/ledger-transactions.test.ts @@ -194,7 +194,6 @@ describe('resource ledgerTransactions', () => { external_id: 'string', ledger_account_category_id: 'string', ledger_account_id: 'string', - ledger_account_payout_id: 'string', ledger_account_settlement_id: 'string', ledger_id: 'string', ledgerable_id: 'string', From 843dd7759ae5eded8ac565816ea26c837885a69b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 17:36:41 +0000 Subject: [PATCH 14/15] feat(api): mark ConnectionLegalEntity response properties as required (#407) --- .stats.yml | 2 +- src/resources/bulk-requests.ts | 10 ++- src/resources/connection-legal-entities.ts | 18 ++--- src/resources/counterparties.ts | 5 +- src/resources/external-accounts.ts | 20 ++++- src/resources/incoming-payment-details.ts | 1 + src/resources/invoices/invoices.ts | 64 +--------------- src/resources/legal-entities.ts | 42 +++++------ src/resources/legal-entity-associations.ts | 74 +++++++++---------- .../payment-orders/payment-orders.ts | 15 ++-- src/resources/routing-details.ts | 6 +- src/resources/validations.ts | 3 +- src/resources/virtual-accounts.ts | 3 +- tests/api-resources/external-accounts.test.ts | 2 + .../legal-entity-associations.test.ts | 3 +- 15 files changed, 118 insertions(+), 150 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9055d0eb..e7626cf6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 158 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-83d243745498afb4f6e8661829a75db0064ac47220203b90f299be128c18a818.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/modern-treasury-b8ef1dc20de340169529881f53e2a23e68dc24d7578316d167a098884250512a.yml diff --git a/src/resources/bulk-requests.ts b/src/resources/bulk-requests.ts index 1a35143e..de8dc7d3 100644 --- a/src/resources/bulk-requests.ts +++ b/src/resources/bulk-requests.ts @@ -741,7 +741,8 @@ export namespace BulkRequestCreateParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; payment_type?: | 'ach' @@ -765,10 +766,10 @@ export namespace BulkRequestCreateParams { | 'provxchange' | 'ro_sent' | 'rtp' - | 'sg_giro' | 'se_bankgirot' | 'sen' | 'sepa' + | 'sg_giro' | 'sic' | 'signet' | 'sknbi' @@ -1742,7 +1743,8 @@ export namespace BulkRequestCreateParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; payment_type?: | 'ach' @@ -1766,10 +1768,10 @@ export namespace BulkRequestCreateParams { | 'provxchange' | 'ro_sent' | 'rtp' - | 'sg_giro' | 'se_bankgirot' | 'sen' | 'sepa' + | 'sg_giro' | 'sic' | 'signet' | 'sknbi' diff --git a/src/resources/connection-legal-entities.ts b/src/resources/connection-legal-entities.ts index 4f30d8d0..9a7e1610 100644 --- a/src/resources/connection-legal-entities.ts +++ b/src/resources/connection-legal-entities.ts @@ -80,36 +80,36 @@ export class ConnectionLegalEntities extends APIResource { export class ConnectionLegalEntitiesPage extends Page {} export interface ConnectionLegalEntity { - id?: string; + id: string; /** * The ID of the connection. */ - connection_id?: string; + connection_id: string; - created_at?: string; + created_at: string; - discarded_at?: string | null; + discarded_at: string | null; /** * The ID of the legal entity. */ - legal_entity_id?: string; + legal_entity_id: string; /** * This field will be true if this object exists in the live environment or false * if it exists in the test environment. */ - live_mode?: boolean; + live_mode: boolean; - object?: string; + object: string; /** * The status of the connection legal entity. */ - status?: 'completed' | 'denied' | 'failed' | 'processing'; + status: 'completed' | 'denied' | 'failed' | 'processing'; - updated_at?: string; + updated_at: string; } export interface ConnectionLegalEntityCreateParams { diff --git a/src/resources/counterparties.ts b/src/resources/counterparties.ts index bebee664..ef22698d 100644 --- a/src/resources/counterparties.ts +++ b/src/resources/counterparties.ts @@ -566,7 +566,8 @@ export namespace CounterpartyCreateParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; payment_type?: | 'ach' @@ -590,10 +591,10 @@ export namespace CounterpartyCreateParams { | 'provxchange' | 'ro_sent' | 'rtp' - | 'sg_giro' | 'se_bankgirot' | 'sen' | 'sepa' + | 'sg_giro' | 'sic' | 'signet' | 'sknbi' diff --git a/src/resources/external-accounts.ts b/src/resources/external-accounts.ts index da99ec33..140f53e6 100644 --- a/src/resources/external-accounts.ts +++ b/src/resources/external-accounts.ts @@ -475,7 +475,8 @@ export namespace ExternalAccountCreateParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; payment_type?: | 'ach' @@ -499,10 +500,10 @@ export namespace ExternalAccountCreateParams { | 'provxchange' | 'ro_sent' | 'rtp' - | 'sg_giro' | 'se_bankgirot' | 'sen' | 'sepa' + | 'sg_giro' | 'sic' | 'signet' | 'sknbi' @@ -600,7 +601,7 @@ export interface ExternalAccountVerifyParams { originating_account_id: string; /** - * Both ach and eft are supported payment types. + * Can be `ach`, `eft`, or `rtp`. */ payment_type: | 'ach' @@ -638,6 +639,19 @@ export interface ExternalAccountVerifyParams { * Defaults to the currency of the originating account. */ currency?: Shared.Currency | null; + + /** + * A payment type to fallback to if the original type is not valid for the + * receiving account. Currently, this only supports falling back from RTP to ACH + * (payment_type=rtp and fallback_type=ach) + */ + fallback_type?: 'ach'; + + /** + * Either `normal` or `high`. For ACH payments, `high` represents a same-day ACH + * transfer. This will apply to both `payment_type` and `fallback_type`. + */ + priority?: 'high' | 'normal'; } export namespace ExternalAccounts { diff --git a/src/resources/incoming-payment-details.ts b/src/resources/incoming-payment-details.ts index e4e6b7b6..7baf52c2 100644 --- a/src/resources/incoming-payment-details.ts +++ b/src/resources/incoming-payment-details.ts @@ -193,6 +193,7 @@ export interface IncomingPaymentDetail { | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' | 'swift' + | 'za_national_clearing_code' | null; /** diff --git a/src/resources/invoices/invoices.ts b/src/resources/invoices/invoices.ts index fde69538..e9557f73 100644 --- a/src/resources/invoices/invoices.ts +++ b/src/resources/invoices/invoices.ts @@ -490,37 +490,7 @@ export interface InvoiceCreateParams { * `bacs`, `au_becs`, `interac`, `neft`, `nics`, `nz_national_clearing_code`, * `sic`, `signet`, `provexchange`, `zengin`. */ - payment_type?: - | 'ach' - | 'au_becs' - | 'bacs' - | 'book' - | 'card' - | 'chats' - | 'check' - | 'cross_border' - | 'dk_nets' - | 'eft' - | 'hu_ics' - | 'interac' - | 'masav' - | 'mx_ccen' - | 'neft' - | 'nics' - | 'nz_becs' - | 'pl_elixir' - | 'provxchange' - | 'ro_sent' - | 'rtp' - | 'sg_giro' - | 'se_bankgirot' - | 'sen' - | 'sepa' - | 'sic' - | 'signet' - | 'sknbi' - | 'wire' - | 'zengin'; + payment_type?: PaymentOrdersAPI.PaymentOrderType; /** * The receiving account ID. Can be an `external_account`. @@ -812,37 +782,7 @@ export interface InvoiceUpdateParams { * `bacs`, `au_becs`, `interac`, `neft`, `nics`, `nz_national_clearing_code`, * `sic`, `signet`, `provexchange`, `zengin`. */ - payment_type?: - | 'ach' - | 'au_becs' - | 'bacs' - | 'book' - | 'card' - | 'chats' - | 'check' - | 'cross_border' - | 'dk_nets' - | 'eft' - | 'hu_ics' - | 'interac' - | 'masav' - | 'mx_ccen' - | 'neft' - | 'nics' - | 'nz_becs' - | 'pl_elixir' - | 'provxchange' - | 'ro_sent' - | 'rtp' - | 'sg_giro' - | 'se_bankgirot' - | 'sen' - | 'sepa' - | 'sic' - | 'signet' - | 'sknbi' - | 'wire' - | 'zengin'; + payment_type?: PaymentOrdersAPI.PaymentOrderType; /** * The receiving account ID. Can be an `external_account`. diff --git a/src/resources/legal-entities.ts b/src/resources/legal-entities.ts index a8ed4de3..5a0494d2 100644 --- a/src/resources/legal-entities.ts +++ b/src/resources/legal-entities.ts @@ -75,68 +75,68 @@ export class LegalEntities extends APIResource { export class LegalEntitiesPage extends Page {} export interface LegalEntity { - id?: string; + id: string; /** * A list of addresses for the entity. */ - addresses?: Array; + addresses: Array; /** * The business's legal business name. */ - business_name?: string | null; + business_name: string | null; - created_at?: string; + created_at: string; /** * A business's formation date (YYYY-MM-DD). */ - date_formed?: string | null; + date_formed: string | null; /** * An individual's date of birth (YYYY-MM-DD). */ - date_of_birth?: string | null; + date_of_birth: string | null; - discarded_at?: string | null; + discarded_at: string | null; - doing_business_as_names?: Array; + doing_business_as_names: Array; /** * The entity's primary email. */ - email?: string | null; + email: string | null; /** * An individual's first name. */ - first_name?: string | null; + first_name: string | null; /** * A list of identifications for the legal entity. */ - identifications?: Array; + identifications: Array; /** * An individual's last name. */ - last_name?: string | null; + last_name: string | null; /** * The legal entity associations and its child legal entities. */ - legal_entity_associations?: Array | null; + legal_entity_associations: Array | null; /** * The type of legal entity. */ - legal_entity_type?: 'business' | 'individual' | 'joint'; + legal_entity_type: 'business' | 'individual' | 'joint'; /** * The business's legal structure. */ - legal_structure?: + legal_structure: | 'corporation' | 'llc' | 'non_profit' @@ -149,24 +149,24 @@ export interface LegalEntity { * This field will be true if this object exists in the live environment or false * if it exists in the test environment. */ - live_mode?: boolean; + live_mode: boolean; /** * Additional data represented as key-value pairs. Both the key and value must be * strings. */ - metadata?: Record; + metadata: Record; - object?: string; + object: string; - phone_numbers?: Array; + phone_numbers: Array; - updated_at?: string; + updated_at: string; /** * The entity's primary website URL. */ - website?: string | null; + website: string | null; } export namespace LegalEntity { diff --git a/src/resources/legal-entity-associations.ts b/src/resources/legal-entity-associations.ts index 4cf1680f..625d8a16 100644 --- a/src/resources/legal-entity-associations.ts +++ b/src/resources/legal-entity-associations.ts @@ -28,44 +28,44 @@ export class LegalEntityAssociations extends APIResource { } export interface LegalEntityAssociation { - id?: string; + id: string; /** * The child legal entity. */ - child_legal_entity?: LegalEntityAssociation.ChildLegalEntity; + child_legal_entity: LegalEntityAssociation.ChildLegalEntity; - created_at?: string; + created_at: string; - discarded_at?: string | null; + discarded_at: string | null; /** * This field will be true if this object exists in the live environment or false * if it exists in the test environment. */ - live_mode?: boolean; + live_mode: boolean; - object?: string; + object: string; /** * The child entity's ownership percentage iff they are a beneficial owner. */ - ownership_percentage?: number | null; + ownership_percentage: number | null; /** * The ID of the parent legal entity. This must be a business or joint legal * entity. */ - parent_legal_entity_id?: string; + parent_legal_entity_id: string; - relationship_types?: Array<'beneficial_owner' | 'control_person'>; + relationship_types: Array<'beneficial_owner' | 'control_person'>; /** * The job title of the child entity at the parent entity. */ - title?: string | null; + title: string | null; - updated_at?: string; + updated_at: string; } export namespace LegalEntityAssociation { @@ -73,63 +73,63 @@ export namespace LegalEntityAssociation { * The child legal entity. */ export interface ChildLegalEntity { - id?: string; + id: string; /** * A list of addresses for the entity. */ - addresses?: Array; + addresses: Array; /** * The business's legal business name. */ - business_name?: string | null; + business_name: string | null; - created_at?: string; + created_at: string; /** * A business's formation date (YYYY-MM-DD). */ - date_formed?: string | null; + date_formed: string | null; /** * An individual's date of birth (YYYY-MM-DD). */ - date_of_birth?: string | null; + date_of_birth: string | null; - discarded_at?: string | null; + discarded_at: string | null; - doing_business_as_names?: Array; + doing_business_as_names: Array; /** * The entity's primary email. */ - email?: string | null; + email: string | null; /** * An individual's first name. */ - first_name?: string | null; + first_name: string | null; /** * A list of identifications for the legal entity. */ - identifications?: Array; + identifications: Array; /** * An individual's last name. */ - last_name?: string | null; + last_name: string | null; /** * The type of legal entity. */ - legal_entity_type?: 'business' | 'individual' | 'joint'; + legal_entity_type: 'business' | 'individual' | 'joint'; /** * The business's legal structure. */ - legal_structure?: + legal_structure: | 'corporation' | 'llc' | 'non_profit' @@ -142,24 +142,24 @@ export namespace LegalEntityAssociation { * This field will be true if this object exists in the live environment or false * if it exists in the test environment. */ - live_mode?: boolean; + live_mode: boolean; /** * Additional data represented as key-value pairs. Both the key and value must be * strings. */ - metadata?: Record; + metadata: Record; - object?: string; + object: string; - phone_numbers?: Array; + phone_numbers: Array; - updated_at?: string; + updated_at: string; /** * The entity's primary website URL. */ - website?: string | null; + website: string | null; } export namespace ChildLegalEntity { @@ -266,6 +266,12 @@ export namespace LegalEntityAssociation { } export interface LegalEntityAssociationCreateParams { + /** + * The ID of the parent legal entity. This must be a business or joint legal + * entity. + */ + parent_legal_entity_id: string; + relationship_types: Array<'beneficial_owner' | 'control_person'>; /** @@ -283,12 +289,6 @@ export interface LegalEntityAssociationCreateParams { */ ownership_percentage?: number | null; - /** - * The ID of the parent legal entity. This must be a business or joint legal - * entity. - */ - parent_legal_entity_id?: string; - /** * The job title of the child entity at the parent entity. */ diff --git a/src/resources/payment-orders/payment-orders.ts b/src/resources/payment-orders/payment-orders.ts index f6d4bf09..3090bdb4 100644 --- a/src/resources/payment-orders/payment-orders.ts +++ b/src/resources/payment-orders/payment-orders.ts @@ -1223,7 +1223,8 @@ export namespace PaymentOrderCreateParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; payment_type?: | 'ach' @@ -1247,10 +1248,10 @@ export namespace PaymentOrderCreateParams { | 'provxchange' | 'ro_sent' | 'rtp' - | 'sg_giro' | 'se_bankgirot' | 'sen' | 'sepa' + | 'sg_giro' | 'sic' | 'signet' | 'sknbi' @@ -1726,7 +1727,8 @@ export namespace PaymentOrderUpdateParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; payment_type?: | 'ach' @@ -1750,10 +1752,10 @@ export namespace PaymentOrderUpdateParams { | 'provxchange' | 'ro_sent' | 'rtp' - | 'sg_giro' | 'se_bankgirot' | 'sen' | 'sepa' + | 'sg_giro' | 'sic' | 'signet' | 'sknbi' @@ -2458,7 +2460,8 @@ export namespace PaymentOrderCreateAsyncParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; payment_type?: | 'ach' @@ -2482,10 +2485,10 @@ export namespace PaymentOrderCreateAsyncParams { | 'provxchange' | 'ro_sent' | 'rtp' - | 'sg_giro' | 'se_bankgirot' | 'sen' | 'sepa' + | 'sg_giro' | 'sic' | 'signet' | 'sknbi' diff --git a/src/resources/routing-details.ts b/src/resources/routing-details.ts index 2ddb0639..3543ec8a 100644 --- a/src/resources/routing-details.ts +++ b/src/resources/routing-details.ts @@ -178,7 +178,8 @@ export interface RoutingDetail { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; updated_at: string; } @@ -255,7 +256,8 @@ export interface RoutingDetailCreateParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; /** * If the routing detail is to be used for a specific payment type this field will diff --git a/src/resources/validations.ts b/src/resources/validations.ts index 491b3416..3203ea2f 100644 --- a/src/resources/validations.ts +++ b/src/resources/validations.ts @@ -156,7 +156,8 @@ export interface ValidationValidateRoutingNumberParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; } export namespace Validations { diff --git a/src/resources/virtual-accounts.ts b/src/resources/virtual-accounts.ts index ad6dbaa5..c7055525 100644 --- a/src/resources/virtual-accounts.ts +++ b/src/resources/virtual-accounts.ts @@ -323,7 +323,8 @@ export namespace VirtualAccountCreateParams { | 'nz_national_clearing_code' | 'pl_national_clearing_code' | 'se_bankgiro_clearing_code' - | 'swift'; + | 'swift' + | 'za_national_clearing_code'; /** * If the routing detail is to be used for a specific payment type this field will diff --git a/tests/api-resources/external-accounts.test.ts b/tests/api-resources/external-accounts.test.ts index c771a65a..eede329d 100644 --- a/tests/api-resources/external-accounts.test.ts +++ b/tests/api-resources/external-accounts.test.ts @@ -237,6 +237,8 @@ describe('resource externalAccounts', () => { originating_account_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', payment_type: 'ach', currency: 'AED', + fallback_type: 'ach', + priority: 'high', }); }); }); diff --git a/tests/api-resources/legal-entity-associations.test.ts b/tests/api-resources/legal-entity-associations.test.ts index 29bb11d8..948e62a4 100644 --- a/tests/api-resources/legal-entity-associations.test.ts +++ b/tests/api-resources/legal-entity-associations.test.ts @@ -12,6 +12,7 @@ const modernTreasury = new ModernTreasury({ describe('resource legalEntityAssociations', () => { test('create: only required params', async () => { const responsePromise = modernTreasury.legalEntityAssociations.create({ + parent_legal_entity_id: 'string', relationship_types: ['beneficial_owner', 'control_person'], }); const rawResponse = await responsePromise.asResponse(); @@ -25,6 +26,7 @@ describe('resource legalEntityAssociations', () => { test('create: required and optional params', async () => { const response = await modernTreasury.legalEntityAssociations.create({ + parent_legal_entity_id: 'string', relationship_types: ['beneficial_owner', 'control_person'], child_legal_entity: { legal_entity_type: 'business', @@ -76,7 +78,6 @@ describe('resource legalEntityAssociations', () => { }, child_legal_entity_id: 'string', ownership_percentage: 0, - parent_legal_entity_id: 'string', title: 'string', }); }); From 76a21c9f68c325443c0fefc8224beafd28e95a0c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 17:37:04 +0000 Subject: [PATCH 15/15] release: 2.24.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 20929136..50b9d4d8 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.23.0" + ".": "2.24.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 6609d7c9..12c1143f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,39 @@ # Changelog +## 2.24.0 (2024-05-28) + +Full Changelog: [v2.23.0...v2.24.0](https://github.com/Modern-Treasury/modern-treasury-node/compare/v2.23.0...v2.24.0) + +### Features + +* **api:** add currency to ledger account categories ([#405](https://github.com/Modern-Treasury/modern-treasury-node/issues/405)) ([84bc4a0](https://github.com/Modern-Treasury/modern-treasury-node/commit/84bc4a0f89ba2abd4c232cd346a0978d9f437bda)) +* **api:** invoice overdue reminders ([59e3638](https://github.com/Modern-Treasury/modern-treasury-node/commit/59e36383759b57f7c30277a1bb4eda746720a8f7)) +* **api:** mark ConnectionLegalEntity response properties as required ([#407](https://github.com/Modern-Treasury/modern-treasury-node/issues/407)) ([843dd77](https://github.com/Modern-Treasury/modern-treasury-node/commit/843dd7759ae5eded8ac565816ea26c837885a69b)) +* **api:** remove deprecated ledger account payouts ([#406](https://github.com/Modern-Treasury/modern-treasury-node/issues/406)) ([59e3638](https://github.com/Modern-Treasury/modern-treasury-node/commit/59e36383759b57f7c30277a1bb4eda746720a8f7)) +* **api:** updates ([#395](https://github.com/Modern-Treasury/modern-treasury-node/issues/395)) ([d627950](https://github.com/Modern-Treasury/modern-treasury-node/commit/d6279508016f41e6c4e095ea555313508ff64314)) + + +### Bug Fixes + +* **package:** revert recent client file change ([#398](https://github.com/Modern-Treasury/modern-treasury-node/issues/398)) ([e25a0fa](https://github.com/Modern-Treasury/modern-treasury-node/commit/e25a0fab22a47c779aac58d14d87cec0a3768442)) + + +### Chores + +* **docs:** add SECURITY.md ([#401](https://github.com/Modern-Treasury/modern-treasury-node/issues/401)) ([7da6a83](https://github.com/Modern-Treasury/modern-treasury-node/commit/7da6a8304155395bc5c0d0984df76d665306350e)) +* **docs:** streamline payment purpose and vendor failure handling ([#402](https://github.com/Modern-Treasury/modern-treasury-node/issues/402)) ([d816b92](https://github.com/Modern-Treasury/modern-treasury-node/commit/d816b926e4891f4ff0a0da3c64742e87bd0c1348)) +* **internal:** add link to openapi spec ([#392](https://github.com/Modern-Treasury/modern-treasury-node/issues/392)) ([272d794](https://github.com/Modern-Treasury/modern-treasury-node/commit/272d79431c4901b9677b58b03b9ea04e828a15eb)) +* **internal:** add scripts/test, scripts/mock and add ci job ([#393](https://github.com/Modern-Treasury/modern-treasury-node/issues/393)) ([315be57](https://github.com/Modern-Treasury/modern-treasury-node/commit/315be57cb1f4206000e6986123a63789672ec8b4)) +* **internal:** add slightly better logging to scripts ([#404](https://github.com/Modern-Treasury/modern-treasury-node/issues/404)) ([27e0062](https://github.com/Modern-Treasury/modern-treasury-node/commit/27e0062215d71db39b8dd840e1e359487c19745d)) +* **internal:** forward arguments in scripts/test ([#394](https://github.com/Modern-Treasury/modern-treasury-node/issues/394)) ([f583eaf](https://github.com/Modern-Treasury/modern-treasury-node/commit/f583eafab9e417a1760ab077ee041c9b1d5bb237)) +* **internal:** move client class to separate file ([#396](https://github.com/Modern-Treasury/modern-treasury-node/issues/396)) ([8877013](https://github.com/Modern-Treasury/modern-treasury-node/commit/88770139e5265bfc08e7bf7bc142b54bfb9b21bd)) +* **internal:** refactor scripts ([#390](https://github.com/Modern-Treasury/modern-treasury-node/issues/390)) ([8f96c06](https://github.com/Modern-Treasury/modern-treasury-node/commit/8f96c069c19c50107d602b2051c48bf9b9f0a417)) + + +### Refactors + +* change import paths to be relative ([#403](https://github.com/Modern-Treasury/modern-treasury-node/issues/403)) ([00e1c3a](https://github.com/Modern-Treasury/modern-treasury-node/commit/00e1c3a68fac93d65ea7bfcf1293c79381f6ac46)) + ## 2.23.0 (2024-04-26) Full Changelog: [v2.22.0...v2.23.0](https://github.com/Modern-Treasury/modern-treasury-node/compare/v2.22.0...v2.23.0) diff --git a/package.json b/package.json index 844c2294..aa661657 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "modern-treasury", - "version": "2.23.0", + "version": "2.24.0", "description": "The official TypeScript library for the Modern Treasury API", "author": "Modern Treasury ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index 38b677df..51b69b05 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '2.23.0'; // x-release-please-version +export const VERSION = '2.24.0'; // x-release-please-version