Skip to main content

Module to communicate to the Cloud Library API

Project description

aiocloudlibrary

Asynchronous library to communicate with the Cloud Library API

maintainer buyme_coffee discord

MIT License

GitHub issues Average time to resolve an issue Percentage of issues still open PRs Welcome

Python

github release github release date github last-commit github contributors github commit activity

Cloud Library API Example Script

This example script demonstrates how to utilize the CloudLibraryClient class from the aiocloudlibrary module 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.

Usage

  1. Installation: Ensure the aiocloudlibrary module is installed. If not, install it using pip install aiocloudlibrary.

  2. Configuration: Replace the placeholder details (barcode/email, PIN/password, library ID) within the script with actual values.

  3. 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).
  4. Execution: Run the script, and it will sequentially call these functions, displaying the retrieved data for each function.

Important Notes

  • Replace placeholder values (barcode, PIN, library ID) with your actual Cloud Library account details.
  • The notifications() 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 aiocloudlibrary

This script demonstrates fetching current patron items, borrowing history, holds, and saved items
from 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.
"""

from aiocloudlibrary import CloudLibraryClient
import asyncio
import json

async def main():
    client = CloudLibraryClient(
        barcode="xxxxxx@mail.com",  # Replace with actual barcode/email
        pin="xxxxxxxx",  # Replace with actual PIN/password
        library="xxxxx"  # Replace with actual library ID
    )

    try:
        current = await client.current()
        print(f"Current Patron Items: {json.dumps(current, indent=2)}")

        history = await client.history()
        print(f"Patron's Borrowing History: {json.dumps(history, indent=2)}")

        holds = await client.holds()
        print(f"Patron's Holds: {json.dumps(holds, indent=2)}")

        saved_items = await client.saved()
        print(f"Patron's Saved Items: {json.dumps(saved_items, indent=2)}")

        featured_items = await client.featured()
        print(f"Patron's Featured Items: {json.dumps(featured_items, indent=2)}")

        email_settings = await client.email()
        print(f"Patron's Email Settings: {json.dumps(email_settings, indent=2)}")

        unread_notifications = await client.notifications()
        print(f"Unread Notifications: {json.dumps(unread_notifications, indent=2)}")

        notification_ids = ["notification_id_1", "notification_id_2"]  # Replace with actual notification IDs
        archived_notifications = await client.notifications(
            unread="false", notification_id_to_archive=notification_ids
        )
        print(f"Archived Notifications: {json.dumps(archived_notifications, indent=2)}")

    finally:
        await client.close_session()

asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiocloudlibrary-0.1.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

aiocloudlibrary-0.1.0-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page