<?php

namespace App\Services;

use App\Services\Service;
use App\Services\ServiceResponse\ServiceResponse;
use App\Services\ServiceResponse\ServiceResponseInterface;
use App\DAO\ReciboDAO;
use App\DAO\DAOResponse\DAOResponseInterface;

class ReciboService extends Service {

	public function getDadosExtornoByIdToRecibo(int $extorno_id): ServiceResponse {

		$recibo_dao = new ReciboDAO();
		$dao_response = $recibo_dao->getDadosExtornoByIdToRecibo( $extorno_id );
		switch ($dao_response->getStatus()) {
			case DAOResponseInterface::SUCESS :
				$service_response_status = ServiceResponseInterface::SUCESS;
				break;
			case DAOResponseInterface::RECORD_NOT_FOUND :
				$service_response_status = ServiceResponseInterface::RECORD_NOT_FOUND;
				break;
			case DAOResponseInterface::DATABASE_CONNECTION_ERROR :
				$service_response_status = ServiceResponseInterface::DATABASE_CONNECTION_ERROR;
				break;
		}
		$service_response = ServiceResponse::builder()->setStatus( $service_response_status )
			->build();
		if ($service_response_status === DAOResponseInterface::SUCESS) {
			$dao_response_data = $dao_response->getData();
			// $extornos_details_array = ExtornoMapper::getExtornoDetailsArrayFromExtornoDetailsVMCollection( $dao_response_data );
			// $pagination = $dao_response->getPagination();
			$data = [ 
					'dados_recibo' => $dao_response_data
			];
			$service_response->setData( $data );
		}
		return $service_response;

	}

}

