diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b26bf2..63cfe46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - name: Install dependencies run: poetry install - name: Test - run: poetry run pytest . + run: poetry run pytest ./tests/custom/ publish: needs: [compile, test] diff --git a/poetry.lock b/poetry.lock index 2428309..36001cf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "annotated-types" @@ -38,13 +38,13 @@ trio = ["trio (>=0.23)"] [[package]] name = "certifi" -version = "2024.2.2" +version = "2024.6.2" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, - {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, + {file = "certifi-2024.6.2-py3-none-any.whl", hash = "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56"}, + {file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"}, ] [[package]] @@ -236,18 +236,18 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydantic" -version = "2.7.2" +version = "2.7.3" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.7.2-py3-none-any.whl", hash = "sha256:834ab954175f94e6e68258537dc49402c4a5e9d0409b9f1b86b7e934a8372de7"}, - {file = "pydantic-2.7.2.tar.gz", hash = "sha256:71b2945998f9c9b7919a45bde9a50397b289937d215ae141c1d0903ba7149fd7"}, + {file = "pydantic-2.7.3-py3-none-any.whl", hash = "sha256:ea91b002777bf643bb20dd717c028ec43216b24a6001a280f83877fd2655d0b4"}, + {file = "pydantic-2.7.3.tar.gz", hash = "sha256:c46c76a40bb1296728d7a8b99aa73dd70a48c3510111ff290034f860c99c419e"}, ] [package.dependencies] annotated-types = ">=0.4.0" -pydantic-core = "2.18.3" +pydantic-core = "2.18.4" typing-extensions = ">=4.6.1" [package.extras] @@ -255,90 +255,90 @@ email = ["email-validator (>=2.0.0)"] [[package]] name = "pydantic-core" -version = "2.18.3" +version = "2.18.4" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.18.3-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:744697428fcdec6be5670460b578161d1ffe34743a5c15656be7ea82b008197c"}, - {file = "pydantic_core-2.18.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:37b40c05ced1ba4218b14986fe6f283d22e1ae2ff4c8e28881a70fb81fbfcda7"}, - {file = "pydantic_core-2.18.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:544a9a75622357076efb6b311983ff190fbfb3c12fc3a853122b34d3d358126c"}, - {file = "pydantic_core-2.18.3-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e2e253af04ceaebde8eb201eb3f3e3e7e390f2d275a88300d6a1959d710539e2"}, - {file = "pydantic_core-2.18.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:855ec66589c68aa367d989da5c4755bb74ee92ccad4fdb6af942c3612c067e34"}, - {file = "pydantic_core-2.18.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d3e42bb54e7e9d72c13ce112e02eb1b3b55681ee948d748842171201a03a98a"}, - {file = "pydantic_core-2.18.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c6ac9ffccc9d2e69d9fba841441d4259cb668ac180e51b30d3632cd7abca2b9b"}, - {file = "pydantic_core-2.18.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c56eca1686539fa0c9bda992e7bd6a37583f20083c37590413381acfc5f192d6"}, - {file = "pydantic_core-2.18.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:17954d784bf8abfc0ec2a633108207ebc4fa2df1a0e4c0c3ccbaa9bb01d2c426"}, - {file = "pydantic_core-2.18.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:98ed737567d8f2ecd54f7c8d4f8572ca7c7921ede93a2e52939416170d357812"}, - {file = "pydantic_core-2.18.3-cp310-none-win32.whl", hash = "sha256:9f9e04afebd3ed8c15d67a564ed0a34b54e52136c6d40d14c5547b238390e779"}, - {file = "pydantic_core-2.18.3-cp310-none-win_amd64.whl", hash = "sha256:45e4ffbae34f7ae30d0047697e724e534a7ec0a82ef9994b7913a412c21462a0"}, - {file = "pydantic_core-2.18.3-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:b9ebe8231726c49518b16b237b9fe0d7d361dd221302af511a83d4ada01183ab"}, - {file = "pydantic_core-2.18.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b8e20e15d18bf7dbb453be78a2d858f946f5cdf06c5072453dace00ab652e2b2"}, - {file = "pydantic_core-2.18.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c0d9ff283cd3459fa0bf9b0256a2b6f01ac1ff9ffb034e24457b9035f75587cb"}, - {file = "pydantic_core-2.18.3-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2f7ef5f0ebb77ba24c9970da18b771711edc5feaf00c10b18461e0f5f5949231"}, - {file = "pydantic_core-2.18.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:73038d66614d2e5cde30435b5afdced2b473b4c77d4ca3a8624dd3e41a9c19be"}, - {file = "pydantic_core-2.18.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6afd5c867a74c4d314c557b5ea9520183fadfbd1df4c2d6e09fd0d990ce412cd"}, - {file = "pydantic_core-2.18.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bd7df92f28d351bb9f12470f4c533cf03d1b52ec5a6e5c58c65b183055a60106"}, - {file = "pydantic_core-2.18.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:80aea0ffeb1049336043d07799eace1c9602519fb3192916ff525b0287b2b1e4"}, - {file = "pydantic_core-2.18.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:aaee40f25bba38132e655ffa3d1998a6d576ba7cf81deff8bfa189fb43fd2bbe"}, - {file = "pydantic_core-2.18.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9128089da8f4fe73f7a91973895ebf2502539d627891a14034e45fb9e707e26d"}, - {file = "pydantic_core-2.18.3-cp311-none-win32.whl", hash = "sha256:fec02527e1e03257aa25b1a4dcbe697b40a22f1229f5d026503e8b7ff6d2eda7"}, - {file = "pydantic_core-2.18.3-cp311-none-win_amd64.whl", hash = "sha256:58ff8631dbab6c7c982e6425da8347108449321f61fe427c52ddfadd66642af7"}, - {file = "pydantic_core-2.18.3-cp311-none-win_arm64.whl", hash = "sha256:3fc1c7f67f34c6c2ef9c213e0f2a351797cda98249d9ca56a70ce4ebcaba45f4"}, - {file = "pydantic_core-2.18.3-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:f0928cde2ae416a2d1ebe6dee324709c6f73e93494d8c7aea92df99aab1fc40f"}, - {file = "pydantic_core-2.18.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0bee9bb305a562f8b9271855afb6ce00223f545de3d68560b3c1649c7c5295e9"}, - {file = "pydantic_core-2.18.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e862823be114387257dacbfa7d78547165a85d7add33b446ca4f4fae92c7ff5c"}, - {file = "pydantic_core-2.18.3-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6a36f78674cbddc165abab0df961b5f96b14461d05feec5e1f78da58808b97e7"}, - {file = "pydantic_core-2.18.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ba905d184f62e7ddbb7a5a751d8a5c805463511c7b08d1aca4a3e8c11f2e5048"}, - {file = "pydantic_core-2.18.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7fdd362f6a586e681ff86550b2379e532fee63c52def1c666887956748eaa326"}, - {file = "pydantic_core-2.18.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:24b214b7ee3bd3b865e963dbed0f8bc5375f49449d70e8d407b567af3222aae4"}, - {file = "pydantic_core-2.18.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:691018785779766127f531674fa82bb368df5b36b461622b12e176c18e119022"}, - {file = "pydantic_core-2.18.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:60e4c625e6f7155d7d0dcac151edf5858102bc61bf959d04469ca6ee4e8381bd"}, - {file = "pydantic_core-2.18.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a4e651e47d981c1b701dcc74ab8fec5a60a5b004650416b4abbef13db23bc7be"}, - {file = "pydantic_core-2.18.3-cp312-none-win32.whl", hash = "sha256:ffecbb5edb7f5ffae13599aec33b735e9e4c7676ca1633c60f2c606beb17efc5"}, - {file = "pydantic_core-2.18.3-cp312-none-win_amd64.whl", hash = "sha256:2c8333f6e934733483c7eddffdb094c143b9463d2af7e6bd85ebcb2d4a1b82c6"}, - {file = "pydantic_core-2.18.3-cp312-none-win_arm64.whl", hash = "sha256:7a20dded653e516a4655f4c98e97ccafb13753987434fe7cf044aa25f5b7d417"}, - {file = "pydantic_core-2.18.3-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:eecf63195be644b0396f972c82598cd15693550f0ff236dcf7ab92e2eb6d3522"}, - {file = "pydantic_core-2.18.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2c44efdd3b6125419c28821590d7ec891c9cb0dff33a7a78d9d5c8b6f66b9702"}, - {file = "pydantic_core-2.18.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6e59fca51ffbdd1638b3856779342ed69bcecb8484c1d4b8bdb237d0eb5a45e2"}, - {file = "pydantic_core-2.18.3-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:70cf099197d6b98953468461d753563b28e73cf1eade2ffe069675d2657ed1d5"}, - {file = "pydantic_core-2.18.3-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:63081a49dddc6124754b32a3774331467bfc3d2bd5ff8f10df36a95602560361"}, - {file = "pydantic_core-2.18.3-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:370059b7883485c9edb9655355ff46d912f4b03b009d929220d9294c7fd9fd60"}, - {file = "pydantic_core-2.18.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5a64faeedfd8254f05f5cf6fc755023a7e1606af3959cfc1a9285744cc711044"}, - {file = "pydantic_core-2.18.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:19d2e725de0f90d8671f89e420d36c3dd97639b98145e42fcc0e1f6d492a46dc"}, - {file = "pydantic_core-2.18.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:67bc078025d70ec5aefe6200ef094576c9d86bd36982df1301c758a9fff7d7f4"}, - {file = "pydantic_core-2.18.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:adf952c3f4100e203cbaf8e0c907c835d3e28f9041474e52b651761dc248a3c0"}, - {file = "pydantic_core-2.18.3-cp38-none-win32.whl", hash = "sha256:9a46795b1f3beb167eaee91736d5d17ac3a994bf2215a996aed825a45f897558"}, - {file = "pydantic_core-2.18.3-cp38-none-win_amd64.whl", hash = "sha256:200ad4e3133cb99ed82342a101a5abf3d924722e71cd581cc113fe828f727fbc"}, - {file = "pydantic_core-2.18.3-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:304378b7bf92206036c8ddd83a2ba7b7d1a5b425acafff637172a3aa72ad7083"}, - {file = "pydantic_core-2.18.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c826870b277143e701c9ccf34ebc33ddb4d072612683a044e7cce2d52f6c3fef"}, - {file = "pydantic_core-2.18.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e201935d282707394f3668380e41ccf25b5794d1b131cdd96b07f615a33ca4b1"}, - {file = "pydantic_core-2.18.3-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5560dda746c44b48bf82b3d191d74fe8efc5686a9ef18e69bdabccbbb9ad9442"}, - {file = "pydantic_core-2.18.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6b32c2a1f8032570842257e4c19288eba9a2bba4712af542327de9a1204faff8"}, - {file = "pydantic_core-2.18.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:929c24e9dea3990bc8bcd27c5f2d3916c0c86f5511d2caa69e0d5290115344a9"}, - {file = "pydantic_core-2.18.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e1a8376fef60790152564b0eab376b3e23dd6e54f29d84aad46f7b264ecca943"}, - {file = "pydantic_core-2.18.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:dccf3ef1400390ddd1fb55bf0632209d39140552d068ee5ac45553b556780e06"}, - {file = "pydantic_core-2.18.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:41dbdcb0c7252b58fa931fec47937edb422c9cb22528f41cb8963665c372caf6"}, - {file = "pydantic_core-2.18.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:666e45cf071669fde468886654742fa10b0e74cd0fa0430a46ba6056b24fb0af"}, - {file = "pydantic_core-2.18.3-cp39-none-win32.whl", hash = "sha256:f9c08cabff68704a1b4667d33f534d544b8a07b8e5d039c37067fceb18789e78"}, - {file = "pydantic_core-2.18.3-cp39-none-win_amd64.whl", hash = "sha256:4afa5f5973e8572b5c0dcb4e2d4fda7890e7cd63329bd5cc3263a25c92ef0026"}, - {file = "pydantic_core-2.18.3-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:77319771a026f7c7d29c6ebc623de889e9563b7087911b46fd06c044a12aa5e9"}, - {file = "pydantic_core-2.18.3-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:df11fa992e9f576473038510d66dd305bcd51d7dd508c163a8c8fe148454e059"}, - {file = "pydantic_core-2.18.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d531076bdfb65af593326ffd567e6ab3da145020dafb9187a1d131064a55f97c"}, - {file = "pydantic_core-2.18.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d33ce258e4e6e6038f2b9e8b8a631d17d017567db43483314993b3ca345dcbbb"}, - {file = "pydantic_core-2.18.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1f9cd7f5635b719939019be9bda47ecb56e165e51dd26c9a217a433e3d0d59a9"}, - {file = "pydantic_core-2.18.3-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:cd4a032bb65cc132cae1fe3e52877daecc2097965cd3914e44fbd12b00dae7c5"}, - {file = "pydantic_core-2.18.3-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:82f2718430098bcdf60402136c845e4126a189959d103900ebabb6774a5d9fdb"}, - {file = "pydantic_core-2.18.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:c0037a92cf0c580ed14e10953cdd26528e8796307bb8bb312dc65f71547df04d"}, - {file = "pydantic_core-2.18.3-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b95a0972fac2b1ff3c94629fc9081b16371dad870959f1408cc33b2f78ad347a"}, - {file = "pydantic_core-2.18.3-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:a62e437d687cc148381bdd5f51e3e81f5b20a735c55f690c5be94e05da2b0d5c"}, - {file = "pydantic_core-2.18.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b367a73a414bbb08507da102dc2cde0fa7afe57d09b3240ce82a16d608a7679c"}, - {file = "pydantic_core-2.18.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ecce4b2360aa3f008da3327d652e74a0e743908eac306198b47e1c58b03dd2b"}, - {file = "pydantic_core-2.18.3-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:bd4435b8d83f0c9561a2a9585b1de78f1abb17cb0cef5f39bf6a4b47d19bafe3"}, - {file = "pydantic_core-2.18.3-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:616221a6d473c5b9aa83fa8982745441f6a4a62a66436be9445c65f241b86c94"}, - {file = "pydantic_core-2.18.3-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:7e6382ce89a92bc1d0c0c5edd51e931432202b9080dc921d8d003e616402efd1"}, - {file = "pydantic_core-2.18.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:ff58f379345603d940e461eae474b6bbb6dab66ed9a851ecd3cb3709bf4dcf6a"}, - {file = "pydantic_core-2.18.3.tar.gz", hash = "sha256:432e999088d85c8f36b9a3f769a8e2b57aabd817bbb729a90d1fe7f18f6f1f39"}, + {file = "pydantic_core-2.18.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:f76d0ad001edd426b92233d45c746fd08f467d56100fd8f30e9ace4b005266e4"}, + {file = "pydantic_core-2.18.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:59ff3e89f4eaf14050c8022011862df275b552caef8082e37b542b066ce1ff26"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a55b5b16c839df1070bc113c1f7f94a0af4433fcfa1b41799ce7606e5c79ce0a"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4d0dcc59664fcb8974b356fe0a18a672d6d7cf9f54746c05f43275fc48636851"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8951eee36c57cd128f779e641e21eb40bc5073eb28b2d23f33eb0ef14ffb3f5d"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4701b19f7e3a06ea655513f7938de6f108123bf7c86bbebb1196eb9bd35cf724"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e00a3f196329e08e43d99b79b286d60ce46bed10f2280d25a1718399457e06be"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:97736815b9cc893b2b7f663628e63f436018b75f44854c8027040e05230eeddb"}, + {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:6891a2ae0e8692679c07728819b6e2b822fb30ca7445f67bbf6509b25a96332c"}, + {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bc4ff9805858bd54d1a20efff925ccd89c9d2e7cf4986144b30802bf78091c3e"}, + {file = "pydantic_core-2.18.4-cp310-none-win32.whl", hash = "sha256:1b4de2e51bbcb61fdebd0ab86ef28062704f62c82bbf4addc4e37fa4b00b7cbc"}, + {file = "pydantic_core-2.18.4-cp310-none-win_amd64.whl", hash = "sha256:6a750aec7bf431517a9fd78cb93c97b9b0c496090fee84a47a0d23668976b4b0"}, + {file = "pydantic_core-2.18.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:942ba11e7dfb66dc70f9ae66b33452f51ac7bb90676da39a7345e99ffb55402d"}, + {file = "pydantic_core-2.18.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b2ebef0e0b4454320274f5e83a41844c63438fdc874ea40a8b5b4ecb7693f1c4"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a642295cd0c8df1b86fc3dced1d067874c353a188dc8e0f744626d49e9aa51c4"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f09baa656c904807e832cf9cce799c6460c450c4ad80803517032da0cd062e2"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:98906207f29bc2c459ff64fa007afd10a8c8ac080f7e4d5beff4c97086a3dabd"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:19894b95aacfa98e7cb093cd7881a0c76f55731efad31073db4521e2b6ff5b7d"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fbbdc827fe5e42e4d196c746b890b3d72876bdbf160b0eafe9f0334525119c8"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f85d05aa0918283cf29a30b547b4df2fbb56b45b135f9e35b6807cb28bc47951"}, + {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e85637bc8fe81ddb73fda9e56bab24560bdddfa98aa64f87aaa4e4b6730c23d2"}, + {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2f5966897e5461f818e136b8451d0551a2e77259eb0f73a837027b47dc95dab9"}, + {file = "pydantic_core-2.18.4-cp311-none-win32.whl", hash = "sha256:44c7486a4228413c317952e9d89598bcdfb06399735e49e0f8df643e1ccd0558"}, + {file = "pydantic_core-2.18.4-cp311-none-win_amd64.whl", hash = "sha256:8a7164fe2005d03c64fd3b85649891cd4953a8de53107940bf272500ba8a788b"}, + {file = "pydantic_core-2.18.4-cp311-none-win_arm64.whl", hash = "sha256:4e99bc050fe65c450344421017f98298a97cefc18c53bb2f7b3531eb39bc7805"}, + {file = "pydantic_core-2.18.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:6f5c4d41b2771c730ea1c34e458e781b18cc668d194958e0112455fff4e402b2"}, + {file = "pydantic_core-2.18.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2fdf2156aa3d017fddf8aea5adfba9f777db1d6022d392b682d2a8329e087cef"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4748321b5078216070b151d5271ef3e7cc905ab170bbfd27d5c83ee3ec436695"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:847a35c4d58721c5dc3dba599878ebbdfd96784f3fb8bb2c356e123bdcd73f34"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c40d4eaad41f78e3bbda31b89edc46a3f3dc6e171bf0ecf097ff7a0ffff7cb1"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:21a5e440dbe315ab9825fcd459b8814bb92b27c974cbc23c3e8baa2b76890077"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:01dd777215e2aa86dfd664daed5957704b769e726626393438f9c87690ce78c3"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4b06beb3b3f1479d32befd1f3079cc47b34fa2da62457cdf6c963393340b56e9"}, + {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:564d7922e4b13a16b98772441879fcdcbe82ff50daa622d681dd682175ea918c"}, + {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0eb2a4f660fcd8e2b1c90ad566db2b98d7f3f4717c64fe0a83e0adb39766d5b8"}, + {file = "pydantic_core-2.18.4-cp312-none-win32.whl", hash = "sha256:8b8bab4c97248095ae0c4455b5a1cd1cdd96e4e4769306ab19dda135ea4cdb07"}, + {file = "pydantic_core-2.18.4-cp312-none-win_amd64.whl", hash = "sha256:14601cdb733d741b8958224030e2bfe21a4a881fb3dd6fbb21f071cabd48fa0a"}, + {file = "pydantic_core-2.18.4-cp312-none-win_arm64.whl", hash = "sha256:c1322d7dd74713dcc157a2b7898a564ab091ca6c58302d5c7b4c07296e3fd00f"}, + {file = "pydantic_core-2.18.4-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:823be1deb01793da05ecb0484d6c9e20baebb39bd42b5d72636ae9cf8350dbd2"}, + {file = "pydantic_core-2.18.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ebef0dd9bf9b812bf75bda96743f2a6c5734a02092ae7f721c048d156d5fabae"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ae1d6df168efb88d7d522664693607b80b4080be6750c913eefb77e34c12c71a"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f9899c94762343f2cc2fc64c13e7cae4c3cc65cdfc87dd810a31654c9b7358cc"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:99457f184ad90235cfe8461c4d70ab7dd2680e28821c29eca00252ba90308c78"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:18f469a3d2a2fdafe99296a87e8a4c37748b5080a26b806a707f25a902c040a8"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b7cdf28938ac6b8b49ae5e92f2735056a7ba99c9b110a474473fd71185c1af5d"}, + {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:938cb21650855054dc54dfd9120a851c974f95450f00683399006aa6e8abb057"}, + {file = "pydantic_core-2.18.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:44cd83ab6a51da80fb5adbd9560e26018e2ac7826f9626bc06ca3dc074cd198b"}, + {file = "pydantic_core-2.18.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:972658f4a72d02b8abfa2581d92d59f59897d2e9f7e708fdabe922f9087773af"}, + {file = "pydantic_core-2.18.4-cp38-none-win32.whl", hash = "sha256:1d886dc848e60cb7666f771e406acae54ab279b9f1e4143babc9c2258213daa2"}, + {file = "pydantic_core-2.18.4-cp38-none-win_amd64.whl", hash = "sha256:bb4462bd43c2460774914b8525f79b00f8f407c945d50881568f294c1d9b4443"}, + {file = "pydantic_core-2.18.4-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:44a688331d4a4e2129140a8118479443bd6f1905231138971372fcde37e43528"}, + {file = "pydantic_core-2.18.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a2fdd81edd64342c85ac7cf2753ccae0b79bf2dfa063785503cb85a7d3593223"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:86110d7e1907ab36691f80b33eb2da87d780f4739ae773e5fc83fb272f88825f"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:46387e38bd641b3ee5ce247563b60c5ca098da9c56c75c157a05eaa0933ed154"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:123c3cec203e3f5ac7b000bd82235f1a3eced8665b63d18be751f115588fea30"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dc1803ac5c32ec324c5261c7209e8f8ce88e83254c4e1aebdc8b0a39f9ddb443"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53db086f9f6ab2b4061958d9c276d1dbe3690e8dd727d6abf2321d6cce37fa94"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:abc267fa9837245cc28ea6929f19fa335f3dc330a35d2e45509b6566dc18be23"}, + {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a0d829524aaefdebccb869eed855e2d04c21d2d7479b6cada7ace5448416597b"}, + {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:509daade3b8649f80d4e5ff21aa5673e4ebe58590b25fe42fac5f0f52c6f034a"}, + {file = "pydantic_core-2.18.4-cp39-none-win32.whl", hash = "sha256:ca26a1e73c48cfc54c4a76ff78df3727b9d9f4ccc8dbee4ae3f73306a591676d"}, + {file = "pydantic_core-2.18.4-cp39-none-win_amd64.whl", hash = "sha256:c67598100338d5d985db1b3d21f3619ef392e185e71b8d52bceacc4a7771ea7e"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:574d92eac874f7f4db0ca653514d823a0d22e2354359d0759e3f6a406db5d55d"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1f4d26ceb5eb9eed4af91bebeae4b06c3fb28966ca3a8fb765208cf6b51102ab"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77450e6d20016ec41f43ca4a6c63e9fdde03f0ae3fe90e7c27bdbeaece8b1ed4"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d323a01da91851a4f17bf592faf46149c9169d68430b3146dcba2bb5e5719abc"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43d447dd2ae072a0065389092a231283f62d960030ecd27565672bd40746c507"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:578e24f761f3b425834f297b9935e1ce2e30f51400964ce4801002435a1b41ef"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:81b5efb2f126454586d0f40c4d834010979cb80785173d1586df845a632e4e6d"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:ab86ce7c8f9bea87b9d12c7f0af71102acbf5ecbc66c17796cff45dae54ef9a5"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:90afc12421df2b1b4dcc975f814e21bc1754640d502a2fbcc6d41e77af5ec312"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:51991a89639a912c17bef4b45c87bd83593aee0437d8102556af4885811d59f5"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:293afe532740370aba8c060882f7d26cfd00c94cae32fd2e212a3a6e3b7bc15e"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b48ece5bde2e768197a2d0f6e925f9d7e3e826f0ad2271120f8144a9db18d5c8"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:eae237477a873ab46e8dd748e515c72c0c804fb380fbe6c85533c7de51f23a8f"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:834b5230b5dfc0c1ec37b2fda433b271cbbc0e507560b5d1588e2cc1148cf1ce"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e858ac0a25074ba4bce653f9b5d0a85b7456eaddadc0ce82d3878c22489fa4ee"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2fd41f6eff4c20778d717af1cc50eca52f5afe7805ee530a4fbd0bae284f16e9"}, + {file = "pydantic_core-2.18.4.tar.gz", hash = "sha256:ec3beeada09ff865c344ff3bc2f427f5e6c26401cc6113d77e372c3fdac73864"}, ] [package.dependencies] @@ -431,18 +431,29 @@ files = [ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] +[[package]] +name = "types-python-dateutil" +version = "2.9.0.20240316" +description = "Typing stubs for python-dateutil" +optional = false +python-versions = ">=3.8" +files = [ + {file = "types-python-dateutil-2.9.0.20240316.tar.gz", hash = "sha256:5d2f2e240b86905e40944dd787db6da9263f0deabef1076ddaed797351ec0202"}, + {file = "types_python_dateutil-2.9.0.20240316-py3-none-any.whl", hash = "sha256:6b8cb66d960771ce5ff974e9dd45e38facb81718cc1e208b10b1baccbfdbee3b"}, +] + [[package]] name = "typing-extensions" -version = "4.12.0" +version = "4.12.1" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.12.0-py3-none-any.whl", hash = "sha256:b349c66bea9016ac22978d800cfff206d5f9816951f12a7d0ec5578b0a819594"}, - {file = "typing_extensions-4.12.0.tar.gz", hash = "sha256:8cbcdc8606ebcb0d95453ad7dc5065e6237b6aa230a31e81d0f440c30fed5fd8"}, + {file = "typing_extensions-4.12.1-py3-none-any.whl", hash = "sha256:6024b58b69089e5a89c347397254e35f1bf02a907728ec7fee9bf0fe837d203a"}, + {file = "typing_extensions-4.12.1.tar.gz", hash = "sha256:915f5e35ff76f56588223f15fdd5938f9a1cf9195c0de25130c627e4d597f6d1"}, ] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "6f0b8d5044d8d4461b9850fcdfd7c382335fc9481fcfd5bd42e760121c1e1450" +content-hash = "100176daba5de68e31f056b0ba2efb572e64910d0f83cd0cc06c6ccf2f71f69a" diff --git a/pyproject.toml b/pyproject.toml index 6d24a4b..7d76970 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,35 @@ [tool.poetry] name = "mercoa" -version = "v0.3.37" +version = "v0.3.38" description = "" readme = "README.md" authors = [] +keywords = [] + +classifiers = [ + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Operating System :: OS Independent", + "Operating System :: POSIX", + "Operating System :: MacOS", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows", + "Topic :: Software Development :: Libraries :: Python Modules", + "Typing :: Typed" +] packages = [ { include = "mercoa", from = "src"} ] +[project.urls] +Repository = 'https://github.com/mercoa-finance/python' + [tool.poetry.dependencies] python = "^3.8" httpx = ">=0.21.2" @@ -19,6 +41,7 @@ mypy = "1.9.0" pytest = "^7.4.0" pytest-asyncio = "^0.23.5" python-dateutil = "^2.9.0" +types-python-dateutil = "^2.9.0.20240316" [tool.pytest.ini_options] testpaths = [ "tests" ] diff --git a/src/mercoa/bank_lookup/client.py b/src/mercoa/bank_lookup/client.py index d80a0a9..1805e1e 100644 --- a/src/mercoa/bank_lookup/client.py +++ b/src/mercoa/bank_lookup/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ..commons.errors.bad_request import BadRequest @@ -13,9 +12,7 @@ from ..commons.errors.unimplemented import Unimplemented from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 -from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions from .types.bank_lookup_response import BankLookupResponse @@ -54,33 +51,7 @@ def find( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "bankLookup"), - params=jsonable_encoder( - remove_none_from_dict( - { - "routingNumber": routing_number, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + "bankLookup", method="GET", params={"routingNumber": routing_number}, request_options=request_options ) try: _response_json = _response.json() @@ -140,33 +111,7 @@ async def find( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "bankLookup"), - params=jsonable_encoder( - remove_none_from_dict( - { - "routingNumber": routing_number, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + "bankLookup", method="GET", params={"routingNumber": routing_number}, request_options=request_options ) try: _response_json = _response.json() diff --git a/src/mercoa/bank_lookup/types/bank_address.py b/src/mercoa/bank_lookup/types/bank_address.py index 2f79de5..be64d33 100644 --- a/src/mercoa/bank_lookup/types/bank_address.py +++ b/src/mercoa/bank_lookup/types/bank_address.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class BankAddress(pydantic_v1.BaseModel): @@ -33,8 +33,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/bank_lookup/types/bank_lookup_response.py b/src/mercoa/bank_lookup/types/bank_lookup_response.py index 6f25a4a..8489bc0 100644 --- a/src/mercoa/bank_lookup/types/bank_lookup_response.py +++ b/src/mercoa/bank_lookup/types/bank_lookup_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_address import BankAddress @@ -34,8 +34,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/client.py b/src/mercoa/client.py index e03ab37..d62b45c 100644 --- a/src/mercoa/client.py +++ b/src/mercoa/client.py @@ -17,7 +17,7 @@ class Mercoa: """ - Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions. + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. Parameters ---------- @@ -84,7 +84,7 @@ def __init__( class AsyncMercoa: """ - Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions. + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. Parameters ---------- diff --git a/src/mercoa/commons/types/address.py b/src/mercoa/commons/types/address.py index 571954e..427f0fa 100644 --- a/src/mercoa/commons/types/address.py +++ b/src/mercoa/commons/types/address.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class Address(pydantic_v1.BaseModel): @@ -43,8 +43,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/commons/types/birth_date.py b/src/mercoa/commons/types/birth_date.py index 05e28b7..d8a977b 100644 --- a/src/mercoa/commons/types/birth_date.py +++ b/src/mercoa/commons/types/birth_date.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class BirthDate(pydantic_v1.BaseModel): @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/commons/types/full_name.py b/src/mercoa/commons/types/full_name.py index 04ca802..44ec263 100644 --- a/src/mercoa/commons/types/full_name.py +++ b/src/mercoa/commons/types/full_name.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class FullName(pydantic_v1.BaseModel): @@ -31,8 +31,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/commons/types/individual_government_id.py b/src/mercoa/commons/types/individual_government_id.py index 273aa2c..63fd86a 100644 --- a/src/mercoa/commons/types/individual_government_id.py +++ b/src/mercoa/commons/types/individual_government_id.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class IndividualGovernmentId(pydantic_v1.BaseModel): @@ -28,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/commons/types/phone_number.py b/src/mercoa/commons/types/phone_number.py index b06749c..cfbaaf6 100644 --- a/src/mercoa/commons/types/phone_number.py +++ b/src/mercoa/commons/types/phone_number.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class PhoneNumber(pydantic_v1.BaseModel): @@ -27,8 +27,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/core/__init__.py b/src/mercoa/core/__init__.py index 78a7f80..58ad52a 100644 --- a/src/mercoa/core/__init__.py +++ b/src/mercoa/core/__init__.py @@ -6,7 +6,8 @@ from .file import File, convert_file_dict_to_httpx_tuples from .http_client import AsyncHttpClient, HttpClient from .jsonable_encoder import jsonable_encoder -from .pydantic_utilities import pydantic_v1 +from .pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .query_encoder import encode_query from .remove_none_from_dict import remove_none_from_dict from .request_options import RequestOptions @@ -20,6 +21,8 @@ "RequestOptions", "SyncClientWrapper", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", + "encode_query", "jsonable_encoder", "pydantic_v1", "remove_none_from_dict", diff --git a/src/mercoa/core/client_wrapper.py b/src/mercoa/core/client_wrapper.py index 5709b76..746a1fe 100644 --- a/src/mercoa/core/client_wrapper.py +++ b/src/mercoa/core/client_wrapper.py @@ -23,7 +23,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "mercoa", - "X-Fern-SDK-Version": "v0.3.37", + "X-Fern-SDK-Version": "v0.3.38", } headers["Authorization"] = f"Bearer {self._get_token()}" return headers @@ -51,7 +51,12 @@ def __init__( httpx_client: httpx.Client, ): super().__init__(token=token, base_url=base_url, timeout=timeout) - self.httpx_client = HttpClient(httpx_client=httpx_client) + self.httpx_client = HttpClient( + httpx_client=httpx_client, + base_headers=self.get_headers(), + base_timeout=self.get_timeout(), + base_url=self.get_base_url(), + ) class AsyncClientWrapper(BaseClientWrapper): @@ -64,4 +69,9 @@ def __init__( httpx_client: httpx.AsyncClient, ): super().__init__(token=token, base_url=base_url, timeout=timeout) - self.httpx_client = AsyncHttpClient(httpx_client=httpx_client) + self.httpx_client = AsyncHttpClient( + httpx_client=httpx_client, + base_headers=self.get_headers(), + base_timeout=self.get_timeout(), + base_url=self.get_base_url(), + ) diff --git a/src/mercoa/core/http_client.py b/src/mercoa/core/http_client.py index 4e6877d..6c36869 100644 --- a/src/mercoa/core/http_client.py +++ b/src/mercoa/core/http_client.py @@ -5,12 +5,18 @@ import re import time import typing +import urllib.parse from contextlib import asynccontextmanager, contextmanager -from functools import wraps from random import random import httpx +from .file import File, convert_file_dict_to_httpx_tuples +from .jsonable_encoder import jsonable_encoder +from .query_encoder import encode_query +from .remove_none_from_dict import remove_none_from_dict +from .request_options import RequestOptions + INITIAL_RETRY_DELAY_SECONDS = 0.5 MAX_RETRY_DELAY_SECONDS = 10 MAX_RETRY_DELAY_SECONDS_FROM_HEADER = 30 @@ -82,49 +88,348 @@ def _should_retry(response: httpx.Response) -> bool: return response.status_code >= 500 or response.status_code in retriable_400s +def remove_omit_from_dict( + original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any] +) -> typing.Dict[str, typing.Any]: + if omit is None: + return original + new: typing.Dict[str, typing.Any] = {} + for key, value in original.items(): + if value is not omit: + new[key] = value + return new + + +def maybe_filter_request_body( + data: typing.Optional[typing.Any], + request_options: typing.Optional[RequestOptions], + omit: typing.Optional[typing.Any], +) -> typing.Optional[typing.Any]: + if data is None: + return None + elif not isinstance(data, typing.Mapping): + data_content = jsonable_encoder(data) + else: + data_content = { + **(jsonable_encoder(remove_omit_from_dict(data, omit))), # type: ignore + **( + jsonable_encoder(request_options.get("additional_body_parameters", {})) + if request_options is not None + else {} + ), + } + return data_content + + class HttpClient: - def __init__(self, *, httpx_client: httpx.Client): + def __init__( + self, + *, + httpx_client: httpx.Client, + base_timeout: typing.Optional[float], + base_headers: typing.Dict[str, str], + base_url: typing.Optional[str] = None, + ): + self.base_url = base_url + self.base_timeout = base_timeout + self.base_headers = base_headers self.httpx_client = httpx_client - # Ensure that the signature of the `request` method is the same as the `httpx.Client.request` method - @wraps(httpx.Client.request) + def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: + base_url = self.base_url if maybe_base_url is None else maybe_base_url + if base_url is None: + raise ValueError("A base_url is required to make this request, please provide one and try again.") + return base_url + def request( - self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + json: typing.Optional[typing.Any] = None, + data: typing.Optional[typing.Any] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Union[File, typing.List[File]]]] = None, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, ) -> httpx.Response: - response = self.httpx_client.request(*args, **kwargs) + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout + ) + + response = self.httpx_client.request( + method=method, + url=urllib.parse.urljoin(base_url, path), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + params=encode_query( + jsonable_encoder( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ), + json=maybe_filter_request_body(json, request_options, omit), + data=maybe_filter_request_body(data, request_options, omit), + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) + + max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 if _should_retry(response=response): if max_retries > retries: time.sleep(_retry_timeout(response=response, retries=retries)) - return self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) + return self.request( + path=path, + method=method, + base_url=base_url, + params=params, + json=json, + content=content, + files=files, + headers=headers, + request_options=request_options, + retries=retries + 1, + omit=omit, + ) + return response - @wraps(httpx.Client.stream) @contextmanager - def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - with self.httpx_client.stream(*args, **kwargs) as stream: + def stream( + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + json: typing.Optional[typing.Any] = None, + data: typing.Optional[typing.Any] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Union[File, typing.List[File]]]] = None, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, + ) -> typing.Iterator[httpx.Response]: + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout + ) + + with self.httpx_client.stream( + method=method, + url=urllib.parse.urljoin(base_url, path), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + params=encode_query( + jsonable_encoder( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ), + json=maybe_filter_request_body(json, request_options, omit), + data=maybe_filter_request_body(data, request_options, omit), + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) as stream: yield stream class AsyncHttpClient: - def __init__(self, *, httpx_client: httpx.AsyncClient): + def __init__( + self, + *, + httpx_client: httpx.AsyncClient, + base_timeout: typing.Optional[float], + base_headers: typing.Dict[str, str], + base_url: typing.Optional[str] = None, + ): + self.base_url = base_url + self.base_timeout = base_timeout + self.base_headers = base_headers self.httpx_client = httpx_client - # Ensure that the signature of the `request` method is the same as the `httpx.Client.request` method - @wraps(httpx.AsyncClient.request) + def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: + base_url = self.base_url if maybe_base_url is None else maybe_base_url + if base_url is None: + raise ValueError("A base_url is required to make this request, please provide one and try again.") + return base_url + async def request( - self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + json: typing.Optional[typing.Any] = None, + data: typing.Optional[typing.Any] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Union[File, typing.List[File]]]] = None, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, ) -> httpx.Response: - response = await self.httpx_client.request(*args, **kwargs) + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout + ) + + # Add the input to each of these and do None-safety checks + response = await self.httpx_client.request( + method=method, + url=urllib.parse.urljoin(base_url, path), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + params=encode_query( + jsonable_encoder( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ), + json=maybe_filter_request_body(json, request_options, omit), + data=maybe_filter_request_body(data, request_options, omit), + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) + + max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 if _should_retry(response=response): if max_retries > retries: await asyncio.sleep(_retry_timeout(response=response, retries=retries)) - return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) + return await self.request( + path=path, + method=method, + base_url=base_url, + params=params, + json=json, + content=content, + files=files, + headers=headers, + request_options=request_options, + retries=retries + 1, + omit=omit, + ) return response - @wraps(httpx.AsyncClient.stream) @asynccontextmanager async def stream( - self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any - ) -> typing.Any: - async with self.httpx_client.stream(*args, **kwargs) as stream: + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + json: typing.Optional[typing.Any] = None, + data: typing.Optional[typing.Any] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Union[File, typing.List[File]]]] = None, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, + ) -> typing.AsyncIterator[httpx.Response]: + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout + ) + + async with self.httpx_client.stream( + method=method, + url=urllib.parse.urljoin(base_url, path), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + params=encode_query( + jsonable_encoder( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit=omit, + ) + ) + ), + json=maybe_filter_request_body(json, request_options, omit), + data=maybe_filter_request_body(data, request_options, omit), + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) as stream: yield stream diff --git a/src/mercoa/core/pydantic_utilities.py b/src/mercoa/core/pydantic_utilities.py index 952b5f2..a72c1a5 100644 --- a/src/mercoa/core/pydantic_utilities.py +++ b/src/mercoa/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +import typing + import pydantic IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") @@ -9,4 +11,18 @@ else: import pydantic as pydantic_v1 # type: ignore # nopycln: import + +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + __all__ = ["pydantic_v1"] diff --git a/src/mercoa/core/query_encoder.py b/src/mercoa/core/query_encoder.py new file mode 100644 index 0000000..1f5f766 --- /dev/null +++ b/src/mercoa/core/query_encoder.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +from collections import ChainMap +from typing import Any, Dict, Optional + +from .pydantic_utilities import pydantic_v1 + + +# Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: + result = {} + for k, v in dict_flat.items(): + key = f"{key_prefix}[{k}]" if key_prefix is not None else k + if isinstance(v, dict): + result.update(traverse_query_dict(v, key)) + else: + result[key] = v + return result + + +def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: + if isinstance(query_value, pydantic_v1.BaseModel) or isinstance(query_value, dict): + if isinstance(query_value, pydantic_v1.BaseModel): + obj_dict = query_value.dict(by_alias=True) + else: + obj_dict = query_value + return traverse_query_dict(obj_dict, query_key) + + return {query_key: query_value} + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: + return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None diff --git a/src/mercoa/custom_payment_method_schema/client.py b/src/mercoa/custom_payment_method_schema/client.py index 87a8a7d..5ce72ac 100644 --- a/src/mercoa/custom_payment_method_schema/client.py +++ b/src/mercoa/custom_payment_method_schema/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ..commons.errors.bad_request import BadRequest @@ -15,10 +14,10 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 -from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..payment_method_types.types.currency_code import CurrencyCode +from ..payment_method_types.types.custom_payment_method_schema_field import CustomPaymentMethodSchemaField from ..payment_method_types.types.custom_payment_method_schema_id import CustomPaymentMethodSchemaId -from ..payment_method_types.types.custom_payment_method_schema_request import CustomPaymentMethodSchemaRequest from ..payment_method_types.types.custom_payment_method_schema_response import CustomPaymentMethodSchemaResponse # this is used as the default value for optional parameters @@ -54,24 +53,7 @@ def get_all( client.custom_payment_method_schema.get_all() """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "paymentMethod/schema"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + "paymentMethod/schema", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -97,14 +79,32 @@ def get_all( raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, *, request: CustomPaymentMethodSchemaRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + name: str, + is_source: bool, + is_destination: bool, + fields: typing.Sequence[CustomPaymentMethodSchemaField], + supported_currencies: typing.Optional[typing.Sequence[CurrencyCode]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> CustomPaymentMethodSchemaResponse: """ Create custom payment method schema Parameters ---------- - request : CustomPaymentMethodSchemaRequest + name : str + + is_source : bool + This payment method can be used as a payment source for an invoice + + is_destination : bool + This payment method can be used as a payment destination for an invoice + + fields : typing.Sequence[CustomPaymentMethodSchemaField] + + supported_currencies : typing.Optional[typing.Sequence[CurrencyCode]] + List of currencies that this payment method supports. If not provided, the payment method will support only USD. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -115,76 +115,58 @@ def create( Examples -------- - from mercoa import ( - CustomPaymentMethodSchemaField, - CustomPaymentMethodSchemaRequest, - ) + from mercoa import CustomPaymentMethodSchemaField from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.custom_payment_method_schema.create( - request=CustomPaymentMethodSchemaRequest( - name="Wire", - is_source=False, - is_destination=True, - supported_currencies=["USD", "EUR"], - fields=[ - CustomPaymentMethodSchemaField( - name="bankName", - display_name="Bank Name", - type="text", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="recipientName", - display_name="Recipient Name", - type="text", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="accountNumber", - display_name="Account Number", - type="number", - optional=False, - use_as_account_number=True, - ), - CustomPaymentMethodSchemaField( - name="routingNumber", - display_name="Routing Number", - type="number", - optional=False, - ), - ], - ), + name="Wire", + is_source=False, + is_destination=True, + supported_currencies=["USD", "EUR"], + fields=[ + CustomPaymentMethodSchemaField( + name="bankName", + display_name="Bank Name", + type="text", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="recipientName", + display_name="Recipient Name", + type="text", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="accountNumber", + display_name="Account Number", + type="number", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="number", + optional=False, + ), + ], ) """ _response = self._client_wrapper.httpx_client.request( + "paymentMethod/schema", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "paymentMethod/schema"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "isSource": is_source, + "isDestination": is_destination, + "supportedCurrencies": supported_currencies, + "fields": fields, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -213,7 +195,11 @@ def update( self, schema_id: CustomPaymentMethodSchemaId, *, - request: CustomPaymentMethodSchemaRequest, + name: str, + is_source: bool, + is_destination: bool, + fields: typing.Sequence[CustomPaymentMethodSchemaField], + supported_currencies: typing.Optional[typing.Sequence[CurrencyCode]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CustomPaymentMethodSchemaResponse: """ @@ -223,7 +209,18 @@ def update( ---------- schema_id : CustomPaymentMethodSchemaId - request : CustomPaymentMethodSchemaRequest + name : str + + is_source : bool + This payment method can be used as a payment source for an invoice + + is_destination : bool + This payment method can be used as a payment destination for an invoice + + fields : typing.Sequence[CustomPaymentMethodSchemaField] + + supported_currencies : typing.Optional[typing.Sequence[CurrencyCode]] + List of currencies that this payment method supports. If not provided, the payment method will support only USD. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -234,10 +231,7 @@ def update( Examples -------- - from mercoa import ( - CustomPaymentMethodSchemaField, - CustomPaymentMethodSchemaRequest, - ) + from mercoa import CustomPaymentMethodSchemaField from mercoa.client import Mercoa client = Mercoa( @@ -245,68 +239,51 @@ def update( ) client.custom_payment_method_schema.update( schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", - request=CustomPaymentMethodSchemaRequest( - name="Check", - is_source=False, - is_destination=True, - supported_currencies=["USD"], - fields=[ - CustomPaymentMethodSchemaField( - name="payToTheOrderOf", - display_name="Pay To The Order Of", - type="text", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="accountNumber", - display_name="Account Number", - type="number", - optional=False, - use_as_account_number=True, - ), - CustomPaymentMethodSchemaField( - name="routingNumber", - display_name="Routing Number", - type="number", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="address", - display_name="Address", - type="address", - optional=False, - ), - ], - ), + name="Check", + is_source=False, + is_destination=True, + supported_currencies=["USD"], + fields=[ + CustomPaymentMethodSchemaField( + name="payToTheOrderOf", + display_name="Pay To The Order Of", + type="text", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="accountNumber", + display_name="Account Number", + type="number", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="number", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="address", + display_name="Address", + type="address", + optional=False, + ), + ], ) """ _response = self._client_wrapper.httpx_client.request( + f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"paymentMethod/schema/{jsonable_encoder(schema_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "isSource": is_source, + "isDestination": is_destination, + "supportedCurrencies": supported_currencies, + "fields": fields, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -360,26 +337,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"paymentMethod/schema/{jsonable_encoder(schema_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -433,26 +391,7 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( - method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"paymentMethod/schema/{jsonable_encoder(schema_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="DELETE", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -507,24 +446,7 @@ async def get_all( await client.custom_payment_method_schema.get_all() """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "paymentMethod/schema"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + "paymentMethod/schema", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -550,14 +472,32 @@ async def get_all( raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, *, request: CustomPaymentMethodSchemaRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + name: str, + is_source: bool, + is_destination: bool, + fields: typing.Sequence[CustomPaymentMethodSchemaField], + supported_currencies: typing.Optional[typing.Sequence[CurrencyCode]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> CustomPaymentMethodSchemaResponse: """ Create custom payment method schema Parameters ---------- - request : CustomPaymentMethodSchemaRequest + name : str + + is_source : bool + This payment method can be used as a payment source for an invoice + + is_destination : bool + This payment method can be used as a payment destination for an invoice + + fields : typing.Sequence[CustomPaymentMethodSchemaField] + + supported_currencies : typing.Optional[typing.Sequence[CurrencyCode]] + List of currencies that this payment method supports. If not provided, the payment method will support only USD. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -568,76 +508,58 @@ async def create( Examples -------- - from mercoa import ( - CustomPaymentMethodSchemaField, - CustomPaymentMethodSchemaRequest, - ) + from mercoa import CustomPaymentMethodSchemaField from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) await client.custom_payment_method_schema.create( - request=CustomPaymentMethodSchemaRequest( - name="Wire", - is_source=False, - is_destination=True, - supported_currencies=["USD", "EUR"], - fields=[ - CustomPaymentMethodSchemaField( - name="bankName", - display_name="Bank Name", - type="text", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="recipientName", - display_name="Recipient Name", - type="text", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="accountNumber", - display_name="Account Number", - type="number", - optional=False, - use_as_account_number=True, - ), - CustomPaymentMethodSchemaField( - name="routingNumber", - display_name="Routing Number", - type="number", - optional=False, - ), - ], - ), + name="Wire", + is_source=False, + is_destination=True, + supported_currencies=["USD", "EUR"], + fields=[ + CustomPaymentMethodSchemaField( + name="bankName", + display_name="Bank Name", + type="text", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="recipientName", + display_name="Recipient Name", + type="text", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="accountNumber", + display_name="Account Number", + type="number", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="number", + optional=False, + ), + ], ) """ _response = await self._client_wrapper.httpx_client.request( + "paymentMethod/schema", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "paymentMethod/schema"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "isSource": is_source, + "isDestination": is_destination, + "supportedCurrencies": supported_currencies, + "fields": fields, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -666,7 +588,11 @@ async def update( self, schema_id: CustomPaymentMethodSchemaId, *, - request: CustomPaymentMethodSchemaRequest, + name: str, + is_source: bool, + is_destination: bool, + fields: typing.Sequence[CustomPaymentMethodSchemaField], + supported_currencies: typing.Optional[typing.Sequence[CurrencyCode]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CustomPaymentMethodSchemaResponse: """ @@ -676,7 +602,18 @@ async def update( ---------- schema_id : CustomPaymentMethodSchemaId - request : CustomPaymentMethodSchemaRequest + name : str + + is_source : bool + This payment method can be used as a payment source for an invoice + + is_destination : bool + This payment method can be used as a payment destination for an invoice + + fields : typing.Sequence[CustomPaymentMethodSchemaField] + + supported_currencies : typing.Optional[typing.Sequence[CurrencyCode]] + List of currencies that this payment method supports. If not provided, the payment method will support only USD. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -687,10 +624,7 @@ async def update( Examples -------- - from mercoa import ( - CustomPaymentMethodSchemaField, - CustomPaymentMethodSchemaRequest, - ) + from mercoa import CustomPaymentMethodSchemaField from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -698,68 +632,51 @@ async def update( ) await client.custom_payment_method_schema.update( schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", - request=CustomPaymentMethodSchemaRequest( - name="Check", - is_source=False, - is_destination=True, - supported_currencies=["USD"], - fields=[ - CustomPaymentMethodSchemaField( - name="payToTheOrderOf", - display_name="Pay To The Order Of", - type="text", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="accountNumber", - display_name="Account Number", - type="number", - optional=False, - use_as_account_number=True, - ), - CustomPaymentMethodSchemaField( - name="routingNumber", - display_name="Routing Number", - type="number", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="address", - display_name="Address", - type="address", - optional=False, - ), - ], - ), + name="Check", + is_source=False, + is_destination=True, + supported_currencies=["USD"], + fields=[ + CustomPaymentMethodSchemaField( + name="payToTheOrderOf", + display_name="Pay To The Order Of", + type="text", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="accountNumber", + display_name="Account Number", + type="number", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="number", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="address", + display_name="Address", + type="address", + optional=False, + ), + ], ) """ _response = await self._client_wrapper.httpx_client.request( + f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"paymentMethod/schema/{jsonable_encoder(schema_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "isSource": is_source, + "isDestination": is_destination, + "supportedCurrencies": supported_currencies, + "fields": fields, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -813,26 +730,7 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"paymentMethod/schema/{jsonable_encoder(schema_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -886,26 +784,7 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( - method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"paymentMethod/schema/{jsonable_encoder(schema_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="DELETE", request_options=request_options ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/email_log_types/types/email_log.py b/src/mercoa/email_log_types/types/email_log.py index 1e69c6a..2e48fe7 100644 --- a/src/mercoa/email_log_types/types/email_log.py +++ b/src/mercoa/email_log_types/types/email_log.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...invoice_types.types.invoice_id import InvoiceId from .email_log_id import EmailLogId @@ -44,8 +44,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/email_log_types/types/email_log_response.py b/src/mercoa/email_log_types/types/email_log_response.py index 033978e..b949146 100644 --- a/src/mercoa/email_log_types/types/email_log_response.py +++ b/src/mercoa/email_log_types/types/email_log_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .email_log import EmailLog @@ -52,8 +52,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity/approval_policy/client.py b/src/mercoa/entity/approval_policy/client.py index 2a6c0a9..035a62d 100644 --- a/src/mercoa/entity/approval_policy/client.py +++ b/src/mercoa/entity/approval_policy/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,13 +14,12 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.approval_policy_id import ApprovalPolicyId -from ...entity_types.types.approval_policy_request import ApprovalPolicyRequest from ...entity_types.types.approval_policy_response import ApprovalPolicyResponse -from ...entity_types.types.approval_policy_update_request import ApprovalPolicyUpdateRequest from ...entity_types.types.entity_id import EntityId +from ...entity_types.types.rule import Rule +from ...entity_types.types.trigger import Trigger # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -60,26 +58,7 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/approval-policies" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/approval-policies", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -108,7 +87,9 @@ def create( self, entity_id: EntityId, *, - request: ApprovalPolicyRequest, + trigger: typing.Sequence[Trigger], + rule: Rule, + upstream_policy_id: ApprovalPolicyId, request_options: typing.Optional[RequestOptions] = None, ) -> ApprovalPolicyResponse: """ @@ -118,7 +99,13 @@ def create( ---------- entity_id : EntityId - request : ApprovalPolicyRequest + trigger : typing.Sequence[Trigger] + List of triggers that will cause this policy to be evaluated. If no triggers are provided, the policy will be evaluated for all invoices. + + rule : Rule + + upstream_policy_id : ApprovalPolicyId + The policy ID of the previous approval policy in the chain of policies. Use 'root' if no upstreamPolicyId is intended to be set. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -129,12 +116,7 @@ def create( Examples -------- - from mercoa import ( - ApprovalPolicyRequest, - IdentifierList_RolesList, - Rule_Approver, - Trigger_Amount, - ) + from mercoa import IdentifierList_RolesList, Rule_Approver, Trigger_Amount from mercoa.client import Mercoa client = Mercoa( @@ -142,50 +124,25 @@ def create( ) client.entity.approval_policy.create( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=ApprovalPolicyRequest( - trigger=[ - Trigger_Amount( - amount=100.0, - currency="USD", - ) - ], - rule=Rule_Approver( - num_approvers=2, - identifier_list=IdentifierList_RolesList( - value=["Admin", "Controller"] - ), - ), - upstream_policy_id="root", + trigger=[ + Trigger_Amount( + amount=100.0, + currency="USD", + ) + ], + rule=Rule_Approver( + num_approvers=2, + identifier_list=IdentifierList_RolesList(value=["Admin", "Controller"]), ), + upstream_policy_id="root", ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/approval-policy", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/approval-policy" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"trigger": trigger, "rule": rule, "upstreamPolicyId": upstream_policy_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -246,27 +203,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -296,7 +235,9 @@ def update( entity_id: EntityId, policy_id: ApprovalPolicyId, *, - request: ApprovalPolicyUpdateRequest, + trigger: typing.Optional[typing.Sequence[Trigger]] = OMIT, + rule: typing.Optional[Rule] = OMIT, + upstream_policy_id: typing.Optional[ApprovalPolicyId] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ApprovalPolicyResponse: """ @@ -308,7 +249,11 @@ def update( policy_id : ApprovalPolicyId - request : ApprovalPolicyUpdateRequest + trigger : typing.Optional[typing.Sequence[Trigger]] + + rule : typing.Optional[Rule] + + upstream_policy_id : typing.Optional[ApprovalPolicyId] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -319,12 +264,7 @@ def update( Examples -------- - from mercoa import ( - ApprovalPolicyUpdateRequest, - IdentifierList_RolesList, - Rule_Approver, - Trigger_Amount, - ) + from mercoa import IdentifierList_RolesList, Rule_Approver, Trigger_Amount from mercoa.client import Mercoa client = Mercoa( @@ -333,51 +273,25 @@ def update( client.entity.approval_policy.update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", - request=ApprovalPolicyUpdateRequest( - trigger=[ - Trigger_Amount( - amount=100.0, - currency="USD", - ) - ], - rule=Rule_Approver( - num_approvers=2, - identifier_list=IdentifierList_RolesList( - value=["Admin", "Controller"] - ), - ), - upstream_policy_id="root", + trigger=[ + Trigger_Amount( + amount=100.0, + currency="USD", + ) + ], + rule=Rule_Approver( + num_approvers=2, + identifier_list=IdentifierList_RolesList(value=["Admin", "Controller"]), ), + upstream_policy_id="root", ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"trigger": trigger, "rule": rule, "upstreamPolicyId": upstream_policy_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -438,27 +352,9 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -517,26 +413,7 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/approval-policies" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/approval-policies", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -565,7 +442,9 @@ async def create( self, entity_id: EntityId, *, - request: ApprovalPolicyRequest, + trigger: typing.Sequence[Trigger], + rule: Rule, + upstream_policy_id: ApprovalPolicyId, request_options: typing.Optional[RequestOptions] = None, ) -> ApprovalPolicyResponse: """ @@ -575,7 +454,13 @@ async def create( ---------- entity_id : EntityId - request : ApprovalPolicyRequest + trigger : typing.Sequence[Trigger] + List of triggers that will cause this policy to be evaluated. If no triggers are provided, the policy will be evaluated for all invoices. + + rule : Rule + + upstream_policy_id : ApprovalPolicyId + The policy ID of the previous approval policy in the chain of policies. Use 'root' if no upstreamPolicyId is intended to be set. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -586,12 +471,7 @@ async def create( Examples -------- - from mercoa import ( - ApprovalPolicyRequest, - IdentifierList_RolesList, - Rule_Approver, - Trigger_Amount, - ) + from mercoa import IdentifierList_RolesList, Rule_Approver, Trigger_Amount from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -599,50 +479,25 @@ async def create( ) await client.entity.approval_policy.create( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=ApprovalPolicyRequest( - trigger=[ - Trigger_Amount( - amount=100.0, - currency="USD", - ) - ], - rule=Rule_Approver( - num_approvers=2, - identifier_list=IdentifierList_RolesList( - value=["Admin", "Controller"] - ), - ), - upstream_policy_id="root", + trigger=[ + Trigger_Amount( + amount=100.0, + currency="USD", + ) + ], + rule=Rule_Approver( + num_approvers=2, + identifier_list=IdentifierList_RolesList(value=["Admin", "Controller"]), ), + upstream_policy_id="root", ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/approval-policy", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/approval-policy" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"trigger": trigger, "rule": rule, "upstreamPolicyId": upstream_policy_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -703,27 +558,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -753,7 +590,9 @@ async def update( entity_id: EntityId, policy_id: ApprovalPolicyId, *, - request: ApprovalPolicyUpdateRequest, + trigger: typing.Optional[typing.Sequence[Trigger]] = OMIT, + rule: typing.Optional[Rule] = OMIT, + upstream_policy_id: typing.Optional[ApprovalPolicyId] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ApprovalPolicyResponse: """ @@ -765,7 +604,11 @@ async def update( policy_id : ApprovalPolicyId - request : ApprovalPolicyUpdateRequest + trigger : typing.Optional[typing.Sequence[Trigger]] + + rule : typing.Optional[Rule] + + upstream_policy_id : typing.Optional[ApprovalPolicyId] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -776,12 +619,7 @@ async def update( Examples -------- - from mercoa import ( - ApprovalPolicyUpdateRequest, - IdentifierList_RolesList, - Rule_Approver, - Trigger_Amount, - ) + from mercoa import IdentifierList_RolesList, Rule_Approver, Trigger_Amount from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -790,51 +628,25 @@ async def update( await client.entity.approval_policy.update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", - request=ApprovalPolicyUpdateRequest( - trigger=[ - Trigger_Amount( - amount=100.0, - currency="USD", - ) - ], - rule=Rule_Approver( - num_approvers=2, - identifier_list=IdentifierList_RolesList( - value=["Admin", "Controller"] - ), - ), - upstream_policy_id="root", + trigger=[ + Trigger_Amount( + amount=100.0, + currency="USD", + ) + ], + rule=Rule_Approver( + num_approvers=2, + identifier_list=IdentifierList_RolesList(value=["Admin", "Controller"]), ), + upstream_policy_id="root", ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"trigger": trigger, "rule": rule, "upstreamPolicyId": upstream_policy_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -895,27 +707,9 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/entity/client.py b/src/mercoa/entity/client.py index 7937c57..7b64bcd 100644 --- a/src/mercoa/entity/client.py +++ b/src/mercoa/entity/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ..commons.errors.bad_request import BadRequest @@ -15,16 +14,19 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 -from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..entity_types.types.account_type import AccountType from ..entity_types.types.entity_id import EntityId from ..entity_types.types.entity_onboarding_link_type import EntityOnboardingLinkType -from ..entity_types.types.entity_request import EntityRequest from ..entity_types.types.entity_response import EntityResponse from ..entity_types.types.entity_status import EntityStatus -from ..entity_types.types.entity_update_request import EntityUpdateRequest from ..entity_types.types.find_entity_response import FindEntityResponse -from ..entity_types.types.token_generation_options import TokenGenerationOptions +from ..entity_types.types.profile_request import ProfileRequest +from ..entity_types.types.token_generation_entity_options import TokenGenerationEntityOptions +from ..entity_types.types.token_generation_invoice_options import TokenGenerationInvoiceOptions +from ..entity_types.types.token_generation_pages_options import TokenGenerationPagesOptions +from ..entity_types.types.token_generation_style_options import TokenGenerationStyleOptions +from ..entity_types.types.token_generation_vendor_options import TokenGenerationVendorOptions from ..payment_method_types.types.payment_method_id import PaymentMethodId from .approval_policy.client import ApprovalPolicyClient, AsyncApprovalPolicyClient from .counterparty.client import AsyncCounterpartyClient, CounterpartyClient @@ -125,41 +127,20 @@ def find( ) """ _response = self._client_wrapper.httpx_client.request( + "entity", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity"), - params=jsonable_encoder( - remove_none_from_dict( - { - "paymentMethods": payment_methods, - "isCustomer": is_customer, - "foreignId": foreign_id, - "status": status, - "isPayee": is_payee, - "isPayor": is_payor, - "name": name, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "paymentMethods": payment_methods, + "isCustomer": is_customer, + "foreignId": foreign_id, + "status": status, + "isPayee": is_payee, + "isPayor": is_payor, + "name": name, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -185,12 +166,46 @@ def find( raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, *, request: EntityRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + is_customer: bool, + account_type: AccountType, + profile: ProfileRequest, + is_payor: bool, + is_payee: bool, + foreign_id: typing.Optional[str] = OMIT, + email_to: typing.Optional[str] = OMIT, + email_to_alias: typing.Optional[typing.Sequence[str]] = OMIT, + logo: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ Parameters ---------- - request : EntityRequest + is_customer : bool + If this entity has a direct relationship with your organization (e.g your direct customer or client), set this to true. Otherwise, set to false (e.g your customer's vendors). + + account_type : AccountType + + profile : ProfileRequest + + is_payor : bool + If this entity will be paying invoices, set this to true. + + is_payee : bool + If this entity will be receiving payments, set this to true. + + foreign_id : typing.Optional[str] + The ID used to identify this entity in your system. This ID must be unique across all entities in your system. + + email_to : typing.Optional[str] + Sets the email address to which to send invoices to be added to the Invoice Inbox. Only provide the local-part/username of the email address, do not include the @domain.com + + email_to_alias : typing.Optional[typing.Sequence[str]] + Email inbox alias addresses. Used when forwarding emails to the emailTo address from an alias. Include the full email address. + + logo : typing.Optional[str] + Base64 encoded PNG image data for the entity logo. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -205,7 +220,6 @@ def create( Address, BusinessProfileRequest, Ein, - EntityRequest, PhoneNumber, ProfileRequest, TaxId, @@ -216,34 +230,32 @@ def create( token="YOUR_TOKEN", ) client.entity.create( - request=EntityRequest( - is_customer=True, - is_payor=True, - is_payee=False, - account_type="business", - foreign_id="MY-DB-ID-12345", - profile=ProfileRequest( - business=BusinessProfileRequest( - email="customer@acme.com", - legal_business_name="Acme Inc.", - website="http://www.acme.com", - business_type="llc", - phone=PhoneNumber( - country_code="1", - number="4155551234", - ), - address=Address( - address_line_1="123 Main St", - address_line_2="Unit 1", - city="San Francisco", - state_or_province="CA", - postal_code="94105", - country="US", - ), - tax_id=TaxId( - ein=Ein( - number="12-3456789", - ), + is_customer=True, + is_payor=True, + is_payee=False, + account_type="business", + foreign_id="MY-DB-ID-12345", + profile=ProfileRequest( + business=BusinessProfileRequest( + email="customer@acme.com", + legal_business_name="Acme Inc.", + website="http://www.acme.com", + business_type="llc", + phone=PhoneNumber( + country_code="1", + number="4155551234", + ), + address=Address( + address_line_1="123 Main St", + address_line_2="Unit 1", + city="San Francisco", + state_or_province="CA", + postal_code="94105", + country="US", + ), + tax_id=TaxId( + ein=Ein( + number="12-3456789", ), ), ), @@ -251,30 +263,21 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( + "entity", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "foreignId": foreign_id, + "emailTo": email_to, + "emailToAlias": email_to_alias, + "isCustomer": is_customer, + "accountType": account_type, + "profile": profile, + "isPayor": is_payor, + "isPayee": is_payee, + "logo": logo, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -324,26 +327,7 @@ def get(self, entity_id: EntityId, *, request_options: typing.Optional[RequestOp ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -372,7 +356,15 @@ def update( self, entity_id: EntityId, *, - request: EntityUpdateRequest, + foreign_id: typing.Optional[str] = OMIT, + email_to: typing.Optional[str] = OMIT, + email_to_alias: typing.Optional[typing.Sequence[str]] = OMIT, + is_customer: typing.Optional[bool] = OMIT, + account_type: typing.Optional[AccountType] = OMIT, + profile: typing.Optional[ProfileRequest] = OMIT, + is_payor: typing.Optional[bool] = OMIT, + is_payee: typing.Optional[bool] = OMIT, + logo: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ @@ -380,7 +372,30 @@ def update( ---------- entity_id : EntityId - request : EntityUpdateRequest + foreign_id : typing.Optional[str] + The ID used to identify this entity in your system. This ID must be unique across all entities in your system. + + email_to : typing.Optional[str] + Sets the email address to which to send invoices to be added to the Invoice Inbox. Only provide the local-part/username of the email address, do not include the @domain.com + + email_to_alias : typing.Optional[typing.Sequence[str]] + Email inbox alias addresses. Used when forwarding emails to the emailTo address from an alias. Include the full email address. + + is_customer : typing.Optional[bool] + If this entity has a direct relationship with your organization (e.g your direct customer or client), set this to true. Otherwise, set to false (e.g your customer's vendors). + + account_type : typing.Optional[AccountType] + + profile : typing.Optional[ProfileRequest] + + is_payor : typing.Optional[bool] + If this entity will be paying invoices, set this to true. + + is_payee : typing.Optional[bool] + If this entity will be receiving payments, set this to true. + + logo : typing.Optional[str] + Base64 encoded PNG image data for the entity logo. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -395,7 +410,6 @@ def update( Address, BusinessProfileRequest, Ein, - EntityUpdateRequest, PhoneNumber, ProfileRequest, TaxId, @@ -407,34 +421,32 @@ def update( ) client.entity.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=EntityUpdateRequest( - is_customer=True, - is_payor=True, - is_payee=False, - account_type="business", - foreign_id="MY-DB-ID-12345", - profile=ProfileRequest( - business=BusinessProfileRequest( - email="customer@acme.com", - legal_business_name="Acme Inc.", - website="http://www.acme.com", - business_type="llc", - phone=PhoneNumber( - country_code="1", - number="4155551234", - ), - address=Address( - address_line_1="123 Main St", - address_line_2="Unit 1", - city="San Francisco", - state_or_province="CA", - postal_code="94105", - country="US", - ), - tax_id=TaxId( - ein=Ein( - number="12-3456789", - ), + is_customer=True, + is_payor=True, + is_payee=False, + account_type="business", + foreign_id="MY-DB-ID-12345", + profile=ProfileRequest( + business=BusinessProfileRequest( + email="customer@acme.com", + legal_business_name="Acme Inc.", + website="http://www.acme.com", + business_type="llc", + phone=PhoneNumber( + country_code="1", + number="4155551234", + ), + address=Address( + address_line_1="123 Main St", + address_line_2="Unit 1", + city="San Francisco", + state_or_province="CA", + postal_code="94105", + country="US", + ), + tax_id=TaxId( + ein=Ein( + number="12-3456789", ), ), ), @@ -442,32 +454,21 @@ def update( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "foreignId": foreign_id, + "emailTo": email_to, + "emailToAlias": email_to_alias, + "isCustomer": is_customer, + "accountType": account_type, + "profile": profile, + "isPayor": is_payor, + "isPayee": is_payee, + "logo": logo, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -517,26 +518,7 @@ def delete(self, entity_id: EntityId, *, request_options: typing.Optional[Reques ) """ _response = self._client_wrapper.httpx_client.request( - method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}", method="DELETE", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -590,29 +572,7 @@ def accept_terms_of_service( ) """ _response = self._client_wrapper.httpx_client.request( - method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/accept-tos" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/accept-tos", method="POST", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -666,29 +626,7 @@ def initiate_kyb(self, entity_id: EntityId, *, request_options: typing.Optional[ ) """ _response = self._client_wrapper.httpx_client.request( - method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/request-kyb" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/request-kyb", method="POST", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -717,7 +655,12 @@ def get_token( self, entity_id: EntityId, *, - request: TokenGenerationOptions, + expires_in: typing.Optional[str] = OMIT, + invoice: typing.Optional[TokenGenerationInvoiceOptions] = OMIT, + pages: typing.Optional[TokenGenerationPagesOptions] = OMIT, + style: typing.Optional[TokenGenerationStyleOptions] = OMIT, + vendors: typing.Optional[TokenGenerationVendorOptions] = OMIT, + entity: typing.Optional[TokenGenerationEntityOptions] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> str: """ @@ -729,7 +672,18 @@ def get_token( ---------- entity_id : EntityId - request : TokenGenerationOptions + expires_in : typing.Optional[str] + Expressed in seconds or a string describing a time span. The default is 1h. + + invoice : typing.Optional[TokenGenerationInvoiceOptions] + + pages : typing.Optional[TokenGenerationPagesOptions] + + style : typing.Optional[TokenGenerationStyleOptions] + + vendors : typing.Optional[TokenGenerationVendorOptions] + + entity : typing.Optional[TokenGenerationEntityOptions] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -740,7 +694,6 @@ def get_token( Examples -------- - from mercoa import TokenGenerationOptions from mercoa.client import Mercoa client = Mercoa( @@ -748,38 +701,22 @@ def get_token( ) client.entity.get_token( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=TokenGenerationOptions( - expires_in="1h", - ), + expires_in="1h", ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/token", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/token" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "expiresIn": expires_in, + "invoice": invoice, + "pages": pages, + "style": style, + "vendors": vendors, + "entity": entity, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -841,35 +778,10 @@ def plaid_link_token( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/plaidLinkToken", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/plaidLinkToken" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "paymentMethodId": payment_method_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"paymentMethodId": payment_method_id}, + request_options=request_options, ) try: _response_json = _response.json() @@ -940,37 +852,10 @@ def get_onboarding_link( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/onboarding", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/onboarding" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "type": type, - "expiresIn": expires_in, - "connectedEntityId": connected_entity_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"type": type, "expiresIn": expires_in, "connectedEntityId": connected_entity_id}, + request_options=request_options, ) try: _response_json = _response.json() @@ -1042,40 +927,10 @@ def send_onboarding_link( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/onboarding", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/onboarding" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "type": type, - "expiresIn": expires_in, - "connectedEntityId": connected_entity_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"type": type, "expiresIn": expires_in, "connectedEntityId": connected_entity_id}, + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -1184,41 +1039,20 @@ async def find( ) """ _response = await self._client_wrapper.httpx_client.request( + "entity", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity"), - params=jsonable_encoder( - remove_none_from_dict( - { - "paymentMethods": payment_methods, - "isCustomer": is_customer, - "foreignId": foreign_id, - "status": status, - "isPayee": is_payee, - "isPayor": is_payor, - "name": name, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "paymentMethods": payment_methods, + "isCustomer": is_customer, + "foreignId": foreign_id, + "status": status, + "isPayee": is_payee, + "isPayor": is_payor, + "name": name, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -1244,12 +1078,46 @@ async def find( raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, *, request: EntityRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + is_customer: bool, + account_type: AccountType, + profile: ProfileRequest, + is_payor: bool, + is_payee: bool, + foreign_id: typing.Optional[str] = OMIT, + email_to: typing.Optional[str] = OMIT, + email_to_alias: typing.Optional[typing.Sequence[str]] = OMIT, + logo: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ Parameters ---------- - request : EntityRequest + is_customer : bool + If this entity has a direct relationship with your organization (e.g your direct customer or client), set this to true. Otherwise, set to false (e.g your customer's vendors). + + account_type : AccountType + + profile : ProfileRequest + + is_payor : bool + If this entity will be paying invoices, set this to true. + + is_payee : bool + If this entity will be receiving payments, set this to true. + + foreign_id : typing.Optional[str] + The ID used to identify this entity in your system. This ID must be unique across all entities in your system. + + email_to : typing.Optional[str] + Sets the email address to which to send invoices to be added to the Invoice Inbox. Only provide the local-part/username of the email address, do not include the @domain.com + + email_to_alias : typing.Optional[typing.Sequence[str]] + Email inbox alias addresses. Used when forwarding emails to the emailTo address from an alias. Include the full email address. + + logo : typing.Optional[str] + Base64 encoded PNG image data for the entity logo. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1264,7 +1132,6 @@ async def create( Address, BusinessProfileRequest, Ein, - EntityRequest, PhoneNumber, ProfileRequest, TaxId, @@ -1275,34 +1142,32 @@ async def create( token="YOUR_TOKEN", ) await client.entity.create( - request=EntityRequest( - is_customer=True, - is_payor=True, - is_payee=False, - account_type="business", - foreign_id="MY-DB-ID-12345", - profile=ProfileRequest( - business=BusinessProfileRequest( - email="customer@acme.com", - legal_business_name="Acme Inc.", - website="http://www.acme.com", - business_type="llc", - phone=PhoneNumber( - country_code="1", - number="4155551234", - ), - address=Address( - address_line_1="123 Main St", - address_line_2="Unit 1", - city="San Francisco", - state_or_province="CA", - postal_code="94105", - country="US", - ), - tax_id=TaxId( - ein=Ein( - number="12-3456789", - ), + is_customer=True, + is_payor=True, + is_payee=False, + account_type="business", + foreign_id="MY-DB-ID-12345", + profile=ProfileRequest( + business=BusinessProfileRequest( + email="customer@acme.com", + legal_business_name="Acme Inc.", + website="http://www.acme.com", + business_type="llc", + phone=PhoneNumber( + country_code="1", + number="4155551234", + ), + address=Address( + address_line_1="123 Main St", + address_line_2="Unit 1", + city="San Francisco", + state_or_province="CA", + postal_code="94105", + country="US", + ), + tax_id=TaxId( + ein=Ein( + number="12-3456789", ), ), ), @@ -1310,30 +1175,21 @@ async def create( ) """ _response = await self._client_wrapper.httpx_client.request( + "entity", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "foreignId": foreign_id, + "emailTo": email_to, + "emailToAlias": email_to_alias, + "isCustomer": is_customer, + "accountType": account_type, + "profile": profile, + "isPayor": is_payor, + "isPayee": is_payee, + "logo": logo, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -1385,26 +1241,7 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -1433,7 +1270,15 @@ async def update( self, entity_id: EntityId, *, - request: EntityUpdateRequest, + foreign_id: typing.Optional[str] = OMIT, + email_to: typing.Optional[str] = OMIT, + email_to_alias: typing.Optional[typing.Sequence[str]] = OMIT, + is_customer: typing.Optional[bool] = OMIT, + account_type: typing.Optional[AccountType] = OMIT, + profile: typing.Optional[ProfileRequest] = OMIT, + is_payor: typing.Optional[bool] = OMIT, + is_payee: typing.Optional[bool] = OMIT, + logo: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ @@ -1441,7 +1286,30 @@ async def update( ---------- entity_id : EntityId - request : EntityUpdateRequest + foreign_id : typing.Optional[str] + The ID used to identify this entity in your system. This ID must be unique across all entities in your system. + + email_to : typing.Optional[str] + Sets the email address to which to send invoices to be added to the Invoice Inbox. Only provide the local-part/username of the email address, do not include the @domain.com + + email_to_alias : typing.Optional[typing.Sequence[str]] + Email inbox alias addresses. Used when forwarding emails to the emailTo address from an alias. Include the full email address. + + is_customer : typing.Optional[bool] + If this entity has a direct relationship with your organization (e.g your direct customer or client), set this to true. Otherwise, set to false (e.g your customer's vendors). + + account_type : typing.Optional[AccountType] + + profile : typing.Optional[ProfileRequest] + + is_payor : typing.Optional[bool] + If this entity will be paying invoices, set this to true. + + is_payee : typing.Optional[bool] + If this entity will be receiving payments, set this to true. + + logo : typing.Optional[str] + Base64 encoded PNG image data for the entity logo. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1456,7 +1324,6 @@ async def update( Address, BusinessProfileRequest, Ein, - EntityUpdateRequest, PhoneNumber, ProfileRequest, TaxId, @@ -1468,34 +1335,32 @@ async def update( ) await client.entity.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=EntityUpdateRequest( - is_customer=True, - is_payor=True, - is_payee=False, - account_type="business", - foreign_id="MY-DB-ID-12345", - profile=ProfileRequest( - business=BusinessProfileRequest( - email="customer@acme.com", - legal_business_name="Acme Inc.", - website="http://www.acme.com", - business_type="llc", - phone=PhoneNumber( - country_code="1", - number="4155551234", - ), - address=Address( - address_line_1="123 Main St", - address_line_2="Unit 1", - city="San Francisco", - state_or_province="CA", - postal_code="94105", - country="US", - ), - tax_id=TaxId( - ein=Ein( - number="12-3456789", - ), + is_customer=True, + is_payor=True, + is_payee=False, + account_type="business", + foreign_id="MY-DB-ID-12345", + profile=ProfileRequest( + business=BusinessProfileRequest( + email="customer@acme.com", + legal_business_name="Acme Inc.", + website="http://www.acme.com", + business_type="llc", + phone=PhoneNumber( + country_code="1", + number="4155551234", + ), + address=Address( + address_line_1="123 Main St", + address_line_2="Unit 1", + city="San Francisco", + state_or_province="CA", + postal_code="94105", + country="US", + ), + tax_id=TaxId( + ein=Ein( + number="12-3456789", ), ), ), @@ -1503,32 +1368,21 @@ async def update( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "foreignId": foreign_id, + "emailTo": email_to, + "emailToAlias": email_to_alias, + "isCustomer": is_customer, + "accountType": account_type, + "profile": profile, + "isPayor": is_payor, + "isPayee": is_payee, + "logo": logo, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -1578,26 +1432,7 @@ async def delete(self, entity_id: EntityId, *, request_options: typing.Optional[ ) """ _response = await self._client_wrapper.httpx_client.request( - method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}", method="DELETE", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -1651,29 +1486,7 @@ async def accept_terms_of_service( ) """ _response = await self._client_wrapper.httpx_client.request( - method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/accept-tos" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/accept-tos", method="POST", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -1729,29 +1542,7 @@ async def initiate_kyb( ) """ _response = await self._client_wrapper.httpx_client.request( - method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/request-kyb" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/request-kyb", method="POST", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -1780,7 +1571,12 @@ async def get_token( self, entity_id: EntityId, *, - request: TokenGenerationOptions, + expires_in: typing.Optional[str] = OMIT, + invoice: typing.Optional[TokenGenerationInvoiceOptions] = OMIT, + pages: typing.Optional[TokenGenerationPagesOptions] = OMIT, + style: typing.Optional[TokenGenerationStyleOptions] = OMIT, + vendors: typing.Optional[TokenGenerationVendorOptions] = OMIT, + entity: typing.Optional[TokenGenerationEntityOptions] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> str: """ @@ -1792,7 +1588,18 @@ async def get_token( ---------- entity_id : EntityId - request : TokenGenerationOptions + expires_in : typing.Optional[str] + Expressed in seconds or a string describing a time span. The default is 1h. + + invoice : typing.Optional[TokenGenerationInvoiceOptions] + + pages : typing.Optional[TokenGenerationPagesOptions] + + style : typing.Optional[TokenGenerationStyleOptions] + + vendors : typing.Optional[TokenGenerationVendorOptions] + + entity : typing.Optional[TokenGenerationEntityOptions] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1803,7 +1610,6 @@ async def get_token( Examples -------- - from mercoa import TokenGenerationOptions from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -1811,38 +1617,22 @@ async def get_token( ) await client.entity.get_token( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=TokenGenerationOptions( - expires_in="1h", - ), + expires_in="1h", ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/token", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/token" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "expiresIn": expires_in, + "invoice": invoice, + "pages": pages, + "style": style, + "vendors": vendors, + "entity": entity, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -1904,35 +1694,10 @@ async def plaid_link_token( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/plaidLinkToken", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/plaidLinkToken" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "paymentMethodId": payment_method_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"paymentMethodId": payment_method_id}, + request_options=request_options, ) try: _response_json = _response.json() @@ -2003,37 +1768,10 @@ async def get_onboarding_link( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/onboarding", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/onboarding" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "type": type, - "expiresIn": expires_in, - "connectedEntityId": connected_entity_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"type": type, "expiresIn": expires_in, "connectedEntityId": connected_entity_id}, + request_options=request_options, ) try: _response_json = _response.json() @@ -2105,40 +1843,10 @@ async def send_onboarding_link( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/onboarding", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/onboarding" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "type": type, - "expiresIn": expires_in, - "connectedEntityId": connected_entity_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"type": type, "expiresIn": expires_in, "connectedEntityId": connected_entity_id}, + request_options=request_options, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/entity/counterparty/client.py b/src/mercoa/entity/counterparty/client.py index 4ae22dc..6e36a58 100644 --- a/src/mercoa/entity/counterparty/client.py +++ b/src/mercoa/entity/counterparty/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,13 +14,8 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.counterparty_network_type import CounterpartyNetworkType -from ...entity_types.types.entity_add_payees_request import EntityAddPayeesRequest -from ...entity_types.types.entity_add_payors_request import EntityAddPayorsRequest -from ...entity_types.types.entity_hide_payees_request import EntityHidePayeesRequest -from ...entity_types.types.entity_hide_payors_request import EntityHidePayorsRequest from ...entity_types.types.entity_id import EntityId from ...entity_types.types.find_counterparties_response import FindCounterpartiesResponse @@ -98,41 +92,18 @@ def find_payees( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/counterparties/payees", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/counterparties/payees" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "name": name, - "networkType": network_type, - "paymentMethods": payment_methods, - "invoiceMetrics": invoice_metrics, - "counterpartyId": counterparty_id, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "name": name, + "networkType": network_type, + "paymentMethods": payment_methods, + "invoiceMetrics": invoice_metrics, + "counterpartyId": counterparty_id, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -222,41 +193,18 @@ def find_payors( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/counterparties/payors", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/counterparties/payors" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "name": name, - "networkType": network_type, - "paymentMethods": payment_methods, - "invoiceMetrics": invoice_metrics, - "counterpartyId": counterparty_id, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "name": name, + "networkType": network_type, + "paymentMethods": payment_methods, + "invoiceMetrics": invoice_metrics, + "counterpartyId": counterparty_id, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -285,7 +233,7 @@ def add_payees( self, entity_id: EntityId, *, - request: EntityAddPayeesRequest, + payees: typing.Sequence[EntityId], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -295,7 +243,8 @@ def add_payees( ---------- entity_id : EntityId - request : EntityAddPayeesRequest + payees : typing.Sequence[EntityId] + List of payee entity IDs to associate with the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -306,7 +255,6 @@ def add_payees( Examples -------- - from mercoa import EntityAddPayeesRequest from mercoa.client import Mercoa client = Mercoa( @@ -314,38 +262,15 @@ def add_payees( ) client.entity.counterparty.add_payees( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=EntityAddPayeesRequest( - payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ), + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/addPayees", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/addPayees" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"payees": payees}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -374,7 +299,7 @@ def hide_payees( self, entity_id: EntityId, *, - request: EntityHidePayeesRequest, + payees: typing.Sequence[EntityId], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -384,7 +309,8 @@ def hide_payees( ---------- entity_id : EntityId - request : EntityHidePayeesRequest + payees : typing.Sequence[EntityId] + List of payee entity IDs to hide request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -395,7 +321,6 @@ def hide_payees( Examples -------- - from mercoa import EntityHidePayeesRequest from mercoa.client import Mercoa client = Mercoa( @@ -403,38 +328,15 @@ def hide_payees( ) client.entity.counterparty.hide_payees( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=EntityHidePayeesRequest( - payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ), + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/hidePayees", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/hidePayees" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"payees": payees}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -463,7 +365,7 @@ def add_payors( self, entity_id: EntityId, *, - request: EntityAddPayorsRequest, + payors: typing.Sequence[EntityId], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -473,7 +375,8 @@ def add_payors( ---------- entity_id : EntityId - request : EntityAddPayorsRequest + payors : typing.Sequence[EntityId] + List of payor entity IDs to associate with the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -484,7 +387,6 @@ def add_payors( Examples -------- - from mercoa import EntityAddPayorsRequest from mercoa.client import Mercoa client = Mercoa( @@ -492,38 +394,15 @@ def add_payors( ) client.entity.counterparty.add_payors( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=EntityAddPayorsRequest( - payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ), + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/addPayors", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/addPayors" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"payors": payors}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -552,7 +431,7 @@ def hide_payors( self, entity_id: EntityId, *, - request: EntityHidePayorsRequest, + payors: typing.Sequence[EntityId], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -562,7 +441,8 @@ def hide_payors( ---------- entity_id : EntityId - request : EntityHidePayorsRequest + payors : typing.Sequence[EntityId] + List of payor entity IDs to hide request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -573,7 +453,6 @@ def hide_payors( Examples -------- - from mercoa import EntityHidePayorsRequest from mercoa.client import Mercoa client = Mercoa( @@ -581,38 +460,15 @@ def hide_payors( ) client.entity.counterparty.hide_payors( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=EntityHidePayorsRequest( - payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ), + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/hidePayors", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/hidePayors" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"payors": payors}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -707,41 +563,18 @@ async def find_payees( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/counterparties/payees", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/counterparties/payees" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "name": name, - "networkType": network_type, - "paymentMethods": payment_methods, - "invoiceMetrics": invoice_metrics, - "counterpartyId": counterparty_id, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "name": name, + "networkType": network_type, + "paymentMethods": payment_methods, + "invoiceMetrics": invoice_metrics, + "counterpartyId": counterparty_id, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -831,41 +664,18 @@ async def find_payors( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/counterparties/payors", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/counterparties/payors" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "name": name, - "networkType": network_type, - "paymentMethods": payment_methods, - "invoiceMetrics": invoice_metrics, - "counterpartyId": counterparty_id, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "name": name, + "networkType": network_type, + "paymentMethods": payment_methods, + "invoiceMetrics": invoice_metrics, + "counterpartyId": counterparty_id, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -894,7 +704,7 @@ async def add_payees( self, entity_id: EntityId, *, - request: EntityAddPayeesRequest, + payees: typing.Sequence[EntityId], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -904,7 +714,8 @@ async def add_payees( ---------- entity_id : EntityId - request : EntityAddPayeesRequest + payees : typing.Sequence[EntityId] + List of payee entity IDs to associate with the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -915,7 +726,6 @@ async def add_payees( Examples -------- - from mercoa import EntityAddPayeesRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -923,38 +733,15 @@ async def add_payees( ) await client.entity.counterparty.add_payees( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=EntityAddPayeesRequest( - payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ), + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/addPayees", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/addPayees" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"payees": payees}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -983,7 +770,7 @@ async def hide_payees( self, entity_id: EntityId, *, - request: EntityHidePayeesRequest, + payees: typing.Sequence[EntityId], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -993,7 +780,8 @@ async def hide_payees( ---------- entity_id : EntityId - request : EntityHidePayeesRequest + payees : typing.Sequence[EntityId] + List of payee entity IDs to hide request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1004,7 +792,6 @@ async def hide_payees( Examples -------- - from mercoa import EntityHidePayeesRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -1012,38 +799,15 @@ async def hide_payees( ) await client.entity.counterparty.hide_payees( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=EntityHidePayeesRequest( - payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ), + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/hidePayees", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/hidePayees" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"payees": payees}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -1072,7 +836,7 @@ async def add_payors( self, entity_id: EntityId, *, - request: EntityAddPayorsRequest, + payors: typing.Sequence[EntityId], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -1082,7 +846,8 @@ async def add_payors( ---------- entity_id : EntityId - request : EntityAddPayorsRequest + payors : typing.Sequence[EntityId] + List of payor entity IDs to associate with the entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1093,7 +858,6 @@ async def add_payors( Examples -------- - from mercoa import EntityAddPayorsRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -1101,38 +865,15 @@ async def add_payors( ) await client.entity.counterparty.add_payors( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=EntityAddPayorsRequest( - payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ), + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/addPayors", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/addPayors" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"payors": payors}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -1161,7 +902,7 @@ async def hide_payors( self, entity_id: EntityId, *, - request: EntityHidePayorsRequest, + payors: typing.Sequence[EntityId], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -1171,7 +912,8 @@ async def hide_payors( ---------- entity_id : EntityId - request : EntityHidePayorsRequest + payors : typing.Sequence[EntityId] + List of payor entity IDs to hide request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1182,7 +924,6 @@ async def hide_payors( Examples -------- - from mercoa import EntityHidePayorsRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -1190,38 +931,15 @@ async def hide_payors( ) await client.entity.counterparty.hide_payors( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=EntityHidePayorsRequest( - payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ), + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/hidePayors", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/hidePayors" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"payors": payors}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/entity/customization/client.py b/src/mercoa/entity/customization/client.py index 22f0b87..a155c98 100644 --- a/src/mercoa/entity/customization/client.py +++ b/src/mercoa/entity/customization/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,11 +14,11 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions -from ...entity_types.types.entity_customization_request import EntityCustomizationRequest from ...entity_types.types.entity_customization_response import EntityCustomizationResponse from ...entity_types.types.entity_id import EntityId +from ...entity_types.types.metadata_customization_request import MetadataCustomizationRequest +from ...entity_types.types.payment_method_customization_request import PaymentMethodCustomizationRequest # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -58,26 +57,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/customization" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/customization", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -106,7 +86,10 @@ def update( self, entity_id: EntityId, *, - request: EntityCustomizationRequest, + metadata: typing.Sequence[MetadataCustomizationRequest], + payment_source: typing.Sequence[PaymentMethodCustomizationRequest], + backup_disbursement: typing.Sequence[PaymentMethodCustomizationRequest], + payment_destination: typing.Sequence[PaymentMethodCustomizationRequest], request_options: typing.Optional[RequestOptions] = None, ) -> EntityCustomizationResponse: """ @@ -116,7 +99,13 @@ def update( ---------- entity_id : EntityId - request : EntityCustomizationRequest + metadata : typing.Sequence[MetadataCustomizationRequest] + + payment_source : typing.Sequence[PaymentMethodCustomizationRequest] + + backup_disbursement : typing.Sequence[PaymentMethodCustomizationRequest] + + payment_destination : typing.Sequence[PaymentMethodCustomizationRequest] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -128,7 +117,6 @@ def update( Examples -------- from mercoa import ( - EntityCustomizationRequest, MetadataCustomizationRequest, PaymentMethodCustomizationRequest, ) @@ -139,74 +127,56 @@ def update( ) client.entity.customization.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=EntityCustomizationRequest( - metadata=[ - MetadataCustomizationRequest( - key="my_custom_field", - disabled=True, - ), - MetadataCustomizationRequest( - key="my_other_field", - disabled=False, - ), - ], - payment_source=[ - PaymentMethodCustomizationRequest( - type="bankAccount", - disabled=True, - ), - PaymentMethodCustomizationRequest( - type="custom", - schema_id="cpms_7df2974a-4069-454c-912f-7e58ebe030fb", - disabled=True, - ), - ], - backup_disbursement=[ - PaymentMethodCustomizationRequest( - type="check", - disabled=True, - ) - ], - payment_destination=[ - PaymentMethodCustomizationRequest( - type="bankAccount", - disabled=True, - ), - PaymentMethodCustomizationRequest( - type="check", - disabled=True, - ), - ], - ), + metadata=[ + MetadataCustomizationRequest( + key="my_custom_field", + disabled=True, + ), + MetadataCustomizationRequest( + key="my_other_field", + disabled=False, + ), + ], + payment_source=[ + PaymentMethodCustomizationRequest( + type="bankAccount", + disabled=True, + ), + PaymentMethodCustomizationRequest( + type="custom", + schema_id="cpms_7df2974a-4069-454c-912f-7e58ebe030fb", + disabled=True, + ), + ], + backup_disbursement=[ + PaymentMethodCustomizationRequest( + type="check", + disabled=True, + ) + ], + payment_destination=[ + PaymentMethodCustomizationRequest( + type="bankAccount", + disabled=True, + ), + PaymentMethodCustomizationRequest( + type="check", + disabled=True, + ), + ], ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/customization", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/customization" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "metadata": metadata, + "paymentSource": payment_source, + "backupDisbursement": backup_disbursement, + "paymentDestination": payment_destination, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -265,26 +235,7 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/customization" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/customization", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -313,7 +264,10 @@ async def update( self, entity_id: EntityId, *, - request: EntityCustomizationRequest, + metadata: typing.Sequence[MetadataCustomizationRequest], + payment_source: typing.Sequence[PaymentMethodCustomizationRequest], + backup_disbursement: typing.Sequence[PaymentMethodCustomizationRequest], + payment_destination: typing.Sequence[PaymentMethodCustomizationRequest], request_options: typing.Optional[RequestOptions] = None, ) -> EntityCustomizationResponse: """ @@ -323,7 +277,13 @@ async def update( ---------- entity_id : EntityId - request : EntityCustomizationRequest + metadata : typing.Sequence[MetadataCustomizationRequest] + + payment_source : typing.Sequence[PaymentMethodCustomizationRequest] + + backup_disbursement : typing.Sequence[PaymentMethodCustomizationRequest] + + payment_destination : typing.Sequence[PaymentMethodCustomizationRequest] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -335,7 +295,6 @@ async def update( Examples -------- from mercoa import ( - EntityCustomizationRequest, MetadataCustomizationRequest, PaymentMethodCustomizationRequest, ) @@ -346,74 +305,56 @@ async def update( ) await client.entity.customization.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=EntityCustomizationRequest( - metadata=[ - MetadataCustomizationRequest( - key="my_custom_field", - disabled=True, - ), - MetadataCustomizationRequest( - key="my_other_field", - disabled=False, - ), - ], - payment_source=[ - PaymentMethodCustomizationRequest( - type="bankAccount", - disabled=True, - ), - PaymentMethodCustomizationRequest( - type="custom", - schema_id="cpms_7df2974a-4069-454c-912f-7e58ebe030fb", - disabled=True, - ), - ], - backup_disbursement=[ - PaymentMethodCustomizationRequest( - type="check", - disabled=True, - ) - ], - payment_destination=[ - PaymentMethodCustomizationRequest( - type="bankAccount", - disabled=True, - ), - PaymentMethodCustomizationRequest( - type="check", - disabled=True, - ), - ], - ), + metadata=[ + MetadataCustomizationRequest( + key="my_custom_field", + disabled=True, + ), + MetadataCustomizationRequest( + key="my_other_field", + disabled=False, + ), + ], + payment_source=[ + PaymentMethodCustomizationRequest( + type="bankAccount", + disabled=True, + ), + PaymentMethodCustomizationRequest( + type="custom", + schema_id="cpms_7df2974a-4069-454c-912f-7e58ebe030fb", + disabled=True, + ), + ], + backup_disbursement=[ + PaymentMethodCustomizationRequest( + type="check", + disabled=True, + ) + ], + payment_destination=[ + PaymentMethodCustomizationRequest( + type="bankAccount", + disabled=True, + ), + PaymentMethodCustomizationRequest( + type="check", + disabled=True, + ), + ], ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/customization", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/customization" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "metadata": metadata, + "paymentSource": payment_source, + "backupDisbursement": backup_disbursement, + "paymentDestination": payment_destination, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() diff --git a/src/mercoa/entity/email_log/client.py b/src/mercoa/entity/email_log/client.py index 98ca42d..c482ca7 100644 --- a/src/mercoa/entity/email_log/client.py +++ b/src/mercoa/entity/email_log/client.py @@ -2,7 +2,6 @@ import datetime as dt import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -17,7 +16,6 @@ from ...core.datetime_utils import serialize_datetime from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...email_log_types.types.email_log import EmailLog from ...email_log_types.types.email_log_id import EmailLogId @@ -79,39 +77,16 @@ def find( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/emailLogs", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/emailLogs" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "limit": limit, - "startingAfter": starting_after, - "search": search, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "limit": limit, + "startingAfter": starting_after, + "search": search, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -168,27 +143,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/emailLog/{jsonable_encoder(log_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/emailLog/{jsonable_encoder(log_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -268,39 +225,16 @@ async def find( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/emailLogs", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/emailLogs" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "limit": limit, - "startingAfter": starting_after, - "search": search, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "limit": limit, + "startingAfter": starting_after, + "search": search, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -357,27 +291,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/emailLog/{jsonable_encoder(log_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/emailLog/{jsonable_encoder(log_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() diff --git a/src/mercoa/entity/external_accounting_system/client.py b/src/mercoa/entity/external_accounting_system/client.py index dc0cb59..6bb948f 100644 --- a/src/mercoa/entity/external_accounting_system/client.py +++ b/src/mercoa/entity/external_accounting_system/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,7 +14,6 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.entity_id import EntityId from .types.external_accounting_system_company_creation_request import ExternalAccountingSystemCompanyCreationRequest @@ -69,33 +67,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/create", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/create", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -147,27 +123,9 @@ def connect(self, entity_id: EntityId, *, request_options: typing.Optional[Reque ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/connect", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/connect", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -239,38 +197,10 @@ def sync( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/sync", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/sync", - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "vendors": vendors, - "bills": bills, - "glAccounts": gl_accounts, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"vendors": vendors, "bills": bills, "glAccounts": gl_accounts}, + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -339,33 +269,11 @@ async def create( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/create", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/create", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -417,27 +325,9 @@ async def connect(self, entity_id: EntityId, *, request_options: typing.Optional ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/connect", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/connect", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -509,38 +399,10 @@ async def sync( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/sync", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/sync", - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "vendors": vendors, - "bills": bills, - "glAccounts": gl_accounts, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"vendors": vendors, "bills": bills, "glAccounts": gl_accounts}, + request_options=request_options, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/entity/external_accounting_system/types/codat_company_creation_request.py b/src/mercoa/entity/external_accounting_system/types/codat_company_creation_request.py index e19aa91..805b9ff 100644 --- a/src/mercoa/entity/external_accounting_system/types/codat_company_creation_request.py +++ b/src/mercoa/entity/external_accounting_system/types/codat_company_creation_request.py @@ -4,7 +4,7 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class CodatCompanyCreationRequest(pydantic_v1.BaseModel): @@ -18,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity/external_accounting_system/types/codat_company_response.py b/src/mercoa/entity/external_accounting_system/types/codat_company_response.py index 7682cd5..40e933a 100644 --- a/src/mercoa/entity/external_accounting_system/types/codat_company_response.py +++ b/src/mercoa/entity/external_accounting_system/types/codat_company_response.py @@ -4,7 +4,7 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class CodatCompanyResponse(pydantic_v1.BaseModel): @@ -15,8 +15,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity/external_accounting_system/types/external_accounting_system_company_creation_request.py b/src/mercoa/entity/external_accounting_system/types/external_accounting_system_company_creation_request.py index c033c84..adffdad 100644 --- a/src/mercoa/entity/external_accounting_system/types/external_accounting_system_company_creation_request.py +++ b/src/mercoa/entity/external_accounting_system/types/external_accounting_system_company_creation_request.py @@ -2,31 +2,61 @@ from __future__ import annotations +import datetime as dt import typing -from ....core.pydantic_utilities import pydantic_v1 +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class ExternalAccountingSystemCompanyCreationRequest_Codat(pydantic_v1.BaseModel): + company_id: typing.Optional[str] = pydantic_v1.Field(alias="companyId", default=None) type: typing.Literal["codat"] = "codat" - company_id: typing.Optional[str] = pydantic_v1.Field(alias="companyId") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class ExternalAccountingSystemCompanyCreationRequest_Rutter(pydantic_v1.BaseModel): + access_token: typing.Optional[str] = pydantic_v1.Field(alias="accessToken", default=None) type: typing.Literal["rutter"] = "rutter" - access_token: typing.Optional[str] = pydantic_v1.Field(alias="accessToken") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} ExternalAccountingSystemCompanyCreationRequest = typing.Union[ diff --git a/src/mercoa/entity/external_accounting_system/types/external_accounting_system_company_response.py b/src/mercoa/entity/external_accounting_system/types/external_accounting_system_company_response.py index 69bbec3..60e2ccc 100644 --- a/src/mercoa/entity/external_accounting_system/types/external_accounting_system_company_response.py +++ b/src/mercoa/entity/external_accounting_system/types/external_accounting_system_company_response.py @@ -2,31 +2,61 @@ from __future__ import annotations +import datetime as dt import typing -from ....core.pydantic_utilities import pydantic_v1 +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class ExternalAccountingSystemCompanyResponse_Codat(pydantic_v1.BaseModel): - type: typing.Literal["codat"] = "codat" company_id: str = pydantic_v1.Field(alias="companyId") + type: typing.Literal["codat"] = "codat" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class ExternalAccountingSystemCompanyResponse_Rutter(pydantic_v1.BaseModel): - type: typing.Literal["rutter"] = "rutter" access_token: str = pydantic_v1.Field(alias="accessToken") + type: typing.Literal["rutter"] = "rutter" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} ExternalAccountingSystemCompanyResponse = typing.Union[ diff --git a/src/mercoa/entity/external_accounting_system/types/rutter_company_creation_request.py b/src/mercoa/entity/external_accounting_system/types/rutter_company_creation_request.py index 6b77662..89cf9a1 100644 --- a/src/mercoa/entity/external_accounting_system/types/rutter_company_creation_request.py +++ b/src/mercoa/entity/external_accounting_system/types/rutter_company_creation_request.py @@ -4,7 +4,7 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class RutterCompanyCreationRequest(pydantic_v1.BaseModel): @@ -18,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity/external_accounting_system/types/rutter_company_response.py b/src/mercoa/entity/external_accounting_system/types/rutter_company_response.py index ae71e52..96488f5 100644 --- a/src/mercoa/entity/external_accounting_system/types/rutter_company_response.py +++ b/src/mercoa/entity/external_accounting_system/types/rutter_company_response.py @@ -4,7 +4,7 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class RutterCompanyResponse(pydantic_v1.BaseModel): @@ -15,8 +15,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity/invoice/client.py b/src/mercoa/entity/invoice/client.py index 3a3f077..056fbf1 100644 --- a/src/mercoa/entity/invoice/client.py +++ b/src/mercoa/entity/invoice/client.py @@ -2,7 +2,6 @@ import datetime as dt import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -18,7 +17,6 @@ from ...core.datetime_utils import serialize_datetime from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.entity_id import EntityId from ...entity_types.types.entity_user_id import EntityUserId @@ -141,51 +139,28 @@ def find( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/invoices", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/invoices" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "excludePayables": exclude_payables, - "excludeReceivables": exclude_receivables, - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "orderBy": order_by, - "orderDirection": order_direction, - "limit": limit, - "startingAfter": starting_after, - "metadata": jsonable_encoder(metadata), - "search": search, - "payerId": payer_id, - "vendorId": vendor_id, - "approverId": approver_id, - "approverAction": approver_action, - "invoiceId": invoice_id, - "status": status, - "includeFees": include_fees, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "excludePayables": exclude_payables, + "excludeReceivables": exclude_receivables, + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "orderBy": order_by, + "orderDirection": order_direction, + "limit": limit, + "startingAfter": starting_after, + "metadata": jsonable_encoder(metadata), + "search": search, + "payerId": payer_id, + "vendorId": vendor_id, + "approverId": approver_id, + "approverAction": approver_action, + "invoiceId": invoice_id, + "status": status, + "includeFees": include_fees, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -310,52 +285,25 @@ def metrics( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/invoice-metrics", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/invoice-metrics" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "search": search, - "excludePayables": exclude_payables, - "excludeReceivables": exclude_receivables, - "returnByDate": return_by_date, - "payerId": payer_id, - "vendorId": vendor_id, - "approverId": approver_id, - "invoiceId": invoice_id, - "status": status, - "dueDateStart": serialize_datetime(due_date_start) if due_date_start is not None else None, - "dueDateEnd": serialize_datetime(due_date_end) if due_date_end is not None else None, - "createdDateStart": serialize_datetime(created_date_start) - if created_date_start is not None - else None, - "createdDateEnd": serialize_datetime(created_date_end) - if created_date_end is not None - else None, - "currency": currency, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "search": search, + "excludePayables": exclude_payables, + "excludeReceivables": exclude_receivables, + "returnByDate": return_by_date, + "payerId": payer_id, + "vendorId": vendor_id, + "approverId": approver_id, + "invoiceId": invoice_id, + "status": status, + "dueDateStart": serialize_datetime(due_date_start) if due_date_start is not None else None, + "dueDateEnd": serialize_datetime(due_date_end) if due_date_end is not None else None, + "createdDateStart": serialize_datetime(created_date_start) if created_date_start is not None else None, + "createdDateEnd": serialize_datetime(created_date_end) if created_date_end is not None else None, + "currency": currency, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -489,51 +437,28 @@ async def find( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/invoices", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/invoices" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "excludePayables": exclude_payables, - "excludeReceivables": exclude_receivables, - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "orderBy": order_by, - "orderDirection": order_direction, - "limit": limit, - "startingAfter": starting_after, - "metadata": jsonable_encoder(metadata), - "search": search, - "payerId": payer_id, - "vendorId": vendor_id, - "approverId": approver_id, - "approverAction": approver_action, - "invoiceId": invoice_id, - "status": status, - "includeFees": include_fees, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "excludePayables": exclude_payables, + "excludeReceivables": exclude_receivables, + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "orderBy": order_by, + "orderDirection": order_direction, + "limit": limit, + "startingAfter": starting_after, + "metadata": jsonable_encoder(metadata), + "search": search, + "payerId": payer_id, + "vendorId": vendor_id, + "approverId": approver_id, + "approverAction": approver_action, + "invoiceId": invoice_id, + "status": status, + "includeFees": include_fees, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -658,52 +583,25 @@ async def metrics( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/invoice-metrics", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/invoice-metrics" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "search": search, - "excludePayables": exclude_payables, - "excludeReceivables": exclude_receivables, - "returnByDate": return_by_date, - "payerId": payer_id, - "vendorId": vendor_id, - "approverId": approver_id, - "invoiceId": invoice_id, - "status": status, - "dueDateStart": serialize_datetime(due_date_start) if due_date_start is not None else None, - "dueDateEnd": serialize_datetime(due_date_end) if due_date_end is not None else None, - "createdDateStart": serialize_datetime(created_date_start) - if created_date_start is not None - else None, - "createdDateEnd": serialize_datetime(created_date_end) - if created_date_end is not None - else None, - "currency": currency, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "search": search, + "excludePayables": exclude_payables, + "excludeReceivables": exclude_receivables, + "returnByDate": return_by_date, + "payerId": payer_id, + "vendorId": vendor_id, + "approverId": approver_id, + "invoiceId": invoice_id, + "status": status, + "dueDateStart": serialize_datetime(due_date_start) if due_date_start is not None else None, + "dueDateEnd": serialize_datetime(due_date_end) if due_date_end is not None else None, + "createdDateStart": serialize_datetime(created_date_start) if created_date_start is not None else None, + "createdDateEnd": serialize_datetime(created_date_end) if created_date_end is not None else None, + "currency": currency, + }, + request_options=request_options, ) try: _response_json = _response.json() diff --git a/src/mercoa/entity/metadata/client.py b/src/mercoa/entity/metadata/client.py index 295dee0..e3235df 100644 --- a/src/mercoa/entity/metadata/client.py +++ b/src/mercoa/entity/metadata/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,7 +14,6 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.entity_id import EntityId from ...entity_types.types.entity_metadata_response import EntityMetadataResponse @@ -57,26 +55,7 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/metadata" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/metadata", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -133,27 +112,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -221,33 +182,11 @@ def update( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -302,27 +241,9 @@ def delete(self, entity_id: EntityId, key: str, *, request_options: typing.Optio ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -381,26 +302,7 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/metadata" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/metadata", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -457,27 +359,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -545,33 +429,11 @@ async def update( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -628,27 +490,9 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/entity/notification_policy/client.py b/src/mercoa/entity/notification_policy/client.py index b8b6b1a..19a3871 100644 --- a/src/mercoa/entity/notification_policy/client.py +++ b/src/mercoa/entity/notification_policy/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,10 +14,8 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.entity_id import EntityId -from ...entity_types.types.notification_policy_request import NotificationPolicyRequest from ...entity_types.types.notification_policy_response import NotificationPolicyResponse from ...entity_types.types.notification_type import NotificationType @@ -59,26 +56,7 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/notification-policies" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/notification-policies", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -139,27 +117,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -189,7 +149,8 @@ def update( entity_id: EntityId, notification_type: NotificationType, *, - request: NotificationPolicyRequest, + additional_roles: typing.Sequence[str], + disabled: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> NotificationPolicyResponse: """ @@ -201,7 +162,11 @@ def update( notification_type : NotificationType - request : NotificationPolicyRequest + additional_roles : typing.Sequence[str] + List of user roles that should receive notifications in addition to the default users for this notification type + + disabled : typing.Optional[bool] + Set to true if the selected notification type should be disabled for this entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -212,7 +177,6 @@ def update( Examples -------- - from mercoa import NotificationPolicyRequest from mercoa.client import Mercoa client = Mercoa( @@ -221,40 +185,16 @@ def update( client.entity.notification_policy.update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", notification_type="INVOICE_APPROVAL_NEEDED", - request=NotificationPolicyRequest( - disabled=False, - additional_roles=["admin", "approver"], - ), + disabled=False, + additional_roles=["admin", "approver"], ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"disabled": disabled, "additionalRoles": additional_roles}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -313,26 +253,7 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/notification-policies" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/notification-policies", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -393,27 +314,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -443,7 +346,8 @@ async def update( entity_id: EntityId, notification_type: NotificationType, *, - request: NotificationPolicyRequest, + additional_roles: typing.Sequence[str], + disabled: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> NotificationPolicyResponse: """ @@ -455,7 +359,11 @@ async def update( notification_type : NotificationType - request : NotificationPolicyRequest + additional_roles : typing.Sequence[str] + List of user roles that should receive notifications in addition to the default users for this notification type + + disabled : typing.Optional[bool] + Set to true if the selected notification type should be disabled for this entity request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -466,7 +374,6 @@ async def update( Examples -------- - from mercoa import NotificationPolicyRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -475,40 +382,16 @@ async def update( await client.entity.notification_policy.update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", notification_type="INVOICE_APPROVAL_NEEDED", - request=NotificationPolicyRequest( - disabled=False, - additional_roles=["admin", "approver"], - ), + disabled=False, + additional_roles=["admin", "approver"], ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"disabled": disabled, "additionalRoles": additional_roles}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() diff --git a/src/mercoa/entity/payment_method/client.py b/src/mercoa/entity/payment_method/client.py index ee3a00e..e32ef87 100644 --- a/src/mercoa/entity/payment_method/client.py +++ b/src/mercoa/entity/payment_method/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,7 +14,6 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.entity_id import EntityId from ...payment_method_types.types.payment_method_balance_response import PaymentMethodBalanceResponse @@ -67,35 +65,10 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethods", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/paymentMethods" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "type": type, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"type": type}, + request_options=request_options, ) try: _response_json = _response.json() @@ -159,32 +132,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/paymentMethod" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -243,27 +195,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -332,33 +266,11 @@ def update( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -419,27 +331,9 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -500,30 +394,9 @@ def initiate_micro_deposits( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -589,33 +462,11 @@ def complete_micro_deposits( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder({"amounts": amounts}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"amounts": amounts}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"amounts": amounts}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -676,27 +527,9 @@ def get_balance( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/balance", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/balance", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -760,35 +593,10 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethods", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/paymentMethods" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "type": type, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"type": type}, + request_options=request_options, ) try: _response_json = _response.json() @@ -852,32 +660,11 @@ async def create( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/paymentMethod" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -936,27 +723,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -1025,33 +794,11 @@ async def update( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -1112,27 +859,9 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -1193,30 +922,9 @@ async def initiate_micro_deposits( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -1282,33 +990,11 @@ async def complete_micro_deposits( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder({"amounts": amounts}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"amounts": amounts}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"amounts": amounts}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -1369,27 +1055,9 @@ async def get_balance( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/balance", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/balance", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() diff --git a/src/mercoa/entity/representative/client.py b/src/mercoa/entity/representative/client.py index 0c28b51..9a30319 100644 --- a/src/mercoa/entity/representative/client.py +++ b/src/mercoa/entity/representative/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -11,16 +10,20 @@ from ...commons.errors.not_found import NotFound from ...commons.errors.unauthorized import Unauthorized from ...commons.errors.unimplemented import Unimplemented +from ...commons.types.address import Address +from ...commons.types.birth_date import BirthDate +from ...commons.types.full_name import FullName +from ...commons.types.individual_government_id import IndividualGovernmentId +from ...commons.types.phone_number import PhoneNumber from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.entity_id import EntityId from ...entity_types.types.representative_id import RepresentativeId -from ...entity_types.types.representative_request import RepresentativeRequest from ...entity_types.types.representative_response import RepresentativeResponse +from ...entity_types.types.responsibilities import Responsibilities # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -59,26 +62,7 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/representatives" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/representatives", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -107,7 +91,13 @@ def create( self, entity_id: EntityId, *, - request: RepresentativeRequest, + name: FullName, + phone: PhoneNumber, + email: str, + address: Address, + birth_date: BirthDate, + government_id: IndividualGovernmentId, + responsibilities: Responsibilities, request_options: typing.Optional[RequestOptions] = None, ) -> RepresentativeResponse: """ @@ -115,7 +105,19 @@ def create( ---------- entity_id : EntityId - request : RepresentativeRequest + name : FullName + + phone : PhoneNumber + + email : str + + address : Address + + birth_date : BirthDate + + government_id : IndividualGovernmentId + + responsibilities : Responsibilities request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -132,7 +134,6 @@ def create( FullName, IndividualGovernmentId, PhoneNumber, - RepresentativeRequest, Responsibilities, ) from mercoa.client import Mercoa @@ -142,69 +143,54 @@ def create( ) client.entity.representative.create( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=RepresentativeRequest( - name=FullName( - first_name="John", - middle_name="Quincy", - last_name="Adams", - suffix="Jr.", - ), - phone=PhoneNumber( - country_code="1", - number="4155551234", - ), - email="john.doe@acme.com", - address=Address( - address_line_1="123 Main St", - address_line_2="Unit 1", - city="San Francisco", - state_or_province="CA", - postal_code="94105", - country="US", - ), - birth_date=BirthDate( - day="1", - month="1", - year="1980", - ), - government_id=IndividualGovernmentId( - ssn="123-45-6789", - ), - responsibilities=Responsibilities( - is_owner=True, - ownership_percentage=40, - is_controller=True, - ), + name=FullName( + first_name="John", + middle_name="Quincy", + last_name="Adams", + suffix="Jr.", + ), + phone=PhoneNumber( + country_code="1", + number="4155551234", + ), + email="john.doe@acme.com", + address=Address( + address_line_1="123 Main St", + address_line_2="Unit 1", + city="San Francisco", + state_or_province="CA", + postal_code="94105", + country="US", + ), + birth_date=BirthDate( + day="1", + month="1", + year="1980", + ), + government_id=IndividualGovernmentId( + ssn="123-45-6789", + ), + responsibilities=Responsibilities( + is_owner=True, + ownership_percentage=40, + is_controller=True, ), ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/representative", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/representative" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "phone": phone, + "email": email, + "address": address, + "birthDate": birth_date, + "governmentID": government_id, + "responsibilities": responsibilities, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -263,27 +249,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -342,27 +310,9 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -421,26 +371,7 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/representatives" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/representatives", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -469,7 +400,13 @@ async def create( self, entity_id: EntityId, *, - request: RepresentativeRequest, + name: FullName, + phone: PhoneNumber, + email: str, + address: Address, + birth_date: BirthDate, + government_id: IndividualGovernmentId, + responsibilities: Responsibilities, request_options: typing.Optional[RequestOptions] = None, ) -> RepresentativeResponse: """ @@ -477,7 +414,19 @@ async def create( ---------- entity_id : EntityId - request : RepresentativeRequest + name : FullName + + phone : PhoneNumber + + email : str + + address : Address + + birth_date : BirthDate + + government_id : IndividualGovernmentId + + responsibilities : Responsibilities request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -494,7 +443,6 @@ async def create( FullName, IndividualGovernmentId, PhoneNumber, - RepresentativeRequest, Responsibilities, ) from mercoa.client import AsyncMercoa @@ -504,69 +452,54 @@ async def create( ) await client.entity.representative.create( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=RepresentativeRequest( - name=FullName( - first_name="John", - middle_name="Quincy", - last_name="Adams", - suffix="Jr.", - ), - phone=PhoneNumber( - country_code="1", - number="4155551234", - ), - email="john.doe@acme.com", - address=Address( - address_line_1="123 Main St", - address_line_2="Unit 1", - city="San Francisco", - state_or_province="CA", - postal_code="94105", - country="US", - ), - birth_date=BirthDate( - day="1", - month="1", - year="1980", - ), - government_id=IndividualGovernmentId( - ssn="123-45-6789", - ), - responsibilities=Responsibilities( - is_owner=True, - ownership_percentage=40, - is_controller=True, - ), + name=FullName( + first_name="John", + middle_name="Quincy", + last_name="Adams", + suffix="Jr.", + ), + phone=PhoneNumber( + country_code="1", + number="4155551234", + ), + email="john.doe@acme.com", + address=Address( + address_line_1="123 Main St", + address_line_2="Unit 1", + city="San Francisco", + state_or_province="CA", + postal_code="94105", + country="US", + ), + birth_date=BirthDate( + day="1", + month="1", + year="1980", + ), + government_id=IndividualGovernmentId( + ssn="123-45-6789", + ), + responsibilities=Responsibilities( + is_owner=True, + ownership_percentage=40, + is_controller=True, ), ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/representative", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/representative" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "phone": phone, + "email": email, + "address": address, + "birthDate": birth_date, + "governmentID": government_id, + "responsibilities": responsibilities, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -625,27 +558,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -704,27 +619,9 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/entity/user/client.py b/src/mercoa/entity/user/client.py index f1fd9d9..47c6119 100644 --- a/src/mercoa/entity/user/client.py +++ b/src/mercoa/entity/user/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,14 +14,16 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.entity_id import EntityId from ...entity_types.types.entity_user_id import EntityUserId -from ...entity_types.types.entity_user_request import EntityUserRequest from ...entity_types.types.entity_user_response import EntityUserResponse from ...entity_types.types.find_entity_user_response import FindEntityUserResponse -from ...entity_types.types.token_generation_options import TokenGenerationOptions +from ...entity_types.types.token_generation_entity_options import TokenGenerationEntityOptions +from ...entity_types.types.token_generation_invoice_options import TokenGenerationInvoiceOptions +from ...entity_types.types.token_generation_pages_options import TokenGenerationPagesOptions +from ...entity_types.types.token_generation_style_options import TokenGenerationStyleOptions +from ...entity_types.types.token_generation_vendor_options import TokenGenerationVendorOptions from .notification_policy.client import AsyncNotificationPolicyClient, NotificationPolicyClient from .notifications.client import AsyncNotificationsClient, NotificationsClient @@ -40,7 +41,7 @@ def get_all( self, entity_id: EntityId, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.List[EntityUserResponse]: """ - Get all entity users + Get all entity users (DEPRECATED, use Search Entity Users) Parameters ---------- @@ -65,26 +66,7 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/users" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/users", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -122,7 +104,7 @@ def find( request_options: typing.Optional[RequestOptions] = None, ) -> FindEntityUserResponse: """ - Get all entity users + Search entity users Parameters ---------- @@ -166,43 +148,17 @@ def find( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/users", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/users" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "foreignId": foreign_id, - "role": role, - "name": name, - "email": email, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "foreignId": foreign_id, + "role": role, + "name": name, + "email": email, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -231,7 +187,10 @@ def create( self, entity_id: EntityId, *, - request: EntityUserRequest, + foreign_id: typing.Optional[str] = OMIT, + email: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + roles: typing.Optional[typing.Sequence[str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ @@ -239,7 +198,15 @@ def create( ---------- entity_id : EntityId - request : EntityUserRequest + foreign_id : typing.Optional[str] + The ID used to identify this user in your system. + + email : typing.Optional[str] + + name : typing.Optional[str] + + roles : typing.Optional[typing.Sequence[str]] + List of roles. A role can be any string. For example: "payer", "approver", "viewer" request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -250,7 +217,6 @@ def create( Examples -------- - from mercoa import EntityUserRequest from mercoa.client import Mercoa client = Mercoa( @@ -258,41 +224,18 @@ def create( ) client.entity.user.create( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=EntityUserRequest( - foreign_id="MY-DB-ID-12345", - email="john.doe@acme.com", - name="John Doe", - roles=["admin", "approver"], - ), + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/user" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"foreignId": foreign_id, "email": email, "name": name, "roles": roles}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -349,27 +292,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -399,7 +324,10 @@ def update( entity_id: EntityId, user_id: EntityUserId, *, - request: EntityUserRequest, + foreign_id: typing.Optional[str] = OMIT, + email: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + roles: typing.Optional[typing.Sequence[str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ @@ -411,7 +339,15 @@ def update( user_id : EntityUserId - request : EntityUserRequest + foreign_id : typing.Optional[str] + The ID used to identify this user in your system. + + email : typing.Optional[str] + + name : typing.Optional[str] + + roles : typing.Optional[typing.Sequence[str]] + List of roles. A role can be any string. For example: "payer", "approver", "viewer" request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -422,7 +358,6 @@ def update( Examples -------- - from mercoa import EntityUserRequest from mercoa.client import Mercoa client = Mercoa( @@ -431,42 +366,18 @@ def update( client.entity.user.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", user_id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", - request=EntityUserRequest( - foreign_id="MY-DB-ID-12345", - email="john.doe@acme.com", - name="John Doe", - roles=["admin", "approver"], - ), + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"foreignId": foreign_id, "email": email, "name": name, "roles": roles}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -523,27 +434,9 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -573,7 +466,12 @@ def get_token( entity_id: EntityId, user_id: EntityUserId, *, - request: TokenGenerationOptions, + expires_in: typing.Optional[str] = OMIT, + invoice: typing.Optional[TokenGenerationInvoiceOptions] = OMIT, + pages: typing.Optional[TokenGenerationPagesOptions] = OMIT, + style: typing.Optional[TokenGenerationStyleOptions] = OMIT, + vendors: typing.Optional[TokenGenerationVendorOptions] = OMIT, + entity: typing.Optional[TokenGenerationEntityOptions] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> str: """ @@ -585,7 +483,18 @@ def get_token( user_id : EntityUserId - request : TokenGenerationOptions + expires_in : typing.Optional[str] + Expressed in seconds or a string describing a time span. The default is 1h. + + invoice : typing.Optional[TokenGenerationInvoiceOptions] + + pages : typing.Optional[TokenGenerationPagesOptions] + + style : typing.Optional[TokenGenerationStyleOptions] + + vendors : typing.Optional[TokenGenerationVendorOptions] + + entity : typing.Optional[TokenGenerationEntityOptions] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -596,7 +505,6 @@ def get_token( Examples -------- - from mercoa import TokenGenerationOptions from mercoa.client import Mercoa client = Mercoa( @@ -605,39 +513,22 @@ def get_token( client.entity.user.get_token( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", user_id="user_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=TokenGenerationOptions( - expires_in="1h", - ), + expires_in="1h", ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/token", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/token", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "expiresIn": expires_in, + "invoice": invoice, + "pages": pages, + "style": style, + "vendors": vendors, + "entity": entity, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -673,7 +564,7 @@ async def get_all( self, entity_id: EntityId, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.List[EntityUserResponse]: """ - Get all entity users + Get all entity users (DEPRECATED, use Search Entity Users) Parameters ---------- @@ -698,26 +589,7 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/users" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"entity/{jsonable_encoder(entity_id)}/users", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -755,7 +627,7 @@ async def find( request_options: typing.Optional[RequestOptions] = None, ) -> FindEntityUserResponse: """ - Get all entity users + Search entity users Parameters ---------- @@ -799,43 +671,17 @@ async def find( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/users", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/users" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "foreignId": foreign_id, - "role": role, - "name": name, - "email": email, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "foreignId": foreign_id, + "role": role, + "name": name, + "email": email, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -864,7 +710,10 @@ async def create( self, entity_id: EntityId, *, - request: EntityUserRequest, + foreign_id: typing.Optional[str] = OMIT, + email: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + roles: typing.Optional[typing.Sequence[str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ @@ -872,7 +721,15 @@ async def create( ---------- entity_id : EntityId - request : EntityUserRequest + foreign_id : typing.Optional[str] + The ID used to identify this user in your system. + + email : typing.Optional[str] + + name : typing.Optional[str] + + roles : typing.Optional[typing.Sequence[str]] + List of roles. A role can be any string. For example: "payer", "approver", "viewer" request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -883,7 +740,6 @@ async def create( Examples -------- - from mercoa import EntityUserRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -891,41 +747,18 @@ async def create( ) await client.entity.user.create( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=EntityUserRequest( - foreign_id="MY-DB-ID-12345", - email="john.doe@acme.com", - name="John Doe", - roles=["admin", "approver"], - ), + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"entity/{jsonable_encoder(entity_id)}/user" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"foreignId": foreign_id, "email": email, "name": name, "roles": roles}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -982,27 +815,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -1032,7 +847,10 @@ async def update( entity_id: EntityId, user_id: EntityUserId, *, - request: EntityUserRequest, + foreign_id: typing.Optional[str] = OMIT, + email: typing.Optional[str] = OMIT, + name: typing.Optional[str] = OMIT, + roles: typing.Optional[typing.Sequence[str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ @@ -1044,7 +862,15 @@ async def update( user_id : EntityUserId - request : EntityUserRequest + foreign_id : typing.Optional[str] + The ID used to identify this user in your system. + + email : typing.Optional[str] + + name : typing.Optional[str] + + roles : typing.Optional[typing.Sequence[str]] + List of roles. A role can be any string. For example: "payer", "approver", "viewer" request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1055,7 +881,6 @@ async def update( Examples -------- - from mercoa import EntityUserRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -1064,42 +889,18 @@ async def update( await client.entity.user.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", user_id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", - request=EntityUserRequest( - foreign_id="MY-DB-ID-12345", - email="john.doe@acme.com", - name="John Doe", - roles=["admin", "approver"], - ), + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"foreignId": foreign_id, "email": email, "name": name, "roles": roles}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -1156,27 +957,9 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -1206,7 +989,12 @@ async def get_token( entity_id: EntityId, user_id: EntityUserId, *, - request: TokenGenerationOptions, + expires_in: typing.Optional[str] = OMIT, + invoice: typing.Optional[TokenGenerationInvoiceOptions] = OMIT, + pages: typing.Optional[TokenGenerationPagesOptions] = OMIT, + style: typing.Optional[TokenGenerationStyleOptions] = OMIT, + vendors: typing.Optional[TokenGenerationVendorOptions] = OMIT, + entity: typing.Optional[TokenGenerationEntityOptions] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> str: """ @@ -1218,7 +1006,18 @@ async def get_token( user_id : EntityUserId - request : TokenGenerationOptions + expires_in : typing.Optional[str] + Expressed in seconds or a string describing a time span. The default is 1h. + + invoice : typing.Optional[TokenGenerationInvoiceOptions] + + pages : typing.Optional[TokenGenerationPagesOptions] + + style : typing.Optional[TokenGenerationStyleOptions] + + vendors : typing.Optional[TokenGenerationVendorOptions] + + entity : typing.Optional[TokenGenerationEntityOptions] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1229,7 +1028,6 @@ async def get_token( Examples -------- - from mercoa import TokenGenerationOptions from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -1238,39 +1036,22 @@ async def get_token( await client.entity.user.get_token( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", user_id="user_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - request=TokenGenerationOptions( - expires_in="1h", - ), + expires_in="1h", ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/token", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/token", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "expiresIn": expires_in, + "invoice": invoice, + "pages": pages, + "style": style, + "vendors": vendors, + "entity": entity, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() diff --git a/src/mercoa/entity/user/notification_policy/client.py b/src/mercoa/entity/user/notification_policy/client.py index c134462..ce75d81 100644 --- a/src/mercoa/entity/user/notification_policy/client.py +++ b/src/mercoa/entity/user/notification_policy/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ....commons.errors.bad_request import BadRequest @@ -15,12 +14,10 @@ from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ....core.jsonable_encoder import jsonable_encoder from ....core.pydantic_utilities import pydantic_v1 -from ....core.remove_none_from_dict import remove_none_from_dict from ....core.request_options import RequestOptions from ....entity_types.types.entity_id import EntityId from ....entity_types.types.entity_user_id import EntityUserId from ....entity_types.types.notification_type import NotificationType -from ....entity_types.types.user_notification_policy_request import UserNotificationPolicyRequest from ....entity_types.types.user_notification_policy_response import UserNotificationPolicyResponse # this is used as the default value for optional parameters @@ -63,27 +60,9 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policies", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policies", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -148,27 +127,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policy/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -199,7 +160,9 @@ def update( user_id: EntityUserId, notification_type: NotificationType, *, - request: UserNotificationPolicyRequest, + disabled: typing.Optional[bool] = OMIT, + digest: typing.Optional[bool] = OMIT, + immediate: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UserNotificationPolicyResponse: """ @@ -213,7 +176,14 @@ def update( notification_type : NotificationType - request : UserNotificationPolicyRequest + disabled : typing.Optional[bool] + Set to true if the selected notification type should be disabled for this user + + digest : typing.Optional[bool] + Set to true if the selected notification type should be sent as a digest. Default is false. + + immediate : typing.Optional[bool] + Set to true if the selected notification type should be sent immediately. Default is true. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -224,7 +194,6 @@ def update( Examples -------- - from mercoa import UserNotificationPolicyRequest from mercoa.client import Mercoa client = Mercoa( @@ -234,39 +203,15 @@ def update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", notification_type="INVOICE_APPROVED", - request=UserNotificationPolicyRequest( - disabled=True, - ), + disabled=True, ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policy/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"disabled": disabled, "digest": digest, "immediate": immediate}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -328,27 +273,9 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policies", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policies", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -413,27 +340,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policy/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -464,7 +373,9 @@ async def update( user_id: EntityUserId, notification_type: NotificationType, *, - request: UserNotificationPolicyRequest, + disabled: typing.Optional[bool] = OMIT, + digest: typing.Optional[bool] = OMIT, + immediate: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UserNotificationPolicyResponse: """ @@ -478,7 +389,14 @@ async def update( notification_type : NotificationType - request : UserNotificationPolicyRequest + disabled : typing.Optional[bool] + Set to true if the selected notification type should be disabled for this user + + digest : typing.Optional[bool] + Set to true if the selected notification type should be sent as a digest. Default is false. + + immediate : typing.Optional[bool] + Set to true if the selected notification type should be sent immediately. Default is true. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -489,7 +407,6 @@ async def update( Examples -------- - from mercoa import UserNotificationPolicyRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -499,39 +416,15 @@ async def update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", notification_type="INVOICE_APPROVED", - request=UserNotificationPolicyRequest( - disabled=True, - ), + disabled=True, ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policy/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"disabled": disabled, "digest": digest, "immediate": immediate}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() diff --git a/src/mercoa/entity/user/notifications/client.py b/src/mercoa/entity/user/notifications/client.py index b9be872..b43f520 100644 --- a/src/mercoa/entity/user/notifications/client.py +++ b/src/mercoa/entity/user/notifications/client.py @@ -2,7 +2,6 @@ import datetime as dt import typing -import urllib.parse from json.decoder import JSONDecodeError from ....commons.errors.bad_request import BadRequest @@ -18,7 +17,6 @@ from ....core.datetime_utils import serialize_datetime from ....core.jsonable_encoder import jsonable_encoder from ....core.pydantic_utilities import pydantic_v1 -from ....core.remove_none_from_dict import remove_none_from_dict from ....core.request_options import RequestOptions from ....entity_types.types.entity_id import EntityId from ....entity_types.types.entity_user_id import EntityUserId @@ -90,41 +88,17 @@ def find( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notifications", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notifications", - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "orderDirection": order_direction, - "limit": limit, - "startingAfter": starting_after, - "notificationType": notification_type, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "orderDirection": order_direction, + "limit": limit, + "startingAfter": starting_after, + "notificationType": notification_type, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -187,27 +161,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification/{jsonable_encoder(notification_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification/{jsonable_encoder(notification_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -295,41 +251,17 @@ async def find( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notifications", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notifications", - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "orderDirection": order_direction, - "limit": limit, - "startingAfter": starting_after, - "notificationType": notification_type, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "orderDirection": order_direction, + "limit": limit, + "startingAfter": starting_after, + "notificationType": notification_type, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -392,27 +324,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification/{jsonable_encoder(notification_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification/{jsonable_encoder(notification_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() diff --git a/src/mercoa/entity_types/types/amount_trigger.py b/src/mercoa/entity_types/types/amount_trigger.py index 831f311..24ea367 100644 --- a/src/mercoa/entity_types/types/amount_trigger.py +++ b/src/mercoa/entity_types/types/amount_trigger.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.currency_code import CurrencyCode @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/approval_policy_request.py b/src/mercoa/entity_types/types/approval_policy_request.py index d266355..06ba9a1 100644 --- a/src/mercoa/entity_types/types/approval_policy_request.py +++ b/src/mercoa/entity_types/types/approval_policy_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .approval_policy_id import ApprovalPolicyId from .rule import Rule from .trigger import Trigger @@ -52,8 +52,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/approval_policy_response.py b/src/mercoa/entity_types/types/approval_policy_response.py index b98803b..75a0c90 100644 --- a/src/mercoa/entity_types/types/approval_policy_response.py +++ b/src/mercoa/entity_types/types/approval_policy_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .approval_policy_id import ApprovalPolicyId from .rule import Rule from .trigger import Trigger @@ -47,8 +47,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/approval_policy_update_request.py b/src/mercoa/entity_types/types/approval_policy_update_request.py index 9f3760f..3cb73a7 100644 --- a/src/mercoa/entity_types/types/approval_policy_update_request.py +++ b/src/mercoa/entity_types/types/approval_policy_update_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .approval_policy_id import ApprovalPolicyId from .rule import Rule from .trigger import Trigger @@ -45,8 +45,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/approver_rule.py b/src/mercoa/entity_types/types/approver_rule.py index a3d5d10..f741cbf 100644 --- a/src/mercoa/entity_types/types/approver_rule.py +++ b/src/mercoa/entity_types/types/approver_rule.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .identifier_list import IdentifierList @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/business_profile_request.py b/src/mercoa/entity_types/types/business_profile_request.py index 891f6e8..513a3a7 100644 --- a/src/mercoa/entity_types/types/business_profile_request.py +++ b/src/mercoa/entity_types/types/business_profile_request.py @@ -6,7 +6,7 @@ from ...commons.types.address import Address from ...commons.types.phone_number import PhoneNumber from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .business_type import BusinessType from .tax_id import TaxId @@ -85,8 +85,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/business_profile_response.py b/src/mercoa/entity_types/types/business_profile_response.py index b30cc15..4fd41fe 100644 --- a/src/mercoa/entity_types/types/business_profile_response.py +++ b/src/mercoa/entity_types/types/business_profile_response.py @@ -6,7 +6,7 @@ from ...commons.types.address import Address from ...commons.types.phone_number import PhoneNumber from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .business_type import BusinessType @@ -57,8 +57,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/counterparty_invoice_metrics_response.py b/src/mercoa/entity_types/types/counterparty_invoice_metrics_response.py index 217f7fd..c9e4bef 100644 --- a/src/mercoa/entity_types/types/counterparty_invoice_metrics_response.py +++ b/src/mercoa/entity_types/types/counterparty_invoice_metrics_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .counterparty_invoice_metrics_status_response import CounterpartyInvoiceMetricsStatusResponse @@ -49,8 +49,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/counterparty_invoice_metrics_status_response.py b/src/mercoa/entity_types/types/counterparty_invoice_metrics_status_response.py index dcd89ed..6ad0f1a 100644 --- a/src/mercoa/entity_types/types/counterparty_invoice_metrics_status_response.py +++ b/src/mercoa/entity_types/types/counterparty_invoice_metrics_status_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...invoice_types.types.invoice_status import InvoiceStatus @@ -30,8 +30,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/counterparty_response.py b/src/mercoa/entity_types/types/counterparty_response.py index a9b7f5d..8320fed 100644 --- a/src/mercoa/entity_types/types/counterparty_response.py +++ b/src/mercoa/entity_types/types/counterparty_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.payment_method_response import PaymentMethodResponse from .counterparty_invoice_metrics_response import CounterpartyInvoiceMetricsResponse from .counterparty_network_type import CounterpartyNetworkType @@ -85,8 +85,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/ein.py b/src/mercoa/entity_types/types/ein.py index c38b921..7544054 100644 --- a/src/mercoa/entity_types/types/ein.py +++ b/src/mercoa/entity_types/types/ein.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class Ein(pydantic_v1.BaseModel): @@ -28,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_add_payees_request.py b/src/mercoa/entity_types/types/entity_add_payees_request.py index 7bd4334..eccc48c 100644 --- a/src/mercoa/entity_types/types/entity_add_payees_request.py +++ b/src/mercoa/entity_types/types/entity_add_payees_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_id import EntityId @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_add_payors_request.py b/src/mercoa/entity_types/types/entity_add_payors_request.py index 897dd4b..ab7802e 100644 --- a/src/mercoa/entity_types/types/entity_add_payors_request.py +++ b/src/mercoa/entity_types/types/entity_add_payors_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_id import EntityId @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_customization_request.py b/src/mercoa/entity_types/types/entity_customization_request.py index 1c4395e..625d7bb 100644 --- a/src/mercoa/entity_types/types/entity_customization_request.py +++ b/src/mercoa/entity_types/types/entity_customization_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .metadata_customization_request import MetadataCustomizationRequest from .payment_method_customization_request import PaymentMethodCustomizationRequest @@ -70,8 +70,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_customization_response.py b/src/mercoa/entity_types/types/entity_customization_response.py index 6b2a528..c89b27f 100644 --- a/src/mercoa/entity_types/types/entity_customization_response.py +++ b/src/mercoa/entity_types/types/entity_customization_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .metadata_customization_request import MetadataCustomizationRequest from .payment_method_customization_request import PaymentMethodCustomizationRequest @@ -70,8 +70,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_hide_payees_request.py b/src/mercoa/entity_types/types/entity_hide_payees_request.py index 4180ada..c4ac3f4 100644 --- a/src/mercoa/entity_types/types/entity_hide_payees_request.py +++ b/src/mercoa/entity_types/types/entity_hide_payees_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_id import EntityId @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_hide_payors_request.py b/src/mercoa/entity_types/types/entity_hide_payors_request.py index a1630dd..7ffb2c8 100644 --- a/src/mercoa/entity_types/types/entity_hide_payors_request.py +++ b/src/mercoa/entity_types/types/entity_hide_payors_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_id import EntityId @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_metadata_response.py b/src/mercoa/entity_types/types/entity_metadata_response.py index f86651f..ad46edb 100644 --- a/src/mercoa/entity_types/types/entity_metadata_response.py +++ b/src/mercoa/entity_types/types/entity_metadata_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class EntityMetadataResponse(pydantic_v1.BaseModel): @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_request.py b/src/mercoa/entity_types/types/entity_request.py index f637f9a..b945b39 100644 --- a/src/mercoa/entity_types/types/entity_request.py +++ b/src/mercoa/entity_types/types/entity_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .account_type import AccountType from .profile_request import ProfileRequest @@ -99,8 +99,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_response.py b/src/mercoa/entity_types/types/entity_response.py index 0f5baf5..a9f5289 100644 --- a/src/mercoa/entity_types/types/entity_response.py +++ b/src/mercoa/entity_types/types/entity_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .account_type import AccountType from .entity_id import EntityId from .entity_status import EntityStatus @@ -115,8 +115,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_update_request.py b/src/mercoa/entity_types/types/entity_update_request.py index 31eda93..cd32792 100644 --- a/src/mercoa/entity_types/types/entity_update_request.py +++ b/src/mercoa/entity_types/types/entity_update_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .account_type import AccountType from .profile_request import ProfileRequest @@ -99,8 +99,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_user_request.py b/src/mercoa/entity_types/types/entity_user_request.py index ca12955..e507c09 100644 --- a/src/mercoa/entity_types/types/entity_user_request.py +++ b/src/mercoa/entity_types/types/entity_user_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class EntityUserRequest(pydantic_v1.BaseModel): @@ -38,8 +38,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_user_response.py b/src/mercoa/entity_types/types/entity_user_response.py index 762219b..9c3201a 100644 --- a/src/mercoa/entity_types/types/entity_user_response.py +++ b/src/mercoa/entity_types/types/entity_user_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_user_id import EntityUserId @@ -48,8 +48,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/entity_with_payment_method_response.py b/src/mercoa/entity_types/types/entity_with_payment_method_response.py index d92e58b..610b78b 100644 --- a/src/mercoa/entity_types/types/entity_with_payment_method_response.py +++ b/src/mercoa/entity_types/types/entity_with_payment_method_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.payment_method_response import PaymentMethodResponse from .entity_response import EntityResponse @@ -94,8 +94,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/find_counterparties_response.py b/src/mercoa/entity_types/types/find_counterparties_response.py index f875150..29d4eaf 100644 --- a/src/mercoa/entity_types/types/find_counterparties_response.py +++ b/src/mercoa/entity_types/types/find_counterparties_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .counterparty_response import CounterpartyResponse @@ -95,8 +95,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/find_entity_response.py b/src/mercoa/entity_types/types/find_entity_response.py index cb0cbf8..1a3474d 100644 --- a/src/mercoa/entity_types/types/find_entity_response.py +++ b/src/mercoa/entity_types/types/find_entity_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_with_payment_method_response import EntityWithPaymentMethodResponse @@ -108,8 +108,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/find_entity_user_response.py b/src/mercoa/entity_types/types/find_entity_user_response.py index c0039a4..5bc9496 100644 --- a/src/mercoa/entity_types/types/find_entity_user_response.py +++ b/src/mercoa/entity_types/types/find_entity_user_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_user_response import EntityUserResponse @@ -54,8 +54,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/find_notification_response.py b/src/mercoa/entity_types/types/find_notification_response.py index 7e4c75d..67087f4 100644 --- a/src/mercoa/entity_types/types/find_notification_response.py +++ b/src/mercoa/entity_types/types/find_notification_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .notification_response import NotificationResponse @@ -57,8 +57,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/identifier_list.py b/src/mercoa/entity_types/types/identifier_list.py index 4a90f1b..924bde2 100644 --- a/src/mercoa/entity_types/types/identifier_list.py +++ b/src/mercoa/entity_types/types/identifier_list.py @@ -9,8 +9,8 @@ class IdentifierList_RolesList(pydantic_v1.BaseModel): - type: typing.Literal["rolesList"] = "rolesList" value: typing.List[str] + type: typing.Literal["rolesList"] = "rolesList" class Config: frozen = True @@ -18,8 +18,8 @@ class Config: class IdentifierList_UserList(pydantic_v1.BaseModel): - type: typing.Literal["userList"] = "userList" value: typing.List[EntityUserId] + type: typing.Literal["userList"] = "userList" class Config: frozen = True diff --git a/src/mercoa/entity_types/types/individual_profile_request.py b/src/mercoa/entity_types/types/individual_profile_request.py index c06f26f..1640577 100644 --- a/src/mercoa/entity_types/types/individual_profile_request.py +++ b/src/mercoa/entity_types/types/individual_profile_request.py @@ -9,7 +9,7 @@ from ...commons.types.individual_government_id import IndividualGovernmentId from ...commons.types.phone_number import PhoneNumber from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class IndividualProfileRequest(pydantic_v1.BaseModel): @@ -25,8 +25,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/individual_profile_response.py b/src/mercoa/entity_types/types/individual_profile_response.py index c7e67c1..51935d1 100644 --- a/src/mercoa/entity_types/types/individual_profile_response.py +++ b/src/mercoa/entity_types/types/individual_profile_response.py @@ -7,7 +7,7 @@ from ...commons.types.full_name import FullName from ...commons.types.phone_number import PhoneNumber from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class IndividualProfileResponse(pydantic_v1.BaseModel): @@ -23,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/metadata_customization_request.py b/src/mercoa/entity_types/types/metadata_customization_request.py index 3a24540..5d84445 100644 --- a/src/mercoa/entity_types/types/metadata_customization_request.py +++ b/src/mercoa/entity_types/types/metadata_customization_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class MetadataCustomizationRequest(pydantic_v1.BaseModel): @@ -34,8 +34,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/metadata_trigger.py b/src/mercoa/entity_types/types/metadata_trigger.py index e7f2426..3248eec 100644 --- a/src/mercoa/entity_types/types/metadata_trigger.py +++ b/src/mercoa/entity_types/types/metadata_trigger.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class MetadataTrigger(pydantic_v1.BaseModel): @@ -23,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/notification_policy_request.py b/src/mercoa/entity_types/types/notification_policy_request.py index 7a03c93..d2ace95 100644 --- a/src/mercoa/entity_types/types/notification_policy_request.py +++ b/src/mercoa/entity_types/types/notification_policy_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class NotificationPolicyRequest(pydantic_v1.BaseModel): @@ -34,8 +34,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/notification_policy_response.py b/src/mercoa/entity_types/types/notification_policy_response.py index e48d295..866c78a 100644 --- a/src/mercoa/entity_types/types/notification_policy_response.py +++ b/src/mercoa/entity_types/types/notification_policy_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .notification_type import NotificationType @@ -38,8 +38,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/notification_response.py b/src/mercoa/entity_types/types/notification_response.py index bd33ce9..0960889 100644 --- a/src/mercoa/entity_types/types/notification_response.py +++ b/src/mercoa/entity_types/types/notification_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...invoice_types.types.invoice_id import InvoiceId from .notification_id import NotificationId from .notification_type import NotificationType @@ -42,8 +42,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/payment_method_customization_request.py b/src/mercoa/entity_types/types/payment_method_customization_request.py index 863374d..4e81422 100644 --- a/src/mercoa/entity_types/types/payment_method_customization_request.py +++ b/src/mercoa/entity_types/types/payment_method_customization_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.payment_method_type import PaymentMethodType @@ -36,8 +36,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/profile_request.py b/src/mercoa/entity_types/types/profile_request.py index dbc7f50..10ba4f5 100644 --- a/src/mercoa/entity_types/types/profile_request.py +++ b/src/mercoa/entity_types/types/profile_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .business_profile_request import BusinessProfileRequest from .individual_profile_request import IndividualProfileRequest @@ -64,8 +64,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/profile_response.py b/src/mercoa/entity_types/types/profile_response.py index 5a96aad..6ce4956 100644 --- a/src/mercoa/entity_types/types/profile_response.py +++ b/src/mercoa/entity_types/types/profile_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .business_profile_response import BusinessProfileResponse from .individual_profile_response import IndividualProfileResponse @@ -58,8 +58,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/representative_request.py b/src/mercoa/entity_types/types/representative_request.py index 549378a..d4a5d16 100644 --- a/src/mercoa/entity_types/types/representative_request.py +++ b/src/mercoa/entity_types/types/representative_request.py @@ -9,7 +9,7 @@ from ...commons.types.individual_government_id import IndividualGovernmentId from ...commons.types.phone_number import PhoneNumber from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .responsibilities import Responsibilities @@ -76,8 +76,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/representative_response.py b/src/mercoa/entity_types/types/representative_response.py index 6498998..5e2981f 100644 --- a/src/mercoa/entity_types/types/representative_response.py +++ b/src/mercoa/entity_types/types/representative_response.py @@ -7,7 +7,7 @@ from ...commons.types.full_name import FullName from ...commons.types.phone_number import PhoneNumber from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .representative_id import RepresentativeId from .responsibilities import Responsibilities @@ -80,8 +80,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/responsibilities.py b/src/mercoa/entity_types/types/responsibilities.py index 131360f..330e2e4 100644 --- a/src/mercoa/entity_types/types/responsibilities.py +++ b/src/mercoa/entity_types/types/responsibilities.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class Responsibilities(pydantic_v1.BaseModel): @@ -40,8 +40,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/rule.py b/src/mercoa/entity_types/types/rule.py index 341baad..4c00c94 100644 --- a/src/mercoa/entity_types/types/rule.py +++ b/src/mercoa/entity_types/types/rule.py @@ -2,22 +2,49 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .identifier_list import IdentifierList class Rule_Approver(pydantic_v1.BaseModel): - type: typing.Literal["approver"] = "approver" + """ + Examples + -------- + from mercoa import IdentifierList_RolesList, Rule_Approver + + Rule_Approver( + num_approvers=2, + identifier_list=IdentifierList_RolesList(value=["Admin", "Controller"]), + ) + """ + num_approvers: int = pydantic_v1.Field(alias="numApprovers") identifier_list: IdentifierList = pydantic_v1.Field(alias="identifierList") + type: typing.Literal["approver"] = "approver" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} """ diff --git a/src/mercoa/entity_types/types/tax_id.py b/src/mercoa/entity_types/types/tax_id.py index ecd1726..8ea63d6 100644 --- a/src/mercoa/entity_types/types/tax_id.py +++ b/src/mercoa/entity_types/types/tax_id.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .ein import Ein @@ -28,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/token_generation_entity_options.py b/src/mercoa/entity_types/types/token_generation_entity_options.py index 84d5162..0f4dee3 100644 --- a/src/mercoa/entity_types/types/token_generation_entity_options.py +++ b/src/mercoa/entity_types/types/token_generation_entity_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class TokenGenerationEntityOptions(pydantic_v1.BaseModel): @@ -18,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/token_generation_invoice_options.py b/src/mercoa/entity_types/types/token_generation_invoice_options.py index c4d15d2..28e04dc 100644 --- a/src/mercoa/entity_types/types/token_generation_invoice_options.py +++ b/src/mercoa/entity_types/types/token_generation_invoice_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...invoice_types.types.invoice_status import InvoiceStatus from .line_item_availabilities import LineItemAvailabilities @@ -27,8 +27,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/token_generation_options.py b/src/mercoa/entity_types/types/token_generation_options.py index 0b55d1e..47639fa 100644 --- a/src/mercoa/entity_types/types/token_generation_options.py +++ b/src/mercoa/entity_types/types/token_generation_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .token_generation_entity_options import TokenGenerationEntityOptions from .token_generation_invoice_options import TokenGenerationInvoiceOptions from .token_generation_pages_options import TokenGenerationPagesOptions @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/token_generation_pages_options.py b/src/mercoa/entity_types/types/token_generation_pages_options.py index 455f447..5674b29 100644 --- a/src/mercoa/entity_types/types/token_generation_pages_options.py +++ b/src/mercoa/entity_types/types/token_generation_pages_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class TokenGenerationPagesOptions(pydantic_v1.BaseModel): @@ -20,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/token_generation_style_options.py b/src/mercoa/entity_types/types/token_generation_style_options.py index fe41eea..b29271b 100644 --- a/src/mercoa/entity_types/types/token_generation_style_options.py +++ b/src/mercoa/entity_types/types/token_generation_style_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class TokenGenerationStyleOptions(pydantic_v1.BaseModel): @@ -15,8 +15,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/token_generation_vendor_options.py b/src/mercoa/entity_types/types/token_generation_vendor_options.py index 09510ab..c94d015 100644 --- a/src/mercoa/entity_types/types/token_generation_vendor_options.py +++ b/src/mercoa/entity_types/types/token_generation_vendor_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .vendor_network import VendorNetwork @@ -21,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/trigger.py b/src/mercoa/entity_types/types/trigger.py index 5706ecc..18355e3 100644 --- a/src/mercoa/entity_types/types/trigger.py +++ b/src/mercoa/entity_types/types/trigger.py @@ -2,42 +2,119 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.currency_code import CurrencyCode from .entity_id import EntityId class Trigger_Amount(pydantic_v1.BaseModel): - type: typing.Literal["amount"] = "amount" + """ + Examples + -------- + from mercoa import Trigger_Amount + + Trigger_Amount( + amount=100.0, + currency="USD", + ) + """ + amount: float currency: CurrencyCode + type: typing.Literal["amount"] = "amount" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class Trigger_Vendor(pydantic_v1.BaseModel): - type: typing.Literal["vendor"] = "vendor" + """ + Examples + -------- + from mercoa import Trigger_Amount + + Trigger_Amount( + amount=100.0, + currency="USD", + ) + """ + vendor_ids: typing.List[EntityId] = pydantic_v1.Field(alias="vendorIds") + type: typing.Literal["vendor"] = "vendor" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class Trigger_Metadata(pydantic_v1.BaseModel): - type: typing.Literal["metadata"] = "metadata" + """ + Examples + -------- + from mercoa import Trigger_Amount + + Trigger_Amount( + amount=100.0, + currency="USD", + ) + """ + key: str value: str + type: typing.Literal["metadata"] = "metadata" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} """ diff --git a/src/mercoa/entity_types/types/user_notification_policy_request.py b/src/mercoa/entity_types/types/user_notification_policy_request.py index 021dbb9..f952066 100644 --- a/src/mercoa/entity_types/types/user_notification_policy_request.py +++ b/src/mercoa/entity_types/types/user_notification_policy_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class UserNotificationPolicyRequest(pydantic_v1.BaseModel): @@ -38,8 +38,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/user_notification_policy_response.py b/src/mercoa/entity_types/types/user_notification_policy_response.py index 63bc6c0..57267ef 100644 --- a/src/mercoa/entity_types/types/user_notification_policy_response.py +++ b/src/mercoa/entity_types/types/user_notification_policy_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .notification_type import NotificationType @@ -44,8 +44,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/entity_types/types/vendor_trigger.py b/src/mercoa/entity_types/types/vendor_trigger.py index d64a8bc..80d7be3 100644 --- a/src/mercoa/entity_types/types/vendor_trigger.py +++ b/src/mercoa/entity_types/types/vendor_trigger.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_id import EntityId @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/fees/client.py b/src/mercoa/fees/client.py index 4f396e3..d6bb99e 100644 --- a/src/mercoa/fees/client.py +++ b/src/mercoa/fees/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ..commons.errors.bad_request import BadRequest @@ -13,12 +12,12 @@ from ..commons.errors.unimplemented import Unimplemented from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 -from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions from ..invoice_types.types.invoice_fees_response import InvoiceFeesResponse -from .types.calculate_fees_request import CalculateFeesRequest +from ..invoice_types.types.payment_destination_options import PaymentDestinationOptions +from ..payment_method_types.types.currency_code import CurrencyCode +from ..payment_method_types.types.payment_method_id import PaymentMethodId # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -29,14 +28,34 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def calculate( - self, *, request: CalculateFeesRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + amount: float, + payment_source_id: PaymentMethodId, + payment_destination_id: PaymentMethodId, + currency: typing.Optional[CurrencyCode] = OMIT, + payment_destination_options: typing.Optional[PaymentDestinationOptions] = OMIT, + request_options: typing.Optional[RequestOptions] = None ) -> InvoiceFeesResponse: """ Calculate the fees associated with an payment given the amount, payment source, and disbursement method. Can be used to calculate fees for a payment before creating an invoice. Parameters ---------- - request : CalculateFeesRequest + amount : float + Total amount in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated. + + payment_source_id : PaymentMethodId + ID of payment source. + + payment_destination_id : PaymentMethodId + ID of payment destination. + + currency : typing.Optional[CurrencyCode] + Currency code for the amount. Defaults to USD. + + payment_destination_options : typing.Optional[PaymentDestinationOptions] + Options for the payment destination. Depending on the payment destination, this may include things such as check delivery method. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -47,45 +66,29 @@ def calculate( Examples -------- - from mercoa import CalculateFeesRequest from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.fees.calculate( - request=CalculateFeesRequest( - amount=100.0, - payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - payment_destination_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - ), + amount=100.0, + payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + payment_destination_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", ) """ _response = self._client_wrapper.httpx_client.request( + "fees", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "fees"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "amount": amount, + "currency": currency, + "paymentSourceId": payment_source_id, + "paymentDestinationId": payment_destination_id, + "paymentDestinationOptions": payment_destination_options, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -116,14 +119,34 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def calculate( - self, *, request: CalculateFeesRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + amount: float, + payment_source_id: PaymentMethodId, + payment_destination_id: PaymentMethodId, + currency: typing.Optional[CurrencyCode] = OMIT, + payment_destination_options: typing.Optional[PaymentDestinationOptions] = OMIT, + request_options: typing.Optional[RequestOptions] = None ) -> InvoiceFeesResponse: """ Calculate the fees associated with an payment given the amount, payment source, and disbursement method. Can be used to calculate fees for a payment before creating an invoice. Parameters ---------- - request : CalculateFeesRequest + amount : float + Total amount in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated. + + payment_source_id : PaymentMethodId + ID of payment source. + + payment_destination_id : PaymentMethodId + ID of payment destination. + + currency : typing.Optional[CurrencyCode] + Currency code for the amount. Defaults to USD. + + payment_destination_options : typing.Optional[PaymentDestinationOptions] + Options for the payment destination. Depending on the payment destination, this may include things such as check delivery method. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -134,45 +157,29 @@ async def calculate( Examples -------- - from mercoa import CalculateFeesRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) await client.fees.calculate( - request=CalculateFeesRequest( - amount=100.0, - payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - payment_destination_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - ), + amount=100.0, + payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + payment_destination_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", ) """ _response = await self._client_wrapper.httpx_client.request( + "fees", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "fees"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "amount": amount, + "currency": currency, + "paymentSourceId": payment_source_id, + "paymentDestinationId": payment_destination_id, + "paymentDestinationOptions": payment_destination_options, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() diff --git a/src/mercoa/fees/types/calculate_fees_request.py b/src/mercoa/fees/types/calculate_fees_request.py index b557aeb..3fd3f0d 100644 --- a/src/mercoa/fees/types/calculate_fees_request.py +++ b/src/mercoa/fees/types/calculate_fees_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...invoice_types.types.payment_destination_options import PaymentDestinationOptions from ...payment_method_types.types.currency_code import CurrencyCode from ...payment_method_types.types.payment_method_id import PaymentMethodId @@ -55,8 +55,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice/approval/client.py b/src/mercoa/invoice/approval/client.py index 13be07d..1ebead8 100644 --- a/src/mercoa/invoice/approval/client.py +++ b/src/mercoa/invoice/approval/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,10 +14,9 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions -from ...invoice_types.types.add_approver_request import AddApproverRequest -from ...invoice_types.types.approval_request import ApprovalRequest +from ...entity_types.types.entity_user_id import EntityUserId +from ...invoice_types.types.approval_slot_id import ApprovalSlotId from ...invoice_types.types.invoice_id import InvoiceId # this is used as the default value for optional parameters @@ -33,7 +31,8 @@ def add_approver( self, invoice_id: InvoiceId, *, - request: AddApproverRequest, + user_id: EntityUserId, + approval_slot_id: typing.Optional[ApprovalSlotId] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -43,7 +42,10 @@ def add_approver( ---------- invoice_id : InvoiceId - request : AddApproverRequest + user_id : EntityUserId + + approval_slot_id : typing.Optional[ApprovalSlotId] + The identifier for the approval slot this user is assigned to. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -54,7 +56,6 @@ def add_approver( Examples -------- - from mercoa import AddApproverRequest from mercoa.client import Mercoa client = Mercoa( @@ -62,39 +63,16 @@ def add_approver( ) client.invoice.approval.add_approver( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=AddApproverRequest( - approval_slot_id="inap_9bb311c9-7c15-4c9e-8148-63814e0abec6", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + approval_slot_id="inap_9bb311c9-7c15-4c9e-8148-63814e0abec6", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/add-approver", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/add-approver" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"approvalSlotId": approval_slot_id, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -123,7 +101,8 @@ def approve( self, invoice_id: InvoiceId, *, - request: ApprovalRequest, + user_id: EntityUserId, + text: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -131,7 +110,10 @@ def approve( ---------- invoice_id : InvoiceId - request : ApprovalRequest + user_id : EntityUserId + + text : typing.Optional[str] + Comment associated with this approval action. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -142,7 +124,6 @@ def approve( Examples -------- - from mercoa import ApprovalRequest from mercoa.client import Mercoa client = Mercoa( @@ -150,39 +131,16 @@ def approve( ) client.invoice.approval.approve( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=ApprovalRequest( - text="This is a reason for my action", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + text="This is a reason for my action", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/approve", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/approve" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"text": text, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -211,7 +169,8 @@ def reject( self, invoice_id: InvoiceId, *, - request: ApprovalRequest, + user_id: EntityUserId, + text: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -219,7 +178,10 @@ def reject( ---------- invoice_id : InvoiceId - request : ApprovalRequest + user_id : EntityUserId + + text : typing.Optional[str] + Comment associated with this approval action. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -230,7 +192,6 @@ def reject( Examples -------- - from mercoa import ApprovalRequest from mercoa.client import Mercoa client = Mercoa( @@ -238,39 +199,16 @@ def reject( ) client.invoice.approval.reject( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=ApprovalRequest( - text="This is a reason for my action", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + text="This is a reason for my action", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/reject", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/reject" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"text": text, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -304,7 +242,8 @@ async def add_approver( self, invoice_id: InvoiceId, *, - request: AddApproverRequest, + user_id: EntityUserId, + approval_slot_id: typing.Optional[ApprovalSlotId] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -314,7 +253,10 @@ async def add_approver( ---------- invoice_id : InvoiceId - request : AddApproverRequest + user_id : EntityUserId + + approval_slot_id : typing.Optional[ApprovalSlotId] + The identifier for the approval slot this user is assigned to. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -325,7 +267,6 @@ async def add_approver( Examples -------- - from mercoa import AddApproverRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -333,39 +274,16 @@ async def add_approver( ) await client.invoice.approval.add_approver( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=AddApproverRequest( - approval_slot_id="inap_9bb311c9-7c15-4c9e-8148-63814e0abec6", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + approval_slot_id="inap_9bb311c9-7c15-4c9e-8148-63814e0abec6", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/add-approver", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/add-approver" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"approvalSlotId": approval_slot_id, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -394,7 +312,8 @@ async def approve( self, invoice_id: InvoiceId, *, - request: ApprovalRequest, + user_id: EntityUserId, + text: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -402,7 +321,10 @@ async def approve( ---------- invoice_id : InvoiceId - request : ApprovalRequest + user_id : EntityUserId + + text : typing.Optional[str] + Comment associated with this approval action. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -413,7 +335,6 @@ async def approve( Examples -------- - from mercoa import ApprovalRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -421,39 +342,16 @@ async def approve( ) await client.invoice.approval.approve( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=ApprovalRequest( - text="This is a reason for my action", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + text="This is a reason for my action", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/approve", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/approve" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"text": text, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -482,7 +380,8 @@ async def reject( self, invoice_id: InvoiceId, *, - request: ApprovalRequest, + user_id: EntityUserId, + text: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -490,7 +389,10 @@ async def reject( ---------- invoice_id : InvoiceId - request : ApprovalRequest + user_id : EntityUserId + + text : typing.Optional[str] + Comment associated with this approval action. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -501,7 +403,6 @@ async def reject( Examples -------- - from mercoa import ApprovalRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -509,39 +410,16 @@ async def reject( ) await client.invoice.approval.reject( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=ApprovalRequest( - text="This is a reason for my action", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + text="This is a reason for my action", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/reject", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/reject" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"text": text, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/invoice/client.py b/src/mercoa/invoice/client.py index d8e6fa9..134ab58 100644 --- a/src/mercoa/invoice/client.py +++ b/src/mercoa/invoice/client.py @@ -2,7 +2,6 @@ import datetime as dt import typing -import urllib.parse from json.decoder import JSONDecodeError from ..commons.errors.bad_request import BadRequest @@ -18,19 +17,21 @@ from ..core.datetime_utils import serialize_datetime from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 -from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions from ..entity_types.types.entity_id import EntityId from ..entity_types.types.entity_user_id import EntityUserId +from ..invoice_types.types.approval_slot_assignment import ApprovalSlotAssignment from ..invoice_types.types.approver_action import ApproverAction from ..invoice_types.types.find_invoice_response import FindInvoiceResponse -from ..invoice_types.types.invoice_creation_request import InvoiceCreationRequest from ..invoice_types.types.invoice_id import InvoiceId +from ..invoice_types.types.invoice_line_item_request import InvoiceLineItemRequest from ..invoice_types.types.invoice_metadata_filter import InvoiceMetadataFilter from ..invoice_types.types.invoice_order_by_field import InvoiceOrderByField from ..invoice_types.types.invoice_response import InvoiceResponse from ..invoice_types.types.invoice_status import InvoiceStatus -from ..invoice_types.types.invoice_update_request import InvoiceUpdateRequest +from ..invoice_types.types.payment_destination_options import PaymentDestinationOptions +from ..payment_method_types.types.currency_code import CurrencyCode +from ..payment_method_types.types.payment_method_id import PaymentMethodId from .approval.client import ApprovalClient, AsyncApprovalClient from .comment.client import AsyncCommentClient, CommentClient from .document.client import AsyncDocumentClient, DocumentClient @@ -141,48 +142,27 @@ def find( ) """ _response = self._client_wrapper.httpx_client.request( + "invoices", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "invoices"), - params=jsonable_encoder( - remove_none_from_dict( - { - "entityId": entity_id, - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "orderBy": order_by, - "orderDirection": order_direction, - "limit": limit, - "startingAfter": starting_after, - "search": search, - "metadata": jsonable_encoder(metadata), - "payerId": payer_id, - "vendorId": vendor_id, - "approverId": approver_id, - "approverAction": approver_action, - "invoiceId": invoice_id, - "status": status, - "includeFees": include_fees, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "entityId": entity_id, + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "orderBy": order_by, + "orderDirection": order_direction, + "limit": limit, + "startingAfter": starting_after, + "search": search, + "metadata": jsonable_encoder(metadata), + "payerId": payer_id, + "vendorId": vendor_id, + "approverId": approver_id, + "approverAction": approver_action, + "invoiceId": invoice_id, + "status": status, + "includeFees": include_fees, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -208,12 +188,101 @@ def find( raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, *, request: InvoiceCreationRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + creator_entity_id: EntityId, + status: typing.Optional[InvoiceStatus] = OMIT, + amount: typing.Optional[float] = OMIT, + currency: typing.Optional[CurrencyCode] = OMIT, + invoice_date: typing.Optional[dt.datetime] = OMIT, + deduction_date: typing.Optional[dt.datetime] = OMIT, + settlement_date: typing.Optional[dt.datetime] = OMIT, + due_date: typing.Optional[dt.datetime] = OMIT, + invoice_number: typing.Optional[str] = OMIT, + note_to_self: typing.Optional[str] = OMIT, + service_start_date: typing.Optional[dt.datetime] = OMIT, + service_end_date: typing.Optional[dt.datetime] = OMIT, + payer_id: typing.Optional[EntityId] = OMIT, + payment_source_id: typing.Optional[PaymentMethodId] = OMIT, + vendor_id: typing.Optional[EntityId] = OMIT, + payment_destination_id: typing.Optional[PaymentMethodId] = OMIT, + payment_destination_options: typing.Optional[PaymentDestinationOptions] = OMIT, + approvers: typing.Optional[typing.Sequence[ApprovalSlotAssignment]] = OMIT, + line_items: typing.Optional[typing.Sequence[InvoiceLineItemRequest]] = OMIT, + metadata: typing.Optional[typing.Dict[str, str]] = OMIT, + foreign_id: typing.Optional[str] = OMIT, + document: typing.Optional[str] = OMIT, + uploaded_image: typing.Optional[str] = OMIT, + creator_user_id: typing.Optional[EntityUserId] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> InvoiceResponse: """ Parameters ---------- - request : InvoiceCreationRequest + creator_entity_id : EntityId + ID of entity who created this invoice. + + status : typing.Optional[InvoiceStatus] + + amount : typing.Optional[float] + Total amount of invoice in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated. + + currency : typing.Optional[CurrencyCode] + Currency code for the amount. Defaults to USD. + + invoice_date : typing.Optional[dt.datetime] + Date the invoice was issued. + + deduction_date : typing.Optional[dt.datetime] + Date when funds will be deducted from payer's account. + + settlement_date : typing.Optional[dt.datetime] + Date of funds settlement. + + due_date : typing.Optional[dt.datetime] + Due date of invoice. + + invoice_number : typing.Optional[str] + + note_to_self : typing.Optional[str] + Note to self or memo on invoice. + + service_start_date : typing.Optional[dt.datetime] + + service_end_date : typing.Optional[dt.datetime] + + payer_id : typing.Optional[EntityId] + + payment_source_id : typing.Optional[PaymentMethodId] + ID of payment source for this invoice. If not provided, will attempt to use the default payment source for the payer when creating an invoice if a default payment source exists for the payer. + + vendor_id : typing.Optional[EntityId] + + payment_destination_id : typing.Optional[PaymentMethodId] + ID of payment destination for this invoice. If not provided, will attempt to use the default payment destination for the vendor when creating an invoice if a default payment destination exists for the vendor. + + payment_destination_options : typing.Optional[PaymentDestinationOptions] + Options for the payment destination. Depending on the payment destination, this may include things such as check delivery method. + + approvers : typing.Optional[typing.Sequence[ApprovalSlotAssignment]] + Set approvers for this invoice. + + line_items : typing.Optional[typing.Sequence[InvoiceLineItemRequest]] + + metadata : typing.Optional[typing.Dict[str, str]] + Metadata associated with this invoice. You can specify up to 10 keys, with key names up to 40 characters long and values up to 200 characters long. + + foreign_id : typing.Optional[str] + The ID used to identify this invoice in your system. This ID must be unique within each creatorEntity in your system, e.g. two invoices with the same creatorEntity may not have the same foreign ID. + + document : typing.Optional[str] + Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. + + uploaded_image : typing.Optional[str] + DEPRECATED. Use document field instead. + + creator_user_id : typing.Optional[EntityUserId] + ID of entity user who created this invoice. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -226,84 +295,84 @@ def create( -------- import datetime - from mercoa import ( - InvoiceCreationRequest, - InvoiceLineItemRequest, - PaymentDestinationOptions_Check, - ) + from mercoa import InvoiceLineItemRequest, PaymentDestinationOptions_Check from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.invoice.create( - request=InvoiceCreationRequest( - status="NEW", - amount=100.0, - currency="USD", - invoice_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - due_date=datetime.datetime.fromisoformat( - "2021-01-31 00:00:00+00:00", - ), - invoice_number="INV-123", - note_to_self="For the month of January", - payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", - payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", - payment_destination_options=PaymentDestinationOptions_Check( - delivery="MAIL", - ), - line_items=[ - InvoiceLineItemRequest( - amount=100.0, - currency="USD", - description="Product A", - name="Product A", - quantity=1, - unit_price=100.0, - service_start_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - service_end_date=datetime.datetime.fromisoformat( - "2021-01-31 00:00:00+00:00", - ), - metadata={"key1": "value1", "key2": "value2"}, - gl_account_id="600394", - ) - ], - creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - creator_user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + status="NEW", + amount=100.0, + currency="USD", + invoice_date=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + due_date=datetime.datetime.fromisoformat( + "2021-01-31 00:00:00+00:00", ), + invoice_number="INV-123", + note_to_self="For the month of January", + payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", + payment_destination_options=PaymentDestinationOptions_Check( + delivery="MAIL", + ), + line_items=[ + InvoiceLineItemRequest( + amount=100.0, + currency="USD", + description="Product A", + name="Product A", + quantity=1, + unit_price=100.0, + service_start_date=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + service_end_date=datetime.datetime.fromisoformat( + "2021-01-31 00:00:00+00:00", + ), + metadata={"key1": "value1", "key2": "value2"}, + gl_account_id="600394", + ) + ], + creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + creator_user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = self._client_wrapper.httpx_client.request( + "invoice", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "invoice"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "creatorEntityId": creator_entity_id, + "status": status, + "amount": amount, + "currency": currency, + "invoiceDate": invoice_date, + "deductionDate": deduction_date, + "settlementDate": settlement_date, + "dueDate": due_date, + "invoiceNumber": invoice_number, + "noteToSelf": note_to_self, + "serviceStartDate": service_start_date, + "serviceEndDate": service_end_date, + "payerId": payer_id, + "paymentSourceId": payment_source_id, + "vendorId": vendor_id, + "paymentDestinationId": payment_destination_id, + "paymentDestinationOptions": payment_destination_options, + "approvers": approvers, + "lineItems": line_items, + "metadata": metadata, + "foreignId": foreign_id, + "document": document, + "uploadedImage": uploaded_image, + "creatorUserId": creator_user_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -362,35 +431,10 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "includeFees": include_fees, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"includeFees": include_fees}, + request_options=request_options, ) try: _response_json = _response.json() @@ -419,7 +463,30 @@ def update( self, invoice_id: InvoiceId, *, - request: InvoiceUpdateRequest, + creator_entity_id: typing.Optional[EntityId] = OMIT, + status: typing.Optional[InvoiceStatus] = OMIT, + amount: typing.Optional[float] = OMIT, + currency: typing.Optional[CurrencyCode] = OMIT, + invoice_date: typing.Optional[dt.datetime] = OMIT, + deduction_date: typing.Optional[dt.datetime] = OMIT, + settlement_date: typing.Optional[dt.datetime] = OMIT, + due_date: typing.Optional[dt.datetime] = OMIT, + invoice_number: typing.Optional[str] = OMIT, + note_to_self: typing.Optional[str] = OMIT, + service_start_date: typing.Optional[dt.datetime] = OMIT, + service_end_date: typing.Optional[dt.datetime] = OMIT, + payer_id: typing.Optional[EntityId] = OMIT, + payment_source_id: typing.Optional[PaymentMethodId] = OMIT, + vendor_id: typing.Optional[EntityId] = OMIT, + payment_destination_id: typing.Optional[PaymentMethodId] = OMIT, + payment_destination_options: typing.Optional[PaymentDestinationOptions] = OMIT, + approvers: typing.Optional[typing.Sequence[ApprovalSlotAssignment]] = OMIT, + line_items: typing.Optional[typing.Sequence[InvoiceLineItemRequest]] = OMIT, + metadata: typing.Optional[typing.Dict[str, str]] = OMIT, + foreign_id: typing.Optional[str] = OMIT, + document: typing.Optional[str] = OMIT, + uploaded_image: typing.Optional[str] = OMIT, + creator_user_id: typing.Optional[EntityUserId] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> InvoiceResponse: """ @@ -427,7 +494,70 @@ def update( ---------- invoice_id : InvoiceId - request : InvoiceUpdateRequest + creator_entity_id : typing.Optional[EntityId] + ID of entity who created this invoice. If creating a payable invoice (AP), this must be the same as the payerId. If creating a receivable invoice (AR), this must be the same as the vendorId. + + status : typing.Optional[InvoiceStatus] + + amount : typing.Optional[float] + Total amount of invoice in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated. + + currency : typing.Optional[CurrencyCode] + Currency code for the amount. Defaults to USD. + + invoice_date : typing.Optional[dt.datetime] + Date the invoice was issued. + + deduction_date : typing.Optional[dt.datetime] + Date when funds will be deducted from payer's account. + + settlement_date : typing.Optional[dt.datetime] + Date of funds settlement. + + due_date : typing.Optional[dt.datetime] + Due date of invoice. + + invoice_number : typing.Optional[str] + + note_to_self : typing.Optional[str] + Note to self or memo on invoice. + + service_start_date : typing.Optional[dt.datetime] + + service_end_date : typing.Optional[dt.datetime] + + payer_id : typing.Optional[EntityId] + + payment_source_id : typing.Optional[PaymentMethodId] + ID of payment source for this invoice. If not provided, will attempt to use the default payment source for the payer when creating an invoice if a default payment source exists for the payer. + + vendor_id : typing.Optional[EntityId] + + payment_destination_id : typing.Optional[PaymentMethodId] + ID of payment destination for this invoice. If not provided, will attempt to use the default payment destination for the vendor when creating an invoice if a default payment destination exists for the vendor. + + payment_destination_options : typing.Optional[PaymentDestinationOptions] + Options for the payment destination. Depending on the payment destination, this may include things such as check delivery method. + + approvers : typing.Optional[typing.Sequence[ApprovalSlotAssignment]] + Set approvers for this invoice. + + line_items : typing.Optional[typing.Sequence[InvoiceLineItemRequest]] + + metadata : typing.Optional[typing.Dict[str, str]] + Metadata associated with this invoice. You can specify up to 10 keys, with key names up to 40 characters long and values up to 200 characters long. + + foreign_id : typing.Optional[str] + The ID used to identify this invoice in your system. This ID must be unique within each creatorEntity in your system, e.g. two invoices with the same creatorEntity may not have the same foreign ID. + + document : typing.Optional[str] + Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. + + uploaded_image : typing.Optional[str] + DEPRECATED. Use document field instead. + + creator_user_id : typing.Optional[EntityUserId] + ID of entity user who created this invoice. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -440,11 +570,7 @@ def update( -------- import datetime - from mercoa import ( - InvoiceLineItemRequest, - InvoiceUpdateRequest, - PaymentDestinationOptions_Check, - ) + from mercoa import InvoiceLineItemRequest, PaymentDestinationOptions_Check from mercoa.client import Mercoa client = Mercoa( @@ -452,75 +578,77 @@ def update( ) client.invoice.update( invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=InvoiceUpdateRequest( - status="NEW", - amount=100.0, - currency="USD", - invoice_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - due_date=datetime.datetime.fromisoformat( - "2021-01-31 00:00:00+00:00", - ), - invoice_number="INV-123", - note_to_self="For the month of January", - payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", - payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", - payment_destination_options=PaymentDestinationOptions_Check( - delivery="MAIL", - ), - line_items=[ - InvoiceLineItemRequest( - amount=100.0, - currency="USD", - description="Product A", - name="Product A", - quantity=1, - unit_price=100.0, - service_start_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - service_end_date=datetime.datetime.fromisoformat( - "2021-01-31 00:00:00+00:00", - ), - metadata={"key1": "value1", "key2": "value2"}, - gl_account_id="600394", - ) - ], - creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - creator_user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + status="NEW", + amount=100.0, + currency="USD", + invoice_date=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + due_date=datetime.datetime.fromisoformat( + "2021-01-31 00:00:00+00:00", + ), + invoice_number="INV-123", + note_to_self="For the month of January", + payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", + payment_destination_options=PaymentDestinationOptions_Check( + delivery="MAIL", ), + line_items=[ + InvoiceLineItemRequest( + amount=100.0, + currency="USD", + description="Product A", + name="Product A", + quantity=1, + unit_price=100.0, + service_start_date=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + service_end_date=datetime.datetime.fromisoformat( + "2021-01-31 00:00:00+00:00", + ), + metadata={"key1": "value1", "key2": "value2"}, + gl_account_id="600394", + ) + ], + creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + creator_user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "creatorEntityId": creator_entity_id, + "status": status, + "amount": amount, + "currency": currency, + "invoiceDate": invoice_date, + "deductionDate": deduction_date, + "settlementDate": settlement_date, + "dueDate": due_date, + "invoiceNumber": invoice_number, + "noteToSelf": note_to_self, + "serviceStartDate": service_start_date, + "serviceEndDate": service_end_date, + "payerId": payer_id, + "paymentSourceId": payment_source_id, + "vendorId": vendor_id, + "paymentDestinationId": payment_destination_id, + "paymentDestinationOptions": payment_destination_options, + "approvers": approvers, + "lineItems": line_items, + "metadata": metadata, + "foreignId": foreign_id, + "document": document, + "uploadedImage": uploaded_image, + "creatorUserId": creator_user_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -572,26 +700,7 @@ def delete(self, invoice_id: InvoiceId, *, request_options: typing.Optional[Requ ) """ _response = self._client_wrapper.httpx_client.request( - method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}", method="DELETE", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -718,48 +827,27 @@ async def find( ) """ _response = await self._client_wrapper.httpx_client.request( + "invoices", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "invoices"), - params=jsonable_encoder( - remove_none_from_dict( - { - "entityId": entity_id, - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "orderBy": order_by, - "orderDirection": order_direction, - "limit": limit, - "startingAfter": starting_after, - "search": search, - "metadata": jsonable_encoder(metadata), - "payerId": payer_id, - "vendorId": vendor_id, - "approverId": approver_id, - "approverAction": approver_action, - "invoiceId": invoice_id, - "status": status, - "includeFees": include_fees, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "entityId": entity_id, + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "orderBy": order_by, + "orderDirection": order_direction, + "limit": limit, + "startingAfter": starting_after, + "search": search, + "metadata": jsonable_encoder(metadata), + "payerId": payer_id, + "vendorId": vendor_id, + "approverId": approver_id, + "approverAction": approver_action, + "invoiceId": invoice_id, + "status": status, + "includeFees": include_fees, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -785,12 +873,101 @@ async def find( raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, *, request: InvoiceCreationRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + creator_entity_id: EntityId, + status: typing.Optional[InvoiceStatus] = OMIT, + amount: typing.Optional[float] = OMIT, + currency: typing.Optional[CurrencyCode] = OMIT, + invoice_date: typing.Optional[dt.datetime] = OMIT, + deduction_date: typing.Optional[dt.datetime] = OMIT, + settlement_date: typing.Optional[dt.datetime] = OMIT, + due_date: typing.Optional[dt.datetime] = OMIT, + invoice_number: typing.Optional[str] = OMIT, + note_to_self: typing.Optional[str] = OMIT, + service_start_date: typing.Optional[dt.datetime] = OMIT, + service_end_date: typing.Optional[dt.datetime] = OMIT, + payer_id: typing.Optional[EntityId] = OMIT, + payment_source_id: typing.Optional[PaymentMethodId] = OMIT, + vendor_id: typing.Optional[EntityId] = OMIT, + payment_destination_id: typing.Optional[PaymentMethodId] = OMIT, + payment_destination_options: typing.Optional[PaymentDestinationOptions] = OMIT, + approvers: typing.Optional[typing.Sequence[ApprovalSlotAssignment]] = OMIT, + line_items: typing.Optional[typing.Sequence[InvoiceLineItemRequest]] = OMIT, + metadata: typing.Optional[typing.Dict[str, str]] = OMIT, + foreign_id: typing.Optional[str] = OMIT, + document: typing.Optional[str] = OMIT, + uploaded_image: typing.Optional[str] = OMIT, + creator_user_id: typing.Optional[EntityUserId] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> InvoiceResponse: """ Parameters ---------- - request : InvoiceCreationRequest + creator_entity_id : EntityId + ID of entity who created this invoice. + + status : typing.Optional[InvoiceStatus] + + amount : typing.Optional[float] + Total amount of invoice in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated. + + currency : typing.Optional[CurrencyCode] + Currency code for the amount. Defaults to USD. + + invoice_date : typing.Optional[dt.datetime] + Date the invoice was issued. + + deduction_date : typing.Optional[dt.datetime] + Date when funds will be deducted from payer's account. + + settlement_date : typing.Optional[dt.datetime] + Date of funds settlement. + + due_date : typing.Optional[dt.datetime] + Due date of invoice. + + invoice_number : typing.Optional[str] + + note_to_self : typing.Optional[str] + Note to self or memo on invoice. + + service_start_date : typing.Optional[dt.datetime] + + service_end_date : typing.Optional[dt.datetime] + + payer_id : typing.Optional[EntityId] + + payment_source_id : typing.Optional[PaymentMethodId] + ID of payment source for this invoice. If not provided, will attempt to use the default payment source for the payer when creating an invoice if a default payment source exists for the payer. + + vendor_id : typing.Optional[EntityId] + + payment_destination_id : typing.Optional[PaymentMethodId] + ID of payment destination for this invoice. If not provided, will attempt to use the default payment destination for the vendor when creating an invoice if a default payment destination exists for the vendor. + + payment_destination_options : typing.Optional[PaymentDestinationOptions] + Options for the payment destination. Depending on the payment destination, this may include things such as check delivery method. + + approvers : typing.Optional[typing.Sequence[ApprovalSlotAssignment]] + Set approvers for this invoice. + + line_items : typing.Optional[typing.Sequence[InvoiceLineItemRequest]] + + metadata : typing.Optional[typing.Dict[str, str]] + Metadata associated with this invoice. You can specify up to 10 keys, with key names up to 40 characters long and values up to 200 characters long. + + foreign_id : typing.Optional[str] + The ID used to identify this invoice in your system. This ID must be unique within each creatorEntity in your system, e.g. two invoices with the same creatorEntity may not have the same foreign ID. + + document : typing.Optional[str] + Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. + + uploaded_image : typing.Optional[str] + DEPRECATED. Use document field instead. + + creator_user_id : typing.Optional[EntityUserId] + ID of entity user who created this invoice. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -803,84 +980,84 @@ async def create( -------- import datetime - from mercoa import ( - InvoiceCreationRequest, - InvoiceLineItemRequest, - PaymentDestinationOptions_Check, - ) + from mercoa import InvoiceLineItemRequest, PaymentDestinationOptions_Check from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) await client.invoice.create( - request=InvoiceCreationRequest( - status="NEW", - amount=100.0, - currency="USD", - invoice_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - due_date=datetime.datetime.fromisoformat( - "2021-01-31 00:00:00+00:00", - ), - invoice_number="INV-123", - note_to_self="For the month of January", - payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", - payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", - payment_destination_options=PaymentDestinationOptions_Check( - delivery="MAIL", - ), - line_items=[ - InvoiceLineItemRequest( - amount=100.0, - currency="USD", - description="Product A", - name="Product A", - quantity=1, - unit_price=100.0, - service_start_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - service_end_date=datetime.datetime.fromisoformat( - "2021-01-31 00:00:00+00:00", - ), - metadata={"key1": "value1", "key2": "value2"}, - gl_account_id="600394", - ) - ], - creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - creator_user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + status="NEW", + amount=100.0, + currency="USD", + invoice_date=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + due_date=datetime.datetime.fromisoformat( + "2021-01-31 00:00:00+00:00", ), + invoice_number="INV-123", + note_to_self="For the month of January", + payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", + payment_destination_options=PaymentDestinationOptions_Check( + delivery="MAIL", + ), + line_items=[ + InvoiceLineItemRequest( + amount=100.0, + currency="USD", + description="Product A", + name="Product A", + quantity=1, + unit_price=100.0, + service_start_date=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + service_end_date=datetime.datetime.fromisoformat( + "2021-01-31 00:00:00+00:00", + ), + metadata={"key1": "value1", "key2": "value2"}, + gl_account_id="600394", + ) + ], + creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + creator_user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = await self._client_wrapper.httpx_client.request( + "invoice", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "invoice"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "creatorEntityId": creator_entity_id, + "status": status, + "amount": amount, + "currency": currency, + "invoiceDate": invoice_date, + "deductionDate": deduction_date, + "settlementDate": settlement_date, + "dueDate": due_date, + "invoiceNumber": invoice_number, + "noteToSelf": note_to_self, + "serviceStartDate": service_start_date, + "serviceEndDate": service_end_date, + "payerId": payer_id, + "paymentSourceId": payment_source_id, + "vendorId": vendor_id, + "paymentDestinationId": payment_destination_id, + "paymentDestinationOptions": payment_destination_options, + "approvers": approvers, + "lineItems": line_items, + "metadata": metadata, + "foreignId": foreign_id, + "document": document, + "uploadedImage": uploaded_image, + "creatorUserId": creator_user_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -939,35 +1116,10 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "includeFees": include_fees, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"includeFees": include_fees}, + request_options=request_options, ) try: _response_json = _response.json() @@ -996,7 +1148,30 @@ async def update( self, invoice_id: InvoiceId, *, - request: InvoiceUpdateRequest, + creator_entity_id: typing.Optional[EntityId] = OMIT, + status: typing.Optional[InvoiceStatus] = OMIT, + amount: typing.Optional[float] = OMIT, + currency: typing.Optional[CurrencyCode] = OMIT, + invoice_date: typing.Optional[dt.datetime] = OMIT, + deduction_date: typing.Optional[dt.datetime] = OMIT, + settlement_date: typing.Optional[dt.datetime] = OMIT, + due_date: typing.Optional[dt.datetime] = OMIT, + invoice_number: typing.Optional[str] = OMIT, + note_to_self: typing.Optional[str] = OMIT, + service_start_date: typing.Optional[dt.datetime] = OMIT, + service_end_date: typing.Optional[dt.datetime] = OMIT, + payer_id: typing.Optional[EntityId] = OMIT, + payment_source_id: typing.Optional[PaymentMethodId] = OMIT, + vendor_id: typing.Optional[EntityId] = OMIT, + payment_destination_id: typing.Optional[PaymentMethodId] = OMIT, + payment_destination_options: typing.Optional[PaymentDestinationOptions] = OMIT, + approvers: typing.Optional[typing.Sequence[ApprovalSlotAssignment]] = OMIT, + line_items: typing.Optional[typing.Sequence[InvoiceLineItemRequest]] = OMIT, + metadata: typing.Optional[typing.Dict[str, str]] = OMIT, + foreign_id: typing.Optional[str] = OMIT, + document: typing.Optional[str] = OMIT, + uploaded_image: typing.Optional[str] = OMIT, + creator_user_id: typing.Optional[EntityUserId] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> InvoiceResponse: """ @@ -1004,7 +1179,70 @@ async def update( ---------- invoice_id : InvoiceId - request : InvoiceUpdateRequest + creator_entity_id : typing.Optional[EntityId] + ID of entity who created this invoice. If creating a payable invoice (AP), this must be the same as the payerId. If creating a receivable invoice (AR), this must be the same as the vendorId. + + status : typing.Optional[InvoiceStatus] + + amount : typing.Optional[float] + Total amount of invoice in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated. + + currency : typing.Optional[CurrencyCode] + Currency code for the amount. Defaults to USD. + + invoice_date : typing.Optional[dt.datetime] + Date the invoice was issued. + + deduction_date : typing.Optional[dt.datetime] + Date when funds will be deducted from payer's account. + + settlement_date : typing.Optional[dt.datetime] + Date of funds settlement. + + due_date : typing.Optional[dt.datetime] + Due date of invoice. + + invoice_number : typing.Optional[str] + + note_to_self : typing.Optional[str] + Note to self or memo on invoice. + + service_start_date : typing.Optional[dt.datetime] + + service_end_date : typing.Optional[dt.datetime] + + payer_id : typing.Optional[EntityId] + + payment_source_id : typing.Optional[PaymentMethodId] + ID of payment source for this invoice. If not provided, will attempt to use the default payment source for the payer when creating an invoice if a default payment source exists for the payer. + + vendor_id : typing.Optional[EntityId] + + payment_destination_id : typing.Optional[PaymentMethodId] + ID of payment destination for this invoice. If not provided, will attempt to use the default payment destination for the vendor when creating an invoice if a default payment destination exists for the vendor. + + payment_destination_options : typing.Optional[PaymentDestinationOptions] + Options for the payment destination. Depending on the payment destination, this may include things such as check delivery method. + + approvers : typing.Optional[typing.Sequence[ApprovalSlotAssignment]] + Set approvers for this invoice. + + line_items : typing.Optional[typing.Sequence[InvoiceLineItemRequest]] + + metadata : typing.Optional[typing.Dict[str, str]] + Metadata associated with this invoice. You can specify up to 10 keys, with key names up to 40 characters long and values up to 200 characters long. + + foreign_id : typing.Optional[str] + The ID used to identify this invoice in your system. This ID must be unique within each creatorEntity in your system, e.g. two invoices with the same creatorEntity may not have the same foreign ID. + + document : typing.Optional[str] + Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. If the invoice already has a document, this will add a new document to the invoice. + + uploaded_image : typing.Optional[str] + DEPRECATED. Use document field instead. + + creator_user_id : typing.Optional[EntityUserId] + ID of entity user who created this invoice. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1017,11 +1255,7 @@ async def update( -------- import datetime - from mercoa import ( - InvoiceLineItemRequest, - InvoiceUpdateRequest, - PaymentDestinationOptions_Check, - ) + from mercoa import InvoiceLineItemRequest, PaymentDestinationOptions_Check from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -1029,75 +1263,77 @@ async def update( ) await client.invoice.update( invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=InvoiceUpdateRequest( - status="NEW", - amount=100.0, - currency="USD", - invoice_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - due_date=datetime.datetime.fromisoformat( - "2021-01-31 00:00:00+00:00", - ), - invoice_number="INV-123", - note_to_self="For the month of January", - payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", - payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", - payment_destination_options=PaymentDestinationOptions_Check( - delivery="MAIL", - ), - line_items=[ - InvoiceLineItemRequest( - amount=100.0, - currency="USD", - description="Product A", - name="Product A", - quantity=1, - unit_price=100.0, - service_start_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - service_end_date=datetime.datetime.fromisoformat( - "2021-01-31 00:00:00+00:00", - ), - metadata={"key1": "value1", "key2": "value2"}, - gl_account_id="600394", - ) - ], - creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - creator_user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + status="NEW", + amount=100.0, + currency="USD", + invoice_date=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + due_date=datetime.datetime.fromisoformat( + "2021-01-31 00:00:00+00:00", + ), + invoice_number="INV-123", + note_to_self="For the month of January", + payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", + payment_destination_options=PaymentDestinationOptions_Check( + delivery="MAIL", ), + line_items=[ + InvoiceLineItemRequest( + amount=100.0, + currency="USD", + description="Product A", + name="Product A", + quantity=1, + unit_price=100.0, + service_start_date=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + service_end_date=datetime.datetime.fromisoformat( + "2021-01-31 00:00:00+00:00", + ), + metadata={"key1": "value1", "key2": "value2"}, + gl_account_id="600394", + ) + ], + creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + creator_user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "creatorEntityId": creator_entity_id, + "status": status, + "amount": amount, + "currency": currency, + "invoiceDate": invoice_date, + "deductionDate": deduction_date, + "settlementDate": settlement_date, + "dueDate": due_date, + "invoiceNumber": invoice_number, + "noteToSelf": note_to_self, + "serviceStartDate": service_start_date, + "serviceEndDate": service_end_date, + "payerId": payer_id, + "paymentSourceId": payment_source_id, + "vendorId": vendor_id, + "paymentDestinationId": payment_destination_id, + "paymentDestinationOptions": payment_destination_options, + "approvers": approvers, + "lineItems": line_items, + "metadata": metadata, + "foreignId": foreign_id, + "document": document, + "uploadedImage": uploaded_image, + "creatorUserId": creator_user_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -1149,26 +1385,7 @@ async def delete(self, invoice_id: InvoiceId, *, request_options: typing.Optiona ) """ _response = await self._client_wrapper.httpx_client.request( - method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}", method="DELETE", request_options=request_options ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/invoice/comment/client.py b/src/mercoa/invoice/comment/client.py index 693de61..34d845c 100644 --- a/src/mercoa/invoice/comment/client.py +++ b/src/mercoa/invoice/comment/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,10 +14,9 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions +from ...entity_types.types.entity_user_id import EntityUserId from ...invoice_types.types.comment_id import CommentId -from ...invoice_types.types.comment_request import CommentRequest from ...invoice_types.types.comment_response import CommentResponse from ...invoice_types.types.invoice_id import InvoiceId @@ -59,26 +57,7 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/comments" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/comments", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -104,7 +83,12 @@ def get_all( raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, invoice_id: InvoiceId, *, request: CommentRequest, request_options: typing.Optional[RequestOptions] = None + self, + invoice_id: InvoiceId, + *, + text: str, + user_id: typing.Optional[EntityUserId] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> CommentResponse: """ Add a comment to this invoice @@ -113,7 +97,9 @@ def create( ---------- invoice_id : InvoiceId - request : CommentRequest + text : str + + user_id : typing.Optional[EntityUserId] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -124,7 +110,6 @@ def create( Examples -------- - from mercoa import CommentRequest from mercoa.client import Mercoa client = Mercoa( @@ -132,39 +117,16 @@ def create( ) client.invoice.comment.create( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=CommentRequest( - text="This is a comment", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + text="This is a comment", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/comment", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/comment" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"text": text, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -219,27 +181,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -269,7 +213,8 @@ def update( invoice_id: InvoiceId, comment_id: CommentId, *, - request: CommentRequest, + text: str, + user_id: typing.Optional[EntityUserId] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CommentResponse: """ @@ -281,7 +226,9 @@ def update( comment_id : CommentId - request : CommentRequest + text : str + + user_id : typing.Optional[EntityUserId] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -292,7 +239,6 @@ def update( Examples -------- - from mercoa import CommentRequest from mercoa.client import Mercoa client = Mercoa( @@ -301,40 +247,16 @@ def update( client.invoice.comment.update( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=CommentRequest( - text="This is a comment", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + text="This is a comment", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"text": text, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -391,27 +313,9 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -470,26 +374,7 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/comments" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/comments", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -515,7 +400,12 @@ async def get_all( raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, invoice_id: InvoiceId, *, request: CommentRequest, request_options: typing.Optional[RequestOptions] = None + self, + invoice_id: InvoiceId, + *, + text: str, + user_id: typing.Optional[EntityUserId] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> CommentResponse: """ Add a comment to this invoice @@ -524,7 +414,9 @@ async def create( ---------- invoice_id : InvoiceId - request : CommentRequest + text : str + + user_id : typing.Optional[EntityUserId] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -535,7 +427,6 @@ async def create( Examples -------- - from mercoa import CommentRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -543,39 +434,16 @@ async def create( ) await client.invoice.comment.create( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=CommentRequest( - text="This is a comment", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + text="This is a comment", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/comment", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/comment" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"text": text, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -630,27 +498,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -680,7 +530,8 @@ async def update( invoice_id: InvoiceId, comment_id: CommentId, *, - request: CommentRequest, + text: str, + user_id: typing.Optional[EntityUserId] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CommentResponse: """ @@ -692,7 +543,9 @@ async def update( comment_id : CommentId - request : CommentRequest + text : str + + user_id : typing.Optional[EntityUserId] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -703,7 +556,6 @@ async def update( Examples -------- - from mercoa import CommentRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( @@ -712,40 +564,16 @@ async def update( await client.invoice.comment.update( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - request=CommentRequest( - text="This is a comment", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ), + text="This is a comment", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"text": text, "userId": user_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -802,27 +630,9 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/invoice/document/client.py b/src/mercoa/invoice/document/client.py index b3f6e1a..d003853 100644 --- a/src/mercoa/invoice/document/client.py +++ b/src/mercoa/invoice/document/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,7 +14,6 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...email_log_types.types.email_log_response import EmailLogResponse from ...invoice_types.types.document_response import DocumentResponse @@ -58,26 +56,7 @@ def get_all( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/documents" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/documents", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -138,36 +117,12 @@ def upload( document="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", ) """ - _request: typing.Dict[str, typing.Any] = {} - if document is not OMIT: - _request["document"] = document _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/document", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/document" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"document": document}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -224,27 +179,9 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/document/{jsonable_encoder(document_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"invoice/{jsonable_encoder(invoice_id)}/document/{jsonable_encoder(document_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -299,26 +236,7 @@ def generate_invoice_pdf( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/pdf/generate" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/pdf/generate", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -373,26 +291,7 @@ def generate_check_pdf( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/check/generate" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/check/generate", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -446,26 +345,7 @@ def get_source_email( ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/source-email" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/source-email", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -524,26 +404,7 @@ async def get_all( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/documents" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/documents", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -604,36 +465,12 @@ async def upload( document="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", ) """ - _request: typing.Dict[str, typing.Any] = {} - if document is not OMIT: - _request["document"] = document _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/document", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/document" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"document": document}, + request_options=request_options, + omit=OMIT, ) if 200 <= _response.status_code < 300: return @@ -690,27 +527,9 @@ async def delete( ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/document/{jsonable_encoder(document_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"invoice/{jsonable_encoder(invoice_id)}/document/{jsonable_encoder(document_id)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -765,26 +584,7 @@ async def generate_invoice_pdf( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/pdf/generate" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/pdf/generate", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -839,26 +639,7 @@ async def generate_check_pdf( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/check/generate" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/check/generate", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -912,26 +693,7 @@ async def get_source_email( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/source-email" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/source-email", method="GET", request_options=request_options ) try: _response_json = _response.json() diff --git a/src/mercoa/invoice/payment_links/client.py b/src/mercoa/invoice/payment_links/client.py index 89290fe..0f86e2c 100644 --- a/src/mercoa/invoice/payment_links/client.py +++ b/src/mercoa/invoice/payment_links/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,7 +14,6 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...invoice_types.types.invoice_id import InvoiceId @@ -51,26 +49,7 @@ def get_payer_link(self, invoice_id: InvoiceId, *, request_options: typing.Optio ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/payerLink" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/payerLink", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -132,38 +111,10 @@ def send_payer_email( ) """ _response = self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/sendPayerEmail", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/sendPayerEmail" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "attachInvoice": attach_invoice, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"attachInvoice": attach_invoice}, + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -215,26 +166,7 @@ def get_vendor_link(self, invoice_id: InvoiceId, *, request_options: typing.Opti ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/vendorLink" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/vendorLink", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -288,29 +220,7 @@ def send_vendor_email( ) """ _response = self._client_wrapper.httpx_client.request( - method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/sendVendorEmail" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/sendVendorEmail", method="POST", request_options=request_options ) if 200 <= _response.status_code < 300: return @@ -369,26 +279,7 @@ async def get_payer_link( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/payerLink" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/payerLink", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -450,38 +341,10 @@ async def send_payer_email( ) """ _response = await self._client_wrapper.httpx_client.request( + f"invoice/{jsonable_encoder(invoice_id)}/sendPayerEmail", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/sendPayerEmail" - ), - params=jsonable_encoder( - remove_none_from_dict( - { - "attachInvoice": attach_invoice, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={"attachInvoice": attach_invoice}, + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -535,26 +398,7 @@ async def get_vendor_link( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/vendorLink" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/vendorLink", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -608,29 +452,7 @@ async def send_vendor_email( ) """ _response = await self._client_wrapper.httpx_client.request( - method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"invoice/{jsonable_encoder(invoice_id)}/sendVendorEmail" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) - if request_options is not None - else None, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"invoice/{jsonable_encoder(invoice_id)}/sendVendorEmail", method="POST", request_options=request_options ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/invoice_types/types/add_approver_request.py b/src/mercoa/invoice_types/types/add_approver_request.py index 871c796..f054587 100644 --- a/src/mercoa/invoice_types/types/add_approver_request.py +++ b/src/mercoa/invoice_types/types/add_approver_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_user_id import EntityUserId from .approval_slot_id import ApprovalSlotId @@ -33,8 +33,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/approval_request.py b/src/mercoa/invoice_types/types/approval_request.py index f4a5ce6..1756abd 100644 --- a/src/mercoa/invoice_types/types/approval_request.py +++ b/src/mercoa/invoice_types/types/approval_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_user_id import EntityUserId @@ -32,8 +32,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/approval_slot.py b/src/mercoa/invoice_types/types/approval_slot.py index 6034295..d8e3f8a 100644 --- a/src/mercoa/invoice_types/types/approval_slot.py +++ b/src/mercoa/invoice_types/types/approval_slot.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.approval_policy_id import ApprovalPolicyId from ...entity_types.types.entity_user_id import EntityUserId from .approval_slot_id import ApprovalSlotId @@ -56,8 +56,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/approval_slot_assignment.py b/src/mercoa/invoice_types/types/approval_slot_assignment.py index 8eea00d..aa982fe 100644 --- a/src/mercoa/invoice_types/types/approval_slot_assignment.py +++ b/src/mercoa/invoice_types/types/approval_slot_assignment.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_user_id import EntityUserId from .approval_slot_id import ApprovalSlotId @@ -33,8 +33,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/associated_approval_action.py b/src/mercoa/invoice_types/types/associated_approval_action.py index 1da6feb..ddb0662 100644 --- a/src/mercoa/invoice_types/types/associated_approval_action.py +++ b/src/mercoa/invoice_types/types/associated_approval_action.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_user_id import EntityUserId from .approver_action import ApproverAction @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/bank_account_payment_destination_options.py b/src/mercoa/invoice_types/types/bank_account_payment_destination_options.py index 4584147..9ced646 100644 --- a/src/mercoa/invoice_types/types/bank_account_payment_destination_options.py +++ b/src/mercoa/invoice_types/types/bank_account_payment_destination_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_delivery_method import BankDeliveryMethod @@ -34,8 +34,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/check_payment_destination_options.py b/src/mercoa/invoice_types/types/check_payment_destination_options.py index 00f87d4..2c7ff87 100644 --- a/src/mercoa/invoice_types/types/check_payment_destination_options.py +++ b/src/mercoa/invoice_types/types/check_payment_destination_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .check_delivery_method import CheckDeliveryMethod @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/comment_request.py b/src/mercoa/invoice_types/types/comment_request.py index 22bbb88..2896320 100644 --- a/src/mercoa/invoice_types/types/comment_request.py +++ b/src/mercoa/invoice_types/types/comment_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_user_id import EntityUserId @@ -28,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/comment_response.py b/src/mercoa/invoice_types/types/comment_response.py index c0d60c0..42a54c0 100644 --- a/src/mercoa/invoice_types/types/comment_response.py +++ b/src/mercoa/invoice_types/types/comment_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_user_response import EntityUserResponse from .associated_approval_action import AssociatedApprovalAction @@ -60,8 +60,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/document_response.py b/src/mercoa/invoice_types/types/document_response.py index 39afb3a..09ae1f1 100644 --- a/src/mercoa/invoice_types/types/document_response.py +++ b/src/mercoa/invoice_types/types/document_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class DocumentResponse(pydantic_v1.BaseModel): @@ -33,8 +33,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/find_invoice_response.py b/src/mercoa/invoice_types/types/find_invoice_response.py index 735d6e2..1449def 100644 --- a/src/mercoa/invoice_types/types/find_invoice_response.py +++ b/src/mercoa/invoice_types/types/find_invoice_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .invoice_response import InvoiceResponse @@ -311,8 +311,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_creation_request.py b/src/mercoa/invoice_types/types/invoice_creation_request.py index 0425ed7..5b465c1 100644 --- a/src/mercoa/invoice_types/types/invoice_creation_request.py +++ b/src/mercoa/invoice_types/types/invoice_creation_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_id import EntityId from .invoice_request_base import InvoiceRequestBase @@ -73,8 +73,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_fees_response.py b/src/mercoa/invoice_types/types/invoice_fees_response.py index 23f44e5..132b723 100644 --- a/src/mercoa/invoice_types/types/invoice_fees_response.py +++ b/src/mercoa/invoice_types/types/invoice_fees_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class InvoiceFeesResponse(pydantic_v1.BaseModel): @@ -46,8 +46,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_line_item_request.py b/src/mercoa/invoice_types/types/invoice_line_item_request.py index 63fd305..fe9b86a 100644 --- a/src/mercoa/invoice_types/types/invoice_line_item_request.py +++ b/src/mercoa/invoice_types/types/invoice_line_item_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.currency_code import CurrencyCode @@ -70,8 +70,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_line_item_response.py b/src/mercoa/invoice_types/types/invoice_line_item_response.py index 88ecc85..ff97b92 100644 --- a/src/mercoa/invoice_types/types/invoice_line_item_response.py +++ b/src/mercoa/invoice_types/types/invoice_line_item_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.currency_code import CurrencyCode @@ -72,8 +72,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_metadata_filter.py b/src/mercoa/invoice_types/types/invoice_metadata_filter.py index 7183939..4c721c1 100644 --- a/src/mercoa/invoice_types/types/invoice_metadata_filter.py +++ b/src/mercoa/invoice_types/types/invoice_metadata_filter.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class InvoiceMetadataFilter(pydantic_v1.BaseModel): @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_metrics_per_date_response.py b/src/mercoa/invoice_types/types/invoice_metrics_per_date_response.py index 15072e2..a7e76a7 100644 --- a/src/mercoa/invoice_types/types/invoice_metrics_per_date_response.py +++ b/src/mercoa/invoice_types/types/invoice_metrics_per_date_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.currency_code import CurrencyCode @@ -38,8 +38,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_metrics_response.py b/src/mercoa/invoice_types/types/invoice_metrics_response.py index 7512c70..a48d59b 100644 --- a/src/mercoa/invoice_types/types/invoice_metrics_response.py +++ b/src/mercoa/invoice_types/types/invoice_metrics_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.currency_code import CurrencyCode from .invoice_metrics_per_date_response import InvoiceMetricsPerDateResponse @@ -65,8 +65,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_request_base.py b/src/mercoa/invoice_types/types/invoice_request_base.py index fd3a8d0..9a754e8 100644 --- a/src/mercoa/invoice_types/types/invoice_request_base.py +++ b/src/mercoa/invoice_types/types/invoice_request_base.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_id import EntityId from ...entity_types.types.entity_user_id import EntityUserId from ...payment_method_types.types.currency_code import CurrencyCode @@ -114,8 +114,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_response.py b/src/mercoa/invoice_types/types/invoice_response.py index 67a3fba..e73dcb7 100644 --- a/src/mercoa/invoice_types/types/invoice_response.py +++ b/src/mercoa/invoice_types/types/invoice_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.approval_policy_response import ApprovalPolicyResponse from ...entity_types.types.entity_id import EntityId from ...entity_types.types.entity_response import EntityResponse @@ -404,8 +404,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/invoice_update_request.py b/src/mercoa/invoice_types/types/invoice_update_request.py index 870beeb..65455c8 100644 --- a/src/mercoa/invoice_types/types/invoice_update_request.py +++ b/src/mercoa/invoice_types/types/invoice_update_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_id import EntityId from .invoice_request_base import InvoiceRequestBase @@ -73,8 +73,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/invoice_types/types/payment_destination_options.py b/src/mercoa/invoice_types/types/payment_destination_options.py index f29d69a..e3bb1b8 100644 --- a/src/mercoa/invoice_types/types/payment_destination_options.py +++ b/src/mercoa/invoice_types/types/payment_destination_options.py @@ -2,30 +2,80 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_delivery_method import BankDeliveryMethod from .check_delivery_method import CheckDeliveryMethod class PaymentDestinationOptions_Check(pydantic_v1.BaseModel): + """ + Examples + -------- + from mercoa import PaymentDestinationOptions_Check + + PaymentDestinationOptions_Check( + delivery="MAIL", + ) + """ + + delivery: typing.Optional[CheckDeliveryMethod] = None type: typing.Literal["check"] = "check" - delivery: typing.Optional[CheckDeliveryMethod] + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentDestinationOptions_BankAccount(pydantic_v1.BaseModel): + """ + Examples + -------- + from mercoa import PaymentDestinationOptions_Check + + PaymentDestinationOptions_Check( + delivery="MAIL", + ) + """ + + delivery: typing.Optional[BankDeliveryMethod] = None + description: typing.Optional[str] = None type: typing.Literal["bankAccount"] = "bankAccount" - delivery: typing.Optional[BankDeliveryMethod] - description: typing.Optional[str] + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} """ diff --git a/src/mercoa/ocr/client.py b/src/mercoa/ocr/client.py index 9bafa25..a4f6d07 100644 --- a/src/mercoa/ocr/client.py +++ b/src/mercoa/ocr/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ..commons.errors.bad_request import BadRequest @@ -15,11 +14,11 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 -from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..entity_types.types.entity_id import EntityId +from ..entity_types.types.vendor_network import VendorNetwork from .types.ocr_async_response import OcrAsyncResponse from .types.ocr_job_response import OcrJobResponse -from .types.ocr_request import OcrRequest from .types.ocr_response import OcrResponse # this is used as the default value for optional parameters @@ -30,13 +29,31 @@ class OcrClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def ocr(self, *, request: OcrRequest, request_options: typing.Optional[RequestOptions] = None) -> OcrResponse: + def ocr( + self, + *, + mime_type: str, + image: str, + vendor_network: typing.Optional[VendorNetwork] = OMIT, + entity_id: typing.Optional[EntityId] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> OcrResponse: """ Run OCR on an Base64 encoded image or PDF. This endpoint will block until the OCR is complete. Parameters ---------- - request : OcrRequest + mime_type : str + MIME type of the image. Supported types are image/png, image/jpeg, and application/pdf. + + image : str + Base64 encoded image or PDF. PNG, JPG, and PDF are supported. 10MB max. + + vendor_network : typing.Optional[VendorNetwork] + Limit OCR vendor search to a specific network + + entity_id : typing.Optional[EntityId] + When using the Entity vendor network, specify the entity to use if. EntityId on an auth token will take precedence over this parameter. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -47,46 +64,24 @@ def ocr(self, *, request: OcrRequest, request_options: typing.Optional[RequestOp Examples -------- - from mercoa import OcrRequest from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.ocr.ocr( - request=OcrRequest( - vendor_network="entity", - entity_id="entity_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", - mime_type="image/png", - image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", - ), + vendor_network="entity", + entity_id="entity_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", + mime_type="image/png", + image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", ) """ _response = self._client_wrapper.httpx_client.request( + "ocr", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "ocr"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"mimeType": mime_type, "image": image, "vendorNetwork": vendor_network, "entityId": entity_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -112,14 +107,30 @@ def ocr(self, *, request: OcrRequest, request_options: typing.Optional[RequestOp raise ApiError(status_code=_response.status_code, body=_response_json) def run_async_ocr( - self, *, request: OcrRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + mime_type: str, + image: str, + vendor_network: typing.Optional[VendorNetwork] = OMIT, + entity_id: typing.Optional[EntityId] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> OcrAsyncResponse: """ Run OCR on an Base64 encoded image or PDF. This endpoint will return immediately and the OCR will be processed asynchronously. Parameters ---------- - request : OcrRequest + mime_type : str + MIME type of the image. Supported types are image/png, image/jpeg, and application/pdf. + + image : str + Base64 encoded image or PDF. PNG, JPG, and PDF are supported. 10MB max. + + vendor_network : typing.Optional[VendorNetwork] + Limit OCR vendor search to a specific network + + entity_id : typing.Optional[EntityId] + When using the Entity vendor network, specify the entity to use if. EntityId on an auth token will take precedence over this parameter. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -130,46 +141,24 @@ def run_async_ocr( Examples -------- - from mercoa import OcrRequest from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.ocr.run_async_ocr( - request=OcrRequest( - vendor_network="entity", - entity_id="entity_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", - mime_type="image/png", - image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", - ), + vendor_network="entity", + entity_id="entity_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", + mime_type="image/png", + image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", ) """ _response = self._client_wrapper.httpx_client.request( + "ocr-async", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "ocr-async"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"mimeType": mime_type, "image": image, "vendorNetwork": vendor_network, "entityId": entity_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -221,26 +210,7 @@ def get_async_ocr(self, job_id: str, *, request_options: typing.Optional[Request ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"ocr-async/{jsonable_encoder(job_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"ocr-async/{jsonable_encoder(job_id)}", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -270,13 +240,31 @@ class AsyncOcrClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def ocr(self, *, request: OcrRequest, request_options: typing.Optional[RequestOptions] = None) -> OcrResponse: + async def ocr( + self, + *, + mime_type: str, + image: str, + vendor_network: typing.Optional[VendorNetwork] = OMIT, + entity_id: typing.Optional[EntityId] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> OcrResponse: """ Run OCR on an Base64 encoded image or PDF. This endpoint will block until the OCR is complete. Parameters ---------- - request : OcrRequest + mime_type : str + MIME type of the image. Supported types are image/png, image/jpeg, and application/pdf. + + image : str + Base64 encoded image or PDF. PNG, JPG, and PDF are supported. 10MB max. + + vendor_network : typing.Optional[VendorNetwork] + Limit OCR vendor search to a specific network + + entity_id : typing.Optional[EntityId] + When using the Entity vendor network, specify the entity to use if. EntityId on an auth token will take precedence over this parameter. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -287,46 +275,24 @@ async def ocr(self, *, request: OcrRequest, request_options: typing.Optional[Req Examples -------- - from mercoa import OcrRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) await client.ocr.ocr( - request=OcrRequest( - vendor_network="entity", - entity_id="entity_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", - mime_type="image/png", - image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", - ), + vendor_network="entity", + entity_id="entity_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", + mime_type="image/png", + image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", ) """ _response = await self._client_wrapper.httpx_client.request( + "ocr", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "ocr"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"mimeType": mime_type, "image": image, "vendorNetwork": vendor_network, "entityId": entity_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -352,14 +318,30 @@ async def ocr(self, *, request: OcrRequest, request_options: typing.Optional[Req raise ApiError(status_code=_response.status_code, body=_response_json) async def run_async_ocr( - self, *, request: OcrRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + mime_type: str, + image: str, + vendor_network: typing.Optional[VendorNetwork] = OMIT, + entity_id: typing.Optional[EntityId] = OMIT, + request_options: typing.Optional[RequestOptions] = None, ) -> OcrAsyncResponse: """ Run OCR on an Base64 encoded image or PDF. This endpoint will return immediately and the OCR will be processed asynchronously. Parameters ---------- - request : OcrRequest + mime_type : str + MIME type of the image. Supported types are image/png, image/jpeg, and application/pdf. + + image : str + Base64 encoded image or PDF. PNG, JPG, and PDF are supported. 10MB max. + + vendor_network : typing.Optional[VendorNetwork] + Limit OCR vendor search to a specific network + + entity_id : typing.Optional[EntityId] + When using the Entity vendor network, specify the entity to use if. EntityId on an auth token will take precedence over this parameter. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -370,46 +352,24 @@ async def run_async_ocr( Examples -------- - from mercoa import OcrRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) await client.ocr.run_async_ocr( - request=OcrRequest( - vendor_network="entity", - entity_id="entity_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", - mime_type="image/png", - image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", - ), + vendor_network="entity", + entity_id="entity_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", + mime_type="image/png", + image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", ) """ _response = await self._client_wrapper.httpx_client.request( + "ocr-async", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "ocr-async"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json={"mimeType": mime_type, "image": image, "vendorNetwork": vendor_network, "entityId": entity_id}, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -463,26 +423,7 @@ async def get_async_ocr( ) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"ocr-async/{jsonable_encoder(job_id)}" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"ocr-async/{jsonable_encoder(job_id)}", method="GET", request_options=request_options ) try: _response_json = _response.json() diff --git a/src/mercoa/ocr/types/ocr_async_response.py b/src/mercoa/ocr/types/ocr_async_response.py index e6e6a12..742bdf1 100644 --- a/src/mercoa/ocr/types/ocr_async_response.py +++ b/src/mercoa/ocr/types/ocr_async_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class OcrAsyncResponse(pydantic_v1.BaseModel): @@ -15,8 +15,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/ocr/types/ocr_job_response.py b/src/mercoa/ocr/types/ocr_job_response.py index de741ff..3bed924 100644 --- a/src/mercoa/ocr/types/ocr_job_response.py +++ b/src/mercoa/ocr/types/ocr_job_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .ocr_job_status import OcrJobStatus from .ocr_response import OcrResponse @@ -19,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/ocr/types/ocr_request.py b/src/mercoa/ocr/types/ocr_request.py index 9f3f84e..358cd3e 100644 --- a/src/mercoa/ocr/types/ocr_request.py +++ b/src/mercoa/ocr/types/ocr_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_id import EntityId from ...entity_types.types.vendor_network import VendorNetwork @@ -48,8 +48,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/ocr/types/ocr_response.py b/src/mercoa/ocr/types/ocr_response.py index 5b35df9..245459d 100644 --- a/src/mercoa/ocr/types/ocr_response.py +++ b/src/mercoa/ocr/types/ocr_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_response import EntityResponse from ...invoice_types.types.invoice_response import InvoiceResponse from ...payment_method_types.types.bank_account_response import BankAccountResponse @@ -234,8 +234,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization/client.py b/src/mercoa/organization/client.py index 4702af6..234635d 100644 --- a/src/mercoa/organization/client.py +++ b/src/mercoa/organization/client.py @@ -2,7 +2,6 @@ import datetime as dt import typing -import urllib.parse from json.decoder import JSONDecodeError from ..commons.errors.bad_request import BadRequest @@ -15,13 +14,18 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.datetime_utils import serialize_datetime -from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 -from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions from ..email_log_types.types.email_log_response import EmailLogResponse -from ..organization_types.types.organization_request import OrganizationRequest +from ..organization_types.types.color_scheme_request import ColorSchemeRequest +from ..organization_types.types.email_provider_request import EmailProviderRequest +from ..organization_types.types.external_accounting_system_provider_request import ( + ExternalAccountingSystemProviderRequest, +) +from ..organization_types.types.metadata_schema import MetadataSchema +from ..organization_types.types.onboarding_options_request import OnboardingOptionsRequest from ..organization_types.types.organization_response import OrganizationResponse +from ..organization_types.types.payment_methods_request import PaymentMethodsRequest from .notification_configuration.client import AsyncNotificationConfigurationClient, NotificationConfigurationClient # this is used as the default value for optional parameters @@ -43,7 +47,7 @@ def get( payee_onboarding_options: typing.Optional[bool] = None, payor_onboarding_options: typing.Optional[bool] = None, metadata_schema: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None, + request_options: typing.Optional[RequestOptions] = None ) -> OrganizationResponse: """ Get current organization information @@ -96,39 +100,18 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + "organization", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "organization"), - params=jsonable_encoder( - remove_none_from_dict( - { - "paymentMethods": payment_methods, - "emailProvider": email_provider, - "externalAccountingSystemProvider": external_accounting_system_provider, - "colorScheme": color_scheme, - "payeeOnboardingOptions": payee_onboarding_options, - "payorOnboardingOptions": payor_onboarding_options, - "metadataSchema": metadata_schema, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "paymentMethods": payment_methods, + "emailProvider": email_provider, + "externalAccountingSystemProvider": external_accounting_system_provider, + "colorScheme": color_scheme, + "payeeOnboardingOptions": payee_onboarding_options, + "payorOnboardingOptions": payor_onboarding_options, + "metadataSchema": metadata_schema, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -154,14 +137,47 @@ def get( raise ApiError(status_code=_response.status_code, body=_response_json) def update( - self, *, request: OrganizationRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + name: typing.Optional[str] = OMIT, + logo: typing.Optional[str] = OMIT, + website_url: typing.Optional[str] = OMIT, + support_email: typing.Optional[str] = OMIT, + payment_methods: typing.Optional[PaymentMethodsRequest] = OMIT, + email_provider: typing.Optional[EmailProviderRequest] = OMIT, + external_accounting_system_provider: typing.Optional[ExternalAccountingSystemProviderRequest] = OMIT, + color_scheme: typing.Optional[ColorSchemeRequest] = OMIT, + payee_onboarding_options: typing.Optional[OnboardingOptionsRequest] = OMIT, + payor_onboarding_options: typing.Optional[OnboardingOptionsRequest] = OMIT, + metadata_schema: typing.Optional[typing.Sequence[MetadataSchema]] = OMIT, + request_options: typing.Optional[RequestOptions] = None ) -> OrganizationResponse: """ Update current organization Parameters ---------- - request : OrganizationRequest + name : typing.Optional[str] + + logo : typing.Optional[str] + + website_url : typing.Optional[str] + + support_email : typing.Optional[str] + + payment_methods : typing.Optional[PaymentMethodsRequest] + + email_provider : typing.Optional[EmailProviderRequest] + + external_accounting_system_provider : typing.Optional[ExternalAccountingSystemProviderRequest] + + color_scheme : typing.Optional[ColorSchemeRequest] + + payee_onboarding_options : typing.Optional[OnboardingOptionsRequest] + + payor_onboarding_options : typing.Optional[OnboardingOptionsRequest] + + metadata_schema : typing.Optional[typing.Sequence[MetadataSchema]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -178,7 +194,6 @@ def update( ExternalAccountingSystemProviderRequest_None, MetadataSchema, OnboardingOptionsRequest, - OrganizationRequest, PaymentMethodsRequest, ) from mercoa.client import Mercoa @@ -187,46 +202,37 @@ def update( token="YOUR_TOKEN", ) client.organization.update( - request=OrganizationRequest( - name="string", - logo="string", - website_url="string", - support_email="string", - payment_methods=PaymentMethodsRequest(), - email_provider=EmailProviderRequest(), - external_accounting_system_provider=ExternalAccountingSystemProviderRequest_None(), - color_scheme=ColorSchemeRequest(), - payee_onboarding_options=OnboardingOptionsRequest(), - payor_onboarding_options=OnboardingOptionsRequest(), - metadata_schema=[MetadataSchema()], - ), + name="string", + logo="string", + website_url="string", + support_email="string", + payment_methods=PaymentMethodsRequest(), + email_provider=EmailProviderRequest(), + external_accounting_system_provider=ExternalAccountingSystemProviderRequest_None(), + color_scheme=ColorSchemeRequest(), + payee_onboarding_options=OnboardingOptionsRequest(), + payor_onboarding_options=OnboardingOptionsRequest(), + metadata_schema=[MetadataSchema()], ) """ _response = self._client_wrapper.httpx_client.request( + "organization", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "organization"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "logo": logo, + "websiteUrl": website_url, + "supportEmail": support_email, + "paymentMethods": payment_methods, + "emailProvider": email_provider, + "externalAccountingSystemProvider": external_accounting_system_provider, + "colorScheme": color_scheme, + "payeeOnboardingOptions": payee_onboarding_options, + "payorOnboardingOptions": payor_onboarding_options, + "metadataSchema": metadata_schema, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -258,7 +264,7 @@ def email_log( end_date: typing.Optional[dt.datetime] = None, limit: typing.Optional[int] = None, starting_after: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, + request_options: typing.Optional[RequestOptions] = None ) -> EmailLogResponse: """ Get log of all emails sent to this organization. Content format subject to change. @@ -303,36 +309,15 @@ def email_log( ) """ _response = self._client_wrapper.httpx_client.request( + "organization/emailLog", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "organization/emailLog"), - params=jsonable_encoder( - remove_none_from_dict( - { - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -373,7 +358,7 @@ async def get( payee_onboarding_options: typing.Optional[bool] = None, payor_onboarding_options: typing.Optional[bool] = None, metadata_schema: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None, + request_options: typing.Optional[RequestOptions] = None ) -> OrganizationResponse: """ Get current organization information @@ -426,39 +411,18 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + "organization", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "organization"), - params=jsonable_encoder( - remove_none_from_dict( - { - "paymentMethods": payment_methods, - "emailProvider": email_provider, - "externalAccountingSystemProvider": external_accounting_system_provider, - "colorScheme": color_scheme, - "payeeOnboardingOptions": payee_onboarding_options, - "payorOnboardingOptions": payor_onboarding_options, - "metadataSchema": metadata_schema, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "paymentMethods": payment_methods, + "emailProvider": email_provider, + "externalAccountingSystemProvider": external_accounting_system_provider, + "colorScheme": color_scheme, + "payeeOnboardingOptions": payee_onboarding_options, + "payorOnboardingOptions": payor_onboarding_options, + "metadataSchema": metadata_schema, + }, + request_options=request_options, ) try: _response_json = _response.json() @@ -484,14 +448,47 @@ async def get( raise ApiError(status_code=_response.status_code, body=_response_json) async def update( - self, *, request: OrganizationRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + name: typing.Optional[str] = OMIT, + logo: typing.Optional[str] = OMIT, + website_url: typing.Optional[str] = OMIT, + support_email: typing.Optional[str] = OMIT, + payment_methods: typing.Optional[PaymentMethodsRequest] = OMIT, + email_provider: typing.Optional[EmailProviderRequest] = OMIT, + external_accounting_system_provider: typing.Optional[ExternalAccountingSystemProviderRequest] = OMIT, + color_scheme: typing.Optional[ColorSchemeRequest] = OMIT, + payee_onboarding_options: typing.Optional[OnboardingOptionsRequest] = OMIT, + payor_onboarding_options: typing.Optional[OnboardingOptionsRequest] = OMIT, + metadata_schema: typing.Optional[typing.Sequence[MetadataSchema]] = OMIT, + request_options: typing.Optional[RequestOptions] = None ) -> OrganizationResponse: """ Update current organization Parameters ---------- - request : OrganizationRequest + name : typing.Optional[str] + + logo : typing.Optional[str] + + website_url : typing.Optional[str] + + support_email : typing.Optional[str] + + payment_methods : typing.Optional[PaymentMethodsRequest] + + email_provider : typing.Optional[EmailProviderRequest] + + external_accounting_system_provider : typing.Optional[ExternalAccountingSystemProviderRequest] + + color_scheme : typing.Optional[ColorSchemeRequest] + + payee_onboarding_options : typing.Optional[OnboardingOptionsRequest] + + payor_onboarding_options : typing.Optional[OnboardingOptionsRequest] + + metadata_schema : typing.Optional[typing.Sequence[MetadataSchema]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -508,7 +505,6 @@ async def update( ExternalAccountingSystemProviderRequest_None, MetadataSchema, OnboardingOptionsRequest, - OrganizationRequest, PaymentMethodsRequest, ) from mercoa.client import AsyncMercoa @@ -517,46 +513,37 @@ async def update( token="YOUR_TOKEN", ) await client.organization.update( - request=OrganizationRequest( - name="string", - logo="string", - website_url="string", - support_email="string", - payment_methods=PaymentMethodsRequest(), - email_provider=EmailProviderRequest(), - external_accounting_system_provider=ExternalAccountingSystemProviderRequest_None(), - color_scheme=ColorSchemeRequest(), - payee_onboarding_options=OnboardingOptionsRequest(), - payor_onboarding_options=OnboardingOptionsRequest(), - metadata_schema=[MetadataSchema()], - ), + name="string", + logo="string", + website_url="string", + support_email="string", + payment_methods=PaymentMethodsRequest(), + email_provider=EmailProviderRequest(), + external_accounting_system_provider=ExternalAccountingSystemProviderRequest_None(), + color_scheme=ColorSchemeRequest(), + payee_onboarding_options=OnboardingOptionsRequest(), + payor_onboarding_options=OnboardingOptionsRequest(), + metadata_schema=[MetadataSchema()], ) """ _response = await self._client_wrapper.httpx_client.request( + "organization", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "organization"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "logo": logo, + "websiteUrl": website_url, + "supportEmail": support_email, + "paymentMethods": payment_methods, + "emailProvider": email_provider, + "externalAccountingSystemProvider": external_accounting_system_provider, + "colorScheme": color_scheme, + "payeeOnboardingOptions": payee_onboarding_options, + "payorOnboardingOptions": payor_onboarding_options, + "metadataSchema": metadata_schema, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -588,7 +575,7 @@ async def email_log( end_date: typing.Optional[dt.datetime] = None, limit: typing.Optional[int] = None, starting_after: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, + request_options: typing.Optional[RequestOptions] = None ) -> EmailLogResponse: """ Get log of all emails sent to this organization. Content format subject to change. @@ -633,36 +620,15 @@ async def email_log( ) """ _response = await self._client_wrapper.httpx_client.request( + "organization/emailLog", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "organization/emailLog"), - params=jsonable_encoder( - remove_none_from_dict( - { - "startDate": serialize_datetime(start_date) if start_date is not None else None, - "endDate": serialize_datetime(end_date) if end_date is not None else None, - "limit": limit, - "startingAfter": starting_after, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "startDate": serialize_datetime(start_date) if start_date is not None else None, + "endDate": serialize_datetime(end_date) if end_date is not None else None, + "limit": limit, + "startingAfter": starting_after, + }, + request_options=request_options, ) try: _response_json = _response.json() diff --git a/src/mercoa/organization/notification_configuration/client.py b/src/mercoa/organization/notification_configuration/client.py index 5767ecf..c7efeef 100644 --- a/src/mercoa/organization/notification_configuration/client.py +++ b/src/mercoa/organization/notification_configuration/client.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse from json.decoder import JSONDecodeError from ...commons.errors.bad_request import BadRequest @@ -15,7 +14,6 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 -from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions from ...entity_types.types.notification_type import NotificationType from ...organization_types.types.notification_configuration_request import NotificationConfigurationRequest @@ -54,26 +52,7 @@ def get_all( client.organization.notification_configuration.get_all() """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", "organization/notification-configurations" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + "organization/notification-configurations", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -127,27 +106,9 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( + f"organization/notification-configuration/{jsonable_encoder(notification_type)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"organization/notification-configuration/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -211,33 +172,11 @@ def update( ) """ _response = self._client_wrapper.httpx_client.request( + f"organization/notification-configuration/{jsonable_encoder(notification_type)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"organization/notification-configuration/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -291,27 +230,9 @@ def reset( ) """ _response = self._client_wrapper.httpx_client.request( + f"organization/notification-configuration/{jsonable_encoder(notification_type)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"organization/notification-configuration/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return @@ -366,26 +287,7 @@ async def get_all( await client.organization.notification_configuration.get_all() """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", "organization/notification-configurations" - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + "organization/notification-configurations", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -439,27 +341,9 @@ async def get( ) """ _response = await self._client_wrapper.httpx_client.request( + f"organization/notification-configuration/{jsonable_encoder(notification_type)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"organization/notification-configuration/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) try: _response_json = _response.json() @@ -523,33 +407,11 @@ async def update( ) """ _response = await self._client_wrapper.httpx_client.request( + f"organization/notification-configuration/{jsonable_encoder(notification_type)}", method="POST", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"organization/notification-configuration/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - json=jsonable_encoder(request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + json=request, + request_options=request_options, + omit=OMIT, ) try: _response_json = _response.json() @@ -603,27 +465,9 @@ async def reset( ) """ _response = await self._client_wrapper.httpx_client.request( + f"organization/notification-configuration/{jsonable_encoder(notification_type)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"organization/notification-configuration/{jsonable_encoder(notification_type)}", - ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) if 200 <= _response.status_code < 300: return diff --git a/src/mercoa/organization_types/types/business_onboarding_options.py b/src/mercoa/organization_types/types/business_onboarding_options.py index e398017..1ba9f7b 100644 --- a/src/mercoa/organization_types/types/business_onboarding_options.py +++ b/src/mercoa/organization_types/types/business_onboarding_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .onboarding_option import OnboardingOption @@ -27,8 +27,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/codat_provider_request.py b/src/mercoa/organization_types/types/codat_provider_request.py index 343ccd9..0d5038c 100644 --- a/src/mercoa/organization_types/types/codat_provider_request.py +++ b/src/mercoa/organization_types/types/codat_provider_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class CodatProviderRequest(pydantic_v1.BaseModel): @@ -15,8 +15,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/codat_provider_response.py b/src/mercoa/organization_types/types/codat_provider_response.py index 3dd6b59..44651af 100644 --- a/src/mercoa/organization_types/types/codat_provider_response.py +++ b/src/mercoa/organization_types/types/codat_provider_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class CodatProviderResponse(pydantic_v1.BaseModel): @@ -15,8 +15,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/color_scheme_request.py b/src/mercoa/organization_types/types/color_scheme_request.py index ced039d..db34863 100644 --- a/src/mercoa/organization_types/types/color_scheme_request.py +++ b/src/mercoa/organization_types/types/color_scheme_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class ColorSchemeRequest(pydantic_v1.BaseModel): @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/color_scheme_response.py b/src/mercoa/organization_types/types/color_scheme_response.py index a29736b..628aef6 100644 --- a/src/mercoa/organization_types/types/color_scheme_response.py +++ b/src/mercoa/organization_types/types/color_scheme_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class ColorSchemeResponse(pydantic_v1.BaseModel): @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/email_provider_request.py b/src/mercoa/organization_types/types/email_provider_request.py index a86bb4f..8021b2e 100644 --- a/src/mercoa/organization_types/types/email_provider_request.py +++ b/src/mercoa/organization_types/types/email_provider_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .email_sender_request import EmailSenderRequest @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/email_provider_response.py b/src/mercoa/organization_types/types/email_provider_response.py index 35332d7..3ee328d 100644 --- a/src/mercoa/organization_types/types/email_provider_response.py +++ b/src/mercoa/organization_types/types/email_provider_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .email_sender_response import EmailSenderResponse @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/email_sender_request.py b/src/mercoa/organization_types/types/email_sender_request.py index f7a2f49..ed4544b 100644 --- a/src/mercoa/organization_types/types/email_sender_request.py +++ b/src/mercoa/organization_types/types/email_sender_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .email_sender_provider import EmailSenderProvider @@ -19,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/email_sender_response.py b/src/mercoa/organization_types/types/email_sender_response.py index 08f0ee1..9eba2e6 100644 --- a/src/mercoa/organization_types/types/email_sender_response.py +++ b/src/mercoa/organization_types/types/email_sender_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .email_sender_provider import EmailSenderProvider @@ -19,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/external_accounting_system_provider_request.py b/src/mercoa/organization_types/types/external_accounting_system_provider_request.py index 1b6f0a6..e1bec7e 100644 --- a/src/mercoa/organization_types/types/external_accounting_system_provider_request.py +++ b/src/mercoa/organization_types/types/external_accounting_system_provider_request.py @@ -2,43 +2,87 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class ExternalAccountingSystemProviderRequest_None(pydantic_v1.BaseModel): - type: typing.Literal["none"] = "none" api_key: str = pydantic_v1.Field(alias="apiKey") + type: typing.Literal["none"] = "none" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class ExternalAccountingSystemProviderRequest_Codat(pydantic_v1.BaseModel): - type: typing.Literal["codat"] = "codat" api_key: str = pydantic_v1.Field(alias="apiKey") + type: typing.Literal["codat"] = "codat" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class ExternalAccountingSystemProviderRequest_Rutter(pydantic_v1.BaseModel): - type: typing.Literal["rutter"] = "rutter" client_id: str = pydantic_v1.Field(alias="clientId") client_secret: str = pydantic_v1.Field(alias="clientSecret") + type: typing.Literal["rutter"] = "rutter" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} ExternalAccountingSystemProviderRequest = typing.Union[ diff --git a/src/mercoa/organization_types/types/external_accounting_system_provider_response.py b/src/mercoa/organization_types/types/external_accounting_system_provider_response.py index 46c574e..9913f4f 100644 --- a/src/mercoa/organization_types/types/external_accounting_system_provider_response.py +++ b/src/mercoa/organization_types/types/external_accounting_system_provider_response.py @@ -2,43 +2,87 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class ExternalAccountingSystemProviderResponse_None(pydantic_v1.BaseModel): - type: typing.Literal["none"] = "none" has_api_key: bool = pydantic_v1.Field(alias="hasApiKey") + type: typing.Literal["none"] = "none" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class ExternalAccountingSystemProviderResponse_Codat(pydantic_v1.BaseModel): - type: typing.Literal["codat"] = "codat" has_api_key: bool = pydantic_v1.Field(alias="hasApiKey") + type: typing.Literal["codat"] = "codat" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class ExternalAccountingSystemProviderResponse_Rutter(pydantic_v1.BaseModel): - type: typing.Literal["rutter"] = "rutter" has_client_id: bool = pydantic_v1.Field(alias="hasClientId") has_client_secret: bool = pydantic_v1.Field(alias="hasClientSecret") + type: typing.Literal["rutter"] = "rutter" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} ExternalAccountingSystemProviderResponse = typing.Union[ diff --git a/src/mercoa/organization_types/types/individual_onboarding_options.py b/src/mercoa/organization_types/types/individual_onboarding_options.py index 71e7ec3..8af9e29 100644 --- a/src/mercoa/organization_types/types/individual_onboarding_options.py +++ b/src/mercoa/organization_types/types/individual_onboarding_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .onboarding_option import OnboardingOption @@ -22,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/invoice_notification_configuration_request.py b/src/mercoa/organization_types/types/invoice_notification_configuration_request.py index 3c008c2..ff4c998 100644 --- a/src/mercoa/organization_types/types/invoice_notification_configuration_request.py +++ b/src/mercoa/organization_types/types/invoice_notification_configuration_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class InvoiceNotificationConfigurationRequest(pydantic_v1.BaseModel): @@ -15,8 +15,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/invoice_notification_configuration_response.py b/src/mercoa/organization_types/types/invoice_notification_configuration_response.py index 6f317aa..2d3de33 100644 --- a/src/mercoa/organization_types/types/invoice_notification_configuration_response.py +++ b/src/mercoa/organization_types/types/invoice_notification_configuration_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.notification_type import NotificationType from .invoice_notification_configuration_request import InvoiceNotificationConfigurationRequest @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/metadata_regex_validation_rule.py b/src/mercoa/organization_types/types/metadata_regex_validation_rule.py index b651890..f1620d3 100644 --- a/src/mercoa/organization_types/types/metadata_regex_validation_rule.py +++ b/src/mercoa/organization_types/types/metadata_regex_validation_rule.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class MetadataRegexValidationRule(pydantic_v1.BaseModel): @@ -23,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/metadata_schema.py b/src/mercoa/organization_types/types/metadata_schema.py index 88020da..a29bee1 100644 --- a/src/mercoa/organization_types/types/metadata_schema.py +++ b/src/mercoa/organization_types/types/metadata_schema.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .metadata_show_conditions import MetadataShowConditions from .metadata_type import MetadataType from .metadata_validation_rule import MetadataValidationRule @@ -40,8 +40,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/metadata_show_conditions.py b/src/mercoa/organization_types/types/metadata_show_conditions.py index 32df595..1fcb5a3 100644 --- a/src/mercoa/organization_types/types/metadata_show_conditions.py +++ b/src/mercoa/organization_types/types/metadata_show_conditions.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.payment_method_type import PaymentMethodType @@ -57,8 +57,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/metadata_validation_rule.py b/src/mercoa/organization_types/types/metadata_validation_rule.py index cf889ba..521b3b5 100644 --- a/src/mercoa/organization_types/types/metadata_validation_rule.py +++ b/src/mercoa/organization_types/types/metadata_validation_rule.py @@ -2,21 +2,37 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class MetadataValidationRule_Regex(pydantic_v1.BaseModel): - type: typing.Literal["regex"] = "regex" regex: str error_message: str = pydantic_v1.Field(alias="errorMessage") + type: typing.Literal["regex"] = "regex" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} MetadataValidationRule = typing.Union[MetadataValidationRule_Regex] diff --git a/src/mercoa/organization_types/types/notification_configuration_request.py b/src/mercoa/organization_types/types/notification_configuration_request.py index a97cbb5..92bae4e 100644 --- a/src/mercoa/organization_types/types/notification_configuration_request.py +++ b/src/mercoa/organization_types/types/notification_configuration_request.py @@ -2,20 +2,36 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class NotificationConfigurationRequest_Invoice(pydantic_v1.BaseModel): - notification_type: typing.Literal["invoice"] = pydantic_v1.Field(alias="notificationType", default="invoice") url: str + notification_type: typing.Literal["invoice"] = pydantic_v1.Field(alias="notificationType", default="invoice") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} NotificationConfigurationRequest = typing.Union[NotificationConfigurationRequest_Invoice] diff --git a/src/mercoa/organization_types/types/notification_configuration_response.py b/src/mercoa/organization_types/types/notification_configuration_response.py index f1d6998..0c1bd83 100644 --- a/src/mercoa/organization_types/types/notification_configuration_response.py +++ b/src/mercoa/organization_types/types/notification_configuration_response.py @@ -2,22 +2,38 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.notification_type import NotificationType class NotificationConfigurationResponse_Invoice(pydantic_v1.BaseModel): - notification_type: typing.Literal["invoice"] = pydantic_v1.Field(alias="notificationType", default="invoice") type: NotificationType url: str + notification_type: typing.Literal["invoice"] = pydantic_v1.Field(alias="notificationType", default="invoice") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} NotificationConfigurationResponse = typing.Union[NotificationConfigurationResponse_Invoice] diff --git a/src/mercoa/organization_types/types/onboarding_option.py b/src/mercoa/organization_types/types/onboarding_option.py index 7c01c85..5fb451f 100644 --- a/src/mercoa/organization_types/types/onboarding_option.py +++ b/src/mercoa/organization_types/types/onboarding_option.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class OnboardingOption(pydantic_v1.BaseModel): @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/onboarding_options_request.py b/src/mercoa/organization_types/types/onboarding_options_request.py index 3381037..0231c3f 100644 --- a/src/mercoa/organization_types/types/onboarding_options_request.py +++ b/src/mercoa/organization_types/types/onboarding_options_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .business_onboarding_options import BusinessOnboardingOptions from .individual_onboarding_options import IndividualOnboardingOptions @@ -21,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/onboarding_options_response.py b/src/mercoa/organization_types/types/onboarding_options_response.py index 985fa0a..77862bd 100644 --- a/src/mercoa/organization_types/types/onboarding_options_response.py +++ b/src/mercoa/organization_types/types/onboarding_options_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .business_onboarding_options import BusinessOnboardingOptions from .individual_onboarding_options import IndividualOnboardingOptions @@ -21,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/organization_request.py b/src/mercoa/organization_types/types/organization_request.py index fd914ca..a93e993 100644 --- a/src/mercoa/organization_types/types/organization_request.py +++ b/src/mercoa/organization_types/types/organization_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .color_scheme_request import ColorSchemeRequest from .email_provider_request import EmailProviderRequest from .external_accounting_system_provider_request import ExternalAccountingSystemProviderRequest @@ -39,8 +39,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/organization_response.py b/src/mercoa/organization_types/types/organization_response.py index 6e694e4..5e4aadb 100644 --- a/src/mercoa/organization_types/types/organization_response.py +++ b/src/mercoa/organization_types/types/organization_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .color_scheme_response import ColorSchemeResponse from .email_provider_response import EmailProviderResponse from .external_accounting_system_provider_response import ExternalAccountingSystemProviderResponse @@ -42,8 +42,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/payment_methods_request.py b/src/mercoa/organization_types/types/payment_methods_request.py index d9ad6d3..abdb798 100644 --- a/src/mercoa/organization_types/types/payment_methods_request.py +++ b/src/mercoa/organization_types/types/payment_methods_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .payment_rail_request import PaymentRailRequest @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/payment_methods_response.py b/src/mercoa/organization_types/types/payment_methods_response.py index 41676df..a4b9808 100644 --- a/src/mercoa/organization_types/types/payment_methods_response.py +++ b/src/mercoa/organization_types/types/payment_methods_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .payment_rail_response import PaymentRailResponse @@ -29,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/payment_rail_request.py b/src/mercoa/organization_types/types/payment_rail_request.py index 509c6f4..8d11cd9 100644 --- a/src/mercoa/organization_types/types/payment_rail_request.py +++ b/src/mercoa/organization_types/types/payment_rail_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.payment_method_type import PaymentMethodType @@ -22,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/payment_rail_response.py b/src/mercoa/organization_types/types/payment_rail_response.py index 92da320..6e37551 100644 --- a/src/mercoa/organization_types/types/payment_rail_response.py +++ b/src/mercoa/organization_types/types/payment_rail_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...payment_method_types.types.payment_method_type import PaymentMethodType @@ -16,14 +16,22 @@ class PaymentRailResponse(pydantic_v1.BaseModel): """ active: bool + available: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + unused + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/rutter_provider_request.py b/src/mercoa/organization_types/types/rutter_provider_request.py index 0121598..6f299e3 100644 --- a/src/mercoa/organization_types/types/rutter_provider_request.py +++ b/src/mercoa/organization_types/types/rutter_provider_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class RutterProviderRequest(pydantic_v1.BaseModel): @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/organization_types/types/rutter_provider_response.py b/src/mercoa/organization_types/types/rutter_provider_response.py index cafe84b..7e56e89 100644 --- a/src/mercoa/organization_types/types/rutter_provider_response.py +++ b/src/mercoa/organization_types/types/rutter_provider_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class RutterProviderResponse(pydantic_v1.BaseModel): @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/bank_account_check_options.py b/src/mercoa/payment_method_types/types/bank_account_check_options.py index 4a0879c..302db2b 100644 --- a/src/mercoa/payment_method_types/types/bank_account_check_options.py +++ b/src/mercoa/payment_method_types/types/bank_account_check_options.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class BankAccountCheckOptions(pydantic_v1.BaseModel): @@ -48,8 +48,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/bank_account_request.py b/src/mercoa/payment_method_types/types/bank_account_request.py index 8e166db..6b5d30b 100644 --- a/src/mercoa/payment_method_types/types/bank_account_request.py +++ b/src/mercoa/payment_method_types/types/bank_account_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_account_check_options import BankAccountCheckOptions from .bank_type import BankType from .payment_method_base_request import PaymentMethodBaseRequest @@ -40,8 +40,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/bank_account_response.py b/src/mercoa/payment_method_types/types/bank_account_response.py index 1222954..c05575a 100644 --- a/src/mercoa/payment_method_types/types/bank_account_response.py +++ b/src/mercoa/payment_method_types/types/bank_account_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_account_check_options import BankAccountCheckOptions from .bank_status import BankStatus from .bank_type import BankType @@ -55,8 +55,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/bank_account_update_request.py b/src/mercoa/payment_method_types/types/bank_account_update_request.py index 7998c53..dbb1f56 100644 --- a/src/mercoa/payment_method_types/types/bank_account_update_request.py +++ b/src/mercoa/payment_method_types/types/bank_account_update_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_account_check_options import BankAccountCheckOptions from .payment_method_base_request import PaymentMethodBaseRequest from .plaid_link_request import PlaidLinkRequest @@ -27,8 +27,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/card_request.py b/src/mercoa/payment_method_types/types/card_request.py index 0a93ecb..3560f2d 100644 --- a/src/mercoa/payment_method_types/types/card_request.py +++ b/src/mercoa/payment_method_types/types/card_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .card_brand import CardBrand from .card_type import CardType from .payment_method_base_request import PaymentMethodBaseRequest @@ -23,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/card_response.py b/src/mercoa/payment_method_types/types/card_response.py index f87fe4a..f752cfd 100644 --- a/src/mercoa/payment_method_types/types/card_response.py +++ b/src/mercoa/payment_method_types/types/card_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .card_brand import CardBrand from .card_type import CardType from .payment_method_base_response import PaymentMethodBaseResponse @@ -22,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/check_request.py b/src/mercoa/payment_method_types/types/check_request.py index b690da4..7a6d674 100644 --- a/src/mercoa/payment_method_types/types/check_request.py +++ b/src/mercoa/payment_method_types/types/check_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .payment_method_base_request import PaymentMethodBaseRequest @@ -22,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/check_response.py b/src/mercoa/payment_method_types/types/check_response.py index 6754d1d..0924ddb 100644 --- a/src/mercoa/payment_method_types/types/check_response.py +++ b/src/mercoa/payment_method_types/types/check_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .payment_method_base_response import PaymentMethodBaseResponse @@ -50,8 +50,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/custom_payment_method_request.py b/src/mercoa/payment_method_types/types/custom_payment_method_request.py index ce3abfd..9968cbe 100644 --- a/src/mercoa/payment_method_types/types/custom_payment_method_request.py +++ b/src/mercoa/payment_method_types/types/custom_payment_method_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .custom_payment_method_schema_id import CustomPaymentMethodSchemaId from .payment_method_base_request import PaymentMethodBaseRequest @@ -51,8 +51,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/custom_payment_method_response.py b/src/mercoa/payment_method_types/types/custom_payment_method_response.py index 103e635..8aee4e6 100644 --- a/src/mercoa/payment_method_types/types/custom_payment_method_response.py +++ b/src/mercoa/payment_method_types/types/custom_payment_method_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .custom_payment_method_schema_id import CustomPaymentMethodSchemaId from .custom_payment_method_schema_response import CustomPaymentMethodSchemaResponse from .payment_method_base_response import PaymentMethodBaseResponse @@ -34,8 +34,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/custom_payment_method_schema_field.py b/src/mercoa/payment_method_types/types/custom_payment_method_schema_field.py index 03190aa..fcb9977 100644 --- a/src/mercoa/payment_method_types/types/custom_payment_method_schema_field.py +++ b/src/mercoa/payment_method_types/types/custom_payment_method_schema_field.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .custom_payment_method_schema_field_type import CustomPaymentMethodSchemaFieldType @@ -50,8 +50,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/custom_payment_method_schema_request.py b/src/mercoa/payment_method_types/types/custom_payment_method_schema_request.py index 4896905..5362098 100644 --- a/src/mercoa/payment_method_types/types/custom_payment_method_schema_request.py +++ b/src/mercoa/payment_method_types/types/custom_payment_method_schema_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .currency_code import CurrencyCode from .custom_payment_method_schema_field import CustomPaymentMethodSchemaField @@ -78,8 +78,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/custom_payment_method_schema_response.py b/src/mercoa/payment_method_types/types/custom_payment_method_schema_response.py index f843c3c..c4124ad 100644 --- a/src/mercoa/payment_method_types/types/custom_payment_method_schema_response.py +++ b/src/mercoa/payment_method_types/types/custom_payment_method_schema_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .currency_code import CurrencyCode from .custom_payment_method_schema_field import CustomPaymentMethodSchemaField from .custom_payment_method_schema_id import CustomPaymentMethodSchemaId @@ -89,8 +89,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/custom_payment_method_update_request.py b/src/mercoa/payment_method_types/types/custom_payment_method_update_request.py index cdf54a2..a028188 100644 --- a/src/mercoa/payment_method_types/types/custom_payment_method_update_request.py +++ b/src/mercoa/payment_method_types/types/custom_payment_method_update_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .custom_payment_method_schema_id import CustomPaymentMethodSchemaId from .payment_method_base_request import PaymentMethodBaseRequest @@ -32,8 +32,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/payment_method_balance_response.py b/src/mercoa/payment_method_types/types/payment_method_balance_response.py index 8935a99..d7b9cd9 100644 --- a/src/mercoa/payment_method_types/types/payment_method_balance_response.py +++ b/src/mercoa/payment_method_types/types/payment_method_balance_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .currency_code import CurrencyCode from .payment_method_balance_status import PaymentMethodBalanceStatus @@ -27,8 +27,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/payment_method_base_request.py b/src/mercoa/payment_method_types/types/payment_method_base_request.py index 8b29e66..ee52c8e 100644 --- a/src/mercoa/payment_method_types/types/payment_method_base_request.py +++ b/src/mercoa/payment_method_types/types/payment_method_base_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class PaymentMethodBaseRequest(pydantic_v1.BaseModel): @@ -23,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/payment_method_base_response.py b/src/mercoa/payment_method_types/types/payment_method_base_response.py index ee479d5..a053ada 100644 --- a/src/mercoa/payment_method_types/types/payment_method_base_response.py +++ b/src/mercoa/payment_method_types/types/payment_method_base_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .currency_code import CurrencyCode from .payment_method_id import PaymentMethodId @@ -30,8 +30,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/mercoa/payment_method_types/types/payment_method_request.py b/src/mercoa/payment_method_types/types/payment_method_request.py index 7593ea2..cf70489 100644 --- a/src/mercoa/payment_method_types/types/payment_method_request.py +++ b/src/mercoa/payment_method_types/types/payment_method_request.py @@ -2,9 +2,11 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_account_check_options import BankAccountCheckOptions from .bank_type import BankType from .card_brand import CardBrand @@ -14,88 +16,218 @@ class PaymentMethodRequest_BankAccount(pydantic_v1.BaseModel): - type: typing.Literal["bankAccount"] = "bankAccount" - account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName") - bank_name: typing.Optional[str] = pydantic_v1.Field(alias="bankName") + """ + Examples + -------- + from mercoa import PaymentMethodRequest_BankAccount + + PaymentMethodRequest_BankAccount( + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + ) + """ + + account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName", default=None) + bank_name: typing.Optional[str] = pydantic_v1.Field(alias="bankName", default=None) routing_number: str = pydantic_v1.Field(alias="routingNumber") account_number: str = pydantic_v1.Field(alias="accountNumber") account_type: BankType = pydantic_v1.Field(alias="accountType") - plaid: typing.Optional[PlaidLinkRequest] - check_options: typing.Optional[BankAccountCheckOptions] = pydantic_v1.Field(alias="checkOptions") - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + plaid: typing.Optional[PlaidLinkRequest] = None + check_options: typing.Optional[BankAccountCheckOptions] = pydantic_v1.Field(alias="checkOptions", default=None) + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) + type: typing.Literal["bankAccount"] = "bankAccount" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodRequest_Card(pydantic_v1.BaseModel): - type: typing.Literal["card"] = "card" + """ + Examples + -------- + from mercoa import PaymentMethodRequest_BankAccount + + PaymentMethodRequest_BankAccount( + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + ) + """ + card_type: CardType = pydantic_v1.Field(alias="cardType") card_brand: CardBrand = pydantic_v1.Field(alias="cardBrand") last_four: str = pydantic_v1.Field(alias="lastFour") exp_month: str = pydantic_v1.Field(alias="expMonth") exp_year: str = pydantic_v1.Field(alias="expYear") token: str - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) + type: typing.Literal["card"] = "card" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodRequest_Check(pydantic_v1.BaseModel): - type: typing.Literal["check"] = "check" + """ + Examples + -------- + from mercoa import PaymentMethodRequest_BankAccount + + PaymentMethodRequest_BankAccount( + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + ) + """ + pay_to_the_order_of: str = pydantic_v1.Field(alias="payToTheOrderOf") address_line_1: str = pydantic_v1.Field(alias="addressLine1") - address_line_2: typing.Optional[str] = pydantic_v1.Field(alias="addressLine2") + address_line_2: typing.Optional[str] = pydantic_v1.Field(alias="addressLine2", default=None) city: str state_or_province: str = pydantic_v1.Field(alias="stateOrProvince") postal_code: str = pydantic_v1.Field(alias="postalCode") country: str - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) + type: typing.Literal["check"] = "check" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodRequest_Custom(pydantic_v1.BaseModel): - type: typing.Literal["custom"] = "custom" + """ + Examples + -------- + from mercoa import PaymentMethodRequest_BankAccount + + PaymentMethodRequest_BankAccount( + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + ) + """ + foreign_id: str = pydantic_v1.Field(alias="foreignId") - account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName") - account_number: typing.Optional[str] = pydantic_v1.Field(alias="accountNumber") + account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName", default=None) + account_number: typing.Optional[str] = pydantic_v1.Field(alias="accountNumber", default=None) schema_id: CustomPaymentMethodSchemaId = pydantic_v1.Field(alias="schemaId") data: typing.Dict[str, str] - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) + type: typing.Literal["custom"] = "custom" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodRequest_OffPlatform(pydantic_v1.BaseModel): + """ + Examples + -------- + from mercoa import PaymentMethodRequest_BankAccount + + PaymentMethodRequest_BankAccount( + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + ) + """ + + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) type: typing.Literal["offPlatform"] = "offPlatform" - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} """ diff --git a/src/mercoa/payment_method_types/types/payment_method_response.py b/src/mercoa/payment_method_types/types/payment_method_response.py index 22914fd..0937d1b 100644 --- a/src/mercoa/payment_method_types/types/payment_method_response.py +++ b/src/mercoa/payment_method_types/types/payment_method_response.py @@ -5,7 +5,8 @@ import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_account_check_options import BankAccountCheckOptions from .bank_status import BankStatus from .bank_type import BankType @@ -18,30 +19,97 @@ class PaymentMethodResponse_BankAccount(pydantic_v1.BaseModel): - type: typing.Literal["bankAccount"] = "bankAccount" + """ + Examples + -------- + import datetime + + from mercoa import PaymentMethodResponse_BankAccount + + PaymentMethodResponse_BankAccount( + id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + account_name="My Checking Account", + bank_name="Chase", + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + status="VERIFIED", + is_default_source=True, + is_default_destination=True, + supported_currencies=["USD"], + created_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + ) + """ + account_name: str = pydantic_v1.Field(alias="accountName") bank_name: str = pydantic_v1.Field(alias="bankName") routing_number: str = pydantic_v1.Field(alias="routingNumber") account_number: str = pydantic_v1.Field(alias="accountNumber") account_type: BankType = pydantic_v1.Field(alias="accountType") status: BankStatus - check_options: typing.Optional[BankAccountCheckOptions] = pydantic_v1.Field(alias="checkOptions") + check_options: typing.Optional[BankAccountCheckOptions] = pydantic_v1.Field(alias="checkOptions", default=None) id: PaymentMethodId is_default_source: bool = pydantic_v1.Field(alias="isDefaultSource") is_default_destination: bool = pydantic_v1.Field(alias="isDefaultDestination") supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies") created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") + type: typing.Literal["bankAccount"] = "bankAccount" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodResponse_Card(pydantic_v1.BaseModel): - type: typing.Literal["card"] = "card" + """ + Examples + -------- + import datetime + + from mercoa import PaymentMethodResponse_BankAccount + + PaymentMethodResponse_BankAccount( + id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + account_name="My Checking Account", + bank_name="Chase", + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + status="VERIFIED", + is_default_source=True, + is_default_destination=True, + supported_currencies=["USD"], + created_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + ) + """ + card_type: CardType = pydantic_v1.Field(alias="cardType") card_brand: CardBrand = pydantic_v1.Field(alias="cardBrand") last_four: str = pydantic_v1.Field(alias="lastFour") @@ -53,19 +121,60 @@ class PaymentMethodResponse_Card(pydantic_v1.BaseModel): supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies") created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") + type: typing.Literal["card"] = "card" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodResponse_Check(pydantic_v1.BaseModel): - type: typing.Literal["check"] = "check" + """ + Examples + -------- + import datetime + + from mercoa import PaymentMethodResponse_BankAccount + + PaymentMethodResponse_BankAccount( + id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + account_name="My Checking Account", + bank_name="Chase", + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + status="VERIFIED", + is_default_source=True, + is_default_destination=True, + supported_currencies=["USD"], + created_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + ) + """ + pay_to_the_order_of: str = pydantic_v1.Field(alias="payToTheOrderOf") address_line_1: str = pydantic_v1.Field(alias="addressLine1") - address_line_2: typing.Optional[str] = pydantic_v1.Field(alias="addressLine2") + address_line_2: typing.Optional[str] = pydantic_v1.Field(alias="addressLine2", default=None) city: str state_or_province: str = pydantic_v1.Field(alias="stateOrProvince") postal_code: str = pydantic_v1.Field(alias="postalCode") @@ -76,19 +185,60 @@ class PaymentMethodResponse_Check(pydantic_v1.BaseModel): supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies") created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") + type: typing.Literal["check"] = "check" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodResponse_Custom(pydantic_v1.BaseModel): - type: typing.Literal["custom"] = "custom" + """ + Examples + -------- + import datetime + + from mercoa import PaymentMethodResponse_BankAccount + + PaymentMethodResponse_BankAccount( + id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + account_name="My Checking Account", + bank_name="Chase", + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + status="VERIFIED", + is_default_source=True, + is_default_destination=True, + supported_currencies=["USD"], + created_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + ) + """ + foreign_id: str = pydantic_v1.Field(alias="foreignId") - account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName") - account_number: typing.Optional[str] = pydantic_v1.Field(alias="accountNumber") + account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName", default=None) + account_number: typing.Optional[str] = pydantic_v1.Field(alias="accountNumber", default=None) schema_id: CustomPaymentMethodSchemaId = pydantic_v1.Field(alias="schemaId") schema_: CustomPaymentMethodSchemaResponse = pydantic_v1.Field(alias="schema") data: typing.Dict[str, str] @@ -98,28 +248,84 @@ class PaymentMethodResponse_Custom(pydantic_v1.BaseModel): supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies") created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") + type: typing.Literal["custom"] = "custom" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodResponse_OffPlatform(pydantic_v1.BaseModel): - type: typing.Literal["offPlatform"] = "offPlatform" + """ + Examples + -------- + import datetime + + from mercoa import PaymentMethodResponse_BankAccount + + PaymentMethodResponse_BankAccount( + id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + account_name="My Checking Account", + bank_name="Chase", + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + status="VERIFIED", + is_default_source=True, + is_default_destination=True, + supported_currencies=["USD"], + created_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + ) + """ + id: PaymentMethodId is_default_source: bool = pydantic_v1.Field(alias="isDefaultSource") is_default_destination: bool = pydantic_v1.Field(alias="isDefaultDestination") supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies") created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") + type: typing.Literal["offPlatform"] = "offPlatform" + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} """ diff --git a/src/mercoa/payment_method_types/types/payment_method_update_request.py b/src/mercoa/payment_method_types/types/payment_method_update_request.py index 489bd7a..fcb7f5a 100644 --- a/src/mercoa/payment_method_types/types/payment_method_update_request.py +++ b/src/mercoa/payment_method_types/types/payment_method_update_request.py @@ -2,80 +2,217 @@ from __future__ import annotations +import datetime as dt import typing -from ...core.pydantic_utilities import pydantic_v1 +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bank_account_check_options import BankAccountCheckOptions from .custom_payment_method_schema_id import CustomPaymentMethodSchemaId from .plaid_link_request import PlaidLinkRequest class PaymentMethodUpdateRequest_Custom(pydantic_v1.BaseModel): + """ + Update a payment method. for non custom payment methods. + + Examples + -------- + from mercoa import PaymentMethodUpdateRequest_BankAccount + + PaymentMethodUpdateRequest_BankAccount( + default_source=True, + default_destination=True, + ) + """ + + foreign_id: typing.Optional[str] = pydantic_v1.Field(alias="foreignId", default=None) + account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName", default=None) + account_number: typing.Optional[str] = pydantic_v1.Field(alias="accountNumber", default=None) + schema_id: typing.Optional[CustomPaymentMethodSchemaId] = pydantic_v1.Field(alias="schemaId", default=None) + data: typing.Optional[typing.Dict[str, str]] = None + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) type: typing.Literal["custom"] = "custom" - foreign_id: typing.Optional[str] = pydantic_v1.Field(alias="foreignId") - account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName") - account_number: typing.Optional[str] = pydantic_v1.Field(alias="accountNumber") - schema_id: typing.Optional[CustomPaymentMethodSchemaId] = pydantic_v1.Field(alias="schemaId") - data: typing.Optional[typing.Dict[str, str]] - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodUpdateRequest_BankAccount(pydantic_v1.BaseModel): + """ + Update a payment method. for non custom payment methods. + + Examples + -------- + from mercoa import PaymentMethodUpdateRequest_BankAccount + + PaymentMethodUpdateRequest_BankAccount( + default_source=True, + default_destination=True, + ) + """ + + account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName", default=None) + plaid: typing.Optional[PlaidLinkRequest] = None + check_options: typing.Optional[BankAccountCheckOptions] = pydantic_v1.Field(alias="checkOptions", default=None) + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) type: typing.Literal["bankAccount"] = "bankAccount" - account_name: typing.Optional[str] = pydantic_v1.Field(alias="accountName") - plaid: typing.Optional[PlaidLinkRequest] - check_options: typing.Optional[BankAccountCheckOptions] = pydantic_v1.Field(alias="checkOptions") - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodUpdateRequest_Card(pydantic_v1.BaseModel): + """ + Update a payment method. for non custom payment methods. + + Examples + -------- + from mercoa import PaymentMethodUpdateRequest_BankAccount + + PaymentMethodUpdateRequest_BankAccount( + default_source=True, + default_destination=True, + ) + """ + + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) type: typing.Literal["card"] = "card" - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodUpdateRequest_Check(pydantic_v1.BaseModel): + """ + Update a payment method. for non custom payment methods. + + Examples + -------- + from mercoa import PaymentMethodUpdateRequest_BankAccount + + PaymentMethodUpdateRequest_BankAccount( + default_source=True, + default_destination=True, + ) + """ + + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) type: typing.Literal["check"] = "check" - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} class PaymentMethodUpdateRequest_OffPlatform(pydantic_v1.BaseModel): + """ + Update a payment method. for non custom payment methods. + + Examples + -------- + from mercoa import PaymentMethodUpdateRequest_BankAccount + + PaymentMethodUpdateRequest_BankAccount( + default_source=True, + default_destination=True, + ) + """ + + default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None) + default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None) type: typing.Literal["offPlatform"] = "offPlatform" - default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource") - default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True allow_population_by_field_name = True populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} """ diff --git a/src/mercoa/payment_method_types/types/plaid_link_request.py b/src/mercoa/payment_method_types/types/plaid_link_request.py index ebe2b7d..f12bcdd 100644 --- a/src/mercoa/payment_method_types/types/plaid_link_request.py +++ b/src/mercoa/payment_method_types/types/plaid_link_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 class PlaidLinkRequest(pydantic_v1.BaseModel): @@ -28,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True