<?php


namespace App\Controllers;

use App\Services\AgendaService;
use App\Services\CepService;
use App\Services\ServiceResponse\ServiceResponseInterface;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;

class CEPController extends BaseController
{
    public function getCEPData (string $cep) : Response{
        $cep_service_response = (new CepService())->getCEPData($cep);
        $response_messages = [
            ServiceResponseInterface::VALIDATION_PARAMS_ERROR => [
                'code' => ResponseInterface::HTTP_BAD_REQUEST,
                'message' => 'O formato do CEP é inválido.'
            ],
            ServiceResponseInterface::EXTERNAL_SERVICE_UNAVAILABLE => [
                'code' => ResponseInterface::HTTP_PARTIAL_CONTENT,
                'message' => 'O CEP informado não está disponível para consulta.'
            ],
            ServiceResponseInterface::SUCESS => [
                'code' => ResponseInterface::HTTP_OK,
                'message' => 'Os dados do CEP foram encontrados com sucesso.'
            ],
        ];
        return $this->getResponse($cep_service_response, $response_messages);
    }

}