"""This module provides FastAPI dependencies for commonly used query parameters."""


from enum import Enum
from typing import Callable

import sqlalchemy

from todo.database.engine import Base


class SortOrder(Enum):
    """Possible sort orders for database queries."""

    asc = 'asc'
    desc = 'desc'

    @property
    def call(self) -> Callable:
        """Returns the sqlalchemy sort function depending on the instance value."""

        if self.value == 'asc':
            return sqlalchemy.asc
        elif self.value == 'desc':
            return sqlalchemy.desc
        else:
            raise RuntimeError("Logic error.")


class PaginationParams():
    """Represents query parameters used for pagination, when querying for a list of items.

    Attributes
    ----------
    skip : int
        The number of items to be skipped from the start of the start of the list.
    limit : int
        Limits the total number of returned list items to the specified number.
    """

    def __init__(self, skip: int = 0, limit: int = 100):
        self.skip = skip
        self.limit = limit
