from .blackbox import Blackbox
from injector import singleton

@singleton
class Sum(Blackbox):
  
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
    
    def __call__(self, *args, **kwargs):
        return self.processing(*args, **kwargs)
    
    def processing(self, *args, **kwargs):
        total = 0
        for arg in args[0]:
            total += arg
        return total
    
    def valid(self, *args, **kwargs) -> bool:
        return super().valid(*args, **kwargs)
    
    async def fast_api_handler(self, request):
        json = await request.json()
        return self.processing(json)