@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Integrations\SuiteCrm\SuiteCrmClient;
|
||||
use App\Integrations\SuiteCrm\SuiteCrmException;
|
||||
use Illuminate\Console\Command;
|
||||
use Throwable;
|
||||
|
||||
class SuiteCrmProbe extends Command
|
||||
{
|
||||
protected $signature = 'suitecrm:probe {--module=Contacts : Modulo cujos metadados serao consultados}';
|
||||
|
||||
protected $description = 'Verifica OAuth e leitura de metadados sem escrever registos comerciais';
|
||||
|
||||
public function handle(SuiteCrmClient $client): int
|
||||
{
|
||||
try {
|
||||
$response = $client->fields((string) $this->option('module'));
|
||||
if (! isset($response['data']) || ! is_array($response['data']) || $response['data'] === []) {
|
||||
$this->error('Resposta sem metadados utilizaveis. Integracao nao validada.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
} catch (SuiteCrmException $exception) {
|
||||
$this->error('SuiteCRM indisponivel: '.$exception->reason);
|
||||
|
||||
return self::FAILURE;
|
||||
} catch (Throwable) {
|
||||
// Cache/database exceptions may contain secrets: never render their messages.
|
||||
$this->error('Falha interna no diagnostico. Verifique cache, chave da aplicacao e configuracao.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$this->info('OAuth e leitura de metadados confirmados. Nenhum registo comercial alterado.');
|
||||
$this->warn('Este teste nao valida permissoes de escrita, sincronizacao, reconciliacao ou prontidao para producao.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user