Skip to main content

No project description provided

Project description

LOTR SDK

A Python SDK for https://the-one-api.dev.

This library provides a client for interacting with The One API, as well as helper classes for building queries and handling errors. The main classes are LotrClient, which sends requests to the API, and LotrQueryBuilder, which helps construct query parameters for those requests.

Example usage:

    from lotr_sdk import client
    from lotr_sdk import query
    from lotr_sdk import options

    # Use query builder to construct parameters for client fetch requests.
    query_builder = query.LotrQueryBuilder(models.BOOK)
    query_builder \
        .paginate(page=1, limit=10) \
        .add(query.Sort("title", SortOrder.DESCENDING))
    query = query_builder.build()

    # Create a LotrClient using your API key from https://the-one-api.dev.
    lotr_client = client.LotrClient(api_key="your_api_key")
    books = lotr_client.get_books(query)

This module depends on the requests library for sending HTTP requests, and the backoff and ratelimit libraries for handling rate limits and retries.

Project Configuration

This project uses poetry. From the poetry site:

Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Poetry offers a lockfile to ensure repeatable installs, and can build your project for distribution.

LotrQueryBuilder

The lotr_sdk.query module contains a query parameter builder and supporting classes. Specifically, it contains the LotrQueryBuilder class with the following primary methods:

  • add() takes instances of Paginate, Sort, or Filter classes for defining clauses in the query. These classes can also be found in the lotr_sdk.client module.
  • build() returns the query parameters as a dictionary, ready to be used with the LotrClient interface.

LotrClient

The LotrClient class provides methods for fetching information from [The One API](https: //the-one-api.dev). Fetch results use types defined in the lotr_sdk.models module. The client methods return either a single object, or a homogeneous list of objects. The following types are supported:

  • Book
  • Chapter
  • Movie
  • Quote
  • Character

Tests

Tests use the pytest library, and can be found in the tests module. Assuming that you have poetry installed and set up, tests can be run using: poetry run pytest tests/test_lotr_sdk.py

The One API key is read from THE_ONE_API_KEY environment variable. It can be specified in most shells using the following syntax: THE_ONE_API_KEY="your-api-key" poetry run pytest tests/test_lotr_sdk.py

Tests are divided between the following classes:

  • TestLotrClientUnit runs through the client methods with mocked network requests.
  • TestLotrClientIntegration runs through the client methods making network requests. Beware of API rate limitations.
  • TestLotrQueryBuilder runs through the query builder methods to create query parameter dictionaries for all clauses.

To run a subset of tests, use the following syntax: poetry run pytest tests/test_lotr_sdk.py::TestLotrClientUnit to run only tests in that test class.

poetry run pytest tests/test_lotr_sdk.py::TestLotrClientUnit::test_get_books to run only the get_books test in that test class.

Build

To build sdist and wheel: poetry build

Publish

To set your PyPI token: poetry config pypi-token.pypi your-api-token

To publish: poetry publish

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

owx_lotr_sdk-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

owx_lotr_sdk-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file owx_lotr_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: owx_lotr_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.11.3 Linux/6.2.14-2-MANJARO

File hashes

Hashes for owx_lotr_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 caf3316d55fcd80a9bd3846e78dc7736bd58db6ca6e1092a37b05c120e2a3a8f
MD5 9c290552e5c752068be2be5b884b9a94
BLAKE2b-256 c6d8f3897eb47102b42993aaa436c5cdb62f22c399db07c7cea09bccaa467f4c

See more details on using hashes here.

File details

Details for the file owx_lotr_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: owx_lotr_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.11.3 Linux/6.2.14-2-MANJARO

File hashes

Hashes for owx_lotr_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13002347f42a287c9a675296b5f07bad2fbd6f074ab2a167977a4121e0d73183
MD5 ff986083ae274a4e7d8d3264b725a77c
BLAKE2b-256 532a063bc82e7b03c32ba2d9af4a05ae00aae0c165ed705e1a3b81dbe208b1b8

See more details on using hashes here.

Supported by

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