aioridwell


Nameaioridwell JSON
Version 2024.1.0 PyPI version JSON
download
home_pagehttps://github.com/bachya/aioridwell
SummaryA Python3, asyncio-based API for interacting with Ridwell waste recycling
upload_time2024-01-15 21:27:51
maintainer
docs_urlNone
authorAaron Bach
requires_python>=3.10,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ♻️ aioridwell: A Python3, asyncio-based API for interacting with Ridwell

[![CI][ci-badge]][ci]
[![PyPI][pypi-badge]][pypi]
[![Version][version-badge]][version]
[![License][license-badge]][license]
[![Code Coverage][codecov-badge]][codecov]
[![Maintainability][maintainability-badge]][maintainability]

<a href="https://www.buymeacoffee.com/bachya1208P" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

`aioridwell` is a Python 3, asyncio-friendly library for interacting with
[Ridwell][ridwell] to view information on upcoming recycling pickups.

- [Installation](#installation)
- [Python Versions](#python-versions)
- [Usage](#usage)
- [Contributing](#contributing)

# Installation

```bash
pip install aioridwell
```

# Python Versions

`aioridwell` is currently supported on:

- Python 3.10
- Python 3.11
- Python 3.12

# Usage

## Creating and Using a Client

The `Client` is the primary method of interacting with the API:

```python
import asyncio

from aioridwell import async_get_client


async def main() -> None:
    client = await async_get_client("<EMAIL>", "<PASSWORD>")
    # ...


asyncio.run(main())
```

By default, the library creates a new connection to the API with each coroutine. If
you are calling a large number of coroutines (or merely want to squeeze out every second
of runtime savings possible), an [`aiohttp`][aiohttp] `ClientSession` can be used for
connection pooling:

```python
import asyncio

from aiohttp import ClientSession

from aiowatttime import Client


async def main() -> None:
    async with ClientSession() as session:
        client = await async_get_client("<EMAIL>", "<PASSWORD>", session=session)
        # ...


asyncio.run(main())
```

## Getting the User's Dashboard URL

```python
import asyncio

from aioridwell import async_get_client


async def main() -> None:
    client = await async_get_client("<EMAIL>", "<PASSWORD>")
    client.get_dashboard_url()
    # >>> https://www.ridwell.com/users/userId1/dashboard


asyncio.run(main())
```

## Getting Accounts

Getting all accounts associated with this email address is easy:

```python
import asyncio

from aioridwell import async_get_client


async def main() -> None:
    client = await async_get_client("<EMAIL>", "<PASSWORD>")

    accounts = await client.async_get_accounts()
    # >>> {"account_id_1": RidwellAccount(...), ...}


asyncio.run(main())
```

The `RidwellAccount` object comes with some useful properties:

- `account_id`: the Ridwell ID for the account
- `address`: the address being serviced
- `email`: the email address on the account
- `full_name`: the full name of the account owner
- `phone`: the phone number of the account owner
- `subscription_id`: the Ridwell ID for the primary subscription
- `subscription_active`: whether the primary subscription is active

## Getting Pickup Events

Getting pickup events associated with an account is easy, too:

```python
import asyncio

from aioridwell import async_get_client


async def main() -> None:
    client = await async_get_client("<EMAIL>", "<PASSWORD>")

    accounts = await client.async_get_accounts()
    for account in accounts.values():
        events = await account.async_get_pickup_events()
        # >>> [RidwellPickupEvent(...), ...]

        # You can also get just the next pickup event from today's date:
        next_event = await account.async_get_next_pickup_event()
        # >>> RidwellPickupEvent(...)


asyncio.run(main())
```

The `RidwellPickupEvent` object comes with some useful properties:

- `pickup_date`: the date of the pickup (in `datetime.date` format)
- `pickups`: a list of `RidwellPickup` objects
- `state`: an `EventState` enum whose name represents the current state of the pickup event

Likewise, the `RidwellPickup` object comes with some useful properties:

- `category`: a `PickupCategory` enum whose name represents the type of pickup
- `name`: the name of the item being picked up
- `offer_id`: the Ridwell ID for this particular offer
- `priority`: the pickup priority
- `product_id`: the Ridwell ID for this particular product
- `quantity`: the amount of the product being picked up

### Opting Into or Out Of a Pickup Event

```python
import asyncio

from aioridwell import async_get_client


async def main() -> None:
    client = await async_get_client("<EMAIL>", "<PASSWORD>")

    accounts = await client.async_get_accounts()
    for account in accounts.values():
        events = await account.async_get_pickup_events()
        # >>> [RidwellPickupEvent(...), ...]

        await events[0].async_opt_in()
        await events[0].async_opt_out()


asyncio.run(main())
```

### Calculating a Pickup Event's Estimated Add-on Cost

```python
import asyncio

from aioridwell import async_get_client


async def main() -> None:
    client = await async_get_client("<EMAIL>", "<PASSWORD>")

    accounts = await client.async_get_accounts()
    for account in accounts.values():
        events = await account.async_get_pickup_events()
        # >>> [RidwellPickupEvent(...), ...]

        event_1_cost = await events[0].async_get_estimated_addon_cost()
        # >>> 22.00


asyncio.run(main())
```

# Contributing

Thanks to all of [our contributors][contributors] so far!

1. [Check for open features/bugs][issues] or [initiate a discussion on one][new-issue].
2. [Fork the repository][fork].
3. (_optional, but highly recommended_) Create a virtual environment: `python3 -m venv .venv`
4. (_optional, but highly recommended_) Enter the virtual environment: `source ./.venv/bin/activate`
5. Install the dev environment: `script/setup`
6. Code your new feature or bug fix on a new branch.
7. Write tests that cover your new functionality.
8. Run tests and ensure 100% code coverage: `poetry run pytest --cov aioridwell tests`
9. Update `README.md` with any new documentation.
10. Submit a pull request!

[aiohttp]: https://github.com/aio-libs/aiohttp
[ci-badge]: https://img.shields.io/github/actions/workflow/status/bachya/aioridwell/test.yml
[ci]: https://github.com/bachya/aioridwell/actions
[codecov-badge]: https://codecov.io/gh/bachya/aioridwell/branch/dev/graph/badge.svg
[codecov]: https://codecov.io/gh/bachya/aioridwell
[contributors]: https://github.com/bachya/aioridwell/graphs/contributors
[fork]: https://github.com/bachya/aioridwell/fork
[issues]: https://github.com/bachya/aioridwell/issues
[license-badge]: https://img.shields.io/pypi/l/aioridwell.svg
[license]: https://github.com/bachya/aioridwell/blob/main/LICENSE
[maintainability-badge]: https://api.codeclimate.com/v1/badges/9c1dcc1c991cecb06eda/maintainability
[maintainability]: https://codeclimate.com/github/bachya/aioridwell/maintainability
[new-issue]: https://github.com/bachya/aioridwell/issues/new
[new-issue]: https://github.com/bachya/aioridwell/issues/new
[pypi-badge]: https://img.shields.io/pypi/v/aioridwell.svg
[pypi]: https://pypi.python.org/pypi/aioridwell
[ridwell]: https://ridwell.com
[version-badge]: https://img.shields.io/pypi/pyversions/aioridwell.svg
[version]: https://pypi.python.org/pypi/aioridwell

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/bachya/aioridwell",
    "name": "aioridwell",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Aaron Bach",
    "author_email": "bachya1208@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6f/85/bdc831718d4d8022b0728ad5d44014a41d6004495d9b3eb9ac295cc45775/aioridwell-2024.1.0.tar.gz",
    "platform": null,
    "description": "# \u267b\ufe0f aioridwell: A Python3, asyncio-based API for interacting with Ridwell\n\n[![CI][ci-badge]][ci]\n[![PyPI][pypi-badge]][pypi]\n[![Version][version-badge]][version]\n[![License][license-badge]][license]\n[![Code Coverage][codecov-badge]][codecov]\n[![Maintainability][maintainability-badge]][maintainability]\n\n<a href=\"https://www.buymeacoffee.com/bachya1208P\" target=\"_blank\"><img src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"></a>\n\n`aioridwell` is a Python 3, asyncio-friendly library for interacting with\n[Ridwell][ridwell] to view information on upcoming recycling pickups.\n\n- [Installation](#installation)\n- [Python Versions](#python-versions)\n- [Usage](#usage)\n- [Contributing](#contributing)\n\n# Installation\n\n```bash\npip install aioridwell\n```\n\n# Python Versions\n\n`aioridwell` is currently supported on:\n\n- Python 3.10\n- Python 3.11\n- Python 3.12\n\n# Usage\n\n## Creating and Using a Client\n\nThe `Client` is the primary method of interacting with the API:\n\n```python\nimport asyncio\n\nfrom aioridwell import async_get_client\n\n\nasync def main() -> None:\n    client = await async_get_client(\"<EMAIL>\", \"<PASSWORD>\")\n    # ...\n\n\nasyncio.run(main())\n```\n\nBy default, the library creates a new connection to the API with each coroutine. If\nyou are calling a large number of coroutines (or merely want to squeeze out every second\nof runtime savings possible), an [`aiohttp`][aiohttp] `ClientSession` can be used for\nconnection pooling:\n\n```python\nimport asyncio\n\nfrom aiohttp import ClientSession\n\nfrom aiowatttime import Client\n\n\nasync def main() -> None:\n    async with ClientSession() as session:\n        client = await async_get_client(\"<EMAIL>\", \"<PASSWORD>\", session=session)\n        # ...\n\n\nasyncio.run(main())\n```\n\n## Getting the User's Dashboard URL\n\n```python\nimport asyncio\n\nfrom aioridwell import async_get_client\n\n\nasync def main() -> None:\n    client = await async_get_client(\"<EMAIL>\", \"<PASSWORD>\")\n    client.get_dashboard_url()\n    # >>> https://www.ridwell.com/users/userId1/dashboard\n\n\nasyncio.run(main())\n```\n\n## Getting Accounts\n\nGetting all accounts associated with this email address is easy:\n\n```python\nimport asyncio\n\nfrom aioridwell import async_get_client\n\n\nasync def main() -> None:\n    client = await async_get_client(\"<EMAIL>\", \"<PASSWORD>\")\n\n    accounts = await client.async_get_accounts()\n    # >>> {\"account_id_1\": RidwellAccount(...), ...}\n\n\nasyncio.run(main())\n```\n\nThe `RidwellAccount` object comes with some useful properties:\n\n- `account_id`: the Ridwell ID for the account\n- `address`: the address being serviced\n- `email`: the email address on the account\n- `full_name`: the full name of the account owner\n- `phone`: the phone number of the account owner\n- `subscription_id`: the Ridwell ID for the primary subscription\n- `subscription_active`: whether the primary subscription is active\n\n## Getting Pickup Events\n\nGetting pickup events associated with an account is easy, too:\n\n```python\nimport asyncio\n\nfrom aioridwell import async_get_client\n\n\nasync def main() -> None:\n    client = await async_get_client(\"<EMAIL>\", \"<PASSWORD>\")\n\n    accounts = await client.async_get_accounts()\n    for account in accounts.values():\n        events = await account.async_get_pickup_events()\n        # >>> [RidwellPickupEvent(...), ...]\n\n        # You can also get just the next pickup event from today's date:\n        next_event = await account.async_get_next_pickup_event()\n        # >>> RidwellPickupEvent(...)\n\n\nasyncio.run(main())\n```\n\nThe `RidwellPickupEvent` object comes with some useful properties:\n\n- `pickup_date`: the date of the pickup (in `datetime.date` format)\n- `pickups`: a list of `RidwellPickup` objects\n- `state`: an `EventState` enum whose name represents the current state of the pickup event\n\nLikewise, the `RidwellPickup` object comes with some useful properties:\n\n- `category`: a `PickupCategory` enum whose name represents the type of pickup\n- `name`: the name of the item being picked up\n- `offer_id`: the Ridwell ID for this particular offer\n- `priority`: the pickup priority\n- `product_id`: the Ridwell ID for this particular product\n- `quantity`: the amount of the product being picked up\n\n### Opting Into or Out Of a Pickup Event\n\n```python\nimport asyncio\n\nfrom aioridwell import async_get_client\n\n\nasync def main() -> None:\n    client = await async_get_client(\"<EMAIL>\", \"<PASSWORD>\")\n\n    accounts = await client.async_get_accounts()\n    for account in accounts.values():\n        events = await account.async_get_pickup_events()\n        # >>> [RidwellPickupEvent(...), ...]\n\n        await events[0].async_opt_in()\n        await events[0].async_opt_out()\n\n\nasyncio.run(main())\n```\n\n### Calculating a Pickup Event's Estimated Add-on Cost\n\n```python\nimport asyncio\n\nfrom aioridwell import async_get_client\n\n\nasync def main() -> None:\n    client = await async_get_client(\"<EMAIL>\", \"<PASSWORD>\")\n\n    accounts = await client.async_get_accounts()\n    for account in accounts.values():\n        events = await account.async_get_pickup_events()\n        # >>> [RidwellPickupEvent(...), ...]\n\n        event_1_cost = await events[0].async_get_estimated_addon_cost()\n        # >>> 22.00\n\n\nasyncio.run(main())\n```\n\n# Contributing\n\nThanks to all of [our contributors][contributors] so far!\n\n1. [Check for open features/bugs][issues] or [initiate a discussion on one][new-issue].\n2. [Fork the repository][fork].\n3. (_optional, but highly recommended_) Create a virtual environment: `python3 -m venv .venv`\n4. (_optional, but highly recommended_) Enter the virtual environment: `source ./.venv/bin/activate`\n5. Install the dev environment: `script/setup`\n6. Code your new feature or bug fix on a new branch.\n7. Write tests that cover your new functionality.\n8. Run tests and ensure 100% code coverage: `poetry run pytest --cov aioridwell tests`\n9. Update `README.md` with any new documentation.\n10. Submit a pull request!\n\n[aiohttp]: https://github.com/aio-libs/aiohttp\n[ci-badge]: https://img.shields.io/github/actions/workflow/status/bachya/aioridwell/test.yml\n[ci]: https://github.com/bachya/aioridwell/actions\n[codecov-badge]: https://codecov.io/gh/bachya/aioridwell/branch/dev/graph/badge.svg\n[codecov]: https://codecov.io/gh/bachya/aioridwell\n[contributors]: https://github.com/bachya/aioridwell/graphs/contributors\n[fork]: https://github.com/bachya/aioridwell/fork\n[issues]: https://github.com/bachya/aioridwell/issues\n[license-badge]: https://img.shields.io/pypi/l/aioridwell.svg\n[license]: https://github.com/bachya/aioridwell/blob/main/LICENSE\n[maintainability-badge]: https://api.codeclimate.com/v1/badges/9c1dcc1c991cecb06eda/maintainability\n[maintainability]: https://codeclimate.com/github/bachya/aioridwell/maintainability\n[new-issue]: https://github.com/bachya/aioridwell/issues/new\n[new-issue]: https://github.com/bachya/aioridwell/issues/new\n[pypi-badge]: https://img.shields.io/pypi/v/aioridwell.svg\n[pypi]: https://pypi.python.org/pypi/aioridwell\n[ridwell]: https://ridwell.com\n[version-badge]: https://img.shields.io/pypi/pyversions/aioridwell.svg\n[version]: https://pypi.python.org/pypi/aioridwell\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python3, asyncio-based API for interacting with Ridwell waste recycling",
    "version": "2024.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/bachya/aioridwell/issues",
        "Changelog": "https://github.com/bachya/aioridwell/releases",
        "Homepage": "https://github.com/bachya/aioridwell",
        "Repository": "https://github.com/bachya/aioridwell"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73da7865156ec57db862f3ea7766ec947f7e6a3fdc7004d5e6707028a99e2937",
                "md5": "c6fcfae2b5710bc8224db745d3684177",
                "sha256": "4dc04d4dcbc671357b7243a66033477af2b032891ad4a14856c03333da2fcb0a"
            },
            "downloads": -1,
            "filename": "aioridwell-2024.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c6fcfae2b5710bc8224db745d3684177",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 11014,
            "upload_time": "2024-01-15T21:27:49",
            "upload_time_iso_8601": "2024-01-15T21:27:49.764051Z",
            "url": "https://files.pythonhosted.org/packages/73/da/7865156ec57db862f3ea7766ec947f7e6a3fdc7004d5e6707028a99e2937/aioridwell-2024.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f85bdc831718d4d8022b0728ad5d44014a41d6004495d9b3eb9ac295cc45775",
                "md5": "dc6721721bc2fdeefdecebf8ca3bdd9c",
                "sha256": "3541770330eb17e5d5e593d41f14067da543842fa58687efa065891a822a3017"
            },
            "downloads": -1,
            "filename": "aioridwell-2024.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "dc6721721bc2fdeefdecebf8ca3bdd9c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 11905,
            "upload_time": "2024-01-15T21:27:51",
            "upload_time_iso_8601": "2024-01-15T21:27:51.391107Z",
            "url": "https://files.pythonhosted.org/packages/6f/85/bdc831718d4d8022b0728ad5d44014a41d6004495d9b3eb9ac295cc45775/aioridwell-2024.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-15 21:27:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bachya",
    "github_project": "aioridwell",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aioridwell"
}
        
Elapsed time: 0.19691s