diff --git a/poetry.lock b/poetry.lock index 371ffe1..95c5026 100644 --- a/poetry.lock +++ b/poetry.lock @@ -38,13 +38,13 @@ trio = ["trio (>=0.23)"] [[package]] name = "certifi" -version = "2024.6.2" +version = "2024.7.4" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.6.2-py3-none-any.whl", hash = "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56"}, - {file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"}, + {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, + {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, ] [[package]] @@ -235,18 +235,18 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydantic" -version = "2.8.0" +version = "2.8.2" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.8.0-py3-none-any.whl", hash = "sha256:ead4f3a1e92386a734ca1411cb25d94147cf8778ed5be6b56749047676d6364e"}, - {file = "pydantic-2.8.0.tar.gz", hash = "sha256:d970ffb9d030b710795878940bd0489842c638e7252fc4a19c3ae2f7da4d6141"}, + {file = "pydantic-2.8.2-py3-none-any.whl", hash = "sha256:73ee9fddd406dc318b885c7a2eab8a6472b68b8fb5ba8150949fc3db939f23c8"}, + {file = "pydantic-2.8.2.tar.gz", hash = "sha256:6f62c13d067b0755ad1c21a34bdd06c0c12625a22b0fc09c6b149816604f7c2a"}, ] [package.dependencies] annotated-types = ">=0.4.0" -pydantic-core = "2.20.0" +pydantic-core = "2.20.1" typing-extensions = [ {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, {version = ">=4.6.1", markers = "python_version < \"3.13\""}, @@ -257,99 +257,100 @@ email = ["email-validator (>=2.0.0)"] [[package]] name = "pydantic-core" -version = "2.20.0" +version = "2.20.1" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.20.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:e9dcd7fb34f7bfb239b5fa420033642fff0ad676b765559c3737b91f664d4fa9"}, - {file = "pydantic_core-2.20.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:649a764d9b0da29816889424697b2a3746963ad36d3e0968784ceed6e40c6355"}, - {file = "pydantic_core-2.20.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7701df088d0b05f3460f7ba15aec81ac8b0fb5690367dfd072a6c38cf5b7fdb5"}, - {file = "pydantic_core-2.20.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ab760f17c3e792225cdaef31ca23c0aea45c14ce80d8eff62503f86a5ab76bff"}, - {file = "pydantic_core-2.20.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cb1ad5b4d73cde784cf64580166568074f5ccd2548d765e690546cff3d80937d"}, - {file = "pydantic_core-2.20.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b81ec2efc04fc1dbf400647d4357d64fb25543bae38d2d19787d69360aad21c9"}, - {file = "pydantic_core-2.20.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c4a9732a5cad764ba37f3aa873dccb41b584f69c347a57323eda0930deec8e10"}, - {file = "pydantic_core-2.20.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6dc85b9e10cc21d9c1055f15684f76fa4facadddcb6cd63abab702eb93c98943"}, - {file = "pydantic_core-2.20.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:21d9f7e24f63fdc7118e6cc49defaab8c1d27570782f7e5256169d77498cf7c7"}, - {file = "pydantic_core-2.20.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8b315685832ab9287e6124b5d74fc12dda31e6421d7f6b08525791452844bc2d"}, - {file = "pydantic_core-2.20.0-cp310-none-win32.whl", hash = "sha256:c3dc8ec8b87c7ad534c75b8855168a08a7036fdb9deeeed5705ba9410721c84d"}, - {file = "pydantic_core-2.20.0-cp310-none-win_amd64.whl", hash = "sha256:85770b4b37bb36ef93a6122601795231225641003e0318d23c6233c59b424279"}, - {file = "pydantic_core-2.20.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:58e251bb5a5998f7226dc90b0b753eeffa720bd66664eba51927c2a7a2d5f32c"}, - {file = "pydantic_core-2.20.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:78d584caac52c24240ef9ecd75de64c760bbd0e20dbf6973631815e3ef16ef8b"}, - {file = "pydantic_core-2.20.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5084ec9721f82bef5ff7c4d1ee65e1626783abb585f8c0993833490b63fe1792"}, - {file = "pydantic_core-2.20.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6d0f52684868db7c218437d260e14d37948b094493f2646f22d3dda7229bbe3f"}, - {file = "pydantic_core-2.20.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1def125d59a87fe451212a72ab9ed34c118ff771e5473fef4f2f95d8ede26d75"}, - {file = "pydantic_core-2.20.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b34480fd6778ab356abf1e9086a4ced95002a1e195e8d2fd182b0def9d944d11"}, - {file = "pydantic_core-2.20.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d42669d319db366cb567c3b444f43caa7ffb779bf9530692c6f244fc635a41eb"}, - {file = "pydantic_core-2.20.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:53b06aea7a48919a254b32107647be9128c066aaa6ee6d5d08222325f25ef175"}, - {file = "pydantic_core-2.20.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:1f038156b696a1c39d763b2080aeefa87ddb4162c10aa9fabfefffc3dd8180fa"}, - {file = "pydantic_core-2.20.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3f0f3a4a23717280a5ee3ac4fb1f81d6fde604c9ec5100f7f6f987716bb8c137"}, - {file = "pydantic_core-2.20.0-cp311-none-win32.whl", hash = "sha256:316fe7c3fec017affd916a0c83d6f1ec697cbbbdf1124769fa73328e7907cc2e"}, - {file = "pydantic_core-2.20.0-cp311-none-win_amd64.whl", hash = "sha256:2d06a7fa437f93782e3f32d739c3ec189f82fca74336c08255f9e20cea1ed378"}, - {file = "pydantic_core-2.20.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:d6f8c49657f3eb7720ed4c9b26624063da14937fc94d1812f1e04a2204db3e17"}, - {file = "pydantic_core-2.20.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ad1bd2f377f56fec11d5cfd0977c30061cd19f4fa199bf138b200ec0d5e27eeb"}, - {file = "pydantic_core-2.20.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed741183719a5271f97d93bbcc45ed64619fa38068aaa6e90027d1d17e30dc8d"}, - {file = "pydantic_core-2.20.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d82e5ed3a05f2dcb89c6ead2fd0dbff7ac09bc02c1b4028ece2d3a3854d049ce"}, - {file = "pydantic_core-2.20.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b2ba34a099576234671f2e4274e5bc6813b22e28778c216d680eabd0db3f7dad"}, - {file = "pydantic_core-2.20.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:879ae6bb08a063b3e1b7ac8c860096d8fd6b48dd9b2690b7f2738b8c835e744b"}, - {file = "pydantic_core-2.20.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b0eefc7633a04c0694340aad91fbfd1986fe1a1e0c63a22793ba40a18fcbdc8"}, - {file = "pydantic_core-2.20.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:73deadd6fd8a23e2f40b412b3ac617a112143c8989a4fe265050fd91ba5c0608"}, - {file = "pydantic_core-2.20.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:35681445dc85446fb105943d81ae7569aa7e89de80d1ca4ac3229e05c311bdb1"}, - {file = "pydantic_core-2.20.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0f6dd3612a3b9f91f2e63924ea18a4476656c6d01843ca20a4c09e00422195af"}, - {file = "pydantic_core-2.20.0-cp312-none-win32.whl", hash = "sha256:7e37b6bb6e90c2b8412b06373c6978d9d81e7199a40e24a6ef480e8acdeaf918"}, - {file = "pydantic_core-2.20.0-cp312-none-win_amd64.whl", hash = "sha256:7d4df13d1c55e84351fab51383520b84f490740a9f1fec905362aa64590b7a5d"}, - {file = "pydantic_core-2.20.0-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:d43e7ab3b65e4dc35a7612cfff7b0fd62dce5bc11a7cd198310b57f39847fd6c"}, - {file = "pydantic_core-2.20.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7b6a24d7b5893392f2b8e3b7a0031ae3b14c6c1942a4615f0d8794fdeeefb08b"}, - {file = "pydantic_core-2.20.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b2f13c3e955a087c3ec86f97661d9f72a76e221281b2262956af381224cfc243"}, - {file = "pydantic_core-2.20.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:72432fd6e868c8d0a6849869e004b8bcae233a3c56383954c228316694920b38"}, - {file = "pydantic_core-2.20.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d70a8ff2d4953afb4cbe6211f17268ad29c0b47e73d3372f40e7775904bc28fc"}, - {file = "pydantic_core-2.20.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8e49524917b8d3c2f42cd0d2df61178e08e50f5f029f9af1f402b3ee64574392"}, - {file = "pydantic_core-2.20.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a4f0f71653b1c1bad0350bc0b4cc057ab87b438ff18fa6392533811ebd01439c"}, - {file = "pydantic_core-2.20.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:16197e6f4fdecb9892ed2436e507e44f0a1aa2cff3b9306d1c879ea2f9200997"}, - {file = "pydantic_core-2.20.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:763602504bf640b3ded3bba3f8ed8a1cc2fc6a87b8d55c1c5689f428c49c947e"}, - {file = "pydantic_core-2.20.0-cp313-none-win32.whl", hash = "sha256:a3f243f318bd9523277fa123b3163f4c005a3e8619d4b867064de02f287a564d"}, - {file = "pydantic_core-2.20.0-cp313-none-win_amd64.whl", hash = "sha256:03aceaf6a5adaad3bec2233edc5a7905026553916615888e53154807e404545c"}, - {file = "pydantic_core-2.20.0-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:d6f2d8b8da1f03f577243b07bbdd3412eee3d37d1f2fd71d1513cbc76a8c1239"}, - {file = "pydantic_core-2.20.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a272785a226869416c6b3c1b7e450506152d3844207331f02f27173562c917e0"}, - {file = "pydantic_core-2.20.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:efbb412d55a4ffe73963fed95c09ccb83647ec63b711c4b3752be10a56f0090b"}, - {file = "pydantic_core-2.20.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1e4f46189d8740561b43655263a41aac75ff0388febcb2c9ec4f1b60a0ec12f3"}, - {file = "pydantic_core-2.20.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:87d3df115f4a3c8c5e4d5acf067d399c6466d7e604fc9ee9acbe6f0c88a0c3cf"}, - {file = "pydantic_core-2.20.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a340d2bdebe819d08f605e9705ed551c3feb97e4fd71822d7147c1e4bdbb9508"}, - {file = "pydantic_core-2.20.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:616b9c2f882393d422ba11b40e72382fe975e806ad693095e9a3b67c59ea6150"}, - {file = "pydantic_core-2.20.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:25c46bb2ff6084859bbcfdf4f1a63004b98e88b6d04053e8bf324e115398e9e7"}, - {file = "pydantic_core-2.20.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:23425eccef8f2c342f78d3a238c824623836c6c874d93c726673dbf7e56c78c0"}, - {file = "pydantic_core-2.20.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:52527e8f223ba29608d999d65b204676398009725007c9336651c2ec2d93cffc"}, - {file = "pydantic_core-2.20.0-cp38-none-win32.whl", hash = "sha256:1c3c5b7f70dd19a6845292b0775295ea81c61540f68671ae06bfe4421b3222c2"}, - {file = "pydantic_core-2.20.0-cp38-none-win_amd64.whl", hash = "sha256:8093473d7b9e908af1cef30025609afc8f5fd2a16ff07f97440fd911421e4432"}, - {file = "pydantic_core-2.20.0-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:ee7785938e407418795e4399b2bf5b5f3cf6cf728077a7f26973220d58d885cf"}, - {file = "pydantic_core-2.20.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0e75794883d635071cf6b4ed2a5d7a1e50672ab7a051454c76446ef1ebcdcc91"}, - {file = "pydantic_core-2.20.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:344e352c96e53b4f56b53d24728217c69399b8129c16789f70236083c6ceb2ac"}, - {file = "pydantic_core-2.20.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:978d4123ad1e605daf1ba5e01d4f235bcf7b6e340ef07e7122e8e9cfe3eb61ab"}, - {file = "pydantic_core-2.20.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c05eaf6c863781eb834ab41f5963604ab92855822a2062897958089d1335dad"}, - {file = "pydantic_core-2.20.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bc7e43b4a528ffca8c9151b6a2ca34482c2fdc05e6aa24a84b7f475c896fc51d"}, - {file = "pydantic_core-2.20.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:658287a29351166510ebbe0a75c373600cc4367a3d9337b964dada8d38bcc0f4"}, - {file = "pydantic_core-2.20.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1dacf660d6de692fe351e8c806e7efccf09ee5184865893afbe8e59be4920b4a"}, - {file = "pydantic_core-2.20.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:3e147fc6e27b9a487320d78515c5f29798b539179f7777018cedf51b7749e4f4"}, - {file = "pydantic_core-2.20.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c867230d715a3dd1d962c8d9bef0d3168994ed663e21bf748b6e3a529a129aab"}, - {file = "pydantic_core-2.20.0-cp39-none-win32.whl", hash = "sha256:22b813baf0dbf612752d8143a2dbf8e33ccb850656b7850e009bad2e101fc377"}, - {file = "pydantic_core-2.20.0-cp39-none-win_amd64.whl", hash = "sha256:3a7235b46c1bbe201f09b6f0f5e6c36b16bad3d0532a10493742f91fbdc8035f"}, - {file = "pydantic_core-2.20.0-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:cafde15a6f7feaec2f570646e2ffc5b73412295d29134a29067e70740ec6ee20"}, - {file = "pydantic_core-2.20.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:2aec8eeea0b08fd6bc2213d8e86811a07491849fd3d79955b62d83e32fa2ad5f"}, - {file = "pydantic_core-2.20.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:840200827984f1c4e114008abc2f5ede362d6e11ed0b5931681884dd41852ff1"}, - {file = "pydantic_core-2.20.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f8ea1d8b7df522e5ced34993c423c3bf3735c53df8b2a15688a2f03a7d678800"}, - {file = "pydantic_core-2.20.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d5b8376a867047bf08910573deb95d3c8dfb976eb014ee24f3b5a61ccc5bee1b"}, - {file = "pydantic_core-2.20.0-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:d08264b4460326cefacc179fc1411304d5af388a79910832835e6f641512358b"}, - {file = "pydantic_core-2.20.0-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:7a3639011c2e8a9628466f616ed7fb413f30032b891898e10895a0a8b5857d6c"}, - {file = "pydantic_core-2.20.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:05e83ce2f7eba29e627dd8066aa6c4c0269b2d4f889c0eba157233a353053cea"}, - {file = "pydantic_core-2.20.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:603a843fea76a595c8f661cd4da4d2281dff1e38c4a836a928eac1a2f8fe88e4"}, - {file = "pydantic_core-2.20.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:ac76f30d5d3454f4c28826d891fe74d25121a346c69523c9810ebba43f3b1cec"}, - {file = "pydantic_core-2.20.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22e3b1d4b1b3f6082849f9b28427ef147a5b46a6132a3dbaf9ca1baa40c88609"}, - {file = "pydantic_core-2.20.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2761f71faed820e25ec62eacba670d1b5c2709bb131a19fcdbfbb09884593e5a"}, - {file = "pydantic_core-2.20.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a0586cddbf4380e24569b8a05f234e7305717cc8323f50114dfb2051fcbce2a3"}, - {file = "pydantic_core-2.20.0-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:b8c46a8cf53e849eea7090f331ae2202cd0f1ceb090b00f5902c423bd1e11805"}, - {file = "pydantic_core-2.20.0-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:b4a085bd04af7245e140d1b95619fe8abb445a3d7fdf219b3f80c940853268ef"}, - {file = "pydantic_core-2.20.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:116b326ac82c8b315e7348390f6d30bcfe6e688a7d3f1de50ff7bcc2042a23c2"}, - {file = "pydantic_core-2.20.0.tar.gz", hash = "sha256:366be8e64e0cb63d87cf79b4e1765c0703dd6313c729b22e7b9e378db6b96877"}, + {file = "pydantic_core-2.20.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:3acae97ffd19bf091c72df4d726d552c473f3576409b2a7ca36b2f535ffff4a3"}, + {file = "pydantic_core-2.20.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:41f4c96227a67a013e7de5ff8f20fb496ce573893b7f4f2707d065907bffdbd6"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f239eb799a2081495ea659d8d4a43a8f42cd1fe9ff2e7e436295c38a10c286a"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:53e431da3fc53360db73eedf6f7124d1076e1b4ee4276b36fb25514544ceb4a3"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f1f62b2413c3a0e846c3b838b2ecd6c7a19ec6793b2a522745b0869e37ab5bc1"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5d41e6daee2813ecceea8eda38062d69e280b39df793f5a942fa515b8ed67953"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d482efec8b7dc6bfaedc0f166b2ce349df0011f5d2f1f25537ced4cfc34fd98"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e93e1a4b4b33daed65d781a57a522ff153dcf748dee70b40c7258c5861e1768a"}, + {file = "pydantic_core-2.20.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e7c4ea22b6739b162c9ecaaa41d718dfad48a244909fe7ef4b54c0b530effc5a"}, + {file = "pydantic_core-2.20.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4f2790949cf385d985a31984907fecb3896999329103df4e4983a4a41e13e840"}, + {file = "pydantic_core-2.20.1-cp310-none-win32.whl", hash = "sha256:5e999ba8dd90e93d57410c5e67ebb67ffcaadcea0ad973240fdfd3a135506250"}, + {file = "pydantic_core-2.20.1-cp310-none-win_amd64.whl", hash = "sha256:512ecfbefef6dac7bc5eaaf46177b2de58cdf7acac8793fe033b24ece0b9566c"}, + {file = "pydantic_core-2.20.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d2a8fa9d6d6f891f3deec72f5cc668e6f66b188ab14bb1ab52422fe8e644f312"}, + {file = "pydantic_core-2.20.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:175873691124f3d0da55aeea1d90660a6ea7a3cfea137c38afa0a5ffabe37b88"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:37eee5b638f0e0dcd18d21f59b679686bbd18917b87db0193ae36f9c23c355fc"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:25e9185e2d06c16ee438ed39bf62935ec436474a6ac4f9358524220f1b236e43"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:150906b40ff188a3260cbee25380e7494ee85048584998c1e66df0c7a11c17a6"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8ad4aeb3e9a97286573c03df758fc7627aecdd02f1da04516a86dc159bf70121"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3f3ed29cd9f978c604708511a1f9c2fdcb6c38b9aae36a51905b8811ee5cbf1"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b0dae11d8f5ded51699c74d9548dcc5938e0804cc8298ec0aa0da95c21fff57b"}, + {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:faa6b09ee09433b87992fb5a2859efd1c264ddc37280d2dd5db502126d0e7f27"}, + {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9dc1b507c12eb0481d071f3c1808f0529ad41dc415d0ca11f7ebfc666e66a18b"}, + {file = "pydantic_core-2.20.1-cp311-none-win32.whl", hash = "sha256:fa2fddcb7107e0d1808086ca306dcade7df60a13a6c347a7acf1ec139aa6789a"}, + {file = "pydantic_core-2.20.1-cp311-none-win_amd64.whl", hash = "sha256:40a783fb7ee353c50bd3853e626f15677ea527ae556429453685ae32280c19c2"}, + {file = "pydantic_core-2.20.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:595ba5be69b35777474fa07f80fc260ea71255656191adb22a8c53aba4479231"}, + {file = "pydantic_core-2.20.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a4f55095ad087474999ee28d3398bae183a66be4823f753cd7d67dd0153427c9"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f9aa05d09ecf4c75157197f27cdc9cfaeb7c5f15021c6373932bf3e124af029f"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e97fdf088d4b31ff4ba35db26d9cc472ac7ef4a2ff2badeabf8d727b3377fc52"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bc633a9fe1eb87e250b5c57d389cf28998e4292336926b0b6cdaee353f89a237"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d573faf8eb7e6b1cbbcb4f5b247c60ca8be39fe2c674495df0eb4318303137fe"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26dc97754b57d2fd00ac2b24dfa341abffc380b823211994c4efac7f13b9e90e"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:33499e85e739a4b60c9dac710c20a08dc73cb3240c9a0e22325e671b27b70d24"}, + {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:bebb4d6715c814597f85297c332297c6ce81e29436125ca59d1159b07f423eb1"}, + {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:516d9227919612425c8ef1c9b869bbbee249bc91912c8aaffb66116c0b447ebd"}, + {file = "pydantic_core-2.20.1-cp312-none-win32.whl", hash = "sha256:469f29f9093c9d834432034d33f5fe45699e664f12a13bf38c04967ce233d688"}, + {file = "pydantic_core-2.20.1-cp312-none-win_amd64.whl", hash = "sha256:035ede2e16da7281041f0e626459bcae33ed998cca6a0a007a5ebb73414ac72d"}, + {file = "pydantic_core-2.20.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0827505a5c87e8aa285dc31e9ec7f4a17c81a813d45f70b1d9164e03a813a686"}, + {file = "pydantic_core-2.20.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:19c0fa39fa154e7e0b7f82f88ef85faa2a4c23cc65aae2f5aea625e3c13c735a"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4aa223cd1e36b642092c326d694d8bf59b71ddddc94cdb752bbbb1c5c91d833b"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c336a6d235522a62fef872c6295a42ecb0c4e1d0f1a3e500fe949415761b8a19"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7eb6a0587eded33aeefea9f916899d42b1799b7b14b8f8ff2753c0ac1741edac"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:70c8daf4faca8da5a6d655f9af86faf6ec2e1768f4b8b9d0226c02f3d6209703"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e9fa4c9bf273ca41f940bceb86922a7667cd5bf90e95dbb157cbb8441008482c"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:11b71d67b4725e7e2a9f6e9c0ac1239bbc0c48cce3dc59f98635efc57d6dac83"}, + {file = "pydantic_core-2.20.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:270755f15174fb983890c49881e93f8f1b80f0b5e3a3cc1394a255706cabd203"}, + {file = "pydantic_core-2.20.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:c81131869240e3e568916ef4c307f8b99583efaa60a8112ef27a366eefba8ef0"}, + {file = "pydantic_core-2.20.1-cp313-none-win32.whl", hash = "sha256:b91ced227c41aa29c672814f50dbb05ec93536abf8f43cd14ec9521ea09afe4e"}, + {file = "pydantic_core-2.20.1-cp313-none-win_amd64.whl", hash = "sha256:65db0f2eefcaad1a3950f498aabb4875c8890438bc80b19362cf633b87a8ab20"}, + {file = "pydantic_core-2.20.1-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:4745f4ac52cc6686390c40eaa01d48b18997cb130833154801a442323cc78f91"}, + {file = "pydantic_core-2.20.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a8ad4c766d3f33ba8fd692f9aa297c9058970530a32c728a2c4bfd2616d3358b"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:41e81317dd6a0127cabce83c0c9c3fbecceae981c8391e6f1dec88a77c8a569a"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:04024d270cf63f586ad41fff13fde4311c4fc13ea74676962c876d9577bcc78f"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:eaad4ff2de1c3823fddf82f41121bdf453d922e9a238642b1dedb33c4e4f98ad"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:26ab812fa0c845df815e506be30337e2df27e88399b985d0bb4e3ecfe72df31c"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3c5ebac750d9d5f2706654c638c041635c385596caf68f81342011ddfa1e5598"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2aafc5a503855ea5885559eae883978c9b6d8c8993d67766ee73d82e841300dd"}, + {file = "pydantic_core-2.20.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:4868f6bd7c9d98904b748a2653031fc9c2f85b6237009d475b1008bfaeb0a5aa"}, + {file = "pydantic_core-2.20.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aa2f457b4af386254372dfa78a2eda2563680d982422641a85f271c859df1987"}, + {file = "pydantic_core-2.20.1-cp38-none-win32.whl", hash = "sha256:225b67a1f6d602de0ce7f6c1c3ae89a4aa25d3de9be857999e9124f15dab486a"}, + {file = "pydantic_core-2.20.1-cp38-none-win_amd64.whl", hash = "sha256:6b507132dcfc0dea440cce23ee2182c0ce7aba7054576efc65634f080dbe9434"}, + {file = "pydantic_core-2.20.1-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:b03f7941783b4c4a26051846dea594628b38f6940a2fdc0df00b221aed39314c"}, + {file = "pydantic_core-2.20.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1eedfeb6089ed3fad42e81a67755846ad4dcc14d73698c120a82e4ccf0f1f9f6"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:635fee4e041ab9c479e31edda27fcf966ea9614fff1317e280d99eb3e5ab6fe2"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:77bf3ac639c1ff567ae3b47f8d4cc3dc20f9966a2a6dd2311dcc055d3d04fb8a"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ed1b0132f24beeec5a78b67d9388656d03e6a7c837394f99257e2d55b461611"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c6514f963b023aeee506678a1cf821fe31159b925c4b76fe2afa94cc70b3222b"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10d4204d8ca33146e761c79f83cc861df20e7ae9f6487ca290a97702daf56006"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2d036c7187b9422ae5b262badb87a20a49eb6c5238b2004e96d4da1231badef1"}, + {file = "pydantic_core-2.20.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9ebfef07dbe1d93efb94b4700f2d278494e9162565a54f124c404a5656d7ff09"}, + {file = "pydantic_core-2.20.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6b9d9bb600328a1ce523ab4f454859e9d439150abb0906c5a1983c146580ebab"}, + {file = "pydantic_core-2.20.1-cp39-none-win32.whl", hash = "sha256:784c1214cb6dd1e3b15dd8b91b9a53852aed16671cc3fbe4786f4f1db07089e2"}, + {file = "pydantic_core-2.20.1-cp39-none-win_amd64.whl", hash = "sha256:d2fe69c5434391727efa54b47a1e7986bb0186e72a41b203df8f5b0a19a4f669"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:a45f84b09ac9c3d35dfcf6a27fd0634d30d183205230a0ebe8373a0e8cfa0906"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:d02a72df14dfdbaf228424573a07af10637bd490f0901cee872c4f434a735b94"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d2b27e6af28f07e2f195552b37d7d66b150adbaa39a6d327766ffd695799780f"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:084659fac3c83fd674596612aeff6041a18402f1e1bc19ca39e417d554468482"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:242b8feb3c493ab78be289c034a1f659e8826e2233786e36f2893a950a719bb6"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:38cf1c40a921d05c5edc61a785c0ddb4bed67827069f535d794ce6bcded919fc"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e0bbdd76ce9aa5d4209d65f2b27fc6e5ef1312ae6c5333c26db3f5ade53a1e99"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:254ec27fdb5b1ee60684f91683be95e5133c994cc54e86a0b0963afa25c8f8a6"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:407653af5617f0757261ae249d3fba09504d7a71ab36ac057c938572d1bc9331"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:c693e916709c2465b02ca0ad7b387c4f8423d1db7b4649c551f27a529181c5ad"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5b5ff4911aea936a47d9376fd3ab17e970cc543d1b68921886e7f64bd28308d1"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:177f55a886d74f1808763976ac4efd29b7ed15c69f4d838bbd74d9d09cf6fa86"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:964faa8a861d2664f0c7ab0c181af0bea66098b1919439815ca8803ef136fc4e"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:4dd484681c15e6b9a977c785a345d3e378d72678fd5f1f3c0509608da24f2ac0"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f6d6cff3538391e8486a431569b77921adfcdef14eb18fbf19b7c0a5294d4e6a"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a6d511cc297ff0883bc3708b465ff82d7560193169a8b93260f74ecb0a5e08a7"}, + {file = "pydantic_core-2.20.1.tar.gz", hash = "sha256:26ca695eeee5f9f1aeeb211ffc12f10bcb6f71e2989988fda61dabd65db878d4"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index 8be94d7..715d699 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mercoa" -version = "0.4.4" +version = "0.4.5" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..1f3e457 --- /dev/null +++ b/reference.md @@ -0,0 +1,9627 @@ +# Reference +## EntityGroup +
client.entity_group.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all entity groups. If using a JWT, will return all groups the entity is part of. If using an API key, will return all groups for the organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity_group.get_all() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — The maximum number of results to return. Defaults to 1. Max is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[EntityGroupId]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity_group.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create an entity group +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import EntityGroupRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity_group.create( + request=EntityGroupRequest( + entity_ids=[ + "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `EntityGroupRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity_group.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get an entity group +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity_group.get( + entity_group_id="entg_a3582b70-fd04-4888-9185-a640ae9048be", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_group_id:** `EntityGroupId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity_group.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an entity group +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import EntityGroupRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity_group.update( + entity_group_id="entg_a3582b70-fd04-4888-9185-a640ae9048be", + request=EntityGroupRequest( + entity_ids=[ + "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_group_id:** `EntityGroupId` + +
+
+ +
+
+ +**request:** `EntityGroupRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity_group.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an entity group +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity_group.delete( + entity_group_id="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_group_id:** `EntityGroupId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity +
client.entity.find(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Search all entities with the given filters. If no filters are provided, all entities will be returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.find( + is_customer=True, + foreign_id="MY-DB-ID-12345", + payment_methods=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payment_methods:** `typing.Optional[bool]` — If true, will include entity payment methods as part of the response + +
+
+ +
+
+ +**is_customer:** `typing.Optional[bool]` — If true, only entities with a direct relationship to the requesting organization will be returned. If false or not provided, all entities will be returned. + +
+
+ +
+
+ +**foreign_id:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — ID used to identify this entity in your system + +
+
+ +
+
+ +**status:** `typing.Optional[typing.Union[EntityStatus, typing.Sequence[EntityStatus]]]` + +
+
+ +
+
+ +**is_payee:** `typing.Optional[bool]` + +If true, entities that are marked as payees will be returned. +If false or not provided, entities that are marked as payees will not be returned. + +
+
+ +
+
+ +**is_payor:** `typing.Optional[bool]` + +If true or not provided, entities that are marked as payors will be returned. +If false, entities that are marked as payors will not be returned. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Filter entities by name. Partial matches are supported. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of entities to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[EntityId]` — The ID of the entity to start after. If not provided, the first page of entities will be returned. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.create(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import BusinessProfileRequest, EntityRequest, ProfileRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.create( + request=EntityRequest( + is_customer=False, + is_payor=False, + is_payee=True, + account_type="business", + foreign_id="MY-DB-ID-90909", + profile=ProfileRequest( + business=BusinessProfileRequest( + email="vendor@bigboxstore.com", + legal_business_name="Big Box Store", + website="http://www.bigboxstore.com", + business_type="publicCorporation", + ), + ), + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `EntityRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.get(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.get( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.update(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ( + Address, + BusinessProfileRequest, + Ein, + EntityUpdateRequest, + PhoneNumber, + ProfileRequest, + TaxId, +) +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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", + ), + ), + ), + ), + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `EntityUpdateRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Will archive the entity. This action cannot be undone, and the entity will no longer be available for use. The foreignId on the entity will be cleared as well. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.delete( + entity_id="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.accept_terms_of_service(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This endpoint is used to indicate acceptance of Mercoa's terms of service for an entity. Send a request to this endpoint only after the entity has accepted the Mercoa ToS. Entities must accept Mercoa ToS before they can be send or pay invoices using Mercoa's payment rails. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.accept_terms_of_service( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.initiate_kyb(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This endpoint is used to initiate KYB for an entity. +Send a request to this endpoint only after the entity has accepted the Mercoa ToS, +all representatives have been added, and all required fields have been filled out. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.initiate_kyb( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.get_token(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Generate a JWT token for an entity with the given options. This token can be used to authenticate the entity in the Mercoa API and iFrame. + +We recommend using [this endpoint](/api-reference/entity/user/get-token). This will enable features such as approvals and comments. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import TokenGenerationOptions +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.get_token( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + request=TokenGenerationOptions( + expires_in="1h", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `TokenGenerationOptions` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.plaid_link_token(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a Plaid link token for an entity. This token can be used to add or update a bank account to the entity using Plaid Link. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.plaid_link_token( + entity_id="string", + payment_method_id="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**payment_method_id:** `typing.Optional[PaymentMethodId]` — ID of Bank Account to update + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.get_onboarding_link(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Generate an onboarding link for the entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.get_onboarding_link( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + type="PAYOR", + expires_in="1h", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**type:** `EntityOnboardingLinkType` — The type of onboarding link to generate. If not provided, the default is payee. The onboarding options are determined by your organization's onboarding configuration. + +
+
+ +
+
+ +**expires_in:** `typing.Optional[str]` — Expressed in seconds or a string describing a time span. The default is 24h. + +
+
+ +
+
+ +**connected_entity_id:** `typing.Optional[EntityId]` — The ID of the entity to connect to. If onboarding a payee, this should be the payor entity ID. If onboarding a payor, this should be the payee entity ID. If no connected entity ID is provided, the onboarding link will be for a standalone entity. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.send_onboarding_link(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Send an email with a onboarding link to the entity. The email will be sent to the email address associated with the entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.send_onboarding_link( + entity_id="string", + type="PAYEE", + expires_in="string", + connected_entity_id="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**type:** `EntityOnboardingLinkType` — The type of onboarding link to generate. If not provided, the default is payee. The onboarding options are determined by your organization's onboarding configuration. + +
+
+ +
+
+ +**expires_in:** `typing.Optional[str]` — Expressed in seconds or a string describing a time span. The default is 7 days. + +
+
+ +
+
+ +**connected_entity_id:** `typing.Optional[EntityId]` — The ID of the entity to connect to. If onboarding a payee, this should be the payor entity ID. If onboarding a payor, this should be the payee entity ID. If no connected entity ID is provided, the onboarding link will be for a standalone entity. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity EmailLog +
client.entity.email_log.find(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all incoming invoice emails for an entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.email_log.find( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**start_date:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**end_date:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of logs to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[EntityId]` — The ID of the log to start after. If not provided, the first page of logs will be returned. + +
+
+ +
+
+ +**search:** `typing.Optional[str]` — Search for logs by email address or subject + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.email_log.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get an email log by ID +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.email_log.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + log_id="log_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**log_id:** `EmailLogId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity User +
client.entity.user.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all entity users (DEPRECATED, use Search Entity Users) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.get_all( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.find(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Search entity users +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.find( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + name="John", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**foreign_id:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — ID used to identify user in your system + +
+
+ +
+
+ +**role:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Filter users by role. If multiple roles are provided, users with any of the roles will be returned. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Filter users by name. Partial matches are supported. + +
+
+ +
+
+ +**email:** `typing.Optional[str]` — Filter users by email. Partial matches are supported. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of entities to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[EntityUserId]` — The ID of the user to start after. If not provided, the first page of entities will be returned. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.create(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import EntityUserRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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"], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `EntityUserRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get entity user +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.get( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + user_id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update entity user +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import EntityUserRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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"], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**request:** `EntityUserRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete entity user. This will also remove the user from all approval policies. If an approval policy will break as a result of this operation, this request will fail. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.delete( + entity_id="string", + user_id="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.get_token(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Generate a JWT token for an entity user with the given options. This token can be used to authenticate the entity and entity user in the Mercoa API and iFrame. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import TokenGenerationOptions +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**request:** `TokenGenerationOptions` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Invoice +
client.invoice.find(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Search invoices for all entities in the organization +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.find( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by the ID of the entity that created the invoice. + +
+
+ +
+
+ +**start_date:** `typing.Optional[dt.datetime]` — Start date for invoice created on date filter. + +
+
+ +
+
+ +**end_date:** `typing.Optional[dt.datetime]` — End date for invoice created date filter. + +
+
+ +
+
+ +**order_by:** `typing.Optional[InvoiceOrderByField]` — Field to order invoices by. Defaults to CREATED_AT. + +
+
+ +
+
+ +**order_direction:** `typing.Optional[OrderDirection]` — Direction to order invoices by. Defaults to asc. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of invoices to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[InvoiceId]` — The ID of the invoice to start after. If not provided, the first page of invoices will be returned. + +
+
+ +
+
+ +**search:** `typing.Optional[str]` — Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + +
+
+ +
+
+ +**metadata:** `typing.Optional[ + typing.Union[InvoiceMetadataFilter, typing.Sequence[InvoiceMetadataFilter]] +]` — Filter invoices by metadata. Each filter will be applied as an AND condition. Duplicate keys will be ignored. + +
+
+ +
+
+ +**payer_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by payer ID. + +
+
+ +
+
+ +**vendor_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by vendor ID. + +
+
+ +
+
+ +**approver_id:** `typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]]` — Filter invoices by assigned approver user ID. + +
+
+ +
+
+ +**approver_action:** `typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]]` — Filter invoices by approver action. Needs to be used with approverId. For example, if you want to find all invoices that have been approved by a specific user, you would use approverId and approverAction=APPROVE. + +
+
+ +
+
+ +**invoice_id:** `typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]]` — Filter invoices by invoice ID. + +
+
+ +
+
+ +**status:** `typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]]` — Invoice status to filter on + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.create(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from mercoa import InvoiceCreationRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.create( + request=InvoiceCreationRequest( + status="SCHEDULED", + payer_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + creator_entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + vendor_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + currency="USD", + amount=100.0, + 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", + ), + payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", + deduction_date=datetime.datetime.fromisoformat( + "2021-01-29 00:00:00+00:00", + ), + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `InvoiceCreationRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.get(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.get( + invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.update(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from mercoa import InvoiceUpdateRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.update( + invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=InvoiceUpdateRequest( + status="SCHEDULED", + payment_destination_id="pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", + deduction_date=datetime.datetime.fromisoformat( + "2021-01-29 00:00:00+00:00", + ), + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request:** `InvoiceUpdateRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Only invoices in the DRAFT and NEW status can be deleted. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.delete( + invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Organization +
client.organization.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get current organization information +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.organization.get( + payment_methods=True, + email_provider=True, + external_accounting_system_provider=True, + color_scheme=True, + payee_onboarding_options=True, + payor_onboarding_options=True, + metadata_schema=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**payment_methods:** `typing.Optional[bool]` — include supported payment methods in response + +
+
+ +
+
+ +**email_provider:** `typing.Optional[bool]` — include email provider info in response + +
+
+ +
+
+ +**external_accounting_system_provider:** `typing.Optional[bool]` — include external accounting system provider info in response + +
+
+ +
+
+ +**color_scheme:** `typing.Optional[bool]` — include color scheme info in response + +
+
+ +
+
+ +**payee_onboarding_options:** `typing.Optional[bool]` — include payee onboarding options in response + +
+
+ +
+
+ +**payor_onboarding_options:** `typing.Optional[bool]` — include payor onboarding options in response + +
+
+ +
+
+ +**metadata_schema:** `typing.Optional[bool]` — include metadata schema in response + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.organization.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update current organization +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ( + ColorSchemeRequest, + EmailProviderRequest, + ExternalAccountingSystemProviderRequest_None, + MetadataSchema, + OnboardingOptionsRequest, + OrganizationRequest, + PaymentMethodsRequest, +) +from mercoa.client import Mercoa + +client = Mercoa( + 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()], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `OrganizationRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.organization.email_log(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get log of all emails sent to this organization. Content format subject to change. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.organization.email_log( + start_date=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + end_date=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + limit=1, + starting_after="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**start_date:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**end_date:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of logs to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[str]` — The ID of the log to start after. If not provided, the first page of logs will be returned. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## BankLookup +
client.bank_lookup.find(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Find bank account details +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.bank_lookup.find( + routing_number="026009593", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**routing_number:** `str` — Routing number to validate + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## CustomPaymentMethodSchema +
client.custom_payment_method_schema.get_all() +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all custom payment method schemas +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.custom_payment_method_schema.get_all() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.custom_payment_method_schema.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create custom payment method schema +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ( + CustomPaymentMethodSchemaField, + CustomPaymentMethodSchemaRequest, +) +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.custom_payment_method_schema.create( + 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="usBankAccountNumber", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="usBankRoutingNumber", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="address", + display_name="Address", + type="address", + optional=False, + ), + ], + estimated_processing_time=7, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CustomPaymentMethodSchemaRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.custom_payment_method_schema.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update custom payment method schema +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ( + CustomPaymentMethodSchemaField, + CustomPaymentMethodSchemaRequest, +) +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.custom_payment_method_schema.update( + schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", + 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="usBankAccountNumber", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="usBankRoutingNumber", + optional=False, + ), + ], + estimated_processing_time=0, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**schema_id:** `CustomPaymentMethodSchemaId` + +
+
+ +
+
+ +**request:** `CustomPaymentMethodSchemaRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.custom_payment_method_schema.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get custom payment method schema +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.custom_payment_method_schema.get( + schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**schema_id:** `CustomPaymentMethodSchemaId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.custom_payment_method_schema.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete custom payment method schema. Schema that have been used in an invoice cannot be deleted. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.custom_payment_method_schema.delete( + schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**schema_id:** `CustomPaymentMethodSchemaId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## EntityGroup Invoice +
client.entity_group.invoice.find(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get invoices for an entity group with the given filters. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity_group.invoice.find( + entity_group_id="entg_8545a84e-a45f-41bf-bdf1-33b42a55812c", + exclude_receivables=True, + order_by="CREATED_AT", + order_direction="ASC", + limit=10, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_group_id:** `EntityGroupId` + +
+
+ +
+
+ +**exclude_payables:** `typing.Optional[bool]` — Return only invoices that are receivable by the entity. + +
+
+ +
+
+ +**exclude_receivables:** `typing.Optional[bool]` — Return only invoices that are payable by the entity. + +
+
+ +
+
+ +**start_date:** `typing.Optional[dt.datetime]` — Start date for invoice created on date filter. + +
+
+ +
+
+ +**end_date:** `typing.Optional[dt.datetime]` — End date for invoice created date filter. + +
+
+ +
+
+ +**order_by:** `typing.Optional[InvoiceOrderByField]` — Field to order invoices by. Defaults to CREATED_AT. + +
+
+ +
+
+ +**order_direction:** `typing.Optional[OrderDirection]` — Direction to order invoices by. Defaults to asc. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of invoices to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[InvoiceId]` — The ID of the invoice to start after. If not provided, the first page of invoices will be returned. + +
+
+ +
+
+ +**metadata:** `typing.Optional[ + typing.Union[InvoiceMetadataFilter, typing.Sequence[InvoiceMetadataFilter]] +]` — Filter invoices by metadata. Each filter will be applied as an AND condition. Duplicate keys will be ignored. + +
+
+ +
+
+ +**search:** `typing.Optional[str]` — Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + +
+
+ +
+
+ +**payer_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by payer ID. + +
+
+ +
+
+ +**vendor_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by vendor ID. + +
+
+ +
+
+ +**approver_id:** `typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]]` — Filter invoices by assigned approver user ID. + +
+
+ +
+
+ +**approver_action:** `typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]]` — Filter invoices by approver action. Needs to be used with approverId. For example, if you want to find all invoices that have been approved by a specific user, you would use approverId and approverAction=APPROVE. + +
+
+ +
+
+ +**invoice_id:** `typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]]` — Filter invoices by invoice ID. + +
+
+ +
+
+ +**status:** `typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]]` — Invoice status to filter on. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity_group.invoice.metrics(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get invoice metrics for an entity group with the given filters. Invoices will be grouped by currency. If none of excludePayables, excludeReceivables, payerId, vendorId, or invoiceId status filters are provided, excludeReceivables will be set to true. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity_group.invoice.metrics( + entity_group_id="entg_8545a84e-a45f-41bf-bdf1-33b42a55812c", + return_by_date="CREATION_DATE", + exclude_receivables=True, + created_date_start=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + created_date_end=datetime.datetime.fromisoformat( + "2021-01-31 23:59:59.999000+00:00", + ), + currency="USD", + status="NEW", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_group_id:** `EntityGroupId` + +
+
+ +
+
+ +**search:** `typing.Optional[str]` — Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + +
+
+ +
+
+ +**exclude_payables:** `typing.Optional[bool]` — Only return invoices that are not payable by the entity. This will return only invoices that are receivable by the entity. + +
+
+ +
+
+ +**exclude_receivables:** `typing.Optional[bool]` — Only return invoices that are not receivable by the entity. This will return only invoices that are payable by the entity. + +
+
+ +
+
+ +**return_by_date:** `typing.Optional[InvoiceMetricsPerDateGroupBy]` — Return invoice metrics grouped by date. + +
+
+ +
+
+ +**payer_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by payer ID. + +
+
+ +
+
+ +**vendor_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by vendor ID. + +
+
+ +
+
+ +**approver_id:** `typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]]` — Filter invoices by assigned approver user ID. + +
+
+ +
+
+ +**invoice_id:** `typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]]` — Filter invoices by invoice ID. + +
+
+ +
+
+ +**status:** `typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]]` — Invoice status to filter on + +
+
+ +
+
+ +**due_date_start:** `typing.Optional[dt.datetime]` — Start date for invoice dueDate filter. + +
+
+ +
+
+ +**due_date_end:** `typing.Optional[dt.datetime]` — End date for invoice dueDate filter. + +
+
+ +
+
+ +**created_date_start:** `typing.Optional[dt.datetime]` — Start date for invoice created on date filter. + +
+
+ +
+
+ +**created_date_end:** `typing.Optional[dt.datetime]` — End date for invoice created date filter. + +
+
+ +
+
+ +**currency:** `typing.Optional[typing.Union[CurrencyCode, typing.Sequence[CurrencyCode]]]` — Currency to filter on + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity ApprovalPolicy +
client.entity.approval_policy.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all invoice approval policies associated with an entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.approval_policy.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.approval_policy.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create an invoice approval policy associated with an entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ApprovalPolicyRequest, IdentifierList_UserList, Rule_Approver +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.approval_policy.create( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=ApprovalPolicyRequest( + trigger=[], + rule=Rule_Approver( + num_approvers=2, + identifier_list=IdentifierList_UserList( + value=[ + "usr_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "usr_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ] + ), + ), + upstream_policy_id="root", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `ApprovalPolicyRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.approval_policy.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve an invoice approval policy associated with an entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.approval_policy.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**policy_id:** `ApprovalPolicyId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.approval_policy.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an invoice approval policy associated with an entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ( + ApprovalPolicyUpdateRequest, + IdentifierList_UserList, + Rule_Approver, +) +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.approval_policy.update( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", + request=ApprovalPolicyUpdateRequest( + trigger=[], + rule=Rule_Approver( + num_approvers=2, + identifier_list=IdentifierList_UserList( + value=[ + "usr_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "usr_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ] + ), + ), + upstream_policy_id="root", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**policy_id:** `ApprovalPolicyId` + +
+
+ +
+
+ +**request:** `ApprovalPolicyUpdateRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.approval_policy.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an invoice approval policy associated with Entity. BEWARE: Any approval policy deletion will result in all associated downstream policies also being deleted. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.approval_policy.delete( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**policy_id:** `ApprovalPolicyId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity Counterparty +
client.entity.counterparty.find_payees(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Find payee counterparties. This endpoint lets you find vendors linked to the entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.counterparty.find_payees( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + name="Big Box", + payment_methods=True, + invoice_metrics=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Filter by counterparty name + +
+
+ +
+
+ +**network_type:** `typing.Optional[ + typing.Union[ + CounterpartyNetworkType, typing.Sequence[CounterpartyNetworkType] + ] +]` — Filter by network type. By default, only ENTITY counterparties are returned. + +
+
+ +
+
+ +**payment_methods:** `typing.Optional[bool]` — If true, will include counterparty payment methods as part of the response + +
+
+ +
+
+ +**invoice_metrics:** `typing.Optional[bool]` — If true, will include counterparty invoice metrics as part of the response + +
+
+ +
+
+ +**logo:** `typing.Optional[bool]` — If true, will include counterparty logo as part of the response + +
+
+ +
+
+ +**counterparty_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter by counterparty ids + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of counterparties to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[EntityId]` — The ID of the counterparties to start after. If not provided, the first page of counterparties will be returned. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.counterparty.find_payors(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Find payor counterparties. This endpoint lets you find customers linked to the entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.counterparty.find_payors( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + name="Big Box", + payment_methods=True, + invoice_metrics=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Filter by counterparty name + +
+
+ +
+
+ +**network_type:** `typing.Optional[ + typing.Union[ + CounterpartyNetworkType, typing.Sequence[CounterpartyNetworkType] + ] +]` — Filter by network type. By default, only ENTITY counterparties are returned. + +
+
+ +
+
+ +**payment_methods:** `typing.Optional[bool]` — If true, will include counterparty payment methods as part of the response + +
+
+ +
+
+ +**invoice_metrics:** `typing.Optional[bool]` — If true, will include counterparty invoice metrics as part of the response + +
+
+ +
+
+ +**logo:** `typing.Optional[bool]` — If true, will include counterparty logo as part of the response + +
+
+ +
+
+ +**counterparty_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter by counterparty ids + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of counterparties to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[EntityId]` — The ID of the counterparties to start after. If not provided, the first page of counterparties will be returned. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.counterparty.add_payees(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create association between Entity and a given list of Payees. If a Payee has previously been archived, unarchive the Payee. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import CounterpartyCustomizationRequest, EntityAddPayeesRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.counterparty.add_payees( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=EntityAddPayeesRequest( + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + customizations=[ + CounterpartyCustomizationRequest( + counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + account_id="85866843", + ) + ], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `EntityAddPayeesRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.counterparty.hide_payees(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Marks Payees as unsearchable by Entity via Counterparty search. Invoices associated with these Payees will still be searchable via Invoice search. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import EntityHidePayeesRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.counterparty.hide_payees( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=EntityHidePayeesRequest( + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `EntityHidePayeesRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.counterparty.add_payors(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create association between Entity and a given list of Payors. If a Payor has previously been archived, unarchive the Payor. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import CounterpartyCustomizationRequest, EntityAddPayorsRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.counterparty.add_payors( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=EntityAddPayorsRequest( + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + customizations=[ + CounterpartyCustomizationRequest( + counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + account_id="85866843", + ) + ], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `EntityAddPayorsRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.counterparty.hide_payors(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Marks Payors as unsearchable by Entity via Counterparty search. Invoices associated with these Payors will still be searchable via Invoice search. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import EntityHidePayorsRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.counterparty.hide_payors( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=EntityHidePayorsRequest( + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `EntityHidePayorsRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity Customization +
client.entity.customization.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get entity customization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.customization.get( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.customization.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update entity customization. This lets you turn off metadata and payment methods for an entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ( + EntityCustomizationRequest, + MetadataCustomizationRequest, + PaymentMethodCustomizationRequest, +) +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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, + ), + ], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `EntityCustomizationRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity ExternalAccountingSystem +
client.entity.external_accounting_system.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get the external accounting system connected to an entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.external_accounting_system.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.external_accounting_system.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create/Link an entity to an external accounting system like Codat or Rutter. If the entity is already linked to an external accounting system, this will return the existing connection. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa +from mercoa.entity import ExternalAccountingSystemCompanyCreationRequest_Rutter + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.external_accounting_system.create( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=ExternalAccountingSystemCompanyCreationRequest_Rutter( + access_token="123", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `ExternalAccountingSystemCompanyCreationRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.external_accounting_system.connect(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a link to connect an entity to an external accounting system like Quickbooks or Xero +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.external_accounting_system.connect( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.external_accounting_system.sync(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sync an entity with an external accounting system. Will sync customers/vendors and invoices. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.external_accounting_system.sync( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + vendors="pull", + bills="push", + gl_accounts="pull", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**vendors:** `typing.Optional[SyncType]` — Sync vendors from external accounting system. Default is to pull vendors from external system. + +
+
+ +
+
+ +**bills:** `typing.Optional[SyncType]` — Sync bills from external accounting system. Default is to not sync bills. Invoices that already exist in both systems will not be updated, only new invoices not present in the other system will be created. + +
+
+ +
+
+ +**gl_accounts:** `typing.Optional[SyncType]` — Sync GL accounts from external accounting system. Default is to pull GL accounts from external system. Pushing GL accounts is not supported. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity Invoice +
client.entity.invoice.find(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get invoices for an entity with the given filters. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.invoice.find( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + exclude_receivables=True, + order_by="CREATED_AT", + order_direction="ASC", + limit=10, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**exclude_payables:** `typing.Optional[bool]` — Return only invoices that are receivable by the entity. + +
+
+ +
+
+ +**exclude_receivables:** `typing.Optional[bool]` — Return only invoices that are payable by the entity. + +
+
+ +
+
+ +**start_date:** `typing.Optional[dt.datetime]` — Start date for invoice created on date filter. + +
+
+ +
+
+ +**end_date:** `typing.Optional[dt.datetime]` — End date for invoice created date filter. + +
+
+ +
+
+ +**order_by:** `typing.Optional[InvoiceOrderByField]` — Field to order invoices by. Defaults to CREATED_AT. + +
+
+ +
+
+ +**order_direction:** `typing.Optional[OrderDirection]` — Direction to order invoices by. Defaults to asc. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of invoices to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[InvoiceId]` — The ID of the invoice to start after. If not provided, the first page of invoices will be returned. + +
+
+ +
+
+ +**metadata:** `typing.Optional[ + typing.Union[InvoiceMetadataFilter, typing.Sequence[InvoiceMetadataFilter]] +]` — Filter invoices by metadata. Each filter will be applied as an AND condition. Duplicate keys will be ignored. + +
+
+ +
+
+ +**search:** `typing.Optional[str]` — Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + +
+
+ +
+
+ +**payer_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by payer ID. + +
+
+ +
+
+ +**vendor_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by vendor ID. + +
+
+ +
+
+ +**approver_id:** `typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]]` — Filter invoices by assigned approver user ID. + +
+
+ +
+
+ +**approver_action:** `typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]]` — Filter invoices by approver action. Needs to be used with approverId. For example, if you want to find all invoices that have been approved by a specific user, you would use approverId and approverAction=APPROVE. + +
+
+ +
+
+ +**invoice_id:** `typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]]` — Filter invoices by invoice ID. + +
+
+ +
+
+ +**status:** `typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]]` — Invoice status to filter on. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.invoice.metrics(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get invoice metrics for an entity with the given filters. Invoices will be grouped by currency. If none of excludePayables, excludeReceivables, payerId, vendorId, or invoiceId status filters are provided, excludeReceivables will be set to true. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.invoice.metrics( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + return_by_date="CREATION_DATE", + exclude_receivables=True, + created_date_start=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + created_date_end=datetime.datetime.fromisoformat( + "2021-01-31 23:59:59.999000+00:00", + ), + currency="USD", + status="NEW", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**search:** `typing.Optional[str]` — Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + +
+
+ +
+
+ +**exclude_payables:** `typing.Optional[bool]` — Only return invoices that are not payable by the entity. This will return only invoices that are receivable by the entity. + +
+
+ +
+
+ +**exclude_receivables:** `typing.Optional[bool]` — Only return invoices that are not receivable by the entity. This will return only invoices that are payable by the entity. + +
+
+ +
+
+ +**return_by_date:** `typing.Optional[InvoiceMetricsPerDateGroupBy]` — Return invoice metrics grouped by date. + +
+
+ +
+
+ +**payer_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by payer ID. + +
+
+ +
+
+ +**vendor_id:** `typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]]` — Filter invoices by vendor ID. + +
+
+ +
+
+ +**approver_id:** `typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]]` — Filter invoices by assigned approver user ID. + +
+
+ +
+
+ +**invoice_id:** `typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]]` — Filter invoices by invoice ID. + +
+
+ +
+
+ +**status:** `typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]]` — Invoice status to filter on + +
+
+ +
+
+ +**due_date_start:** `typing.Optional[dt.datetime]` — Start date for invoice dueDate filter. + +
+
+ +
+
+ +**due_date_end:** `typing.Optional[dt.datetime]` — End date for invoice dueDate filter. + +
+
+ +
+
+ +**created_date_start:** `typing.Optional[dt.datetime]` — Start date for invoice created on date filter. + +
+
+ +
+
+ +**created_date_end:** `typing.Optional[dt.datetime]` — End date for invoice created date filter. + +
+
+ +
+
+ +**currency:** `typing.Optional[typing.Union[CurrencyCode, typing.Sequence[CurrencyCode]]]` — Currency to filter on + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity Metadata +
client.entity.metadata.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all metadata options associated with this entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.metadata.get_all( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.metadata.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve metadata associated with a specific key +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.metadata.get( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + key="projectId", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**key:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.metadata.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update metadata associated with a specific key +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.metadata.update( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + key="projectId", + request=["proj_123", "proj_456"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**key:** `str` + +
+
+ +
+
+ +**request:** `typing.Sequence[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.metadata.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete all metadata associated with a specific key +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.metadata.delete( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + key="propertyId", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**key:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity NotificationPolicy +
client.entity.notification_policy.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all notification policies associated with this entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.notification_policy.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.notification_policy.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve notification policy associated with this entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.notification_policy.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + notification_type="INVOICE_APPROVED", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**notification_type:** `NotificationType` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.notification_policy.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update notification policy associated with this entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import NotificationPolicyRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.notification_policy.update( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + notification_type="INVOICE_APPROVED", + request=NotificationPolicyRequest( + disabled=True, + additional_roles=[], + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**notification_type:** `NotificationType` + +
+
+ +
+
+ +**request:** `NotificationPolicyRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity PaymentMethod +
client.entity.payment_method.get_all(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.payment_method.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + type="bankAccount", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**type:** `typing.Optional[ + typing.Union[PaymentMethodType, typing.Sequence[PaymentMethodType]] +]` — Type of payment method to filter + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.payment_method.create(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import PaymentMethodRequest_Custom +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.payment_method.create( + entity_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + request=PaymentMethodRequest_Custom( + foreign_id="DB_FOREIGN_ID", + account_name="Vendor Wire Account", + account_number="123456789", + schema_id="cpms_4794d597-70dc-4fec-b6ec-c5988e759769", + data={ + "bankName": "Chase", + "recipientName": "John Doe", + "routingNumber": "123456789", + "accountNumber": "99988767623", + }, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `PaymentMethodRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.payment_method.get(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.payment_method.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**payment_method_id:** `PaymentMethodId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.payment_method.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Only custom payment methods can be updated. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import PaymentMethodUpdateRequest_BankAccount +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.payment_method.update( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + request=PaymentMethodUpdateRequest_BankAccount( + default_source=True, + default_destination=True, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**payment_method_id:** `PaymentMethodId` + +
+
+ +
+
+ +**request:** `PaymentMethodUpdateRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.payment_method.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Mark a payment method as inactive. This will not remove the payment method from the system, but will prevent it from being used in the future. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.payment_method.delete( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**payment_method_id:** `PaymentMethodId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.payment_method.initiate_micro_deposits(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Initiate micro deposits for a bank account +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.payment_method.initiate_micro_deposits( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**payment_method_id:** `PaymentMethodId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.payment_method.complete_micro_deposits(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Complete micro deposit verification +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.payment_method.complete_micro_deposits( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + amounts=[40, 2], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**payment_method_id:** `PaymentMethodId` + +
+
+ +
+
+ +**amounts:** `typing.Sequence[int]` — The amounts of the micro deposits in cents + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.payment_method.get_balance(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deprecated. Get the available balance of a payment method. Only bank accounts added with Plaid are supported. This endpoint will return a cached value and will refresh the balance when called. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.payment_method.get_balance( + entity_id="string", + payment_method_id="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**payment_method_id:** `PaymentMethodId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity Representative +
client.entity.representative.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get representatives for an entity +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.representative.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.representative.create(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ( + Address, + BirthDate, + FullName, + IndividualGovernmentId, + PhoneNumber, + RepresentativeRequest, + Responsibilities, +) +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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, + ), + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**request:** `RepresentativeRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.representative.get(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.representative.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + representative_id="rep_7df2974a-4069-454c-912f-7e58ebe030fb", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**representative_id:** `RepresentativeId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.representative.delete(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.representative.delete( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + representative_id="rep_7df2974a-4069-454c-912f-7e58ebe030fb", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**representative_id:** `RepresentativeId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity User NotificationPolicy +
client.entity.user.notification_policy.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all notification policies associated with this entity user +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.notification_policy.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.notification_policy.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve notification policy associated with this entity user +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.notification_policy.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + notification_type="INVOICE_PAID", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**notification_type:** `NotificationType` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.notification_policy.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update notification policy associated with this entity user +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import UserNotificationPolicyRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.notification_policy.update( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + notification_type="INVOICE_PAID", + request=UserNotificationPolicyRequest( + immediate=True, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**notification_type:** `NotificationType` + +
+
+ +
+
+ +**request:** `UserNotificationPolicyRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Entity User Notifications +
client.entity.user.notifications.find(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.notifications.find( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**start_date:** `typing.Optional[dt.datetime]` — Start date for notification created on date filter. + +
+
+ +
+
+ +**end_date:** `typing.Optional[dt.datetime]` — End date for notification created date filter. + +
+
+ +
+
+ +**order_direction:** `typing.Optional[OrderDirection]` — Direction to order notifications by. Defaults to asc. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Number of invoices to return. Limit can range between 1 and 100, and the default is 10. + +
+
+ +
+
+ +**starting_after:** `typing.Optional[NotificationId]` — The ID of the notification to start after. If not provided, the first page of invoices will be returned. + +
+
+ +
+
+ +**notification_type:** `typing.Optional[ + typing.Union[NotificationType, typing.Sequence[NotificationType]] +]` — The type of notification to filter by. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entity.user.notifications.get(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.entity.user.notifications.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + notification_id="notif_7df2974a-4069-454c-912f-7e58ebe030fb", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_id:** `EntityId` + +
+
+ +
+
+ +**user_id:** `EntityUserId` + +
+
+ +
+
+ +**notification_id:** `NotificationId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Fees +
client.fees.calculate(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CalculateFeesRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Invoice Approval +
client.invoice.approval.add_approver(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Adds an approver to the invoice. Will select the first available approver slot that is not already filled and assign the approver to it. If no approver slots are available, an error will be returned. An explicit approver slot can be specified by setting the `approverSlot` field. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import AddApproverRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request:** `AddApproverRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.approval.approve(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ApprovalRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request:** `ApprovalRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.approval.reject(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import ApprovalRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request:** `ApprovalRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Invoice Comment +
client.invoice.comment.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all comments associated with this invoice +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.comment.get_all( + invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.comment.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add a comment to this invoice +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import CommentRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request:** `CommentRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.comment.get(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.comment.get( + invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", + comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**comment_id:** `CommentId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.comment.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Edit a comment on this invoice +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import CommentRequest +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**comment_id:** `CommentId` + +
+
+ +
+
+ +**request:** `CommentRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.comment.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a comment on this invoice +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.comment.delete( + invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", + comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**comment_id:** `CommentId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Invoice Document +
client.invoice.document.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get attachments (scanned/uploaded PDFs and images) associated with this invoice +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.document.get_all( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.document.upload(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Upload documents (scanned/uploaded PDFs and images) associated with this Invoice +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.document.upload( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", + document="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**document:** `typing.Optional[str]` — Base64 encoded image or PDF of invoice document. PNG, JPG, WEBP, and PDF are supported. 10MB max. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.document.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an attachment (scanned/uploaded PDFs and images) associated with this invoice +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.document.delete( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", + document_id="doc_37e6af0a-e637-48fd-b825-d6947b38c4e2", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**document_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.document.generate_invoice_pdf(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Generate a PDF of the invoice. This PDF is generated from the data in the invoice, not from the uploaded documents. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.document.generate_invoice_pdf( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.document.generate_check_pdf(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a PDF of the check for the invoice. If the invoice does not have check as the disbursement method, an error will be returned. If the disbursement option for the check is set to 'MAIL', a void copy of the check will be returned. If the disbursement option for the check is set to 'PRINT', a printable check will be returned. If the invoice is NOT marked as PAID, the check will be a void copy. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.document.generate_check_pdf( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.document.get_source_email(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get the email subject and body that was used to create this invoice. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.document.get_source_email( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Invoice PaymentLinks +
client.invoice.payment_links.get_payer_link(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get temporary link for payer to send payment +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.payment_links.get_payer_link( + invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.payment_links.send_payer_email(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Trigger email to payer inviting them to make payment +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.payment_links.send_payer_email( + invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + attach_invoice=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**attach_invoice:** `typing.Optional[bool]` — Whether to attach the invoice to the email + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.payment_links.get_vendor_link(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get temporary link for vendor to accept payment +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.payment_links.get_vendor_link( + invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.invoice.payment_links.send_vendor_email(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Trigger email to vendor inviting them into the vendor portal +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.invoice.payment_links.send_vendor_email( + invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `InvoiceId` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Ocr +
client.ocr.ocr(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Run OCR on an Base64 encoded image or PDF. This endpoint will block until the OCR is complete. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `OcrRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.ocr.run_async_ocr(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Run OCR on an Base64 encoded image or PDF. This endpoint will return immediately and the OCR will be processed asynchronously. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +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", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `OcrRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.ocr.get_async_ocr(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get the status and results of an asynchronous OCR job. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.ocr.get_async_ocr( + job_id="ocr_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**job_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Organization NotificationConfiguration +
client.organization.notification_configuration.get_all() +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all notification configurations +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.organization.notification_configuration.get_all() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.organization.notification_configuration.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve notification configuration for this notification type +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.organization.notification_configuration.get( + notification_type="INVOICE_APPROVAL_NEEDED", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**notification_type:** `NotificationType` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.organization.notification_configuration.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update notification configuration for this notification type +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa import NotificationConfigurationRequest_Invoice +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.organization.notification_configuration.update( + notification_type="INVOICE_APPROVAL_NEEDED", + request=NotificationConfigurationRequest_Invoice( + url="string", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**notification_type:** `NotificationType` + +
+
+ +
+
+ +**request:** `NotificationConfigurationRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.organization.notification_configuration.reset(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Reset notification configuration for this notification type +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from mercoa.client import Mercoa + +client = Mercoa( + token="YOUR_TOKEN", +) +client.organization.notification_configuration.reset( + notification_type="INVOICE_APPROVAL_NEEDED", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**notification_type:** `NotificationType` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ diff --git a/src/mercoa/__init__.py b/src/mercoa/__init__.py index eaf9797..1d3df5a 100644 --- a/src/mercoa/__init__.py +++ b/src/mercoa/__init__.py @@ -6,6 +6,8 @@ custom_payment_method_schema, email_log_types, entity, + entity_group, + entity_group_types, entity_types, fees, invoice, @@ -33,6 +35,7 @@ Unimplemented, ) from .email_log_types import EmailLog, EmailLogId, EmailLogResponse +from .entity_group_types import EntityGroupFindResponse, EntityGroupId, EntityGroupRequest, EntityGroupResponse from .entity_types import ( AccountType, AmountTrigger, @@ -333,6 +336,10 @@ "EntityAddPayorsRequest", "EntityCustomizationRequest", "EntityCustomizationResponse", + "EntityGroupFindResponse", + "EntityGroupId", + "EntityGroupRequest", + "EntityGroupResponse", "EntityHidePayeesRequest", "EntityHidePayorsRequest", "EntityId", @@ -490,6 +497,8 @@ "custom_payment_method_schema", "email_log_types", "entity", + "entity_group", + "entity_group_types", "entity_types", "fees", "invoice", diff --git a/src/mercoa/bank_lookup/client.py b/src/mercoa/bank_lookup/client.py index 1805e1e..220ab4f 100644 --- a/src/mercoa/bank_lookup/client.py +++ b/src/mercoa/bank_lookup/client.py @@ -101,14 +101,22 @@ async def find( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.bank_lookup.find( - routing_number="026009593", - ) + + + async def main() -> None: + await client.bank_lookup.find( + routing_number="026009593", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "bankLookup", method="GET", params={"routingNumber": routing_number}, request_options=request_options diff --git a/src/mercoa/client.py b/src/mercoa/client.py index 01efd90..fe4127a 100644 --- a/src/mercoa/client.py +++ b/src/mercoa/client.py @@ -8,6 +8,7 @@ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .custom_payment_method_schema.client import AsyncCustomPaymentMethodSchemaClient, CustomPaymentMethodSchemaClient from .entity.client import AsyncEntityClient, EntityClient +from .entity_group.client import AsyncEntityGroupClient, EntityGroupClient from .environment import MercoaEnvironment from .fees.client import AsyncFeesClient, FeesClient from .invoice.client import AsyncInvoiceClient, InvoiceClient @@ -73,6 +74,7 @@ def __init__( else httpx.Client(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) + self.entity_group = EntityGroupClient(client_wrapper=self._client_wrapper) self.entity = EntityClient(client_wrapper=self._client_wrapper) self.invoice = InvoiceClient(client_wrapper=self._client_wrapper) self.organization = OrganizationClient(client_wrapper=self._client_wrapper) @@ -140,6 +142,7 @@ def __init__( else httpx.AsyncClient(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) + self.entity_group = AsyncEntityGroupClient(client_wrapper=self._client_wrapper) self.entity = AsyncEntityClient(client_wrapper=self._client_wrapper) self.invoice = AsyncInvoiceClient(client_wrapper=self._client_wrapper) self.organization = AsyncOrganizationClient(client_wrapper=self._client_wrapper) diff --git a/src/mercoa/core/client_wrapper.py b/src/mercoa/core/client_wrapper.py index 2ce6f13..5d043c8 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": "0.4.4", + "X-Fern-SDK-Version": "0.4.5", } headers["Authorization"] = f"Bearer {self._get_token()}" return headers diff --git a/src/mercoa/core/http_client.py b/src/mercoa/core/http_client.py index ed7cf5d..09c6836 100644 --- a/src/mercoa/core/http_client.py +++ b/src/mercoa/core/http_client.py @@ -2,6 +2,7 @@ import asyncio import email.utils +import json import re import time import typing @@ -125,6 +126,25 @@ def maybe_filter_request_body( return data_content +# Abstracted out for testing purposes +def get_request_body( + *, + json: typing.Optional[typing.Any], + data: typing.Optional[typing.Any], + request_options: typing.Optional[RequestOptions], + omit: typing.Optional[typing.Any], +) -> typing.Tuple[typing.Optional[typing.Any], typing.Optional[typing.Any]]: + json_body = None + data_body = None + if data is not None: + data_body = maybe_filter_request_body(data, request_options, omit) + else: + # If both data and json are None, we send json data in the event extra properties are specified + json_body = maybe_filter_request_body(json, request_options, omit) + + return json_body, data_body + + class HttpClient: def __init__( self, @@ -168,6 +188,8 @@ def request( else self.base_timeout ) + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + response = self.httpx_client.request( method=method, url=urllib.parse.urljoin(f"{base_url}/", path), @@ -197,8 +219,8 @@ def request( ) ) ), - json=maybe_filter_request_body(json, request_options, omit), - data=maybe_filter_request_body(data, request_options, omit), + json=json_body, + data=data_body, content=content, files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, timeout=timeout, @@ -248,6 +270,8 @@ def stream( else self.base_timeout ) + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + with self.httpx_client.stream( method=method, url=urllib.parse.urljoin(f"{base_url}/", path), @@ -277,8 +301,8 @@ def stream( ) ) ), - json=maybe_filter_request_body(json, request_options, omit), - data=maybe_filter_request_body(data, request_options, omit), + json=json_body, + data=data_body, content=content, files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, timeout=timeout, @@ -329,6 +353,8 @@ async def request( else self.base_timeout ) + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + # Add the input to each of these and do None-safety checks response = await self.httpx_client.request( method=method, @@ -359,8 +385,8 @@ async def request( ) ) ), - json=maybe_filter_request_body(json, request_options, omit), - data=maybe_filter_request_body(data, request_options, omit), + json=json_body, + data=data_body, content=content, files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, timeout=timeout, @@ -409,6 +435,8 @@ async def stream( else self.base_timeout ) + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + async with self.httpx_client.stream( method=method, url=urllib.parse.urljoin(f"{base_url}/", path), @@ -438,8 +466,8 @@ async def stream( ) ) ), - json=maybe_filter_request_body(json, request_options, omit), - data=maybe_filter_request_body(data, request_options, omit), + json=json_body, + data=data_body, content=content, files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, timeout=timeout, diff --git a/src/mercoa/core/request_options.py b/src/mercoa/core/request_options.py index cd6f27a..d0bf0db 100644 --- a/src/mercoa/core/request_options.py +++ b/src/mercoa/core/request_options.py @@ -5,10 +5,10 @@ try: from typing import NotRequired # type: ignore except ImportError: - from typing_extensions import NotRequired # type: ignore + from typing_extensions import NotRequired -class RequestOptions(typing.TypedDict): +class RequestOptions(typing.TypedDict, total=False): """ Additional options for request-specific configuration when calling APIs via the SDK. This is used primarily as an optional final parameter for service functions. diff --git a/src/mercoa/custom_payment_method_schema/client.py b/src/mercoa/custom_payment_method_schema/client.py index 5d25c70..5b2f47a 100644 --- a/src/mercoa/custom_payment_method_schema/client.py +++ b/src/mercoa/custom_payment_method_schema/client.py @@ -15,10 +15,8 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 from ..core.request_options import RequestOptions -from ..payment_method_types.types.currency_code import CurrencyCode -from ..payment_method_types.types.custom_payment_method_schema_fee import CustomPaymentMethodSchemaFee -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 @@ -80,39 +78,14 @@ def get_all( raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, - *, - name: str, - is_source: bool, - is_destination: bool, - fields: typing.Sequence[CustomPaymentMethodSchemaField], - supported_currencies: typing.Optional[typing.Sequence[CurrencyCode]] = OMIT, - estimated_processing_time: typing.Optional[int] = OMIT, - fees: typing.Optional[CustomPaymentMethodSchemaFee] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CustomPaymentMethodSchemaRequest, request_options: typing.Optional[RequestOptions] = None ) -> CustomPaymentMethodSchemaResponse: """ Create custom payment method schema Parameters ---------- - 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. - - estimated_processing_time : typing.Optional[int] - Estimated time in days for this payment method to process a payments. Set as 0 for same-day payment methods, -1 for unknown processing time. - - fees : typing.Optional[CustomPaymentMethodSchemaFee] + request : CustomPaymentMethodSchemaRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -123,61 +96,54 @@ def create( Examples -------- - from mercoa import CustomPaymentMethodSchemaField + from mercoa import ( + CustomPaymentMethodSchemaField, + CustomPaymentMethodSchemaRequest, + ) from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.custom_payment_method_schema.create( - 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="usBankAccountNumber", - optional=False, - use_as_account_number=True, - ), - CustomPaymentMethodSchemaField( - name="routingNumber", - display_name="Routing Number", - type="usBankRoutingNumber", - optional=False, - ), - ], - estimated_processing_time=0, + 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="usBankAccountNumber", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="usBankRoutingNumber", + optional=False, + ), + ], + estimated_processing_time=0, + ), ) """ _response = self._client_wrapper.httpx_client.request( - "paymentMethod/schema", - method="POST", - json={ - "name": name, - "isSource": is_source, - "isDestination": is_destination, - "supportedCurrencies": supported_currencies, - "fields": fields, - "estimatedProcessingTime": estimated_processing_time, - "fees": fees, - }, - request_options=request_options, - omit=OMIT, + "paymentMethod/schema", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -206,13 +172,7 @@ def update( self, schema_id: CustomPaymentMethodSchemaId, *, - name: str, - is_source: bool, - is_destination: bool, - fields: typing.Sequence[CustomPaymentMethodSchemaField], - supported_currencies: typing.Optional[typing.Sequence[CurrencyCode]] = OMIT, - estimated_processing_time: typing.Optional[int] = OMIT, - fees: typing.Optional[CustomPaymentMethodSchemaFee] = OMIT, + request: CustomPaymentMethodSchemaRequest, request_options: typing.Optional[RequestOptions] = None, ) -> CustomPaymentMethodSchemaResponse: """ @@ -222,23 +182,7 @@ def update( ---------- schema_id : CustomPaymentMethodSchemaId - 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. - - estimated_processing_time : typing.Optional[int] - Estimated time in days for this payment method to process a payments. Set as 0 for same-day payment methods, -1 for unknown processing time. - - fees : typing.Optional[CustomPaymentMethodSchemaFee] + request : CustomPaymentMethodSchemaRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -249,7 +193,10 @@ def update( Examples -------- - from mercoa import CustomPaymentMethodSchemaField + from mercoa import ( + CustomPaymentMethodSchemaField, + CustomPaymentMethodSchemaRequest, + ) from mercoa.client import Mercoa client = Mercoa( @@ -257,52 +204,46 @@ def update( ) client.custom_payment_method_schema.update( schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", - 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="usBankAccountNumber", - optional=False, - use_as_account_number=True, - ), - CustomPaymentMethodSchemaField( - name="routingNumber", - display_name="Routing Number", - type="usBankRoutingNumber", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="address", - display_name="Address", - type="address", - optional=False, - ), - ], - estimated_processing_time=7, + 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="usBankAccountNumber", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="usBankRoutingNumber", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="address", + display_name="Address", + type="address", + optional=False, + ), + ], + estimated_processing_time=7, + ), ) """ _response = self._client_wrapper.httpx_client.request( f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="POST", - json={ - "name": name, - "isSource": is_source, - "isDestination": is_destination, - "supportedCurrencies": supported_currencies, - "fields": fields, - "estimatedProcessingTime": estimated_processing_time, - "fees": fees, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -459,12 +400,20 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.custom_payment_method_schema.get_all() + + + async def main() -> None: + await client.custom_payment_method_schema.get_all() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "paymentMethod/schema", method="GET", request_options=request_options @@ -493,39 +442,14 @@ async def get_all( raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, - *, - name: str, - is_source: bool, - is_destination: bool, - fields: typing.Sequence[CustomPaymentMethodSchemaField], - supported_currencies: typing.Optional[typing.Sequence[CurrencyCode]] = OMIT, - estimated_processing_time: typing.Optional[int] = OMIT, - fees: typing.Optional[CustomPaymentMethodSchemaFee] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CustomPaymentMethodSchemaRequest, request_options: typing.Optional[RequestOptions] = None ) -> CustomPaymentMethodSchemaResponse: """ Create custom payment method schema Parameters ---------- - 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. - - estimated_processing_time : typing.Optional[int] - Estimated time in days for this payment method to process a payments. Set as 0 for same-day payment methods, -1 for unknown processing time. - - fees : typing.Optional[CustomPaymentMethodSchemaFee] + request : CustomPaymentMethodSchemaRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -536,61 +460,62 @@ async def create( Examples -------- - from mercoa import CustomPaymentMethodSchemaField + import asyncio + + from mercoa import ( + CustomPaymentMethodSchemaField, + CustomPaymentMethodSchemaRequest, + ) from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.custom_payment_method_schema.create( - 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="usBankAccountNumber", - optional=False, - use_as_account_number=True, - ), - CustomPaymentMethodSchemaField( - name="routingNumber", - display_name="Routing Number", - type="usBankRoutingNumber", - optional=False, + + + async def main() -> None: + 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="usBankAccountNumber", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="usBankRoutingNumber", + optional=False, + ), + ], + estimated_processing_time=0, ), - ], - estimated_processing_time=0, - ) + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "paymentMethod/schema", - method="POST", - json={ - "name": name, - "isSource": is_source, - "isDestination": is_destination, - "supportedCurrencies": supported_currencies, - "fields": fields, - "estimatedProcessingTime": estimated_processing_time, - "fees": fees, - }, - request_options=request_options, - omit=OMIT, + "paymentMethod/schema", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -619,13 +544,7 @@ async def update( self, schema_id: CustomPaymentMethodSchemaId, *, - name: str, - is_source: bool, - is_destination: bool, - fields: typing.Sequence[CustomPaymentMethodSchemaField], - supported_currencies: typing.Optional[typing.Sequence[CurrencyCode]] = OMIT, - estimated_processing_time: typing.Optional[int] = OMIT, - fees: typing.Optional[CustomPaymentMethodSchemaFee] = OMIT, + request: CustomPaymentMethodSchemaRequest, request_options: typing.Optional[RequestOptions] = None, ) -> CustomPaymentMethodSchemaResponse: """ @@ -635,23 +554,7 @@ async def update( ---------- schema_id : CustomPaymentMethodSchemaId - 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. - - estimated_processing_time : typing.Optional[int] - Estimated time in days for this payment method to process a payments. Set as 0 for same-day payment methods, -1 for unknown processing time. - - fees : typing.Optional[CustomPaymentMethodSchemaFee] + request : CustomPaymentMethodSchemaRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -662,60 +565,65 @@ async def update( Examples -------- - from mercoa import CustomPaymentMethodSchemaField + import asyncio + + from mercoa import ( + CustomPaymentMethodSchemaField, + CustomPaymentMethodSchemaRequest, + ) from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.custom_payment_method_schema.update( - schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", - 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="usBankAccountNumber", - optional=False, - use_as_account_number=True, - ), - CustomPaymentMethodSchemaField( - name="routingNumber", - display_name="Routing Number", - type="usBankRoutingNumber", - optional=False, - ), - CustomPaymentMethodSchemaField( - name="address", - display_name="Address", - type="address", - optional=False, + + + async def main() -> None: + 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="usBankAccountNumber", + optional=False, + use_as_account_number=True, + ), + CustomPaymentMethodSchemaField( + name="routingNumber", + display_name="Routing Number", + type="usBankRoutingNumber", + optional=False, + ), + CustomPaymentMethodSchemaField( + name="address", + display_name="Address", + type="address", + optional=False, + ), + ], + estimated_processing_time=7, ), - ], - estimated_processing_time=7, - ) + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="POST", - json={ - "name": name, - "isSource": is_source, - "isDestination": is_destination, - "supportedCurrencies": supported_currencies, - "fields": fields, - "estimatedProcessingTime": estimated_processing_time, - "fees": fees, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -761,14 +669,22 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.custom_payment_method_schema.get( - schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", - ) + + + async def main() -> None: + await client.custom_payment_method_schema.get( + schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="GET", request_options=request_options @@ -815,14 +731,22 @@ async def delete( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.custom_payment_method_schema.delete( - schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", - ) + + + async def main() -> None: + await client.custom_payment_method_schema.delete( + schema_id="cpms_14f78dcd-4614-426e-a37a-7af262431d41", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"paymentMethod/schema/{jsonable_encoder(schema_id)}", method="DELETE", request_options=request_options diff --git a/src/mercoa/entity/approval_policy/client.py b/src/mercoa/entity/approval_policy/client.py index 035a62d..f5d2326 100644 --- a/src/mercoa/entity/approval_policy/client.py +++ b/src/mercoa/entity/approval_policy/client.py @@ -16,10 +16,10 @@ from ...core.pydantic_utilities import pydantic_v1 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, ...) @@ -87,9 +87,7 @@ def create( self, entity_id: EntityId, *, - trigger: typing.Sequence[Trigger], - rule: Rule, - upstream_policy_id: ApprovalPolicyId, + request: ApprovalPolicyRequest, request_options: typing.Optional[RequestOptions] = None, ) -> ApprovalPolicyResponse: """ @@ -99,13 +97,7 @@ def create( ---------- entity_id : EntityId - 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 : ApprovalPolicyRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -116,7 +108,12 @@ def create( Examples -------- - from mercoa import IdentifierList_RolesList, Rule_Approver, Trigger_Amount + from mercoa import ( + ApprovalPolicyRequest, + IdentifierList_RolesList, + Rule_Approver, + Trigger_Amount, + ) from mercoa.client import Mercoa client = Mercoa( @@ -124,23 +121,27 @@ def create( ) client.entity.approval_policy.create( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - trigger=[ - Trigger_Amount( - amount=100.0, - currency="USD", - ) - ], - rule=Rule_Approver( - num_approvers=2, - identifier_list=IdentifierList_RolesList(value=["Admin", "Controller"]), + 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", ), - upstream_policy_id="root", ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/approval-policy", method="POST", - json={"trigger": trigger, "rule": rule, "upstreamPolicyId": upstream_policy_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -235,9 +236,7 @@ def update( entity_id: EntityId, policy_id: ApprovalPolicyId, *, - trigger: typing.Optional[typing.Sequence[Trigger]] = OMIT, - rule: typing.Optional[Rule] = OMIT, - upstream_policy_id: typing.Optional[ApprovalPolicyId] = OMIT, + request: ApprovalPolicyUpdateRequest, request_options: typing.Optional[RequestOptions] = None, ) -> ApprovalPolicyResponse: """ @@ -249,11 +248,7 @@ def update( policy_id : ApprovalPolicyId - trigger : typing.Optional[typing.Sequence[Trigger]] - - rule : typing.Optional[Rule] - - upstream_policy_id : typing.Optional[ApprovalPolicyId] + request : ApprovalPolicyUpdateRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -264,7 +259,12 @@ def update( Examples -------- - from mercoa import IdentifierList_RolesList, Rule_Approver, Trigger_Amount + from mercoa import ( + ApprovalPolicyUpdateRequest, + IdentifierList_RolesList, + Rule_Approver, + Trigger_Amount, + ) from mercoa.client import Mercoa client = Mercoa( @@ -273,23 +273,27 @@ def update( client.entity.approval_policy.update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", - trigger=[ - Trigger_Amount( - amount=100.0, - currency="USD", - ) - ], - rule=Rule_Approver( - num_approvers=2, - identifier_list=IdentifierList_RolesList(value=["Admin", "Controller"]), + 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", ), - 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", - json={"trigger": trigger, "rule": rule, "upstreamPolicyId": upstream_policy_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -403,14 +407,22 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.approval_policy.get_all( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.entity.approval_policy.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/approval-policies", method="GET", request_options=request_options @@ -442,9 +454,7 @@ async def create( self, entity_id: EntityId, *, - trigger: typing.Sequence[Trigger], - rule: Rule, - upstream_policy_id: ApprovalPolicyId, + request: ApprovalPolicyRequest, request_options: typing.Optional[RequestOptions] = None, ) -> ApprovalPolicyResponse: """ @@ -454,13 +464,7 @@ async def create( ---------- entity_id : EntityId - 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 : ApprovalPolicyRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -471,31 +475,48 @@ async def create( Examples -------- - from mercoa import IdentifierList_RolesList, Rule_Approver, Trigger_Amount + import asyncio + + from mercoa import ( + ApprovalPolicyRequest, + IdentifierList_RolesList, + Rule_Approver, + Trigger_Amount, + ) from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.approval_policy.create( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - 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", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/approval-policy", method="POST", - json={"trigger": trigger, "rule": rule, "upstreamPolicyId": upstream_policy_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -547,15 +568,23 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.approval_policy.get( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", - ) + + + async def main() -> None: + await client.entity.approval_policy.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", @@ -590,9 +619,7 @@ async def update( entity_id: EntityId, policy_id: ApprovalPolicyId, *, - trigger: typing.Optional[typing.Sequence[Trigger]] = OMIT, - rule: typing.Optional[Rule] = OMIT, - upstream_policy_id: typing.Optional[ApprovalPolicyId] = OMIT, + request: ApprovalPolicyUpdateRequest, request_options: typing.Optional[RequestOptions] = None, ) -> ApprovalPolicyResponse: """ @@ -604,11 +631,7 @@ async def update( policy_id : ApprovalPolicyId - trigger : typing.Optional[typing.Sequence[Trigger]] - - rule : typing.Optional[Rule] - - upstream_policy_id : typing.Optional[ApprovalPolicyId] + request : ApprovalPolicyUpdateRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -619,32 +642,49 @@ async def update( Examples -------- - from mercoa import IdentifierList_RolesList, Rule_Approver, Trigger_Amount + import asyncio + + from mercoa import ( + ApprovalPolicyUpdateRequest, + IdentifierList_RolesList, + Rule_Approver, + Trigger_Amount, + ) from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.approval_policy.update( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", - 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", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", method="POST", - json={"trigger": trigger, "rule": rule, "upstreamPolicyId": upstream_policy_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -696,15 +736,23 @@ async def delete( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.approval_policy.delete( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", - ) + + + async def main() -> None: + await client.entity.approval_policy.delete( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + policy_id="apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/approval-policy/{jsonable_encoder(policy_id)}", diff --git a/src/mercoa/entity/client.py b/src/mercoa/entity/client.py index 2771458..51b7599 100644 --- a/src/mercoa/entity/client.py +++ b/src/mercoa/entity/client.py @@ -15,18 +15,14 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 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.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 ..entity_types.types.token_generation_options import TokenGenerationOptions from ..payment_method_types.types.payment_method_id import PaymentMethodId from .approval_policy.client import ApprovalPolicyClient, AsyncApprovalPolicyClient from .counterparty.client import AsyncCounterpartyClient, CounterpartyClient @@ -166,54 +162,12 @@ def find( raise ApiError(status_code=_response.status_code, body=_response_json) def create( - 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, - is_network_payor: typing.Optional[bool] = OMIT, - is_network_payee: typing.Optional[bool] = OMIT, - logo: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: EntityRequest, request_options: typing.Optional[RequestOptions] = None ) -> EntityResponse: """ Parameters ---------- - 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. - - is_network_payor : typing.Optional[bool] - Control if this entity should be available as a payor to any entity on your platform. If set to false, this entity will only be available as a payor to entities that have a direct relationship with this entity. Defaults to false. - - is_network_payee : typing.Optional[bool] - Control if this entity should be available as a payee to any entity on your platform. If set to false, this entity will only be available as a payee to entities that have a direct relationship with this entity. Defaults to false. - - logo : typing.Optional[str] - Base64 encoded PNG image data for the entity logo. + request : EntityRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -228,6 +182,7 @@ def create( Address, BusinessProfileRequest, Ein, + EntityRequest, PhoneNumber, ProfileRequest, TaxId, @@ -238,32 +193,34 @@ def create( token="YOUR_TOKEN", ) client.entity.create( - 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", + 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", + ), ), ), ), @@ -271,23 +228,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "entity", - method="POST", - 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, - "isNetworkPayor": is_network_payor, - "isNetworkPayee": is_network_payee, - "logo": logo, - }, - request_options=request_options, - omit=OMIT, + "entity", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -366,17 +307,7 @@ def update( self, entity_id: EntityId, *, - 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, - is_network_payor: typing.Optional[bool] = OMIT, - is_network_payee: typing.Optional[bool] = OMIT, - logo: typing.Optional[str] = OMIT, + request: EntityUpdateRequest, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ @@ -384,36 +315,7 @@ def update( ---------- entity_id : EntityId - 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. - - is_network_payor : typing.Optional[bool] - Control if this entity should be available as a payor to any entity on your platform. If set to false, this entity will only be available as a payor to entities that have a direct relationship with this entity. Defaults to false. - - is_network_payee : typing.Optional[bool] - Control if this entity should be available as a payee to any entity on your platform. If set to false, this entity will only be available as a payee to entities that have a direct relationship with this entity. Defaults to false. - - logo : typing.Optional[str] - Base64 encoded PNG image data for the entity logo. + request : EntityUpdateRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -428,6 +330,7 @@ def update( Address, BusinessProfileRequest, Ein, + EntityUpdateRequest, PhoneNumber, ProfileRequest, TaxId, @@ -439,32 +342,34 @@ def update( ) client.entity.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - 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", + 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", + ), ), ), ), @@ -474,19 +379,7 @@ def update( _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}", method="POST", - 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, - "isNetworkPayor": is_network_payor, - "isNetworkPayee": is_network_payee, - "logo": logo, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -677,12 +570,7 @@ def get_token( self, entity_id: EntityId, *, - 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: TokenGenerationOptions, request_options: typing.Optional[RequestOptions] = None, ) -> str: """ @@ -694,18 +582,7 @@ def get_token( ---------- entity_id : EntityId - 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 : TokenGenerationOptions request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -716,6 +593,7 @@ def get_token( Examples -------- + from mercoa import TokenGenerationOptions from mercoa.client import Mercoa client = Mercoa( @@ -723,20 +601,15 @@ def get_token( ) client.entity.get_token( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - expires_in="1h", + request=TokenGenerationOptions( + expires_in="1h", + ), ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/token", method="POST", - json={ - "expiresIn": expires_in, - "invoice": invoice, - "pages": pages, - "style": style, - "vendors": vendors, - "entity": entity, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -1049,16 +922,24 @@ async def find( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.find( - is_customer=True, - foreign_id="MY-DB-ID-12345", - payment_methods=True, - ) + + + async def main() -> None: + await client.entity.find( + is_customer=True, + foreign_id="MY-DB-ID-12345", + payment_methods=True, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "entity", @@ -1100,54 +981,12 @@ async def find( raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - 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, - is_network_payor: typing.Optional[bool] = OMIT, - is_network_payee: typing.Optional[bool] = OMIT, - logo: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: EntityRequest, request_options: typing.Optional[RequestOptions] = None ) -> EntityResponse: """ Parameters ---------- - 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. - - is_network_payor : typing.Optional[bool] - Control if this entity should be available as a payor to any entity on your platform. If set to false, this entity will only be available as a payor to entities that have a direct relationship with this entity. Defaults to false. - - is_network_payee : typing.Optional[bool] - Control if this entity should be available as a payee to any entity on your platform. If set to false, this entity will only be available as a payee to entities that have a direct relationship with this entity. Defaults to false. - - logo : typing.Optional[str] - Base64 encoded PNG image data for the entity logo. + request : EntityRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1158,10 +997,13 @@ async def create( Examples -------- + import asyncio + from mercoa import ( Address, BusinessProfileRequest, Ein, + EntityRequest, PhoneNumber, ProfileRequest, TaxId, @@ -1171,57 +1013,49 @@ async def create( client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.create( - 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", + + + async def main() -> None: + 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", + ), + ), ), ), ), - ), - ) + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "entity", - method="POST", - 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, - "isNetworkPayor": is_network_payor, - "isNetworkPayee": is_network_payee, - "logo": logo, - }, - request_options=request_options, - omit=OMIT, + "entity", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -1263,14 +1097,22 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.get( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.entity.get( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}", method="GET", request_options=request_options @@ -1302,17 +1144,7 @@ async def update( self, entity_id: EntityId, *, - 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, - is_network_payor: typing.Optional[bool] = OMIT, - is_network_payee: typing.Optional[bool] = OMIT, - logo: typing.Optional[str] = OMIT, + request: EntityUpdateRequest, request_options: typing.Optional[RequestOptions] = None, ) -> EntityResponse: """ @@ -1320,36 +1152,7 @@ async def update( ---------- entity_id : EntityId - 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. - - is_network_payor : typing.Optional[bool] - Control if this entity should be available as a payor to any entity on your platform. If set to false, this entity will only be available as a payor to entities that have a direct relationship with this entity. Defaults to false. - - is_network_payee : typing.Optional[bool] - Control if this entity should be available as a payee to any entity on your platform. If set to false, this entity will only be available as a payee to entities that have a direct relationship with this entity. Defaults to false. - - logo : typing.Optional[str] - Base64 encoded PNG image data for the entity logo. + request : EntityUpdateRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1360,10 +1163,13 @@ async def update( Examples -------- + import asyncio + from mercoa import ( Address, BusinessProfileRequest, Ein, + EntityUpdateRequest, PhoneNumber, ProfileRequest, TaxId, @@ -1373,56 +1179,52 @@ async def update( client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.update( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - 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", + + + async def main() -> None: + 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", + ), + ), ), ), ), - ), - ) + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}", method="POST", - 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, - "isNetworkPayor": is_network_payor, - "isNetworkPayee": is_network_payee, - "logo": logo, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -1466,14 +1268,22 @@ async def delete(self, entity_id: EntityId, *, request_options: typing.Optional[ Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.delete( - entity_id="string", - ) + + + async def main() -> None: + await client.entity.delete( + entity_id="string", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}", method="DELETE", request_options=request_options @@ -1520,14 +1330,22 @@ async def accept_terms_of_service( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.accept_terms_of_service( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.entity.accept_terms_of_service( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/accept-tos", method="POST", request_options=request_options @@ -1576,14 +1394,22 @@ async def initiate_kyb( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.initiate_kyb( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.entity.initiate_kyb( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/request-kyb", method="POST", request_options=request_options @@ -1615,12 +1441,7 @@ async def get_token( self, entity_id: EntityId, *, - 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: TokenGenerationOptions, request_options: typing.Optional[RequestOptions] = None, ) -> str: """ @@ -1632,18 +1453,7 @@ async def get_token( ---------- entity_id : EntityId - 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 : TokenGenerationOptions request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1654,27 +1464,31 @@ async def get_token( Examples -------- + import asyncio + + from mercoa import TokenGenerationOptions from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.get_token( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - expires_in="1h", - ) + + + async def main() -> None: + await client.entity.get_token( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + request=TokenGenerationOptions( + expires_in="1h", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/token", method="POST", - json={ - "expiresIn": expires_in, - "invoice": invoice, - "pages": pages, - "style": style, - "vendors": vendors, - "entity": entity, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -1727,15 +1541,23 @@ async def plaid_link_token( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.plaid_link_token( - entity_id="string", - payment_method_id="string", - ) + + + async def main() -> None: + await client.entity.plaid_link_token( + entity_id="string", + payment_method_id="string", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/plaidLinkToken", @@ -1800,16 +1622,24 @@ async def get_onboarding_link( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.get_onboarding_link( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - type="PAYOR", - expires_in="1h", - ) + + + async def main() -> None: + await client.entity.get_onboarding_link( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + type="PAYOR", + expires_in="1h", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/onboarding", @@ -1874,17 +1704,25 @@ async def send_onboarding_link( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.send_onboarding_link( - entity_id="string", - type="PAYEE", - expires_in="string", - connected_entity_id="string", - ) + + + async def main() -> None: + await client.entity.send_onboarding_link( + entity_id="string", + type="PAYEE", + expires_in="string", + connected_entity_id="string", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/onboarding", diff --git a/src/mercoa/entity/counterparty/client.py b/src/mercoa/entity/counterparty/client.py index b24f7ab..dea7bea 100644 --- a/src/mercoa/entity/counterparty/client.py +++ b/src/mercoa/entity/counterparty/client.py @@ -15,8 +15,11 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions -from ...entity_types.types.counterparty_customization_request import CounterpartyCustomizationRequest 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 @@ -244,8 +247,7 @@ def add_payees( self, entity_id: EntityId, *, - payees: typing.Sequence[EntityId], - customizations: typing.Optional[typing.Sequence[CounterpartyCustomizationRequest]] = OMIT, + request: EntityAddPayeesRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -255,11 +257,7 @@ def add_payees( ---------- entity_id : EntityId - payees : typing.Sequence[EntityId] - List of payee entity IDs to associate with the entity - - customizations : typing.Optional[typing.Sequence[CounterpartyCustomizationRequest]] - List of customizations to apply to the payees. If the payee is not currently a counterparty of the entity, the counterparty will be created with the provided customizations. + request : EntityAddPayeesRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -270,7 +268,7 @@ def add_payees( Examples -------- - from mercoa import CounterpartyCustomizationRequest + from mercoa import CounterpartyCustomizationRequest, EntityAddPayeesRequest from mercoa.client import Mercoa client = Mercoa( @@ -278,19 +276,21 @@ def add_payees( ) client.entity.counterparty.add_payees( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - customizations=[ - CounterpartyCustomizationRequest( - counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", - account_id="85866843", - ) - ], + request=EntityAddPayeesRequest( + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + customizations=[ + CounterpartyCustomizationRequest( + counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + account_id="85866843", + ) + ], + ), ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/addPayees", method="POST", - json={"payees": payees, "customizations": customizations}, + json=request, request_options=request_options, omit=OMIT, ) @@ -321,7 +321,7 @@ def hide_payees( self, entity_id: EntityId, *, - payees: typing.Sequence[EntityId], + request: EntityHidePayeesRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -331,8 +331,7 @@ def hide_payees( ---------- entity_id : EntityId - payees : typing.Sequence[EntityId] - List of payee entity IDs to hide + request : EntityHidePayeesRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -343,6 +342,7 @@ def hide_payees( Examples -------- + from mercoa import EntityHidePayeesRequest from mercoa.client import Mercoa client = Mercoa( @@ -350,13 +350,15 @@ def hide_payees( ) client.entity.counterparty.hide_payees( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + request=EntityHidePayeesRequest( + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + ), ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/hidePayees", method="POST", - json={"payees": payees}, + json=request, request_options=request_options, omit=OMIT, ) @@ -387,8 +389,7 @@ def add_payors( self, entity_id: EntityId, *, - payors: typing.Sequence[EntityId], - customizations: typing.Optional[typing.Sequence[CounterpartyCustomizationRequest]] = OMIT, + request: EntityAddPayorsRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -398,11 +399,7 @@ def add_payors( ---------- entity_id : EntityId - payors : typing.Sequence[EntityId] - List of payor entity IDs to associate with the entity - - customizations : typing.Optional[typing.Sequence[CounterpartyCustomizationRequest]] - List of customizations to apply to the payors. If the payor is not currently a counterparty of the entity, the counterparty will be created with the provided customizations. + request : EntityAddPayorsRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -413,7 +410,7 @@ def add_payors( Examples -------- - from mercoa import CounterpartyCustomizationRequest + from mercoa import CounterpartyCustomizationRequest, EntityAddPayorsRequest from mercoa.client import Mercoa client = Mercoa( @@ -421,19 +418,21 @@ def add_payors( ) client.entity.counterparty.add_payors( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - customizations=[ - CounterpartyCustomizationRequest( - counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", - account_id="85866843", - ) - ], + request=EntityAddPayorsRequest( + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + customizations=[ + CounterpartyCustomizationRequest( + counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + account_id="85866843", + ) + ], + ), ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/addPayors", method="POST", - json={"payors": payors, "customizations": customizations}, + json=request, request_options=request_options, omit=OMIT, ) @@ -464,7 +463,7 @@ def hide_payors( self, entity_id: EntityId, *, - payors: typing.Sequence[EntityId], + request: EntityHidePayorsRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -474,8 +473,7 @@ def hide_payors( ---------- entity_id : EntityId - payors : typing.Sequence[EntityId] - List of payor entity IDs to hide + request : EntityHidePayorsRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -486,6 +484,7 @@ def hide_payors( Examples -------- + from mercoa import EntityHidePayorsRequest from mercoa.client import Mercoa client = Mercoa( @@ -493,13 +492,15 @@ def hide_payors( ) client.entity.counterparty.hide_payors( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + request=EntityHidePayorsRequest( + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + ), ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/hidePayors", method="POST", - json={"payors": payors}, + json=request, request_options=request_options, omit=OMIT, ) @@ -587,17 +588,25 @@ async def find_payees( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.counterparty.find_payees( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - name="Big Box", - payment_methods=True, - invoice_metrics=True, - ) + + + async def main() -> None: + await client.entity.counterparty.find_payees( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + name="Big Box", + payment_methods=True, + invoice_metrics=True, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/counterparties/payees", @@ -693,17 +702,25 @@ async def find_payors( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.counterparty.find_payors( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - name="Big Box", - payment_methods=True, - invoice_metrics=True, - ) + + + async def main() -> None: + await client.entity.counterparty.find_payors( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + name="Big Box", + payment_methods=True, + invoice_metrics=True, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/counterparties/payors", @@ -747,8 +764,7 @@ async def add_payees( self, entity_id: EntityId, *, - payees: typing.Sequence[EntityId], - customizations: typing.Optional[typing.Sequence[CounterpartyCustomizationRequest]] = OMIT, + request: EntityAddPayeesRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -758,11 +774,7 @@ async def add_payees( ---------- entity_id : EntityId - payees : typing.Sequence[EntityId] - List of payee entity IDs to associate with the entity - - customizations : typing.Optional[typing.Sequence[CounterpartyCustomizationRequest]] - List of customizations to apply to the payees. If the payee is not currently a counterparty of the entity, the counterparty will be created with the provided customizations. + request : EntityAddPayeesRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -773,27 +785,37 @@ async def add_payees( Examples -------- - from mercoa import CounterpartyCustomizationRequest + import asyncio + + from mercoa import CounterpartyCustomizationRequest, EntityAddPayeesRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.counterparty.add_payees( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - customizations=[ - CounterpartyCustomizationRequest( - counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", - account_id="85866843", - ) - ], - ) + + + async def main() -> None: + await client.entity.counterparty.add_payees( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=EntityAddPayeesRequest( + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + customizations=[ + CounterpartyCustomizationRequest( + counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + account_id="85866843", + ) + ], + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/addPayees", method="POST", - json={"payees": payees, "customizations": customizations}, + json=request, request_options=request_options, omit=OMIT, ) @@ -824,7 +846,7 @@ async def hide_payees( self, entity_id: EntityId, *, - payees: typing.Sequence[EntityId], + request: EntityHidePayeesRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -834,8 +856,7 @@ async def hide_payees( ---------- entity_id : EntityId - payees : typing.Sequence[EntityId] - List of payee entity IDs to hide + request : EntityHidePayeesRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -846,20 +867,31 @@ async def hide_payees( Examples -------- + import asyncio + + from mercoa import EntityHidePayeesRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.counterparty.hide_payees( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ) + + + async def main() -> None: + await client.entity.counterparty.hide_payees( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=EntityHidePayeesRequest( + payees=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/hidePayees", method="POST", - json={"payees": payees}, + json=request, request_options=request_options, omit=OMIT, ) @@ -890,8 +922,7 @@ async def add_payors( self, entity_id: EntityId, *, - payors: typing.Sequence[EntityId], - customizations: typing.Optional[typing.Sequence[CounterpartyCustomizationRequest]] = OMIT, + request: EntityAddPayorsRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -901,11 +932,7 @@ async def add_payors( ---------- entity_id : EntityId - payors : typing.Sequence[EntityId] - List of payor entity IDs to associate with the entity - - customizations : typing.Optional[typing.Sequence[CounterpartyCustomizationRequest]] - List of customizations to apply to the payors. If the payor is not currently a counterparty of the entity, the counterparty will be created with the provided customizations. + request : EntityAddPayorsRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -916,27 +943,37 @@ async def add_payors( Examples -------- - from mercoa import CounterpartyCustomizationRequest + import asyncio + + from mercoa import CounterpartyCustomizationRequest, EntityAddPayorsRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.counterparty.add_payors( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - customizations=[ - CounterpartyCustomizationRequest( - counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", - account_id="85866843", - ) - ], - ) + + + async def main() -> None: + await client.entity.counterparty.add_payors( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=EntityAddPayorsRequest( + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + customizations=[ + CounterpartyCustomizationRequest( + counterparty_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + account_id="85866843", + ) + ], + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/addPayors", method="POST", - json={"payors": payors, "customizations": customizations}, + json=request, request_options=request_options, omit=OMIT, ) @@ -967,7 +1004,7 @@ async def hide_payors( self, entity_id: EntityId, *, - payors: typing.Sequence[EntityId], + request: EntityHidePayorsRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -977,8 +1014,7 @@ async def hide_payors( ---------- entity_id : EntityId - payors : typing.Sequence[EntityId] - List of payor entity IDs to hide + request : EntityHidePayorsRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -989,20 +1025,31 @@ async def hide_payors( Examples -------- + import asyncio + + from mercoa import EntityHidePayorsRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.counterparty.hide_payors( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], - ) + + + async def main() -> None: + await client.entity.counterparty.hide_payors( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=EntityHidePayorsRequest( + payors=["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"], + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/hidePayors", method="POST", - json={"payors": payors}, + json=request, request_options=request_options, omit=OMIT, ) diff --git a/src/mercoa/entity/customization/client.py b/src/mercoa/entity/customization/client.py index a155c98..d3193ce 100644 --- a/src/mercoa/entity/customization/client.py +++ b/src/mercoa/entity/customization/client.py @@ -15,10 +15,9 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 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, ...) @@ -86,10 +85,7 @@ def update( self, entity_id: EntityId, *, - metadata: typing.Sequence[MetadataCustomizationRequest], - payment_source: typing.Sequence[PaymentMethodCustomizationRequest], - backup_disbursement: typing.Sequence[PaymentMethodCustomizationRequest], - payment_destination: typing.Sequence[PaymentMethodCustomizationRequest], + request: EntityCustomizationRequest, request_options: typing.Optional[RequestOptions] = None, ) -> EntityCustomizationResponse: """ @@ -99,13 +95,7 @@ def update( ---------- entity_id : EntityId - metadata : typing.Sequence[MetadataCustomizationRequest] - - payment_source : typing.Sequence[PaymentMethodCustomizationRequest] - - backup_disbursement : typing.Sequence[PaymentMethodCustomizationRequest] - - payment_destination : typing.Sequence[PaymentMethodCustomizationRequest] + request : EntityCustomizationRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -117,6 +107,7 @@ def update( Examples -------- from mercoa import ( + EntityCustomizationRequest, MetadataCustomizationRequest, PaymentMethodCustomizationRequest, ) @@ -127,54 +118,51 @@ def update( ) client.entity.customization.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - 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, - ), - ], + 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, + ), + ], + ), ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/customization", method="POST", - json={ - "metadata": metadata, - "paymentSource": payment_source, - "backupDisbursement": backup_disbursement, - "paymentDestination": payment_destination, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -225,14 +213,22 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.customization.get( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.entity.customization.get( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/customization", method="GET", request_options=request_options @@ -264,10 +260,7 @@ async def update( self, entity_id: EntityId, *, - metadata: typing.Sequence[MetadataCustomizationRequest], - payment_source: typing.Sequence[PaymentMethodCustomizationRequest], - backup_disbursement: typing.Sequence[PaymentMethodCustomizationRequest], - payment_destination: typing.Sequence[PaymentMethodCustomizationRequest], + request: EntityCustomizationRequest, request_options: typing.Optional[RequestOptions] = None, ) -> EntityCustomizationResponse: """ @@ -277,13 +270,7 @@ async def update( ---------- entity_id : EntityId - metadata : typing.Sequence[MetadataCustomizationRequest] - - payment_source : typing.Sequence[PaymentMethodCustomizationRequest] - - backup_disbursement : typing.Sequence[PaymentMethodCustomizationRequest] - - payment_destination : typing.Sequence[PaymentMethodCustomizationRequest] + request : EntityCustomizationRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -294,7 +281,10 @@ async def update( Examples -------- + import asyncio + from mercoa import ( + EntityCustomizationRequest, MetadataCustomizationRequest, PaymentMethodCustomizationRequest, ) @@ -303,56 +293,59 @@ async def update( client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.customization.update( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - 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, + + + async def main() -> None: + 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, + ), + ], ), - ], - ) + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/customization", method="POST", - json={ - "metadata": metadata, - "paymentSource": payment_source, - "backupDisbursement": backup_disbursement, - "paymentDestination": payment_destination, - }, + json=request, request_options=request_options, omit=OMIT, ) diff --git a/src/mercoa/entity/email_log/client.py b/src/mercoa/entity/email_log/client.py index c482ca7..7ecc4c2 100644 --- a/src/mercoa/entity/email_log/client.py +++ b/src/mercoa/entity/email_log/client.py @@ -215,14 +215,22 @@ async def find( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.email_log.find( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.entity.email_log.find( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/emailLogs", @@ -280,15 +288,23 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.email_log.get( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - log_id="log_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.entity.email_log.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + log_id="log_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/emailLog/{jsonable_encoder(log_id)}", diff --git a/src/mercoa/entity/external_accounting_system/client.py b/src/mercoa/entity/external_accounting_system/client.py index 111506c..1aed9d9 100644 --- a/src/mercoa/entity/external_accounting_system/client.py +++ b/src/mercoa/entity/external_accounting_system/client.py @@ -305,14 +305,22 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.external_accounting_system.get( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.entity.external_accounting_system.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/external-accounting-system", @@ -367,18 +375,26 @@ async def create( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa from mercoa.entity import ExternalAccountingSystemCompanyCreationRequest_Rutter client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.external_accounting_system.create( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=ExternalAccountingSystemCompanyCreationRequest_Rutter( - access_token="123", - ), - ) + + + async def main() -> None: + await client.entity.external_accounting_system.create( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=ExternalAccountingSystemCompanyCreationRequest_Rutter( + access_token="123", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/create", @@ -427,14 +443,22 @@ async def connect(self, entity_id: EntityId, *, request_options: typing.Optional Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.external_accounting_system.connect( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.entity.external_accounting_system.connect( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/connect", @@ -498,17 +522,25 @@ async def sync( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.external_accounting_system.sync( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - vendors="pull", - bills="push", - gl_accounts="pull", - ) + + + async def main() -> None: + await client.entity.external_accounting_system.sync( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + vendors="pull", + bills="push", + gl_accounts="pull", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/external-accounting-system/sync", diff --git a/src/mercoa/entity/invoice/client.py b/src/mercoa/entity/invoice/client.py index 056fbf1..19cfc8e 100644 --- a/src/mercoa/entity/invoice/client.py +++ b/src/mercoa/entity/invoice/client.py @@ -55,7 +55,6 @@ def find( approver_action: typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]] = None, invoice_id: typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] = None, status: typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] = None, - include_fees: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> FindInvoiceResponse: """ @@ -113,9 +112,6 @@ def find( status : typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] Invoice status to filter on. - include_fees : typing.Optional[bool] - DEPRECATED. Fees are now included by default in the response. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -158,7 +154,6 @@ def find( "approverAction": approver_action, "invoiceId": invoice_id, "status": status, - "includeFees": include_fees, }, request_options=request_options, ) @@ -353,7 +348,6 @@ async def find( approver_action: typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]] = None, invoice_id: typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] = None, status: typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] = None, - include_fees: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> FindInvoiceResponse: """ @@ -411,9 +405,6 @@ async def find( status : typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] Invoice status to filter on. - include_fees : typing.Optional[bool] - DEPRECATED. Fees are now included by default in the response. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -423,18 +414,26 @@ async def find( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.invoice.find( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - exclude_receivables=True, - order_by="CREATED_AT", - order_direction="ASC", - limit=10, - ) + + + async def main() -> None: + await client.entity.invoice.find( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + exclude_receivables=True, + order_by="CREATED_AT", + order_direction="ASC", + limit=10, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/invoices", @@ -456,7 +455,6 @@ async def find( "approverAction": approver_action, "invoiceId": invoice_id, "status": status, - "includeFees": include_fees, }, request_options=request_options, ) @@ -561,6 +559,7 @@ async def metrics( Examples -------- + import asyncio import datetime from mercoa.client import AsyncMercoa @@ -568,19 +567,25 @@ async def metrics( client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.invoice.metrics( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - return_by_date="CREATION_DATE", - exclude_receivables=True, - created_date_start=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", - ), - created_date_end=datetime.datetime.fromisoformat( - "2021-01-31 23:59:59.999000+00:00", - ), - currency="USD", - status="NEW", - ) + + + async def main() -> None: + await client.entity.invoice.metrics( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + return_by_date="CREATION_DATE", + exclude_receivables=True, + created_date_start=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + created_date_end=datetime.datetime.fromisoformat( + "2021-01-31 23:59:59.999000+00:00", + ), + currency="USD", + status="NEW", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/invoice-metrics", diff --git a/src/mercoa/entity/metadata/client.py b/src/mercoa/entity/metadata/client.py index e3235df..d7fc0c3 100644 --- a/src/mercoa/entity/metadata/client.py +++ b/src/mercoa/entity/metadata/client.py @@ -292,14 +292,22 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.metadata.get_all( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.entity.metadata.get_all( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/metadata", method="GET", request_options=request_options @@ -348,15 +356,23 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.metadata.get( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - key="propertyId", - ) + + + async def main() -> None: + await client.entity.metadata.get( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + key="propertyId", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", @@ -414,19 +430,27 @@ async def update( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.metadata.update( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - key="propertyId", - request=[ - "{key: 'prop_123', value: 'Beach Rental'}", - "{key: 'prop_456', value: 'City Rental'}", - ], - ) + + + async def main() -> None: + await client.entity.metadata.update( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + key="propertyId", + request=[ + "{key: 'prop_123', value: 'Beach Rental'}", + "{key: 'prop_456', value: 'City Rental'}", + ], + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", @@ -479,15 +503,23 @@ async def delete( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.metadata.delete( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - key="propertyId", - ) + + + async def main() -> None: + await client.entity.metadata.delete( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + key="propertyId", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/metadata/{jsonable_encoder(key)}", diff --git a/src/mercoa/entity/notification_policy/client.py b/src/mercoa/entity/notification_policy/client.py index 19a3871..6c617e6 100644 --- a/src/mercoa/entity/notification_policy/client.py +++ b/src/mercoa/entity/notification_policy/client.py @@ -16,6 +16,7 @@ from ...core.pydantic_utilities import pydantic_v1 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 @@ -149,8 +150,7 @@ def update( entity_id: EntityId, notification_type: NotificationType, *, - additional_roles: typing.Sequence[str], - disabled: typing.Optional[bool] = OMIT, + request: NotificationPolicyRequest, request_options: typing.Optional[RequestOptions] = None, ) -> NotificationPolicyResponse: """ @@ -162,11 +162,7 @@ def update( notification_type : NotificationType - 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 : NotificationPolicyRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -177,6 +173,7 @@ def update( Examples -------- + from mercoa import NotificationPolicyRequest from mercoa.client import Mercoa client = Mercoa( @@ -185,14 +182,16 @@ def update( client.entity.notification_policy.update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", notification_type="INVOICE_APPROVAL_NEEDED", - disabled=False, - additional_roles=["admin", "approver"], + request=NotificationPolicyRequest( + 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", - json={"disabled": disabled, "additionalRoles": additional_roles}, + json=request, request_options=request_options, omit=OMIT, ) @@ -243,14 +242,22 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.notification_policy.get_all( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.entity.notification_policy.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/notification-policies", method="GET", request_options=request_options @@ -303,15 +310,23 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.notification_policy.get( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - notification_type="INVOICE_APPROVAL_NEEDED", - ) + + + async def main() -> None: + await client.entity.notification_policy.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + notification_type="INVOICE_APPROVAL_NEEDED", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", @@ -346,8 +361,7 @@ async def update( entity_id: EntityId, notification_type: NotificationType, *, - additional_roles: typing.Sequence[str], - disabled: typing.Optional[bool] = OMIT, + request: NotificationPolicyRequest, request_options: typing.Optional[RequestOptions] = None, ) -> NotificationPolicyResponse: """ @@ -359,11 +373,7 @@ async def update( notification_type : NotificationType - 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 : NotificationPolicyRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -374,22 +384,33 @@ async def update( Examples -------- + import asyncio + + from mercoa import NotificationPolicyRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.notification_policy.update( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - notification_type="INVOICE_APPROVAL_NEEDED", - disabled=False, - additional_roles=["admin", "approver"], - ) + + + async def main() -> None: + 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"], + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/notification-policy/{jsonable_encoder(notification_type)}", method="POST", - json={"disabled": disabled, "additionalRoles": additional_roles}, + json=request, request_options=request_options, omit=OMIT, ) diff --git a/src/mercoa/entity/payment_method/client.py b/src/mercoa/entity/payment_method/client.py index 772ca2d..daa2b3f 100644 --- a/src/mercoa/entity/payment_method/client.py +++ b/src/mercoa/entity/payment_method/client.py @@ -583,14 +583,22 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.payment_method.get_all( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.entity.payment_method.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/paymentMethods", @@ -644,20 +652,28 @@ async def create( Examples -------- + import asyncio + from mercoa import PaymentMethodRequest_BankAccount from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.payment_method.create( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - request=PaymentMethodRequest_BankAccount( - routing_number="12345678", - account_number="99988767623", - account_type="CHECKING", - ), - ) + + + async def main() -> None: + await client.entity.payment_method.create( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=PaymentMethodRequest_BankAccount( + routing_number="12345678", + account_number="99988767623", + account_type="CHECKING", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/paymentMethod", @@ -712,15 +728,23 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.payment_method.get( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - ) + + + async def main() -> None: + await client.entity.payment_method.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", @@ -778,20 +802,28 @@ async def update( Examples -------- + import asyncio + from mercoa import PaymentMethodUpdateRequest_BankAccount from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.payment_method.update( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - request=PaymentMethodUpdateRequest_BankAccount( - default_source=True, - default_destination=True, - ), - ) + + + async def main() -> None: + await client.entity.payment_method.update( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + request=PaymentMethodUpdateRequest_BankAccount( + default_source=True, + default_destination=True, + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", @@ -848,15 +880,23 @@ async def delete( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.payment_method.delete( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - ) + + + async def main() -> None: + await client.entity.payment_method.delete( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}", @@ -911,15 +951,23 @@ async def initiate_micro_deposits( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.payment_method.initiate_micro_deposits( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - ) + + + async def main() -> None: + await client.entity.payment_method.initiate_micro_deposits( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", @@ -978,16 +1026,24 @@ async def complete_micro_deposits( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.payment_method.complete_micro_deposits( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - amounts=[40, 2], - ) + + + async def main() -> None: + await client.entity.payment_method.complete_micro_deposits( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + payment_method_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + amounts=[40, 2], + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/micro-deposits", @@ -1044,15 +1100,23 @@ async def get_balance( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.payment_method.get_balance( - entity_id="string", - payment_method_id="string", - ) + + + async def main() -> None: + await client.entity.payment_method.get_balance( + entity_id="string", + payment_method_id="string", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/paymentMethod/{jsonable_encoder(payment_method_id)}/balance", diff --git a/src/mercoa/entity/representative/client.py b/src/mercoa/entity/representative/client.py index 9a30319..3dd15f1 100644 --- a/src/mercoa/entity/representative/client.py +++ b/src/mercoa/entity/representative/client.py @@ -10,11 +10,6 @@ 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 @@ -22,8 +17,8 @@ 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, ...) @@ -91,13 +86,7 @@ def create( self, entity_id: EntityId, *, - name: FullName, - phone: PhoneNumber, - email: str, - address: Address, - birth_date: BirthDate, - government_id: IndividualGovernmentId, - responsibilities: Responsibilities, + request: RepresentativeRequest, request_options: typing.Optional[RequestOptions] = None, ) -> RepresentativeResponse: """ @@ -105,19 +94,7 @@ def create( ---------- entity_id : EntityId - name : FullName - - phone : PhoneNumber - - email : str - - address : Address - - birth_date : BirthDate - - government_id : IndividualGovernmentId - - responsibilities : Responsibilities + request : RepresentativeRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -134,6 +111,7 @@ def create( FullName, IndividualGovernmentId, PhoneNumber, + RepresentativeRequest, Responsibilities, ) from mercoa.client import Mercoa @@ -143,52 +121,46 @@ def create( ) client.entity.representative.create( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - 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, + 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, + ), ), ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/representative", method="POST", - json={ - "name": name, - "phone": phone, - "email": email, - "address": address, - "birthDate": birth_date, - "governmentID": government_id, - "responsibilities": responsibilities, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -361,14 +333,22 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.representative.get_all( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.entity.representative.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/representatives", method="GET", request_options=request_options @@ -400,13 +380,7 @@ async def create( self, entity_id: EntityId, *, - name: FullName, - phone: PhoneNumber, - email: str, - address: Address, - birth_date: BirthDate, - government_id: IndividualGovernmentId, - responsibilities: Responsibilities, + request: RepresentativeRequest, request_options: typing.Optional[RequestOptions] = None, ) -> RepresentativeResponse: """ @@ -414,19 +388,7 @@ async def create( ---------- entity_id : EntityId - name : FullName - - phone : PhoneNumber - - email : str - - address : Address - - birth_date : BirthDate - - government_id : IndividualGovernmentId - - responsibilities : Responsibilities + request : RepresentativeRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -437,12 +399,15 @@ async def create( Examples -------- + import asyncio + from mercoa import ( Address, BirthDate, FullName, IndividualGovernmentId, PhoneNumber, + RepresentativeRequest, Responsibilities, ) from mercoa.client import AsyncMercoa @@ -450,54 +415,54 @@ async def create( client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.representative.create( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - 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, - ), - ) + + + async def main() -> None: + 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, + ), + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/representative", method="POST", - json={ - "name": name, - "phone": phone, - "email": email, - "address": address, - "birthDate": birth_date, - "governmentID": government_id, - "responsibilities": responsibilities, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -547,15 +512,23 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.representative.get( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - representative_id="rep_7df2974a-4069-454c-912f-7e58ebe030fb", - ) + + + async def main() -> None: + await client.entity.representative.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + representative_id="rep_7df2974a-4069-454c-912f-7e58ebe030fb", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", @@ -608,15 +581,23 @@ async def delete( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.representative.delete( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - representative_id="rep_7df2974a-4069-454c-912f-7e58ebe030fb", - ) + + + async def main() -> None: + await client.entity.representative.delete( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + representative_id="rep_7df2974a-4069-454c-912f-7e58ebe030fb", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/representative/{jsonable_encoder(representative_id)}", diff --git a/src/mercoa/entity/user/client.py b/src/mercoa/entity/user/client.py index 47c6119..b689bf7 100644 --- a/src/mercoa/entity/user/client.py +++ b/src/mercoa/entity/user/client.py @@ -17,13 +17,10 @@ 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_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 ...entity_types.types.token_generation_options import TokenGenerationOptions from .notification_policy.client import AsyncNotificationPolicyClient, NotificationPolicyClient from .notifications.client import AsyncNotificationsClient, NotificationsClient @@ -187,10 +184,7 @@ def create( self, entity_id: EntityId, *, - foreign_id: typing.Optional[str] = OMIT, - email: typing.Optional[str] = OMIT, - name: typing.Optional[str] = OMIT, - roles: typing.Optional[typing.Sequence[str]] = OMIT, + request: EntityUserRequest, request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ @@ -198,15 +192,7 @@ def create( ---------- entity_id : EntityId - 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 : EntityUserRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -217,6 +203,7 @@ def create( Examples -------- + from mercoa import EntityUserRequest from mercoa.client import Mercoa client = Mercoa( @@ -224,16 +211,18 @@ def create( ) client.entity.user.create( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - foreign_id="MY-DB-ID-12345", - email="john.doe@acme.com", - name="John Doe", - roles=["admin", "approver"], + request=EntityUserRequest( + 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", - json={"foreignId": foreign_id, "email": email, "name": name, "roles": roles}, + json=request, request_options=request_options, omit=OMIT, ) @@ -324,10 +313,7 @@ def update( entity_id: EntityId, user_id: EntityUserId, *, - foreign_id: typing.Optional[str] = OMIT, - email: typing.Optional[str] = OMIT, - name: typing.Optional[str] = OMIT, - roles: typing.Optional[typing.Sequence[str]] = OMIT, + request: EntityUserRequest, request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ @@ -339,15 +325,7 @@ def update( user_id : EntityUserId - 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 : EntityUserRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -358,6 +336,7 @@ def update( Examples -------- + from mercoa import EntityUserRequest from mercoa.client import Mercoa client = Mercoa( @@ -366,16 +345,18 @@ def update( client.entity.user.update( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", user_id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", - foreign_id="MY-DB-ID-12345", - email="john.doe@acme.com", - name="John Doe", - roles=["admin", "approver"], + request=EntityUserRequest( + 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", - json={"foreignId": foreign_id, "email": email, "name": name, "roles": roles}, + json=request, request_options=request_options, omit=OMIT, ) @@ -466,12 +447,7 @@ def get_token( entity_id: EntityId, user_id: EntityUserId, *, - 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: TokenGenerationOptions, request_options: typing.Optional[RequestOptions] = None, ) -> str: """ @@ -483,18 +459,7 @@ def get_token( user_id : EntityUserId - 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 : TokenGenerationOptions request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -505,6 +470,7 @@ def get_token( Examples -------- + from mercoa import TokenGenerationOptions from mercoa.client import Mercoa client = Mercoa( @@ -513,20 +479,15 @@ def get_token( client.entity.user.get_token( entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", user_id="user_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - expires_in="1h", + request=TokenGenerationOptions( + expires_in="1h", + ), ) """ _response = self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/token", method="POST", - json={ - "expiresIn": expires_in, - "invoice": invoice, - "pages": pages, - "style": style, - "vendors": vendors, - "entity": entity, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -579,14 +540,22 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.get_all( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.entity.user.get_all( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/users", method="GET", request_options=request_options @@ -660,15 +629,23 @@ async def find( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.find( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - name="John", - ) + + + async def main() -> None: + await client.entity.user.find( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + name="John", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/users", @@ -710,10 +687,7 @@ async def create( self, entity_id: EntityId, *, - foreign_id: typing.Optional[str] = OMIT, - email: typing.Optional[str] = OMIT, - name: typing.Optional[str] = OMIT, - roles: typing.Optional[typing.Sequence[str]] = OMIT, + request: EntityUserRequest, request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ @@ -721,15 +695,7 @@ async def create( ---------- entity_id : EntityId - 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 : EntityUserRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -740,23 +706,34 @@ async def create( Examples -------- + import asyncio + + from mercoa import EntityUserRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.create( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - foreign_id="MY-DB-ID-12345", - email="john.doe@acme.com", - name="John Doe", - roles=["admin", "approver"], - ) + + + async def main() -> None: + 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"], + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user", method="POST", - json={"foreignId": foreign_id, "email": email, "name": name, "roles": roles}, + json=request, request_options=request_options, omit=OMIT, ) @@ -804,15 +781,23 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.get( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - user_id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", - ) + + + async def main() -> None: + await client.entity.user.get( + entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + user_id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", @@ -847,10 +832,7 @@ async def update( entity_id: EntityId, user_id: EntityUserId, *, - foreign_id: typing.Optional[str] = OMIT, - email: typing.Optional[str] = OMIT, - name: typing.Optional[str] = OMIT, - roles: typing.Optional[typing.Sequence[str]] = OMIT, + request: EntityUserRequest, request_options: typing.Optional[RequestOptions] = None, ) -> EntityUserResponse: """ @@ -862,15 +844,7 @@ async def update( user_id : EntityUserId - 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 : EntityUserRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -881,24 +855,35 @@ async def update( Examples -------- + import asyncio + + from mercoa import EntityUserRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.update( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - user_id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", - foreign_id="MY-DB-ID-12345", - email="john.doe@acme.com", - name="John Doe", - roles=["admin", "approver"], - ) + + + async def main() -> None: + 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"], + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", method="POST", - json={"foreignId": foreign_id, "email": email, "name": name, "roles": roles}, + json=request, request_options=request_options, omit=OMIT, ) @@ -946,15 +931,23 @@ async def delete( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.delete( - entity_id="string", - user_id="string", - ) + + + async def main() -> None: + await client.entity.user.delete( + entity_id="string", + user_id="string", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}", @@ -989,12 +982,7 @@ async def get_token( entity_id: EntityId, user_id: EntityUserId, *, - 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: TokenGenerationOptions, request_options: typing.Optional[RequestOptions] = None, ) -> str: """ @@ -1006,18 +994,7 @@ async def get_token( user_id : EntityUserId - 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 : TokenGenerationOptions request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1028,28 +1005,32 @@ async def get_token( Examples -------- + import asyncio + + from mercoa import TokenGenerationOptions from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.get_token( - entity_id="ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - user_id="user_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - expires_in="1h", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/token", method="POST", - json={ - "expiresIn": expires_in, - "invoice": invoice, - "pages": pages, - "style": style, - "vendors": vendors, - "entity": entity, - }, + json=request, request_options=request_options, omit=OMIT, ) diff --git a/src/mercoa/entity/user/notification_policy/client.py b/src/mercoa/entity/user/notification_policy/client.py index ce75d81..c29afe7 100644 --- a/src/mercoa/entity/user/notification_policy/client.py +++ b/src/mercoa/entity/user/notification_policy/client.py @@ -18,6 +18,7 @@ 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 @@ -160,9 +161,7 @@ def update( user_id: EntityUserId, notification_type: NotificationType, *, - disabled: typing.Optional[bool] = OMIT, - digest: typing.Optional[bool] = OMIT, - immediate: typing.Optional[bool] = OMIT, + request: UserNotificationPolicyRequest, request_options: typing.Optional[RequestOptions] = None, ) -> UserNotificationPolicyResponse: """ @@ -176,14 +175,7 @@ def update( notification_type : NotificationType - 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 : UserNotificationPolicyRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -194,6 +186,7 @@ def update( Examples -------- + from mercoa import UserNotificationPolicyRequest from mercoa.client import Mercoa client = Mercoa( @@ -203,13 +196,15 @@ def update( entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", notification_type="INVOICE_APPROVED", - disabled=True, + request=UserNotificationPolicyRequest( + 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", - json={"disabled": disabled, "digest": digest, "immediate": immediate}, + json=request, request_options=request_options, omit=OMIT, ) @@ -262,15 +257,23 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.notification_policy.get_all( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ) + + + async def main() -> None: + await client.entity.user.notification_policy.get_all( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification-policies", @@ -328,16 +331,24 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.notification_policy.get( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - notification_type="INVOICE_APPROVED", - ) + + + async def main() -> None: + await client.entity.user.notification_policy.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + notification_type="INVOICE_APPROVED", + ) + + + asyncio.run(main()) """ _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)}", @@ -373,9 +384,7 @@ async def update( user_id: EntityUserId, notification_type: NotificationType, *, - disabled: typing.Optional[bool] = OMIT, - digest: typing.Optional[bool] = OMIT, - immediate: typing.Optional[bool] = OMIT, + request: UserNotificationPolicyRequest, request_options: typing.Optional[RequestOptions] = None, ) -> UserNotificationPolicyResponse: """ @@ -389,14 +398,7 @@ async def update( notification_type : NotificationType - 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 : UserNotificationPolicyRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -407,22 +409,33 @@ async def update( Examples -------- + import asyncio + + from mercoa import UserNotificationPolicyRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.notification_policy.update( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - notification_type="INVOICE_APPROVED", - disabled=True, - ) + + + async def main() -> None: + await client.entity.user.notification_policy.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, + ), + ) + + + asyncio.run(main()) """ _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", - json={"disabled": disabled, "digest": digest, "immediate": immediate}, + json=request, request_options=request_options, omit=OMIT, ) diff --git a/src/mercoa/entity/user/notifications/client.py b/src/mercoa/entity/user/notifications/client.py index b43f520..6293d6e 100644 --- a/src/mercoa/entity/user/notifications/client.py +++ b/src/mercoa/entity/user/notifications/client.py @@ -240,15 +240,23 @@ async def find( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.notifications.find( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ) + + + async def main() -> None: + await client.entity.user.notifications.find( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notifications", @@ -312,16 +320,24 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.entity.user.notifications.get( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - notification_id="notif_7df2974a-4069-454c-912f-7e58ebe030fb", - ) + + + async def main() -> None: + await client.entity.user.notifications.get( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + notification_id="notif_7df2974a-4069-454c-912f-7e58ebe030fb", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"entity/{jsonable_encoder(entity_id)}/user/{jsonable_encoder(user_id)}/notification/{jsonable_encoder(notification_id)}", diff --git a/src/mercoa/entity_group/__init__.py b/src/mercoa/entity_group/__init__.py new file mode 100644 index 0000000..4e9baa9 --- /dev/null +++ b/src/mercoa/entity_group/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from . import invoice + +__all__ = ["invoice"] diff --git a/src/mercoa/entity_group/client.py b/src/mercoa/entity_group/client.py new file mode 100644 index 0000000..021d737 --- /dev/null +++ b/src/mercoa/entity_group/client.py @@ -0,0 +1,679 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..commons.errors.bad_request import BadRequest +from ..commons.errors.conflict import Conflict +from ..commons.errors.forbidden import Forbidden +from ..commons.errors.internal_server_error import InternalServerError +from ..commons.errors.not_found import NotFound +from ..commons.errors.unauthorized import Unauthorized +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.request_options import RequestOptions +from ..entity_group_types.types.entity_group_find_response import EntityGroupFindResponse +from ..entity_group_types.types.entity_group_id import EntityGroupId +from ..entity_group_types.types.entity_group_request import EntityGroupRequest +from ..entity_group_types.types.entity_group_response import EntityGroupResponse +from .invoice.client import AsyncInvoiceClient, InvoiceClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class EntityGroupClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + self.invoice = InvoiceClient(client_wrapper=self._client_wrapper) + + def get_all( + self, + *, + limit: typing.Optional[int] = None, + starting_after: typing.Optional[EntityGroupId] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> EntityGroupFindResponse: + """ + Get all entity groups. If using a JWT, will return all groups the entity is part of. If using an API key, will return all groups for the organization. + + Parameters + ---------- + limit : typing.Optional[int] + The maximum number of results to return. Defaults to 1. Max is 10. + + starting_after : typing.Optional[EntityGroupId] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EntityGroupFindResponse + + Examples + -------- + from mercoa.client import Mercoa + + client = Mercoa( + token="YOUR_TOKEN", + ) + client.entity_group.get_all() + """ + _response = self._client_wrapper.httpx_client.request( + "entityGroups", + method="GET", + params={"limit": limit, "startingAfter": starting_after}, + request_options=request_options, + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EntityGroupFindResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + def create( + self, *, request: EntityGroupRequest, request_options: typing.Optional[RequestOptions] = None + ) -> EntityGroupResponse: + """ + Create an entity group + + Parameters + ---------- + request : EntityGroupRequest + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EntityGroupResponse + + Examples + -------- + from mercoa import EntityGroupRequest + from mercoa.client import Mercoa + + client = Mercoa( + token="YOUR_TOKEN", + ) + client.entity_group.create( + request=EntityGroupRequest( + entity_ids=[ + "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ], + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + "entityGroup", method="POST", json=request, request_options=request_options, omit=OMIT + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EntityGroupResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + def get( + self, entity_group_id: EntityGroupId, *, request_options: typing.Optional[RequestOptions] = None + ) -> EntityGroupResponse: + """ + Get an entity group + + Parameters + ---------- + entity_group_id : EntityGroupId + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EntityGroupResponse + + Examples + -------- + from mercoa.client import Mercoa + + client = Mercoa( + token="YOUR_TOKEN", + ) + client.entity_group.get( + entity_group_id="entg_a3582b70-fd04-4888-9185-a640ae9048be", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}", method="GET", request_options=request_options + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EntityGroupResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + def update( + self, + entity_group_id: EntityGroupId, + *, + request: EntityGroupRequest, + request_options: typing.Optional[RequestOptions] = None, + ) -> EntityGroupResponse: + """ + Update an entity group + + Parameters + ---------- + entity_group_id : EntityGroupId + + request : EntityGroupRequest + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EntityGroupResponse + + Examples + -------- + from mercoa import EntityGroupRequest + from mercoa.client import Mercoa + + client = Mercoa( + token="YOUR_TOKEN", + ) + client.entity_group.update( + entity_group_id="entg_a3582b70-fd04-4888-9185-a640ae9048be", + request=EntityGroupRequest( + entity_ids=[ + "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ], + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EntityGroupResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + def delete( + self, entity_group_id: EntityGroupId, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Delete an entity group + + Parameters + ---------- + entity_group_id : EntityGroupId + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from mercoa.client import Mercoa + + client = Mercoa( + token="YOUR_TOKEN", + ) + client.entity_group.delete( + entity_group_id="string", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}", method="DELETE", request_options=request_options + ) + if 200 <= _response.status_code < 300: + return + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + +class AsyncEntityGroupClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + self.invoice = AsyncInvoiceClient(client_wrapper=self._client_wrapper) + + async def get_all( + self, + *, + limit: typing.Optional[int] = None, + starting_after: typing.Optional[EntityGroupId] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> EntityGroupFindResponse: + """ + Get all entity groups. If using a JWT, will return all groups the entity is part of. If using an API key, will return all groups for the organization. + + Parameters + ---------- + limit : typing.Optional[int] + The maximum number of results to return. Defaults to 1. Max is 10. + + starting_after : typing.Optional[EntityGroupId] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EntityGroupFindResponse + + Examples + -------- + import asyncio + + from mercoa.client import AsyncMercoa + + client = AsyncMercoa( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.entity_group.get_all() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "entityGroups", + method="GET", + params={"limit": limit, "startingAfter": starting_after}, + request_options=request_options, + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EntityGroupFindResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def create( + self, *, request: EntityGroupRequest, request_options: typing.Optional[RequestOptions] = None + ) -> EntityGroupResponse: + """ + Create an entity group + + Parameters + ---------- + request : EntityGroupRequest + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EntityGroupResponse + + Examples + -------- + import asyncio + + from mercoa import EntityGroupRequest + from mercoa.client import AsyncMercoa + + client = AsyncMercoa( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.entity_group.create( + request=EntityGroupRequest( + entity_ids=[ + "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ], + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "entityGroup", method="POST", json=request, request_options=request_options, omit=OMIT + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EntityGroupResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def get( + self, entity_group_id: EntityGroupId, *, request_options: typing.Optional[RequestOptions] = None + ) -> EntityGroupResponse: + """ + Get an entity group + + Parameters + ---------- + entity_group_id : EntityGroupId + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EntityGroupResponse + + Examples + -------- + import asyncio + + from mercoa.client import AsyncMercoa + + client = AsyncMercoa( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.entity_group.get( + entity_group_id="entg_a3582b70-fd04-4888-9185-a640ae9048be", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}", method="GET", request_options=request_options + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EntityGroupResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def update( + self, + entity_group_id: EntityGroupId, + *, + request: EntityGroupRequest, + request_options: typing.Optional[RequestOptions] = None, + ) -> EntityGroupResponse: + """ + Update an entity group + + Parameters + ---------- + entity_group_id : EntityGroupId + + request : EntityGroupRequest + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EntityGroupResponse + + Examples + -------- + import asyncio + + from mercoa import EntityGroupRequest + from mercoa.client import AsyncMercoa + + client = AsyncMercoa( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.entity_group.update( + entity_group_id="entg_a3582b70-fd04-4888-9185-a640ae9048be", + request=EntityGroupRequest( + entity_ids=[ + "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ], + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(EntityGroupResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def delete( + self, entity_group_id: EntityGroupId, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Delete an entity group + + Parameters + ---------- + entity_group_id : EntityGroupId + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from mercoa.client import AsyncMercoa + + client = AsyncMercoa( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.entity_group.delete( + entity_group_id="string", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}", method="DELETE", request_options=request_options + ) + if 200 <= _response.status_code < 300: + return + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/entity_group/invoice/__init__.py b/src/mercoa/entity_group/invoice/__init__.py new file mode 100644 index 0000000..f3ea265 --- /dev/null +++ b/src/mercoa/entity_group/invoice/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/src/mercoa/entity_group/invoice/client.py b/src/mercoa/entity_group/invoice/client.py new file mode 100644 index 0000000..daefd52 --- /dev/null +++ b/src/mercoa/entity_group/invoice/client.py @@ -0,0 +1,633 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing +from json.decoder import JSONDecodeError + +from ...commons.errors.bad_request import BadRequest +from ...commons.errors.conflict import Conflict +from ...commons.errors.forbidden import Forbidden +from ...commons.errors.internal_server_error import InternalServerError +from ...commons.errors.not_found import NotFound +from ...commons.errors.unauthorized import Unauthorized +from ...commons.errors.unimplemented import Unimplemented +from ...commons.types.order_direction import OrderDirection +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.request_options import RequestOptions +from ...entity_group_types.types.entity_group_id import EntityGroupId +from ...entity_types.types.entity_id import EntityId +from ...entity_types.types.entity_user_id import EntityUserId +from ...invoice_types.types.approver_action import ApproverAction +from ...invoice_types.types.find_invoice_response import FindInvoiceResponse +from ...invoice_types.types.invoice_id import InvoiceId +from ...invoice_types.types.invoice_metadata_filter import InvoiceMetadataFilter +from ...invoice_types.types.invoice_metrics_per_date_group_by import InvoiceMetricsPerDateGroupBy +from ...invoice_types.types.invoice_metrics_response import InvoiceMetricsResponse +from ...invoice_types.types.invoice_order_by_field import InvoiceOrderByField +from ...invoice_types.types.invoice_status import InvoiceStatus +from ...payment_method_types.types.currency_code import CurrencyCode + + +class InvoiceClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def find( + self, + entity_group_id: EntityGroupId, + *, + exclude_payables: typing.Optional[bool] = None, + exclude_receivables: typing.Optional[bool] = None, + start_date: typing.Optional[dt.datetime] = None, + end_date: typing.Optional[dt.datetime] = None, + order_by: typing.Optional[InvoiceOrderByField] = None, + order_direction: typing.Optional[OrderDirection] = None, + limit: typing.Optional[int] = None, + starting_after: typing.Optional[InvoiceId] = None, + metadata: typing.Optional[typing.Union[InvoiceMetadataFilter, typing.Sequence[InvoiceMetadataFilter]]] = None, + search: typing.Optional[str] = None, + payer_id: typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] = None, + vendor_id: typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] = None, + approver_id: typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]] = None, + approver_action: typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]] = None, + invoice_id: typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] = None, + status: typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> FindInvoiceResponse: + """ + Get invoices for an entity group with the given filters. + + Parameters + ---------- + entity_group_id : EntityGroupId + + exclude_payables : typing.Optional[bool] + Return only invoices that are receivable by the entity. + + exclude_receivables : typing.Optional[bool] + Return only invoices that are payable by the entity. + + start_date : typing.Optional[dt.datetime] + Start date for invoice created on date filter. + + end_date : typing.Optional[dt.datetime] + End date for invoice created date filter. + + order_by : typing.Optional[InvoiceOrderByField] + Field to order invoices by. Defaults to CREATED_AT. + + order_direction : typing.Optional[OrderDirection] + Direction to order invoices by. Defaults to asc. + + limit : typing.Optional[int] + Number of invoices to return. Limit can range between 1 and 100, and the default is 10. + + starting_after : typing.Optional[InvoiceId] + The ID of the invoice to start after. If not provided, the first page of invoices will be returned. + + metadata : typing.Optional[typing.Union[InvoiceMetadataFilter, typing.Sequence[InvoiceMetadataFilter]]] + Filter invoices by metadata. Each filter will be applied as an AND condition. Duplicate keys will be ignored. + + search : typing.Optional[str] + Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + + payer_id : typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] + Filter invoices by payer ID. + + vendor_id : typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] + Filter invoices by vendor ID. + + approver_id : typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]] + Filter invoices by assigned approver user ID. + + approver_action : typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]] + Filter invoices by approver action. Needs to be used with approverId. For example, if you want to find all invoices that have been approved by a specific user, you would use approverId and approverAction=APPROVE. + + invoice_id : typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] + Filter invoices by invoice ID. + + status : typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] + Invoice status to filter on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FindInvoiceResponse + + Examples + -------- + from mercoa.client import Mercoa + + client = Mercoa( + token="YOUR_TOKEN", + ) + client.entity_group.invoice.find( + entity_group_id="entg_8545a84e-a45f-41bf-bdf1-33b42a55812c", + exclude_receivables=True, + order_by="CREATED_AT", + order_direction="ASC", + limit=10, + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}/invoices", + method="GET", + 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, + }, + request_options=request_options, + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FindInvoiceResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + def metrics( + self, + entity_group_id: EntityGroupId, + *, + search: typing.Optional[str] = None, + exclude_payables: typing.Optional[bool] = None, + exclude_receivables: typing.Optional[bool] = None, + return_by_date: typing.Optional[InvoiceMetricsPerDateGroupBy] = None, + payer_id: typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] = None, + vendor_id: typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] = None, + approver_id: typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]] = None, + invoice_id: typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] = None, + status: typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] = None, + due_date_start: typing.Optional[dt.datetime] = None, + due_date_end: typing.Optional[dt.datetime] = None, + created_date_start: typing.Optional[dt.datetime] = None, + created_date_end: typing.Optional[dt.datetime] = None, + currency: typing.Optional[typing.Union[CurrencyCode, typing.Sequence[CurrencyCode]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[InvoiceMetricsResponse]: + """ + Get invoice metrics for an entity group with the given filters. Invoices will be grouped by currency. If none of excludePayables, excludeReceivables, payerId, vendorId, or invoiceId status filters are provided, excludeReceivables will be set to true. + + Parameters + ---------- + entity_group_id : EntityGroupId + + search : typing.Optional[str] + Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + + exclude_payables : typing.Optional[bool] + Only return invoices that are not payable by the entity. This will return only invoices that are receivable by the entity. + + exclude_receivables : typing.Optional[bool] + Only return invoices that are not receivable by the entity. This will return only invoices that are payable by the entity. + + return_by_date : typing.Optional[InvoiceMetricsPerDateGroupBy] + Return invoice metrics grouped by date. + + payer_id : typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] + Filter invoices by payer ID. + + vendor_id : typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] + Filter invoices by vendor ID. + + approver_id : typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]] + Filter invoices by assigned approver user ID. + + invoice_id : typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] + Filter invoices by invoice ID. + + status : typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] + Invoice status to filter on + + due_date_start : typing.Optional[dt.datetime] + Start date for invoice dueDate filter. + + due_date_end : typing.Optional[dt.datetime] + End date for invoice dueDate filter. + + created_date_start : typing.Optional[dt.datetime] + Start date for invoice created on date filter. + + created_date_end : typing.Optional[dt.datetime] + End date for invoice created date filter. + + currency : typing.Optional[typing.Union[CurrencyCode, typing.Sequence[CurrencyCode]]] + Currency to filter on + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[InvoiceMetricsResponse] + + Examples + -------- + import datetime + + from mercoa.client import Mercoa + + client = Mercoa( + token="YOUR_TOKEN", + ) + client.entity_group.invoice.metrics( + entity_group_id="entg_8545a84e-a45f-41bf-bdf1-33b42a55812c", + return_by_date="CREATION_DATE", + exclude_receivables=True, + created_date_start=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + created_date_end=datetime.datetime.fromisoformat( + "2021-01-31 23:59:59.999000+00:00", + ), + currency="USD", + status="NEW", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}/invoice-metrics", + method="GET", + 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() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(typing.List[InvoiceMetricsResponse], _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + +class AsyncInvoiceClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def find( + self, + entity_group_id: EntityGroupId, + *, + exclude_payables: typing.Optional[bool] = None, + exclude_receivables: typing.Optional[bool] = None, + start_date: typing.Optional[dt.datetime] = None, + end_date: typing.Optional[dt.datetime] = None, + order_by: typing.Optional[InvoiceOrderByField] = None, + order_direction: typing.Optional[OrderDirection] = None, + limit: typing.Optional[int] = None, + starting_after: typing.Optional[InvoiceId] = None, + metadata: typing.Optional[typing.Union[InvoiceMetadataFilter, typing.Sequence[InvoiceMetadataFilter]]] = None, + search: typing.Optional[str] = None, + payer_id: typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] = None, + vendor_id: typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] = None, + approver_id: typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]] = None, + approver_action: typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]] = None, + invoice_id: typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] = None, + status: typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> FindInvoiceResponse: + """ + Get invoices for an entity group with the given filters. + + Parameters + ---------- + entity_group_id : EntityGroupId + + exclude_payables : typing.Optional[bool] + Return only invoices that are receivable by the entity. + + exclude_receivables : typing.Optional[bool] + Return only invoices that are payable by the entity. + + start_date : typing.Optional[dt.datetime] + Start date for invoice created on date filter. + + end_date : typing.Optional[dt.datetime] + End date for invoice created date filter. + + order_by : typing.Optional[InvoiceOrderByField] + Field to order invoices by. Defaults to CREATED_AT. + + order_direction : typing.Optional[OrderDirection] + Direction to order invoices by. Defaults to asc. + + limit : typing.Optional[int] + Number of invoices to return. Limit can range between 1 and 100, and the default is 10. + + starting_after : typing.Optional[InvoiceId] + The ID of the invoice to start after. If not provided, the first page of invoices will be returned. + + metadata : typing.Optional[typing.Union[InvoiceMetadataFilter, typing.Sequence[InvoiceMetadataFilter]]] + Filter invoices by metadata. Each filter will be applied as an AND condition. Duplicate keys will be ignored. + + search : typing.Optional[str] + Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + + payer_id : typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] + Filter invoices by payer ID. + + vendor_id : typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] + Filter invoices by vendor ID. + + approver_id : typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]] + Filter invoices by assigned approver user ID. + + approver_action : typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]] + Filter invoices by approver action. Needs to be used with approverId. For example, if you want to find all invoices that have been approved by a specific user, you would use approverId and approverAction=APPROVE. + + invoice_id : typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] + Filter invoices by invoice ID. + + status : typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] + Invoice status to filter on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FindInvoiceResponse + + Examples + -------- + import asyncio + + from mercoa.client import AsyncMercoa + + client = AsyncMercoa( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.entity_group.invoice.find( + entity_group_id="entg_8545a84e-a45f-41bf-bdf1-33b42a55812c", + exclude_receivables=True, + order_by="CREATED_AT", + order_direction="ASC", + limit=10, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}/invoices", + method="GET", + 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, + }, + request_options=request_options, + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FindInvoiceResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def metrics( + self, + entity_group_id: EntityGroupId, + *, + search: typing.Optional[str] = None, + exclude_payables: typing.Optional[bool] = None, + exclude_receivables: typing.Optional[bool] = None, + return_by_date: typing.Optional[InvoiceMetricsPerDateGroupBy] = None, + payer_id: typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] = None, + vendor_id: typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] = None, + approver_id: typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]] = None, + invoice_id: typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] = None, + status: typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] = None, + due_date_start: typing.Optional[dt.datetime] = None, + due_date_end: typing.Optional[dt.datetime] = None, + created_date_start: typing.Optional[dt.datetime] = None, + created_date_end: typing.Optional[dt.datetime] = None, + currency: typing.Optional[typing.Union[CurrencyCode, typing.Sequence[CurrencyCode]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[InvoiceMetricsResponse]: + """ + Get invoice metrics for an entity group with the given filters. Invoices will be grouped by currency. If none of excludePayables, excludeReceivables, payerId, vendorId, or invoiceId status filters are provided, excludeReceivables will be set to true. + + Parameters + ---------- + entity_group_id : EntityGroupId + + search : typing.Optional[str] + Find invoices by vendor name, invoice number, or amount. Partial matches are supported. + + exclude_payables : typing.Optional[bool] + Only return invoices that are not payable by the entity. This will return only invoices that are receivable by the entity. + + exclude_receivables : typing.Optional[bool] + Only return invoices that are not receivable by the entity. This will return only invoices that are payable by the entity. + + return_by_date : typing.Optional[InvoiceMetricsPerDateGroupBy] + Return invoice metrics grouped by date. + + payer_id : typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] + Filter invoices by payer ID. + + vendor_id : typing.Optional[typing.Union[EntityId, typing.Sequence[EntityId]]] + Filter invoices by vendor ID. + + approver_id : typing.Optional[typing.Union[EntityUserId, typing.Sequence[EntityUserId]]] + Filter invoices by assigned approver user ID. + + invoice_id : typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] + Filter invoices by invoice ID. + + status : typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] + Invoice status to filter on + + due_date_start : typing.Optional[dt.datetime] + Start date for invoice dueDate filter. + + due_date_end : typing.Optional[dt.datetime] + End date for invoice dueDate filter. + + created_date_start : typing.Optional[dt.datetime] + Start date for invoice created on date filter. + + created_date_end : typing.Optional[dt.datetime] + End date for invoice created date filter. + + currency : typing.Optional[typing.Union[CurrencyCode, typing.Sequence[CurrencyCode]]] + Currency to filter on + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[InvoiceMetricsResponse] + + Examples + -------- + import asyncio + import datetime + + from mercoa.client import AsyncMercoa + + client = AsyncMercoa( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.entity_group.invoice.metrics( + entity_group_id="entg_8545a84e-a45f-41bf-bdf1-33b42a55812c", + return_by_date="CREATION_DATE", + exclude_receivables=True, + created_date_start=datetime.datetime.fromisoformat( + "2021-01-01 00:00:00+00:00", + ), + created_date_end=datetime.datetime.fromisoformat( + "2021-01-31 23:59:59.999000+00:00", + ), + currency="USD", + status="NEW", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"entityGroup/{jsonable_encoder(entity_group_id)}/invoice-metrics", + method="GET", + 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() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(typing.List[InvoiceMetricsResponse], _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "BadRequest": + raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unauthorized": + raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Forbidden": + raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Conflict": + raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InternalServerError": + raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/entity_group_types/__init__.py b/src/mercoa/entity_group_types/__init__.py new file mode 100644 index 0000000..3beb23d --- /dev/null +++ b/src/mercoa/entity_group_types/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import EntityGroupFindResponse, EntityGroupId, EntityGroupRequest, EntityGroupResponse + +__all__ = ["EntityGroupFindResponse", "EntityGroupId", "EntityGroupRequest", "EntityGroupResponse"] diff --git a/src/mercoa/entity_group_types/types/__init__.py b/src/mercoa/entity_group_types/types/__init__.py new file mode 100644 index 0000000..bc2b82c --- /dev/null +++ b/src/mercoa/entity_group_types/types/__init__.py @@ -0,0 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + +from .entity_group_find_response import EntityGroupFindResponse +from .entity_group_id import EntityGroupId +from .entity_group_request import EntityGroupRequest +from .entity_group_response import EntityGroupResponse + +__all__ = ["EntityGroupFindResponse", "EntityGroupId", "EntityGroupRequest", "EntityGroupResponse"] diff --git a/src/mercoa/entity_group_types/types/entity_group_find_response.py b/src/mercoa/entity_group_types/types/entity_group_find_response.py new file mode 100644 index 0000000..cc8bd16 --- /dev/null +++ b/src/mercoa/entity_group_types/types/entity_group_find_response.py @@ -0,0 +1,132 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .entity_group_response import EntityGroupResponse + + +class EntityGroupFindResponse(pydantic_v1.BaseModel): + """ + Examples + -------- + import datetime + + from mercoa import ( + Address, + BusinessProfileResponse, + EntityGroupFindResponse, + EntityGroupResponse, + EntityResponse, + PhoneNumber, + ProfileResponse, + ) + + EntityGroupFindResponse( + count=3, + has_more=False, + data=[ + EntityGroupResponse( + id="entg_a3582b70-fd04-4888-9185-a640ae9048be", + entities=[ + EntityResponse( + id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + foreign_id="MY-DB-ID-12345", + name="Acme Inc.", + email="customer@acme.com", + accepted_tos=True, + status="verified", + is_customer=True, + is_payor=True, + is_payee=False, + is_network_payor=False, + is_network_payee=False, + account_type="business", + updated_at=datetime.datetime.fromisoformat( + "2024-01-02 00:00:00+00:00", + ), + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + profile=ProfileResponse( + business=BusinessProfileResponse( + email="customer@acme.com", + legal_business_name="Acme Inc.", + 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_provided=True, + owners_provided=True, + ), + ), + ), + EntityResponse( + id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + foreign_id="MY-DB-ID-90909", + name="Big Box Store", + email="vendor@bigboxstore.com", + accepted_tos=False, + status="unverified", + is_customer=False, + is_payor=False, + is_payee=True, + is_network_payor=False, + is_network_payee=False, + account_type="business", + updated_at=datetime.datetime.fromisoformat( + "2024-01-02 00:00:00+00:00", + ), + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + profile=ProfileResponse( + business=BusinessProfileResponse( + email="vendor@bigboxstore.com", + legal_business_name="Big Box Store", + business_type="publicCorporation", + tax_id_provided=False, + owners_provided=False, + ), + ), + ), + ], + ) + ], + ) + """ + + count: int + has_more: bool = pydantic_v1.Field(alias="hasMore") + data: typing.List[EntityGroupResponse] + + 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_group_types/types/entity_group_id.py b/src/mercoa/entity_group_types/types/entity_group_id.py new file mode 100644 index 0000000..27c7687 --- /dev/null +++ b/src/mercoa/entity_group_types/types/entity_group_id.py @@ -0,0 +1,3 @@ +# This file was auto-generated by Fern from our API Definition. + +EntityGroupId = str diff --git a/src/mercoa/entity_group_types/types/entity_group_request.py b/src/mercoa/entity_group_types/types/entity_group_request.py new file mode 100644 index 0000000..12b6910 --- /dev/null +++ b/src/mercoa/entity_group_types/types/entity_group_request.py @@ -0,0 +1,45 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...entity_types.types.entity_id import EntityId + + +class EntityGroupRequest(pydantic_v1.BaseModel): + """ + Examples + -------- + from mercoa import EntityGroupRequest + + EntityGroupRequest( + entity_ids=[ + "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + ], + ) + """ + + entity_ids: typing.List[EntityId] = pydantic_v1.Field(alias="entityIds") + + 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_group_types/types/entity_group_response.py b/src/mercoa/entity_group_types/types/entity_group_response.py new file mode 100644 index 0000000..6154374 --- /dev/null +++ b/src/mercoa/entity_group_types/types/entity_group_response.py @@ -0,0 +1,123 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...entity_types.types.entity_response import EntityResponse +from .entity_group_id import EntityGroupId + + +class EntityGroupResponse(pydantic_v1.BaseModel): + """ + Examples + -------- + import datetime + + from mercoa import ( + Address, + BusinessProfileResponse, + EntityGroupResponse, + EntityResponse, + PhoneNumber, + ProfileResponse, + ) + + EntityGroupResponse( + id="entg_a3582b70-fd04-4888-9185-a640ae9048be", + entities=[ + EntityResponse( + id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + foreign_id="MY-DB-ID-12345", + name="Acme Inc.", + email="customer@acme.com", + accepted_tos=True, + status="verified", + is_customer=True, + is_payor=True, + is_payee=False, + is_network_payor=False, + is_network_payee=False, + account_type="business", + updated_at=datetime.datetime.fromisoformat( + "2024-01-02 00:00:00+00:00", + ), + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + profile=ProfileResponse( + business=BusinessProfileResponse( + email="customer@acme.com", + legal_business_name="Acme Inc.", + 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_provided=True, + owners_provided=True, + ), + ), + ), + EntityResponse( + id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", + foreign_id="MY-DB-ID-90909", + name="Big Box Store", + email="vendor@bigboxstore.com", + accepted_tos=False, + status="unverified", + is_customer=False, + is_payor=False, + is_payee=True, + is_network_payor=False, + is_network_payee=False, + account_type="business", + updated_at=datetime.datetime.fromisoformat( + "2024-01-02 00:00:00+00:00", + ), + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + profile=ProfileResponse( + business=BusinessProfileResponse( + email="vendor@bigboxstore.com", + legal_business_name="Big Box Store", + business_type="publicCorporation", + tax_id_provided=False, + owners_provided=False, + ), + ), + ), + ], + ) + """ + + id: EntityGroupId + entities: typing.List[EntityResponse] + + 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/fees/client.py b/src/mercoa/fees/client.py index d6bb99e..2874271 100644 --- a/src/mercoa/fees/client.py +++ b/src/mercoa/fees/client.py @@ -15,9 +15,7 @@ from ..core.pydantic_utilities import pydantic_v1 from ..core.request_options import RequestOptions from ..invoice_types.types.invoice_fees_response import InvoiceFeesResponse -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 .types.calculate_fees_request import CalculateFeesRequest # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -28,34 +26,14 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def calculate( - 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 + self, *, request: CalculateFeesRequest, 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 ---------- - 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 : CalculateFeesRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -66,29 +44,22 @@ def calculate( Examples -------- + from mercoa import CalculateFeesRequest from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.fees.calculate( - amount=100.0, - payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - payment_destination_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", + request=CalculateFeesRequest( + 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", - json={ - "amount": amount, - "currency": currency, - "paymentSourceId": payment_source_id, - "paymentDestinationId": payment_destination_id, - "paymentDestinationOptions": payment_destination_options, - }, - request_options=request_options, - omit=OMIT, + "fees", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -119,34 +90,14 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def calculate( - 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 + self, *, request: CalculateFeesRequest, 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 ---------- - 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 : CalculateFeesRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -157,29 +108,30 @@ async def calculate( Examples -------- + import asyncio + + from mercoa import CalculateFeesRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.fees.calculate( - amount=100.0, - payment_source_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - payment_destination_id="pm_4794d597-70dc-4fec-b6ec-c5988e759769", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "fees", - method="POST", - json={ - "amount": amount, - "currency": currency, - "paymentSourceId": payment_source_id, - "paymentDestinationId": payment_destination_id, - "paymentDestinationOptions": payment_destination_options, - }, - request_options=request_options, - omit=OMIT, + "fees", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() diff --git a/src/mercoa/invoice/approval/client.py b/src/mercoa/invoice/approval/client.py index 1ebead8..13cf19f 100644 --- a/src/mercoa/invoice/approval/client.py +++ b/src/mercoa/invoice/approval/client.py @@ -15,8 +15,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 from ...core.request_options import RequestOptions -from ...entity_types.types.entity_user_id import EntityUserId -from ...invoice_types.types.approval_slot_id import ApprovalSlotId +from ...invoice_types.types.add_approver_request import AddApproverRequest +from ...invoice_types.types.approval_request import ApprovalRequest from ...invoice_types.types.invoice_id import InvoiceId # this is used as the default value for optional parameters @@ -31,8 +31,7 @@ def add_approver( self, invoice_id: InvoiceId, *, - user_id: EntityUserId, - approval_slot_id: typing.Optional[ApprovalSlotId] = OMIT, + request: AddApproverRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -42,10 +41,7 @@ def add_approver( ---------- invoice_id : InvoiceId - user_id : EntityUserId - - approval_slot_id : typing.Optional[ApprovalSlotId] - The identifier for the approval slot this user is assigned to. + request : AddApproverRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -56,6 +52,7 @@ def add_approver( Examples -------- + from mercoa import AddApproverRequest from mercoa.client import Mercoa client = Mercoa( @@ -63,14 +60,16 @@ def add_approver( ) client.invoice.approval.add_approver( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - approval_slot_id="inap_9bb311c9-7c15-4c9e-8148-63814e0abec6", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + request=AddApproverRequest( + 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", - json={"approvalSlotId": approval_slot_id, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -101,8 +100,7 @@ def approve( self, invoice_id: InvoiceId, *, - user_id: EntityUserId, - text: typing.Optional[str] = OMIT, + request: ApprovalRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -110,10 +108,7 @@ def approve( ---------- invoice_id : InvoiceId - user_id : EntityUserId - - text : typing.Optional[str] - Comment associated with this approval action. + request : ApprovalRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -124,6 +119,7 @@ def approve( Examples -------- + from mercoa import ApprovalRequest from mercoa.client import Mercoa client = Mercoa( @@ -131,14 +127,16 @@ def approve( ) client.invoice.approval.approve( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - text="This is a reason for my action", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + request=ApprovalRequest( + 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", - json={"text": text, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -169,8 +167,7 @@ def reject( self, invoice_id: InvoiceId, *, - user_id: EntityUserId, - text: typing.Optional[str] = OMIT, + request: ApprovalRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -178,10 +175,7 @@ def reject( ---------- invoice_id : InvoiceId - user_id : EntityUserId - - text : typing.Optional[str] - Comment associated with this approval action. + request : ApprovalRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -192,6 +186,7 @@ def reject( Examples -------- + from mercoa import ApprovalRequest from mercoa.client import Mercoa client = Mercoa( @@ -199,14 +194,16 @@ def reject( ) client.invoice.approval.reject( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - text="This is a reason for my action", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + request=ApprovalRequest( + 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", - json={"text": text, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -242,8 +239,7 @@ async def add_approver( self, invoice_id: InvoiceId, *, - user_id: EntityUserId, - approval_slot_id: typing.Optional[ApprovalSlotId] = OMIT, + request: AddApproverRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -253,10 +249,7 @@ async def add_approver( ---------- invoice_id : InvoiceId - user_id : EntityUserId - - approval_slot_id : typing.Optional[ApprovalSlotId] - The identifier for the approval slot this user is assigned to. + request : AddApproverRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -267,21 +260,32 @@ async def add_approver( Examples -------- + import asyncio + + from mercoa import AddApproverRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.approval.add_approver( - invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - approval_slot_id="inap_9bb311c9-7c15-4c9e-8148-63814e0abec6", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/add-approver", method="POST", - json={"approvalSlotId": approval_slot_id, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -312,8 +316,7 @@ async def approve( self, invoice_id: InvoiceId, *, - user_id: EntityUserId, - text: typing.Optional[str] = OMIT, + request: ApprovalRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -321,10 +324,7 @@ async def approve( ---------- invoice_id : InvoiceId - user_id : EntityUserId - - text : typing.Optional[str] - Comment associated with this approval action. + request : ApprovalRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -335,21 +335,32 @@ async def approve( Examples -------- + import asyncio + + from mercoa import ApprovalRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.approval.approve( - invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - text="This is a reason for my action", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/approve", method="POST", - json={"text": text, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -380,8 +391,7 @@ async def reject( self, invoice_id: InvoiceId, *, - user_id: EntityUserId, - text: typing.Optional[str] = OMIT, + request: ApprovalRequest, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -389,10 +399,7 @@ async def reject( ---------- invoice_id : InvoiceId - user_id : EntityUserId - - text : typing.Optional[str] - Comment associated with this approval action. + request : ApprovalRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -403,21 +410,32 @@ async def reject( Examples -------- + import asyncio + + from mercoa import ApprovalRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.approval.reject( - invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - text="This is a reason for my action", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/reject", method="POST", - json={"text": text, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) diff --git a/src/mercoa/invoice/client.py b/src/mercoa/invoice/client.py index 857d59b..d1c2984 100644 --- a/src/mercoa/invoice/client.py +++ b/src/mercoa/invoice/client.py @@ -20,19 +20,15 @@ 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_failure_type import InvoiceFailureType +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.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 ..invoice_types.types.invoice_update_request import InvoiceUpdateRequest from .approval.client import ApprovalClient, AsyncApprovalClient from .comment.client import AsyncCommentClient, CommentClient from .document.client import AsyncDocumentClient, DocumentClient @@ -68,7 +64,6 @@ def find( approver_action: typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]] = None, invoice_id: typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] = None, status: typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] = None, - include_fees: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> FindInvoiceResponse: """ @@ -121,9 +116,6 @@ def find( status : typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] Invoice status to filter on - include_fees : typing.Optional[bool] - DEPRECATED. Fees are now included by default in the response. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -161,7 +153,6 @@ def find( "approverAction": approver_action, "invoiceId": invoice_id, "status": status, - "includeFees": include_fees, }, request_options=request_options, ) @@ -189,105 +180,12 @@ def find( raise ApiError(status_code=_response.status_code, body=_response_json) def create( - 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, - failure_type: typing.Optional[InvoiceFailureType] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: InvoiceCreationRequest, request_options: typing.Optional[RequestOptions] = None ) -> InvoiceResponse: """ Parameters ---------- - 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 are scheduled to 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. - - failure_type : typing.Optional[InvoiceFailureType] - If the invoice failed to be paid, indicate the failure reason. Only applicable for invoices with custom payment methods. + request : InvoiceCreationRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -300,85 +198,61 @@ def create( -------- import datetime - from mercoa import InvoiceLineItemRequest, PaymentDestinationOptions_Check + from mercoa import ( + InvoiceCreationRequest, + InvoiceLineItemRequest, + PaymentDestinationOptions_Check, + ) from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.invoice.create( - status="NEW", - amount=100.0, - currency="USD", - invoice_date=datetime.datetime.fromisoformat( - "2021-01-01 00:00:00+00:00", + 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", ), - 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", - 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, - "failureType": failure_type, - }, - request_options=request_options, - omit=OMIT, + "invoice", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -403,21 +277,12 @@ def create( raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore raise ApiError(status_code=_response.status_code, body=_response_json) - def get( - self, - invoice_id: InvoiceId, - *, - include_fees: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> InvoiceResponse: + def get(self, invoice_id: InvoiceId, *, request_options: typing.Optional[RequestOptions] = None) -> InvoiceResponse: """ Parameters ---------- invoice_id : InvoiceId - include_fees : typing.Optional[bool] - DEPRECATED. Fees are now included by default in the response. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -437,10 +302,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"invoice/{jsonable_encoder(invoice_id)}", - method="GET", - params={"includeFees": include_fees}, - request_options=request_options, + f"invoice/{jsonable_encoder(invoice_id)}", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -469,31 +331,7 @@ def update( self, invoice_id: InvoiceId, *, - 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, - failure_type: typing.Optional[InvoiceFailureType] = OMIT, + request: InvoiceUpdateRequest, request_options: typing.Optional[RequestOptions] = None, ) -> InvoiceResponse: """ @@ -501,73 +339,7 @@ def update( ---------- invoice_id : InvoiceId - 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 are scheduled to 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. - - failure_type : typing.Optional[InvoiceFailureType] - If the invoice failed to be paid, indicate the failure reason. Only applicable for invoices with custom payment methods. + request : InvoiceUpdateRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -580,7 +352,11 @@ def update( -------- import datetime - from mercoa import InvoiceLineItemRequest, PaymentDestinationOptions_Check + from mercoa import ( + InvoiceLineItemRequest, + InvoiceUpdateRequest, + PaymentDestinationOptions_Check, + ) from mercoa.client import Mercoa client = Mercoa( @@ -588,76 +364,52 @@ def update( ) client.invoice.update( invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", - 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", + 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", ), - 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", - 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, - "failureType": failure_type, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -763,7 +515,6 @@ async def find( approver_action: typing.Optional[typing.Union[ApproverAction, typing.Sequence[ApproverAction]]] = None, invoice_id: typing.Optional[typing.Union[InvoiceId, typing.Sequence[InvoiceId]]] = None, status: typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] = None, - include_fees: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> FindInvoiceResponse: """ @@ -816,9 +567,6 @@ async def find( status : typing.Optional[typing.Union[InvoiceStatus, typing.Sequence[InvoiceStatus]]] Invoice status to filter on - include_fees : typing.Optional[bool] - DEPRECATED. Fees are now included by default in the response. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -828,14 +576,22 @@ async def find( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.find( - entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.invoice.find( + entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "invoices", @@ -856,7 +612,6 @@ async def find( "approverAction": approver_action, "invoiceId": invoice_id, "status": status, - "includeFees": include_fees, }, request_options=request_options, ) @@ -884,105 +639,12 @@ async def find( raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - 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, - failure_type: typing.Optional[InvoiceFailureType] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: InvoiceCreationRequest, request_options: typing.Optional[RequestOptions] = None ) -> InvoiceResponse: """ Parameters ---------- - 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 are scheduled to 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. - - failure_type : typing.Optional[InvoiceFailureType] - If the invoice failed to be paid, indicate the failure reason. Only applicable for invoices with custom payment methods. + request : InvoiceCreationRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -993,87 +655,70 @@ async def create( Examples -------- + import asyncio import datetime - from mercoa import InvoiceLineItemRequest, PaymentDestinationOptions_Check + from mercoa import ( + InvoiceCreationRequest, + InvoiceLineItemRequest, + PaymentDestinationOptions_Check, + ) from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.create( - 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( + + + async def main() -> None: + await client.invoice.create( + request=InvoiceCreationRequest( + status="NEW", amount=100.0, currency="USD", - description="Product A", - name="Product A", - quantity=1, - unit_price=100.0, - service_start_date=datetime.datetime.fromisoformat( + invoice_date=datetime.datetime.fromisoformat( "2021-01-01 00:00:00+00:00", ), - service_end_date=datetime.datetime.fromisoformat( + due_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", - ) + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "invoice", - method="POST", - 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, - "failureType": failure_type, - }, - request_options=request_options, - omit=OMIT, + "invoice", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -1099,20 +744,13 @@ async def create( raise ApiError(status_code=_response.status_code, body=_response_json) async def get( - self, - invoice_id: InvoiceId, - *, - include_fees: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None, + self, invoice_id: InvoiceId, *, request_options: typing.Optional[RequestOptions] = None ) -> InvoiceResponse: """ Parameters ---------- invoice_id : InvoiceId - include_fees : typing.Optional[bool] - DEPRECATED. Fees are now included by default in the response. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1122,20 +760,25 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.get( - invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.invoice.get( + invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"invoice/{jsonable_encoder(invoice_id)}", - method="GET", - params={"includeFees": include_fees}, - request_options=request_options, + f"invoice/{jsonable_encoder(invoice_id)}", method="GET", request_options=request_options ) try: _response_json = _response.json() @@ -1164,31 +807,7 @@ async def update( self, invoice_id: InvoiceId, *, - 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, - failure_type: typing.Optional[InvoiceFailureType] = OMIT, + request: InvoiceUpdateRequest, request_options: typing.Optional[RequestOptions] = None, ) -> InvoiceResponse: """ @@ -1196,73 +815,7 @@ async def update( ---------- invoice_id : InvoiceId - 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 are scheduled to 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. - - failure_type : typing.Optional[InvoiceFailureType] - If the invoice failed to be paid, indicate the failure reason. Only applicable for invoices with custom payment methods. + request : InvoiceUpdateRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1273,86 +826,73 @@ async def update( Examples -------- + import asyncio import datetime - from mercoa import InvoiceLineItemRequest, PaymentDestinationOptions_Check + from mercoa import ( + InvoiceLineItemRequest, + InvoiceUpdateRequest, + PaymentDestinationOptions_Check, + ) from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.update( - invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", - 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( + + + async def main() -> None: + await client.invoice.update( + invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", + request=InvoiceUpdateRequest( + status="NEW", amount=100.0, currency="USD", - description="Product A", - name="Product A", - quantity=1, - unit_price=100.0, - service_start_date=datetime.datetime.fromisoformat( + invoice_date=datetime.datetime.fromisoformat( "2021-01-01 00:00:00+00:00", ), - service_end_date=datetime.datetime.fromisoformat( + due_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", - ) + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}", method="POST", - 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, - "failureType": failure_type, - }, + json=request, request_options=request_options, omit=OMIT, ) @@ -1396,14 +936,22 @@ async def delete(self, invoice_id: InvoiceId, *, request_options: typing.Optiona Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.delete( - invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", - ) + + + async def main() -> None: + await client.invoice.delete( + invoice_id="inv_8545a84e-a45f-41bf-bdf1-33b42a55812c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}", method="DELETE", request_options=request_options diff --git a/src/mercoa/invoice/comment/client.py b/src/mercoa/invoice/comment/client.py index 34d845c..76ebfa2 100644 --- a/src/mercoa/invoice/comment/client.py +++ b/src/mercoa/invoice/comment/client.py @@ -15,8 +15,8 @@ from ...core.jsonable_encoder import jsonable_encoder from ...core.pydantic_utilities import pydantic_v1 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 @@ -83,12 +83,7 @@ def get_all( raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, - invoice_id: InvoiceId, - *, - text: str, - user_id: typing.Optional[EntityUserId] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + self, invoice_id: InvoiceId, *, request: CommentRequest, request_options: typing.Optional[RequestOptions] = None ) -> CommentResponse: """ Add a comment to this invoice @@ -97,9 +92,7 @@ def create( ---------- invoice_id : InvoiceId - text : str - - user_id : typing.Optional[EntityUserId] + request : CommentRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -110,6 +103,7 @@ def create( Examples -------- + from mercoa import CommentRequest from mercoa.client import Mercoa client = Mercoa( @@ -117,14 +111,16 @@ def create( ) client.invoice.comment.create( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - text="This is a comment", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + request=CommentRequest( + 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", - json={"text": text, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -213,8 +209,7 @@ def update( invoice_id: InvoiceId, comment_id: CommentId, *, - text: str, - user_id: typing.Optional[EntityUserId] = OMIT, + request: CommentRequest, request_options: typing.Optional[RequestOptions] = None, ) -> CommentResponse: """ @@ -226,9 +221,7 @@ def update( comment_id : CommentId - text : str - - user_id : typing.Optional[EntityUserId] + request : CommentRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -239,6 +232,7 @@ def update( Examples -------- + from mercoa import CommentRequest from mercoa.client import Mercoa client = Mercoa( @@ -247,14 +241,16 @@ def update( client.invoice.comment.update( invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - text="This is a comment", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", + request=CommentRequest( + 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", - json={"text": text, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -364,14 +360,22 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.comment.get_all( - invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - ) + + + async def main() -> None: + await client.invoice.comment.get_all( + invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/comments", method="GET", request_options=request_options @@ -400,12 +404,7 @@ async def get_all( raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, - invoice_id: InvoiceId, - *, - text: str, - user_id: typing.Optional[EntityUserId] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + self, invoice_id: InvoiceId, *, request: CommentRequest, request_options: typing.Optional[RequestOptions] = None ) -> CommentResponse: """ Add a comment to this invoice @@ -414,9 +413,7 @@ async def create( ---------- invoice_id : InvoiceId - text : str - - user_id : typing.Optional[EntityUserId] + request : CommentRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -427,21 +424,32 @@ async def create( Examples -------- + import asyncio + + from mercoa import CommentRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.comment.create( - invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - text="This is a comment", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/comment", method="POST", - json={"text": text, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -487,15 +495,23 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.comment.get( - invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - ) + + + async def main() -> None: + await client.invoice.comment.get( + invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", + comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", @@ -530,8 +546,7 @@ async def update( invoice_id: InvoiceId, comment_id: CommentId, *, - text: str, - user_id: typing.Optional[EntityUserId] = OMIT, + request: CommentRequest, request_options: typing.Optional[RequestOptions] = None, ) -> CommentResponse: """ @@ -543,9 +558,7 @@ async def update( comment_id : CommentId - text : str - - user_id : typing.Optional[EntityUserId] + request : CommentRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -556,22 +569,33 @@ async def update( Examples -------- + import asyncio + + from mercoa import CommentRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.comment.update( - invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - text="This is a comment", - user_id="user_e24fc81c-c5ee-47e8-af42-4fe29d895506", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", method="POST", - json={"text": text, "userId": user_id}, + json=request, request_options=request_options, omit=OMIT, ) @@ -619,15 +643,23 @@ async def delete( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.comment.delete( - invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", - ) + + + async def main() -> None: + await client.invoice.comment.delete( + invoice_id="inv_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", + comment_id="ic_3d61faa9-1754-4b7b-9fcb-88ff97f368ff", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/comment/{jsonable_encoder(comment_id)}", diff --git a/src/mercoa/invoice/document/client.py b/src/mercoa/invoice/document/client.py index d003853..62707ae 100644 --- a/src/mercoa/invoice/document/client.py +++ b/src/mercoa/invoice/document/client.py @@ -96,7 +96,7 @@ def upload( invoice_id : InvoiceId document : typing.Optional[str] - Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. + Base64 encoded image or PDF of invoice document. PNG, JPG, WEBP, and PDF are supported. 10MB max. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -394,14 +394,22 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.document.get_all( - invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", - ) + + + async def main() -> None: + await client.invoice.document.get_all( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/documents", method="GET", request_options=request_options @@ -444,7 +452,7 @@ async def upload( invoice_id : InvoiceId document : typing.Optional[str] - Base64 encoded image or PDF of invoice document. PNG, JPG, and PDF are supported. 10MB max. + Base64 encoded image or PDF of invoice document. PNG, JPG, WEBP, and PDF are supported. 10MB max. request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -455,15 +463,23 @@ async def upload( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.document.upload( - invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", - document="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", - ) + + + async def main() -> None: + await client.invoice.document.upload( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", + document="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/document", @@ -516,15 +532,23 @@ async def delete( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.document.delete( - invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", - document_id="doc_37e6af0a-e637-48fd-b825-d6947b38c4e2", - ) + + + async def main() -> None: + await client.invoice.document.delete( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", + document_id="doc_37e6af0a-e637-48fd-b825-d6947b38c4e2", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/document/{jsonable_encoder(document_id)}", @@ -574,14 +598,22 @@ async def generate_invoice_pdf( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.document.generate_invoice_pdf( - invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", - ) + + + async def main() -> None: + await client.invoice.document.generate_invoice_pdf( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/pdf/generate", method="GET", request_options=request_options @@ -629,14 +661,22 @@ async def generate_check_pdf( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.document.generate_check_pdf( - invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", - ) + + + async def main() -> None: + await client.invoice.document.generate_check_pdf( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/check/generate", method="GET", request_options=request_options @@ -683,14 +723,22 @@ async def get_source_email( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.document.get_source_email( - invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", - ) + + + async def main() -> None: + await client.invoice.document.get_source_email( + invoice_id="inv_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/source-email", method="GET", request_options=request_options diff --git a/src/mercoa/invoice/payment_links/client.py b/src/mercoa/invoice/payment_links/client.py index 0f86e2c..86b019b 100644 --- a/src/mercoa/invoice/payment_links/client.py +++ b/src/mercoa/invoice/payment_links/client.py @@ -269,14 +269,22 @@ async def get_payer_link( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.payment_links.get_payer_link( - invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.invoice.payment_links.get_payer_link( + invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/payerLink", method="GET", request_options=request_options @@ -330,15 +338,23 @@ async def send_payer_email( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.payment_links.send_payer_email( - invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - attach_invoice=True, - ) + + + async def main() -> None: + await client.invoice.payment_links.send_payer_email( + invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + attach_invoice=True, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/sendPayerEmail", @@ -388,14 +404,22 @@ async def get_vendor_link( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.payment_links.get_vendor_link( - invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.invoice.payment_links.get_vendor_link( + invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/vendorLink", method="GET", request_options=request_options @@ -442,14 +466,22 @@ async def send_vendor_email( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.invoice.payment_links.send_vendor_email( - invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", - ) + + + async def main() -> None: + await client.invoice.payment_links.send_vendor_email( + invoice_id="inv_a0f6ea94-0761-4a5e-a416-3c453cb7eced", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"invoice/{jsonable_encoder(invoice_id)}/sendVendorEmail", method="POST", request_options=request_options diff --git a/src/mercoa/invoice_types/types/invoice_request_base.py b/src/mercoa/invoice_types/types/invoice_request_base.py index 7c0651c..0d222c0 100644 --- a/src/mercoa/invoice_types/types/invoice_request_base.py +++ b/src/mercoa/invoice_types/types/invoice_request_base.py @@ -97,7 +97,7 @@ class InvoiceRequestBase(pydantic_v1.BaseModel): document: typing.Optional[str] = pydantic_v1.Field(default=None) """ - 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. + Base64 encoded image or PDF of invoice document. PNG, JPG, WEBP, 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] = pydantic_v1.Field(alias="uploadedImage", default=None) diff --git a/src/mercoa/ocr/client.py b/src/mercoa/ocr/client.py index a4f6d07..7714c1a 100644 --- a/src/mercoa/ocr/client.py +++ b/src/mercoa/ocr/client.py @@ -15,10 +15,9 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import pydantic_v1 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 @@ -29,31 +28,13 @@ class OcrClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - 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: + def ocr(self, *, request: OcrRequest, 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 ---------- - 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 : OcrRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -64,24 +45,23 @@ def ocr( Examples -------- + from mercoa import OcrRequest from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.ocr.ocr( - 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", + 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", + ), ) """ _response = self._client_wrapper.httpx_client.request( - "ocr", - method="POST", - json={"mimeType": mime_type, "image": image, "vendorNetwork": vendor_network, "entityId": entity_id}, - request_options=request_options, - omit=OMIT, + "ocr", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -107,30 +87,14 @@ def ocr( raise ApiError(status_code=_response.status_code, body=_response_json) def run_async_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, + self, *, request: OcrRequest, 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 ---------- - 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 : OcrRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -141,24 +105,23 @@ def run_async_ocr( Examples -------- + from mercoa import OcrRequest from mercoa.client import Mercoa client = Mercoa( token="YOUR_TOKEN", ) client.ocr.run_async_ocr( - 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", + 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", + ), ) """ _response = self._client_wrapper.httpx_client.request( - "ocr-async", - method="POST", - json={"mimeType": mime_type, "image": image, "vendorNetwork": vendor_network, "entityId": entity_id}, - request_options=request_options, - omit=OMIT, + "ocr-async", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -240,31 +203,13 @@ class AsyncOcrClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - 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: + async def ocr(self, *, request: OcrRequest, 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 ---------- - 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 : OcrRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -275,24 +220,31 @@ async def ocr( Examples -------- + import asyncio + + from mercoa import OcrRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.ocr.ocr( - 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", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "ocr", - method="POST", - json={"mimeType": mime_type, "image": image, "vendorNetwork": vendor_network, "entityId": entity_id}, - request_options=request_options, - omit=OMIT, + "ocr", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -318,30 +270,14 @@ async def ocr( raise ApiError(status_code=_response.status_code, body=_response_json) async def run_async_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, + self, *, request: OcrRequest, 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 ---------- - 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 : OcrRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -352,24 +288,31 @@ async def run_async_ocr( Examples -------- + import asyncio + + from mercoa import OcrRequest from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.ocr.run_async_ocr( - 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", - ) + + + async def main() -> None: + 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", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "ocr-async", - method="POST", - json={"mimeType": mime_type, "image": image, "vendorNetwork": vendor_network, "entityId": entity_id}, - request_options=request_options, - omit=OMIT, + "ocr-async", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -413,14 +356,22 @@ async def get_async_ocr( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.ocr.get_async_ocr( - job_id="ocr_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", - ) + + + async def main() -> None: + await client.ocr.get_async_ocr( + job_id="ocr_8f86116b-3b4d-4ded-99ef-3bc929d8c33c", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"ocr-async/{jsonable_encoder(job_id)}", method="GET", request_options=request_options diff --git a/src/mercoa/ocr/types/ocr_request.py b/src/mercoa/ocr/types/ocr_request.py index 358cd3e..e5f69b5 100644 --- a/src/mercoa/ocr/types/ocr_request.py +++ b/src/mercoa/ocr/types/ocr_request.py @@ -30,7 +30,7 @@ class OcrRequest(pydantic_v1.BaseModel): image: str = pydantic_v1.Field() """ - Base64 encoded image or PDF. PNG, JPG, and PDF are supported. 10MB max. + Base64 encoded image or PDF. PNG, JPG, WEBP, and PDF are supported. 10MB max. """ vendor_network: typing.Optional[VendorNetwork] = pydantic_v1.Field(alias="vendorNetwork", default=None) diff --git a/src/mercoa/organization/client.py b/src/mercoa/organization/client.py index 234635d..6851120 100644 --- a/src/mercoa/organization/client.py +++ b/src/mercoa/organization/client.py @@ -17,15 +17,8 @@ from ..core.pydantic_utilities import pydantic_v1 from ..core.request_options import RequestOptions from ..email_log_types.types.email_log_response import EmailLogResponse -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_request import OrganizationRequest 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 @@ -137,47 +130,14 @@ def get( raise ApiError(status_code=_response.status_code, body=_response_json) def update( - 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 + self, *, request: OrganizationRequest, request_options: typing.Optional[RequestOptions] = None ) -> OrganizationResponse: """ Update current organization Parameters ---------- - 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 : OrganizationRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -194,6 +154,7 @@ def update( ExternalAccountingSystemProviderRequest_None, MetadataSchema, OnboardingOptionsRequest, + OrganizationRequest, PaymentMethodsRequest, ) from mercoa.client import Mercoa @@ -202,37 +163,23 @@ def update( token="YOUR_TOKEN", ) client.organization.update( - 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()], + 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()], + ), ) """ _response = self._client_wrapper.httpx_client.request( - "organization", - method="POST", - 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, - }, - request_options=request_options, - omit=OMIT, + "organization", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -395,20 +342,28 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.organization.get( - payment_methods=True, - email_provider=True, - external_accounting_system_provider=True, - color_scheme=True, - payee_onboarding_options=True, - payor_onboarding_options=True, - metadata_schema=True, - ) + + + async def main() -> None: + await client.organization.get( + payment_methods=True, + email_provider=True, + external_accounting_system_provider=True, + color_scheme=True, + payee_onboarding_options=True, + payor_onboarding_options=True, + metadata_schema=True, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "organization", @@ -448,47 +403,14 @@ async def get( raise ApiError(status_code=_response.status_code, body=_response_json) async def update( - 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 + self, *, request: OrganizationRequest, request_options: typing.Optional[RequestOptions] = None ) -> OrganizationResponse: """ Update current organization Parameters ---------- - 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 : OrganizationRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -499,12 +421,15 @@ async def update( Examples -------- + import asyncio + from mercoa import ( ColorSchemeRequest, EmailProviderRequest, ExternalAccountingSystemProviderRequest_None, MetadataSchema, OnboardingOptionsRequest, + OrganizationRequest, PaymentMethodsRequest, ) from mercoa.client import AsyncMercoa @@ -512,38 +437,30 @@ async def update( client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.organization.update( - 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()], - ) + + + async def main() -> None: + 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()], + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "organization", - method="POST", - 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, - }, - request_options=request_options, - omit=OMIT, + "organization", method="POST", json=request, request_options=request_options, omit=OMIT ) try: _response_json = _response.json() @@ -601,6 +518,7 @@ async def email_log( Examples -------- + import asyncio import datetime from mercoa.client import AsyncMercoa @@ -608,16 +526,22 @@ async def email_log( client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.organization.email_log( - start_date=datetime.datetime.fromisoformat( - "2024-01-15 09:30:00+00:00", - ), - end_date=datetime.datetime.fromisoformat( - "2024-01-15 09:30:00+00:00", - ), - limit=1, - starting_after="string", - ) + + + async def main() -> None: + await client.organization.email_log( + start_date=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + end_date=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + limit=1, + starting_after="string", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "organization/emailLog", diff --git a/src/mercoa/organization/notification_configuration/client.py b/src/mercoa/organization/notification_configuration/client.py index c7efeef..2e53a82 100644 --- a/src/mercoa/organization/notification_configuration/client.py +++ b/src/mercoa/organization/notification_configuration/client.py @@ -279,12 +279,20 @@ async def get_all( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.organization.notification_configuration.get_all() + + + async def main() -> None: + await client.organization.notification_configuration.get_all() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "organization/notification-configurations", method="GET", request_options=request_options @@ -331,14 +339,22 @@ async def get( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.organization.notification_configuration.get( - notification_type="INVOICE_APPROVAL_NEEDED", - ) + + + async def main() -> None: + await client.organization.notification_configuration.get( + notification_type="INVOICE_APPROVAL_NEEDED", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"organization/notification-configuration/{jsonable_encoder(notification_type)}", @@ -393,18 +409,26 @@ async def update( Examples -------- + import asyncio + from mercoa import NotificationConfigurationRequest_Invoice from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.organization.notification_configuration.update( - notification_type="INVOICE_APPROVAL_NEEDED", - request=NotificationConfigurationRequest_Invoice( - url="string", - ), - ) + + + async def main() -> None: + await client.organization.notification_configuration.update( + notification_type="INVOICE_APPROVAL_NEEDED", + request=NotificationConfigurationRequest_Invoice( + url="string", + ), + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"organization/notification-configuration/{jsonable_encoder(notification_type)}", @@ -455,14 +479,22 @@ async def reset( Examples -------- + import asyncio + from mercoa.client import AsyncMercoa client = AsyncMercoa( token="YOUR_TOKEN", ) - await client.organization.notification_configuration.reset( - notification_type="INVOICE_APPROVAL_NEEDED", - ) + + + async def main() -> None: + await client.organization.notification_configuration.reset( + notification_type="INVOICE_APPROVAL_NEEDED", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"organization/notification-configuration/{jsonable_encoder(notification_type)}", diff --git a/src/mercoa/webhooks/types/counterparty_webhook.py b/src/mercoa/webhooks/types/counterparty_webhook.py index 43e6b87..99bb850 100644 --- a/src/mercoa/webhooks/types/counterparty_webhook.py +++ b/src/mercoa/webhooks/types/counterparty_webhook.py @@ -6,24 +6,44 @@ from ...core.datetime_utils import serialize_datetime 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_response import EntityUserResponse class CounterpartyWebhook(pydantic_v1.BaseModel): """ Examples -------- - from mercoa import CounterpartyWebhook + import datetime + + from mercoa import CounterpartyWebhook, EntityUserResponse CounterpartyWebhook( event_type="counterparty.added", payee_id="ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", payor_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", + user=EntityUserResponse( + id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + ), ) """ event_type: str = pydantic_v1.Field(alias="eventType") payee_id: EntityId = pydantic_v1.Field(alias="payeeId") payor_id: EntityId = pydantic_v1.Field(alias="payorId") + user: typing.Optional[EntityUserResponse] = pydantic_v1.Field(default=None) + """ + User who initiated the change. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/mercoa/webhooks/types/entity_webhook.py b/src/mercoa/webhooks/types/entity_webhook.py index 892f019..a8ddd7b 100644 --- a/src/mercoa/webhooks/types/entity_webhook.py +++ b/src/mercoa/webhooks/types/entity_webhook.py @@ -6,6 +6,7 @@ from ...core.datetime_utils import serialize_datetime from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_response import EntityResponse +from ...entity_types.types.entity_user_response import EntityUserResponse class EntityWebhook(pydantic_v1.BaseModel): @@ -18,6 +19,7 @@ class EntityWebhook(pydantic_v1.BaseModel): Address, BusinessProfileResponse, EntityResponse, + EntityUserResponse, EntityWebhook, PhoneNumber, ProfileResponse, @@ -66,11 +68,28 @@ class EntityWebhook(pydantic_v1.BaseModel): ), ), ), + user=EntityUserResponse( + id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + ), ) """ event_type: str = pydantic_v1.Field(alias="eventType") entity: EntityResponse + user: typing.Optional[EntityUserResponse] = pydantic_v1.Field(default=None) + """ + User who initiated the change. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/mercoa/webhooks/types/invoice_status_changed_webhook.py b/src/mercoa/webhooks/types/invoice_status_changed_webhook.py index f7e050d..1aeab06 100644 --- a/src/mercoa/webhooks/types/invoice_status_changed_webhook.py +++ b/src/mercoa/webhooks/types/invoice_status_changed_webhook.py @@ -18,6 +18,7 @@ class InvoiceStatusChangedWebhook(InvoiceWebhook): Address, BusinessProfileResponse, CounterpartyResponse, + EntityUserResponse, InvoiceResponse, InvoiceStatusChangedWebhook, PaymentMethodResponse_BankAccount, @@ -186,6 +187,19 @@ class InvoiceStatusChangedWebhook(InvoiceWebhook): ), new_status="new", previous_status="draft", + user=EntityUserResponse( + id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + ), ) """ diff --git a/src/mercoa/webhooks/types/invoice_webhook.py b/src/mercoa/webhooks/types/invoice_webhook.py index 5f63bf7..1d3b08b 100644 --- a/src/mercoa/webhooks/types/invoice_webhook.py +++ b/src/mercoa/webhooks/types/invoice_webhook.py @@ -5,6 +5,7 @@ from ...core.datetime_utils import serialize_datetime from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...entity_types.types.entity_user_response import EntityUserResponse from ...invoice_types.types.invoice_response import InvoiceResponse @@ -338,11 +339,28 @@ class InvoiceWebhook(pydantic_v1.BaseModel): "2021-01-01 00:00:00+00:00", ), ), + user=EntityUserResponse( + id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + ), ) """ event_type: str = pydantic_v1.Field(alias="eventType") invoice: InvoiceResponse + user: typing.Optional[EntityUserResponse] = pydantic_v1.Field(default=None) + """ + User who initiated the change. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/mercoa/webhooks/types/payment_method_webhook.py b/src/mercoa/webhooks/types/payment_method_webhook.py index e83ffe5..6b6c4dc 100644 --- a/src/mercoa/webhooks/types/payment_method_webhook.py +++ b/src/mercoa/webhooks/types/payment_method_webhook.py @@ -7,6 +7,7 @@ from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...entity_types.types.entity_id import EntityId from ...entity_types.types.entity_response import EntityResponse +from ...entity_types.types.entity_user_response import EntityUserResponse from ...payment_method_types.types.payment_method_response import PaymentMethodResponse @@ -20,6 +21,7 @@ class PaymentMethodWebhook(pydantic_v1.BaseModel): Address, BusinessProfileResponse, EntityResponse, + EntityUserResponse, PaymentMethodResponse_BankAccount, PaymentMethodWebhook, PhoneNumber, @@ -88,6 +90,19 @@ class PaymentMethodWebhook(pydantic_v1.BaseModel): ), ), ), + user=EntityUserResponse( + id="user_ec3aafc8-ea86-408a-a6c1-545497badbbb", + foreign_id="MY-DB-ID-12345", + email="john.doe@acme.com", + name="John Doe", + roles=["admin", "approver"], + created_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2024-01-01 00:00:00+00:00", + ), + ), ) """ @@ -95,6 +110,10 @@ class PaymentMethodWebhook(pydantic_v1.BaseModel): entity_id: EntityId = pydantic_v1.Field(alias="entityId") payment_method: PaymentMethodResponse = pydantic_v1.Field(alias="paymentMethod") entity: EntityResponse + user: typing.Optional[EntityUserResponse] = pydantic_v1.Field(default=None) + """ + User who initiated the change. + """ def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/tests/utils/test_http_client.py b/tests/utils/test_http_client.py new file mode 100644 index 0000000..0995082 --- /dev/null +++ b/tests/utils/test_http_client.py @@ -0,0 +1,47 @@ +# This file was auto-generated by Fern from our API Definition. + +from mercoa.core.http_client import get_request_body +from mercoa.core.request_options import RequestOptions + + +def get_request_options() -> RequestOptions: + return {"additional_body_parameters": {"see you": "later"}} + + +def test_get_json_request_body() -> None: + json_body, data_body = get_request_body(json={"hello": "world"}, data=None, request_options=None, omit=None) + assert json_body == {"hello": "world"} + assert data_body is None + + json_body_extras, data_body_extras = get_request_body( + json={"goodbye": "world"}, data=None, request_options=get_request_options(), omit=None + ) + + assert json_body_extras == {"goodbye": "world", "see you": "later"} + assert data_body_extras is None + + +def test_get_files_request_body() -> None: + json_body, data_body = get_request_body(json=None, data={"hello": "world"}, request_options=None, omit=None) + assert data_body == {"hello": "world"} + assert json_body is None + + json_body_extras, data_body_extras = get_request_body( + json=None, data={"goodbye": "world"}, request_options=get_request_options(), omit=None + ) + + assert data_body_extras == {"goodbye": "world", "see you": "later"} + assert json_body_extras is None + + +def test_get_none_request_body() -> None: + json_body, data_body = get_request_body(json=None, data=None, request_options=None, omit=None) + assert data_body is None + assert json_body is None + + json_body_extras, data_body_extras = get_request_body( + json=None, data=None, request_options=get_request_options(), omit=None + ) + + assert json_body_extras == {"see you": "later"} + assert data_body_extras is None diff --git a/tests/utils/test_query_encoding.py b/tests/utils/test_query_encoding.py new file mode 100644 index 0000000..b320832 --- /dev/null +++ b/tests/utils/test_query_encoding.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from mercoa.core.query_encoder import encode_query + + +def test_query_encoding() -> None: + assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} + assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { + "hello_world[hello][world]": "today", + "hello_world[test]": "this", + "hi": "there", + }