- Fix storage permissions to use 'www' user instead of 'www-data' - Fix UserModel getAllForAdmin query to avoid placeholders in LIMIT/OFFSET - Import missing modules: Advertising, Dashboard, Analytics - Update deploy script to copy files to public directory
62 lines
1.6 KiB
PHP
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\ScriptBuilderIntegrationService;
|
|
|
|
/**
|
|
* Sync API Controller
|
|
*
|
|
* Handles synchronization API endpoints for Script Builder integration
|
|
*/
|
|
class SyncApiController extends BaseController
|
|
{
|
|
private ScriptBuilderIntegrationService $integrationService;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct('Advertising');
|
|
$this->integrationService = new ScriptBuilderIntegrationService();
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|
|
}
|