from Blueprints.BaseRequestParser import base_parser, handle_request
from Rest.ReportRest import ReportREST
from flask_restx import Namespace, Resource

api = Namespace('Report', path='/report', description='report operations')

report_parser = base_parser.copy()
report_parser.add_argument('message', location='args', required=True)


@api.route('/user/<user_to_report_id>')
@api.doc(params={'user_to_report_id': 'Id of user that will be reported'})
class UserReport(Resource):
    @api.doc(parser=report_parser)
    def post(self, user_to_report_id):
        return handle_request(parser=report_parser,
                              path_args=[user_to_report_id],
                              arg_dict={'message': None},
                              rest_function=ReportREST.post_report_user)


@api.route('/post/<post_to_report_id>')
@api.doc(params={'post_to_report_id': 'Id of post that will be reported'})
class PostReport(Resource):
    @api.doc(parser=report_parser)
    def post(self, post_to_report_id):
        return handle_request(parser=report_parser,
                              path_args=[post_to_report_id],
                              arg_dict={'message': None},
                              rest_function=ReportREST.post_report_post)


@api.route('/media/<media_to_report_id>')
@api.doc(params={'media_to_report_id': 'Id of media that will be reported'})
class MediaReport(Resource):
    @api.doc(parser=report_parser)
    def post(self, media_to_report_id):
        return handle_request(parser=report_parser,
                              path_args=[media_to_report_id],
                              arg_dict={'message': None},
                              rest_function=ReportREST.post_report_media)
