import requests


def get_token(
    email: str,
    password: str,
):
    """Log into AIO Impact and get a token.

    Parameters
    ----------
    email : str
        Email address of the user account.

    password : str
        Password of the user account.

    Returns
    -------

    str
        Bearer token.

    Examples
    --------
    >>> aioconnect.get_token(
    >>>     email="firstname.lastname@aioneers.com", password="xxx",
    >>> )
    """

    url = "https://dev-api.aioneers.tech/v1/login"
    url = url.rstrip("/")

    payload = {"email": email, "password": password}

    response = requests.post(url=url, data=payload)
    response.raise_for_status()

    token = response.json()["data"]["token"]

    return token