A Python3, asyncio-based API for interacting with Ridwell waste recycling
Project description
♻️ aioridwell: DESCRIPTION
aioridwell
is a Python 3, asyncio-friendly library for interacting with
Ridwell to view information on upcoming recycling pickups.
Installation
pip install aioridwell
Python Versions
aioridwell
is currently supported on:
- Python 3.8
- Python 3.9
Usage
Creating and Using a Client
The Client
is the primary method of interacting with the API:
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
ClientSession
can be used for connection
pooling:
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 Accounts
Getting all accounts associated with this email address is easy:
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 accountaddress
: the address being servicedemail
: the email address on the accountfull_name
: the full name of the account ownerphone
: the phone number of the account ownersubscription_id
: the Ridwell ID for the primary subscriptionsubscription_active
: whether the primary subscription is active
Getting Pickup Events
Getting all pickup events associated with an account is easy, too:
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(...), ...]
asyncio.run(main())
The RidwellPickupEvent
object comes with some useful properties:
pickup_date
: the date of the pickup (indatetime.date
format)pickups
: a list ofRidwellPickup
objectsstate
: eitherinitialized
(not scheduled for pickup) orscheduled
Likewise, the RidwellPickup
object comes with some useful properties:
category
: the type of waste being picked upoffer_id
: the Ridwell ID for this particular offerpriority
: the pickup priorityproduct_id
: the Ridwell ID for this particular productquantity
: the amount of the product being picked uprotating
: whether this is a rotating pickup type
Calculating a Pickup Event's Esimated Cost
Calculating the estimated cost of a pickup event is, you guessed it, easy:
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()
event_1_cost = await events[0].async_get_estimated_cost()
# >>> 22.00
asyncio.run(main())
Contributing
- Check for open features/bugs or initiate a discussion on one.
- Fork the repository.
- (optional, but highly recommended) Create a virtual environment:
python3 -m venv .venv
- (optional, but highly recommended) Enter the virtual environment:
source ./.venv/bin/activate
- Install the dev environment:
script/setup
- Code your new feature or bug fix.
- Write tests that cover your new functionality.
- Run tests and ensure 100% code coverage:
script/test
- Update
README.md
with any new documentation. - Add yourself to
AUTHORS.md
. - Submit a pull request!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aioridwell-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd6ba3a44e9f209eff825bcf4671d0257c265d6b5528e28f65fe063dc4f46f4a |
|
MD5 | ca7987b7a8b5832d8a4a9160222febf0 |
|
BLAKE2b-256 | a9fabd5afd055df335b0075cdc802af8471af04428f7f58dffc836e1a8325aac |