"""Blueprint for Payment Search API.""" from http import HTTPStatus from common_apispec import doc, marshal_with, use_kwargs from flask import Blueprint from payment.logic import payment_search as logic from payment.schemas.payment_search import ( PaymentSearchFilterParamsPostSchema, PaymentSearchListSchema, ) from payment.utils.authorization import check_access payment_search_api = Blueprint( 'payment_search_api', __name__, url_prefix='/payment-search', ) @payment_search_api.route('/search', methods=['POST']) @doc( tags=['payment search'], description='Search payments by filters via Cortex Search.', ) @check_access @use_kwargs(PaymentSearchFilterParamsPostSchema, location='json') @marshal_with( PaymentSearchListSchema, code=HTTPStatus.OK, description=HTTPStatus.OK.phrase ) def search_payments(filters: dict): """Search payments via Cortex Search.""" results = logic.search_payments(**filters) return results, HTTPStatus.OK