Files
MoneyFlix/crm/Modules/Advertising/Controllers/Api/SyncApiController.php
1sonhador 831145b2c4 refactor: Remove ScriptBuilderService from MoneyFlix
- Remove ScriptBuilderService and ScriptBuilderIntegrationService (CRM-specific)
- Update controllers to use GoogleSheetsService instead
- Disable script generation/deployment functionality temporarily
- Fix creative count TODO in AdvertisingController
- Clean up module service registrations
- Restore clean User Views files

ScriptBuilder functionality is specific to the main CRM and not needed for MoneyFlix.
2025-10-28 16:18:30 +00:00

62 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Modules\Advertising\Controllers\Api;
use App\Core\BaseController;
use App\Modules\Advertising\Services\GoogleSheetsService;
/**
* Sync API Controller
*
* Handles synchronization API endpoints for Script Builder integration
*/
class SyncApiController extends BaseController
{
private GoogleSheetsService $integrationService;
public function __construct()
{
parent::__construct('Advertising');
$this->integrationService = new GoogleSheetsService();
}
/**
* Sync from Google Sheets to CRM
* Called by Script Builder via cron
*/
public function syncFromSheets(): void
{
try {
$results = $this->integrationService->syncFromGoogleSheets();
$this->jsonResponse([
'success' => true,
'message' => 'Synchronization completed successfully',
'data' => $results
], 200);
} catch (\Exception $e) {
$this->errorResponse('Synchronization failed: ' . $e->getMessage(), 500);
}
}
/**
* Get sync status and statistics
*/
public function getSyncStats(): void
{
try {
$stats = $this->integrationService->getSyncStats();
$this->jsonResponse([
'success' => true,
'data' => $stats
], 200);
} catch (\Exception $e) {
$this->errorResponse('Failed to get sync stats: ' . $e->getMessage(), 500);
}
}
}