Package: aioridwell
♻️ aioridwell: A Python3, asyncio-based API for interacting with Ridwellaioridwellis a Python 3, asyncio-friendly library for interacting withRidwellto view information on upcoming recycling pickups.InstallationPython VersionsUsageContributingInstallationpipinstallaioridwellPython Versionsaioridwellis currently supported on:Python 3.10Python 3.11Python 3.12UsageCreating and Using a ClientTheClientis the primary method of interacting with the API:importasynciofromaioridwellimportasync_get_clientasyncdefmain()->None:client=awaitasync_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), anaiohttpClientSessioncan be used for
connection pooling:importasynciofromaiohttpimportClientSessionfromaiowatttimeimportClientasyncdefmain()->None:asyncwithClientSession()assession:client=awaitasync_get_client("<EMAIL>","<PASSWORD>",session=session)# ...asyncio.run(main())Getting the User's Dashboard URLimportasynciofromaioridwellimportasync_get_clientasyncdefmain()->None:client=awaitasync_get_client("<EMAIL>","<PASSWORD>")client.get_dashboard_url()# >>> https://www.ridwell.com/users/userId1/dashboardasyncio.run(main())Getting AccountsGetting all accounts associated with this email address is easy:importasynciofromaioridwellimportasync_get_clientasyncdefmain()->None:client=awaitasync_get_client("<EMAIL>","<PASSWORD>")accounts=awaitclient.async_get_accounts()# >>> {"account_id_1": RidwellAccount(...), ...}asyncio.run(main())TheRidwellAccountobject 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 activeGetting Pickup EventsGetting pickup events associated with an account is easy, too:importasynciofromaioridwellimportasync_get_clientasyncdefmain()->None:client=awaitasync_get_client("<EMAIL>","<PASSWORD>")accounts=awaitclient.async_get_accounts()foraccountinaccounts.values():events=awaitaccount.async_get_pickup_events()# >>> [RidwellPickupEvent(...), ...]# You can also get just the next pickup event from today's date:next_event=awaitaccount.async_get_next_pickup_event()# >>> RidwellPickupEvent(...)asyncio.run(main())TheRidwellPickupEventobject comes with some useful properties:pickup_date: the date of the pickup (indatetime.dateformat)pickups: a list ofRidwellPickupobjectsstate: anEventStateenum whose name represents the current state of the pickup eventLikewise, theRidwellPickupobject comes with some useful properties:category: aPickupCategoryenum whose name represents the type of pickupname: the name of the item 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 upOpting Into or Out Of a Pickup Eventimportasynciofromaioridwellimportasync_get_clientasyncdefmain()->None:client=awaitasync_get_client("<EMAIL>","<PASSWORD>")accounts=awaitclient.async_get_accounts()foraccountinaccounts.values():events=awaitaccount.async_get_pickup_events()# >>> [RidwellPickupEvent(...), ...]awaitevents[0].async_opt_in()awaitevents[0].async_opt_out()asyncio.run(main())Calculating a Pickup Event's Estimated Add-on Costimportasynciofromaioridwellimportasync_get_clientasyncdefmain()->None:client=awaitasync_get_client("<EMAIL>","<PASSWORD>")accounts=awaitclient.async_get_accounts()foraccountinaccounts.values():events=awaitaccount.async_get_pickup_events()# >>> [RidwellPickupEvent(...), ...]event_1_cost=awaitevents[0].async_get_estimated_addon_cost()# >>> 22.00asyncio.run(main())ContributingThanks to all ofour contributorsso far!Check for open features/bugsorinitiate 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/activateInstall the dev environment:script/setupCode your new feature or bug fix on a new branch.Write tests that cover your new functionality.Run tests and ensure 100% code coverage:poetry run pytest --cov aioridwell testsUpdateREADME.mdwith any new documentation.Submit a pull request!