revanced-api/api/donations.py
Alexandre Teles (afterSt0rm) b18097e030
feat: API Fixes and Adjustments (#23)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-19 23:32:48 -03:00

37 lines
1.0 KiB
Python

"""
This module provides a blueprint for the donations endpoint.
Routes:
- GET /donations: Get ReVanced donation links and wallets.
"""
from sanic import Blueprint, Request
from sanic.response import JSONResponse, json
from sanic_ext import openapi
from api.models.donations import DonationsResponseModel
from config import api_version, wallets, links
donations: Blueprint = Blueprint("donations", version=api_version)
@donations.get("/donations")
@openapi.definition(
summary="Get ReVanced donation links and wallets",
response=[DonationsResponseModel],
)
async def root(request: Request) -> JSONResponse:
"""
Returns a JSONResponse with a dictionary containing ReVanced donation links and wallets.
**Returns:**
- JSONResponse: A Sanic JSONResponse instance containing a dictionary with the donation links and wallets.
"""
data: dict[str, dict] = {
"donations": {
"wallets": wallets,
"links": links,
}
}
return json(data, status=200)