class Response(object):
    def __init__(self, data=None, status_code=None, messages=None):
        self.data = data
        self.status_code = status_code or 200
        self.messages = messages or []


class Interface:
    def __init__(self, request, args, kwargs, service, permission_classes=None):
        self.request = request
        self.args = args
        self.kwargs = kwargs
        self.kwargs['data'] = request.data
        self.kwargs['authenticated_user_id'] = request.user.id
        self.kwargs.update(dict(request.query_params))

        self.service = service

        self.permission_classes = permission_classes or []

        self.messages = []
        self.status_code = 200

    def __call__(self):
        for i in self.permission_classes:
            if not i().has_permission(self.request, *self.args, **self.kwargs):
                self.messages.append('The user in question does not have access to this section.')
                self.status_code = 403
                return Response(status_code=self.status_code, messages=self.messages)

        data = self.service.execute(*self.args, **self.kwargs)
        return Response(data=data)
