<?php

namespace App\Services;

use App\Services\Service;
use App\Services\JWT\UsuarioLogado;
use App\Services\ServiceResponse\ServiceResponse;
use App\DAO\ClienteDAO;

class ClienteService extends Service {

	public function getClienteIdByUsusarioId(int $idusuario): ServiceResponse {

		$serviceReponse = new ServiceResponse();

		$clienteDao = new ClienteDAO();
		$daoResponse = $clienteDao->getClienteIdByUsuarioId( $idusuario );
		$serviceReponse = $this->setServiceResponse( $daoResponse );

		return $serviceReponse;

	}

	public function setAceitoTermos(): ServiceResponse {

		$serviceReponse = new ServiceResponse();
		$idusuario = UsuarioLogado::getUsuarioId();
		$cliente = $this->getClienteIdByUsusarioId( $idusuario );

		if ($cliente->getStatus() == SUCESS) {
			$idcliente = $cliente->getData() ['id'];
			$clienteDao = new ClienteDAO();
			$cliente_response = $clienteDao->setAceitoTermos( $idcliente );
			$serviceReponse = $this->setServiceResponse( $cliente_response );
		} else {
			$serviceReponse = $this->setServiceResponse( $cliente );
		}

		return $serviceReponse;

	}

}

