#global imports
from database.entities.transaction import Transaction
from database.repository import Repository

import json
from flask import Response, request

_repository = Repository()

def all_for_use_case(use_case: str):
    transactions = _repository.all_transactions_for_use_case(use_case)
    return [t.to_serializable_dict() for t in transactions]

def delete_all_transactions():
    _repository.delete_all_transactions()
    return Response(status=200)

def all_failed_for_use_case(use_case: str):
    return _repository.all_failed_transactions_for_use_case(use_case)

def delete_all_failed_for_use_case(use_case: str):
    _repository.delete_all_failed_transactions(use_case)
    return Response(status=200)

def all_duplicated_for_use_case(use_case: str):
    transactions = _repository.all_duplicated_transactions_for_use_case(use_case)
    return [t.to_serializable_dict() for t in transactions]

def delete_all_duplicated_for_use_case(use_case: str):
    _repository.delete_all_duplicated_transactions(use_case)
    return Response(status=200)