class GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService {

    @Override
    @Transactional
    public ServiceResult<Void> approveOrRejectSignedGrantOfferLetter(Long projectId, GrantOfferLetterApprovalResource grantOfferLetterApprovalResource) {

        return validateApprovalOrRejection(grantOfferLetterApprovalResource).andOnSuccess(() ->
            getProject(projectId).andOnSuccess(project -> {
                if (golWorkflowHandler.isReadyToApprove(project)) {
                    if (ApprovalType.APPROVED.equals(grantOfferLetterApprovalResource.getApprovalType()) && !isOnHold(project)) {
                        return approveGOL(project)
                                .andOnSuccess(() -> moveProjectToLiveState(project));
                    } else if (ApprovalType.REJECTED.equals(grantOfferLetterApprovalResource.getApprovalType())) {
                        return rejectGOL(project, grantOfferLetterApprovalResource.getRejectionReason());
                    }
                }
                return serviceFailure(CommonFailureKeys.GRANT_OFFER_LETTER_NOT_READY_TO_APPROVE);
        }));
    }

}