"""Blueprint for reference payment type API.""" from http import HTTPStatus from typing import List from common_apispec import doc, marshal_with, use_kwargs from flask import Blueprint from payment.constants.constants import PERMISSIONS_ACTIONS, PERMISSIONS_RESOURCES from payment.logic import reference_payment_type as logic from payment.schemas.reference_payment_type import ReferencePaymentTypeDataloaderSchema from payment.schemas.request import DataloaderParamsPostSchema from payment.utils.authorization import check_access reference_payment_type_api = Blueprint( 'reference_payment_type_api', __name__, url_prefix='/reference-payment-type', ) @reference_payment_type_api.route('/dataloader', methods=['POST']) @doc( tags=['reference payment type'], description='Dataloader for reference payment types', ) @check_access(PERMISSIONS_RESOURCES.REFERENCE_PAYMENT_TYPE, PERMISSIONS_ACTIONS.VIEW) @use_kwargs(DataloaderParamsPostSchema(), location='json') @marshal_with( ReferencePaymentTypeDataloaderSchema(), code=HTTPStatus.OK, description=HTTPStatus.OK.phrase, ) @marshal_with( None, code=HTTPStatus.BAD_REQUEST, description=HTTPStatus.BAD_REQUEST.phrase, ) def reference_payment_type_dataloader(ids: List[int]): """Dataloader endpoint.""" return logic.dataload_by_ids(ids), 200