ipns-poc-eval / src /services /_proposal_service.py
Aryan Jain
update the apis according to the scores
7a511fb
from src.models import Proposal, ProposalStatus
from src.repositories import ProposalRepository
class ProposalService:
def __init__(self):
self.proposal_repository = ProposalRepository
async def __aenter__(self):
return self
async def __aexit__(self, exc_type, exc_value, traceback):
pass
async def get_proposals(
self, proposal_id: str = None, rfp_id: str = None, status: ProposalStatus = None
):
async with self.proposal_repository() as repository:
return await repository.get_proposals(
proposal_id=proposal_id, rfp_id=rfp_id, status=status
)
async def get_proposals_by_rfp_id(self, rfp_id: str):
async with self.proposal_repository() as repository:
return await repository.get_proposals_by_rfp_id(rfp_id)
async def create_proposal(self, proposal: dict):
async with self.proposal_repository() as repository:
return await repository.create_proposal(proposal)
async def update_proposal(self, proposal_id: str, proposal: dict):
async with self.proposal_repository() as repository:
return await repository.update_proposal(
proposal_id=proposal_id, proposal=proposal
)
async def delete_proposal(self, proposal_id: str = None, rfp_id: str = None):
async with self.proposal_repository() as repository:
return await repository.delete_proposal(
proposal_id=proposal_id, rfp_id=rfp_id
)