# -*- coding: utf-8 -*-
from setuptools import setup

package_dir = \
{'': 'src'}

packages = \
['modern_treasury',
 'modern_treasury._utils',
 'modern_treasury.resources',
 'modern_treasury.resources.internal_accounts',
 'modern_treasury.resources.ledger_transactions',
 'modern_treasury.resources.payment_orders',
 'modern_treasury.types',
 'modern_treasury.types.internal_accounts',
 'modern_treasury.types.ledger_transactions',
 'modern_treasury.types.payment_orders',
 'modern_treasury.types.shared',
 'modern_treasury.types.shared_params']

package_data = \
{'': ['*']}

install_requires = \
['anyio>=3.5.0',
 'distro>=1.7.0',
 'httpx>=0.23.0',
 'pydantic>=1.9.0',
 'typing-extensions>=4.1.1']

setup_kwargs = {
    'name': 'modern-treasury',
    'version': '1.6.0',
    'description': 'Client library for the Modern Treasury API',
    'long_description': '# Modern Treasury Python API Library\n\n> **Migration Guide**\n>\n> We\'ve made some major improvements to how you pass arguments to methods which will require migrating your existing code.\n>\n> If you want to migrate to the new patterns incrementally you can do so by installing `v0.5.0`. This release contains both\n> the new and old patterns with a backwards compatibility layer.\n>\n> You can find a guide to migrating in [this document](#migration-guide).\n\n[![PyPI version](https://img.shields.io/pypi/v/modern-treasury.svg)](https://pypi.org/project/modern-treasury/)\n\nThe Modern Treasury Python library provides convenient access to the Modern Treasury REST API from any Python 3.7+\napplication. It includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\nhttps://user-images.githubusercontent.com/704302/216504942-09ed8dd7-7f44-40a6-a580-3764e91f11b4.mov\n\n## Documentation\n\nThe API documentation can be found [here](https://docs.moderntreasury.com).\n\n## Installation\n\n```sh\npip install modern-treasury\n```\n\n## Usage\n\n```python\nfrom modern_treasury import ModernTreasury\n\nmodern_treasury = ModernTreasury(\n    # defaults to os.environ.get("MODERN_TREASURY_API_KEY")\n    api_key="my api key",\n    organization_id="my-organization-ID",\n)\n\nexternal_account = modern_treasury.external_accounts.create(\n    counterparty_id="123",\n    name="my bank",\n)\nprint(external_account.id)\n```\n\nWhile you can provide an `api_key` keyword argument, we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nand adding `MODERN_TREASURY_API_KEY="my api key"` to your `.env` file so that your API Key is not stored in source control.\n\n## Async Usage\n\nSimply import `AsyncModernTreasury` instead of `ModernTreasury` and use `await` with each API call:\n\n```python\nfrom modern_treasury import AsyncModernTreasury\n\nmodern_treasury = AsyncModernTreasury(\n    # defaults to os.environ.get("MODERN_TREASURY_API_KEY")\n    api_key="my api key",\n    organization_id="my-organization-ID",\n)\n\n\nasync def main():\n    external_account = await modern_treasury.external_accounts.create(\n        counterparty_id="123",\n        name="my bank",\n    )\n    print(external_account.id)\n\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n## Using Types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict), while responses are [Pydantic](https://pydantic-docs.helpmanual.io/) models. This helps provide autocomplete and documentation within your editor.\n\nIf you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `"basic"`.\n\n## Pagination\n\nList methods in the Modern Treasury API are paginated.\n\nThis library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:\n\n```python\nimport modern_treasury\n\nmodern_treasury = ModernTreasury(\n    organization_id="my-organization-ID",\n)\n\nall_external_accounts = []\n# Automatically fetches more pages as needed.\nfor external_account in modern_treasury.external_accounts.list():\n    # Do something with external_account here\n    all_external_accounts.append(external_account)\nprint(all_external_accounts)\n```\n\nOr, asynchronously:\n\n```python\nimport asyncio\nimport modern_treasury\n\nmodern_treasury = AsyncModernTreasury(\n    organization_id="my-organization-ID",\n)\n\n\nasync def main() -> None:\n    all_external_accounts = []\n    # Iterate through items across all pages, issuing requests as needed.\n    async for external_account in modern_treasury.external_accounts.list():\n        all_external_accounts.append(external_account)\n    print(all_external_accounts)\n\n\nasyncio.run(main())\n```\n\nAlternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:\n\n```python\nfirst_page = await modern_treasury.external_accounts.list()\nif first_page.has_next_page():\n    print(f"will fetch next page using these details: {first_page.next_page_info()}")\n    next_page = await first_page.get_next_page()\n    print(f"number of items we just fetched: {len(next_page.items)}")\n\n# Remove `await` for non-async usage.\n```\n\nOr just work directly with the returned data:\n\n```python\nfirst_page = await modern_treasury.external_accounts.list()\n\nprint(f"next page cursor: {first_page.after_cursor}")  # => "next page cursor: ..."\nfor external_account in first_page.items:\n    print(external_account.id)\n\n# Remove `await` for non-async usage.\n```\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```py\nfrom modern_treasury import ModernTreasury\n\nmodern_treasury = ModernTreasury(\n    organization_id="my-organization-ID",\n)\n\nmodern_treasury.external_accounts.create(\n    foo={\n        "bar": True\n    },\n)\n```\n\n## File Uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes` or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom modern_treasury import ModernTreasury\n\nmodern_treasury = ModernTreasury(\n    organization_id="my-organization-ID",\n)\n\ncontents = Path("my/file.txt").read_bytes()\nmodern_treasury.documents.create(\n    "counterparties",\n    "24c6b7a3-02...",\n    file=contents,\n)\n```\n\nThe async client uses the exact same interface. This example uses `aiofiles` to asynchronously read the file contents but you can use whatever method you would like.\n\n```python\nimport aiofiles\nfrom modern_treasury import ModernTreasury\n\nmodern_treasury = ModernTreasury(\n    organization_id="my-organization-ID",\n)\n\nasync with aiofiles.open("pytest.ini", mode="rb") as f:\n    contents = await f.read()\n\nawait modern_treasury.documents.create(\n    "counterparties",\n    "24c6b7a3-02...",\n    file=contents,\n)\n```\n\n## Handling errors\n\nWhen the library is unable to connect to the API (e.g., due to network connection problems or a timeout), a subclass of `modern_treasury.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (i.e., 4xx or 5xx\nresponse), a subclass of `modern_treasury.APIStatusError` will be raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `modern_treasury.APIError`.\n\n```python\nfrom modern_treasury import ModernTreasury\n\nmodern_treasury = ModernTreasury(\n    organization_id="my-organization-ID",\n)\n\ntry:\n    modern_treasury.external_accounts.create(\n        counterparty_id="missing",\n    )\nexcept modern_treasury.APIConnectionError as e:\n    print("The server could not be reached")\n    print(e.__cause__)  # an underlying Exception, likely raised within httpx.\nexcept modern_treasury.RateLimitError as e:\n    print("A 429 status code was received; we should back off a bit.")\nexcept modern_treasury.APIStatusError as e:\n    print("Another non-200-range status code was received")\n    print(e.status_code)\n    print(e.response)\n```\n\nError codes are as followed:\n\n| Status Code | Error Type                 |\n| ----------- | -------------------------- |\n| 400         | `BadRequestError`          |\n| 401         | `AuthenticationError`      |\n| 403         | `PermissionDeniedError`    |\n| 404         | `NotFoundError`            |\n| 422         | `UnprocessableEntityError` |\n| 429         | `RateLimitError`           |\n| >=500       | `InternalServerError`      |\n| N/A         | `APIConnectionError`       |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```python\nfrom modern_treasury import ModernTreasury\n\n# Configure the default for all requests:\nmodern_treasury = ModernTreasury(\n    # default is 2\n    max_retries=0,\n    organization_id="my-organization-ID",\n)\n\n# Or, configure per-request:\nmodern_treasury.with_options(max_retries=5).external_accounts.list()\n```\n\n### Timeouts\n\nRequests time out after 60 seconds by default. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration):\n\n```python\nfrom modern_treasury import ModernTreasury\n\n# Configure the default for all requests:\nmodern_treasury = ModernTreasury(\n    # default is 60s\n    timeout=20.0,\n    organization_id="my-organization-ID",\n)\n\n# More granular control:\nmodern_treasury = ModernTreasury(\n    timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n    organization_id="my-organization-ID",\n)\n\n# Override per-request:\nmodern_treasury.with_options(timeout=5 * 1000).external_accounts.list(\n    party_name="my bank",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n## Advanced: Configuring custom URLs, proxies, and transports\n\nYou can configure the following keyword arguments when instantiating the client:\n\n```python\nimport httpx\nfrom modern_treasury import ModernTreasury\n\nmodern_treasury = ModernTreasury(\n    # Use a custom base URL\n    base_url="http://my.test.server.example.com:8083",\n    proxies="http://my.test.proxy.example.com",\n    transport=httpx.HTTPTransport(local_address="0.0.0.0"),\n    organization_id="my-organization-ID",\n)\n```\n\nSee the httpx documentation for information about the [`proxies`](https://www.python-httpx.org/advanced/#http-proxying) and [`transport`](https://www.python-httpx.org/advanced/#custom-transports) keyword arguments.\n\n# Migration guide\n\nThis section outlines the features that were deprecated in `v0.5.0`, and subsequently removed in `v0.6.0` and how to migrate your code.\n\n## Breaking changes\n\n### TypedDict → keyword arguments\n\nThe way you pass arguments to methods has been changed from a single `TypedDict` to individual arguments. For example, this snippet:\n\n```python\naccount = await client.external_accounts.create(\n    {\n        "name": "my bank",\n        "counterparty_id": "123",\n    }\n)\n```\n\nNow becomes:\n\n```python\naccount = await client.external_accounts.create(\n    name="my bank",\n    counterparty_id="123",\n)\n```\n\n#### Migrating\n\nThe easiest way to make your code compatible with this change is to add `**{`, for example:\n\n```diff\n- account = await client.external_accounts.create({\n-   "name": "my bank",\n-   "counterparty_id": "123",\n- })\n+ account = await client.external_accounts.create(**{\n+   "name": "my bank",\n+   "counterparty_id": "123",\n+ })\n```\n\nHowever, it is highly recommended to completely switch to explicit keyword arguments:\n\n```diff\n- account = await client.external_accounts.create({\n-   "name": "my bank",\n-   "counterparty_id": "123",\n- })\n+ account = await client.external_accounts.create(\n+   name=\'my bank\',\n+   counterparty_id=\'123\',\n+ )\n```\n\n### Named path arguments\n\nAll but the last path parameter must now be passed as named arguments instead of positional arguments, for example, for a method that calls the endpoint `/api/{itemizable_type}/{itemizable_id}/line_items/{id}` you would\'ve been able to call the method like this:\n\n```python\nline_item = await client.line_items.retrieve(\n    "itemizable_type",\n    "itemizable_id",\n    "my_line_id",\n)\n```\n\nBut now you must call the method like this:\n\n```python\nline_item = await client.line_items.retrieve(\n    "my_line_id",\n    itemizable_id="itemizable_id",\n    itemizable_type="itemizable_type",\n)\n```\n\nIf you have type checking enabled in your IDE it will tell you which parts of your code need to be updated.\n\n### Request options\n\nYou used to be able to set request options on a per-method basis, now you can only set them on the client. There are two methods that you can use to make this easy, `with_options` and `copy`.\n\nIf you need to make multiple requests with changed options, you can use `.copy()` to get a new client object with those options. This can be useful if you need to set a custom header for multiple requests, for example:\n\n```python\ncopied = client.copy(default_headers={"X-My-Header": "Foo"})\naccount = await copied.external_accounts.create(\n    name="my bank",\n    counterparty_id="123",\n)\nawait copied.cards.provision(card.token, digital_wallet="GOOGLE_PAY")\n```\n\nIf you just need to override one of the client options for one request, you can use `.with_options()`, for example:\n\n```python\nawait client.with_options(timeout=None).external_accounts.create(\n    name="my bank",\n    counterparty_id="123",\n)\n```\n\nIt should be noted that the `.with_options()` method is simply an alias to `.copy()`, you can use them interchangeably.\n\nYou can pass nearly every argument that is supported by the Client `__init__` method to the `.copy()` method, except for `proxies` and `transport`.\n\n```python\ncopied = client.copy(\n    api_key="...",\n    timeout=httpx.Timeout(read=10),\n    max_retries=5,\n    default_headers={\n        "X-My-Header": "value",\n    },\n    default_query={\n        "my_default_param": "value",\n    },\n)\n```\n\n## New features\n\n### Pass custom headers\n\nIf you need to add additional headers to a request you can easily do so with the `extra_headers` argument:\n\n```python\naccount = await client.external_accounts.create(\n    name="my bank",\n    counterparty_id="123",\n    extra_headers={\n        "X-Foo": "my header",\n    },\n)\n```\n\n### Pass custom JSON properties\n\nYou can add additional properties to the JSON request body that are not included directly in the method definition through the `extra_body` argument. This can be useful when there are in new properties in the API that are in beta and aren\'t in the SDK yet.\n\n```python\naccount = await client.external_accounts.create(\n    name="my bank",\n    counterparty_id="123",\n    extra_body={\n        "special_prop": "foo",\n    },\n)\n# sends this to the API:\n# {"name": "my bank", "counterparty_id": "123", "special_prop": "foo"}\n```\n\n### Pass custom query parameters\n\nYou can add additional query parameters that aren\'t specified in the method definition through the `extra_query` argument. This can be useful when there are any new/beta query parameters that are not yet in the SDK.\n\n```python\naccount = await client.external_accounts.create(\n    name="my bank",\n    counterparty_id="123",\n    extra_query={\n        "special_param": "bar",\n    },\n)\n# makes the request to this URL:\n# https://app.moderntreasury.com/api/external_accounts?special_param=bar\n```\n\n## Array items type name improvements\n\nIn `v1.5.0` we improved the names for types that come from arrays so that they always us a singular name, e.g. `LedgerEntries` -> `LedgerEntry`.\n\nWe\'ve added aliases for the old type names so you can continue to use them without any breaking changes but they will be removed in the future.\n\nFull list of all changed type names:\n\n- `Accounts` -> `Account`\n- `Balances` -> `Balance`\n- `Documents` -> `Document`\n- `LineItems` -> `LineItem`\n- `LedgerEntries` -> `LedgerEntry`\n- `AccountDetail` -> `AccountDetail`\n- `RoutingDetail` -> `RoutingDetail`\n- `AccountDetails` -> `AccountDetail`\n- `ContactDetails` -> `ContactDetail`\n- `RoutingDetails` -> `RoutingDetail`\n- `ReferenceNumbers` -> `ReferenceNumber`\n- `AccountsPartyAddress` -> `AccountPartyAddress`\n- `AccountsAccountDetails` -> `AccountAccountDetail`\n- `AccountsContactDetails` -> `AccountContactDetail`\n- `AccountsRoutingDetails` -> `AccountRoutingDetail`\n- `RoutingDetailBankAddress` -> `RoutingDetailBankAddress`\n- `LedgerTransactionLedgerEntries` -> `LedgerTransactionLedgerEntry`\n- `ReceivingAccountAccountDetails` -> `ReceivingAccountAccountDetail`\n- `ReceivingAccountContactDetails` -> `ReceivingAccountContactDetail`\n- `ReceivingAccountRoutingDetails` -> `ReceivingAccountRoutingDetail`\n- `LedgerEntriesResultingLedgerAccountBalances` -> `LedgerEntryResultingLedgerAccountBalances`\n- `LedgerEntriesResultingLedgerAccountBalancesPostedBalance` -> `LedgerEntryResultingLedgerAccountBalancesPostedBalance`\n- `LedgerEntriesResultingLedgerAccountBalancesPendingBalance` -> `LedgerEntryResultingLedgerAccountBalancesPendingBalance`\n- `LedgerEntriesResultingLedgerAccountBalancesAvailableBalance` -> `LedgerEntryResultingLedgerAccountBalancesAvailableBalance`\n\n## Status\n\nThis package is in beta. Its internals and interfaces are not stable and subject to change without a major semver bump;\nplease reach out if you rely on any undocumented behavior.\n\nWe are keen for your feedback; please email us at [sdk-feedback@moderntreasury.com](mailto:sdk-feedback@moderntreasury.com) or open an issue with questions,\nbugs, or suggestions.\n\n## Requirements\n\nPython 3.7 or higher.',
    'author': 'Modern Treasury',
    'author_email': 'sdk-feedback@moderntreasury.com',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://github.com/Modern-Treasury/modern-treasury-python',
    'package_dir': package_dir,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
