Skip to content

Base Handler

A base class for all tfl handlers.

TFLHandler

Bases: abc.ABC

A base class for all tfl handlers.

Parameters:

Name Type Description Default
client httpx.AsyncClient

The client to use when sending requests.

required

Raises:

Type Description
ValueError

If the client does not have a base URL of https://api.tfl.gov.uk.

Source code in tfl/base/_base_handler.py
class TFLHandler(abc.ABC):
    """A base class for all tfl handlers.

    Args:
        client: The client to use when sending requests.

    Raises:
        ValueError: If the client does not have a base URL of https://api.tfl.gov.uk.
    """

    def __init__(self, client: httpx.AsyncClient) -> None:
        if client.base_url != "https://api.tfl.gov.uk":
            raise ValueError("The client must have a base URL of https://api.tfl.gov.uk")
        self.client = client