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.2.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

aiocloudlibrary-0.2.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file aiocloudlibrary-0.2.0.tar.gz.

File metadata

  • Download URL: aiocloudlibrary-0.2.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for aiocloudlibrary-0.2.0.tar.gz
Algorithm Hash digest
SHA256 17bf16b1c8b6d01e7295d8b2b2346da36cf1f506211da251dd82d14a88071aca
MD5 0e598039ca247da956f7acf5f683fb8a
BLAKE2b-256 d18bccc01a1122dc647b68ba6cc0a3dfcbc158417b6c549bd662fa174a7bc89e

See more details on using hashes here.

File details

Details for the file aiocloudlibrary-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiocloudlibrary-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f97d911baeb93765d9068d9ba5194b6016fdfdd620d9d1ca2a3234bee44b4a81
MD5 c016b943d61407a68f70fcf55db15692
BLAKE2b-256 74a4134f0fde637194b5b31f2bb48593f48ba0c8742b7d7feac4fb7172c70712

See more details on using hashes here.

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