Package: aiocloudlibrary
aiocloudlibraryAsynchronous library to communicate with the Cloud Library APICloud Library API Example ScriptThis example script demonstrates how to utilize theCloudLibraryClientclass from theaiocloudlibrarymodule to interact with the Cloud Library API. It showcases various functionalities available within the client class to retrieve different types of data from the API.UsageInstallation:Ensure theaiocloudlibrarymodule is installed. If not, install it usingpip install aiocloudlibrary.Configuration:Replace the placeholder details (barcode/email, PIN/password, library ID) within the script with actual values.Functionality Displayed:current(): Fetches the current patron items.history(): Retrieves the patron's borrowing history.holds(): Retrieves the patron's holds.saved(): Retrieves the patron's saved items.featured(): Retrieves the patron's featured items.email(): Retrieves the patron's email settings.notifications(): Retrieves patron notifications (unread or archived).Execution:Run the script, and it will sequentially call these functions, displaying the retrieved data for each function.Important NotesReplace placeholder values (barcode, PIN, library ID) with your actual Cloud Library account details.Thenotifications()function demonstrates both fetching unread notifications and archiving specific notifications.Make sure you have appropriate access rights and permissions for the Cloud Library API endpoints being accessed.Feel free to modify the script as needed, adding error handling, logging, or additional functionalities based on your requirements and the Cloud Library API's capabilities."""Example Script: Accessing Cloud Library API with aiocloudlibraryThis script demonstrates fetching current patron items, borrowing history, holds, and saved itemsfrom the Cloud Library API using the aiocloudlibrary library.Make sure to replace 'xxxxxx@mail.com', 'xxxxxxxx', and 'xxxxx' with actual credentials and library details.Requirements:- aiocloudlibrary library (installed via pip)Usage:Run the script and observe the output displaying various data from the Cloud Library API."""fromaiocloudlibraryimportCloudLibraryClientimportasyncioimportjsonasyncdefmain():client=CloudLibraryClient(barcode="xxxxxx@mail.com",# Replace with actual barcode/emailpin="xxxxxxxx",# Replace with actual PIN/passwordlibrary="xxxxx"# Replace with actual library ID)try:current=awaitclient.current()print(f"Current Patron Items:{json.dumps(current,indent=2)}")history=awaitclient.history()print(f"Patron's Borrowing History:{json.dumps(history,indent=2)}")holds=awaitclient.holds()print(f"Patron's Holds:{json.dumps(holds,indent=2)}")saved_items=awaitclient.saved()print(f"Patron's Saved Items:{json.dumps(saved_items,indent=2)}")featured_items=awaitclient.featured()print(f"Patron's Featured Items:{json.dumps(featured_items,indent=2)}")email_settings=awaitclient.email()print(f"Patron's Email Settings:{json.dumps(email_settings,indent=2)}")unread_notifications=awaitclient.notifications()print(f"Unread Notifications:{json.dumps(unread_notifications,indent=2)}")notification_ids=["notification_id_1","notification_id_2"]# Replace with actual notification IDsarchived_notifications=awaitclient.notifications(unread="false",notification_id_to_archive=notification_ids)print(f"Archived Notifications:{json.dumps(archived_notifications,indent=2)}")finally:awaitclient.close_session()asyncio.run(main())