File: /var/www/matriculas_api_dev/app/Http/Controllers/WebhookGeneralController.php
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Services\WebhookService;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class WebhookGeneralController extends Controller
{
protected $webhookGeneralService;
public function __construct(WebhookService $webhookGeneralService)
{
$this->webhookGeneralService = $webhookGeneralService;
}
/**
* @OA\Post(
* path="/webhook-general",
* summary="Webhook General)",
* tags={"WebhookBF"},
* @OA\RequestBody(
* required=true,
* @OA\JsonContent(
* @OA\Property(property="event_type", type="string", example="customer.created"),
* @OA\Property(property="customer", type="object")
* )
* ),
* @OA\Response(response=200, description="Webhook procesado correctamente")
* )
*/
public function handle(Request $request)
{
try {
$data = $this->webhookGeneralService->handleWebhook($request);
return genericResponse(['data' => $data, 'message' => 'ok', 'code' => 200], 200);
} catch (Exception $e) {
$errorCode = $e->getCode();
return genericResponse(['error' => $e->getMessage()], $errorCode ? $errorCode : 500);
}
}
public function list()
{
try {
$data = $this->webhookGeneralService->list();
return genericResponse(['data' => $data, 'message' => 'ok', 'code' => 200], 200);
} catch (Exception $e) {
$errorCode = $e->getCode();
return genericResponse(['error' => $e->getMessage()], $errorCode ? $errorCode : 500);
}
}
}