diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 5e2315b..3bf853d 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -29,6 +29,7 @@ security: - { path: ^/$, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI - { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI docs - { path: ^/auth/login, roles: PUBLIC_ACCESS } + - { path: ^/og-lives/install/webhook, roles: PUBLIC_ACCESS } - { path: ^/auth/refresh, roles: PUBLIC_ACCESS } - { path: ^/, roles: IS_AUTHENTICATED_FULLY } diff --git a/src/Controller/OgBoot/OgLive/Webhook/InstallOgLiveResponseAction.php b/src/Controller/OgBoot/OgLive/Webhook/InstallOgLiveResponseAction.php new file mode 100644 index 0000000..caf97e6 --- /dev/null +++ b/src/Controller/OgBoot/OgLive/Webhook/InstallOgLiveResponseAction.php @@ -0,0 +1,36 @@ +getContent(), true); + + return new JsonResponse(data: ['hola caracola'], status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/OpenApi/OpenApiFactory.php b/src/OpenApi/OpenApiFactory.php index dc755c8..7b8a744 100644 --- a/src/OpenApi/OpenApiFactory.php +++ b/src/OpenApi/OpenApiFactory.php @@ -20,7 +20,8 @@ final readonly class OpenApiFactory implements OpenApiFactoryInterface $this->addRefreshToken($openApi); $this->addSearchEndpoint($openApi); - $this->addStatusEndpoint($openApi); // Agregar el nuevo endpoint + $this->addStatusEndpoint($openApi); + $this->addInstallOgLiveWebhookEndpoint($openApi); // Añadir aquí return $openApi; } @@ -175,4 +176,68 @@ final readonly class OpenApiFactory implements OpenApiFactoryInterface ->withSummary('Get service status') )); } + + private function addInstallOgLiveWebhookEndpoint(OpenApi $openApi): void + { + $openApi + ->getPaths() + ->addPath('/og-lives/install/webhook', (new Model\PathItem())->withPost( + (new Model\Operation('postInstallOgLiveWebhook')) + ->withTags(['OgLive']) + ->withResponses([ + Response::HTTP_OK => [ + 'description' => 'Webhook installation successful', + 'content' => [ + 'application/json' => [ + 'schema' => [ + 'type' => 'object', + 'properties' => [ + 'message' => [ + 'type' => 'string', + 'example' => 'Webhook installed successfully', + ], + ], + ], + ], + ], + ], + Response::HTTP_BAD_REQUEST => [ + 'description' => 'Invalid request data', + 'content' => [ + 'application/json' => [ + 'schema' => [ + 'type' => 'object', + 'properties' => [ + 'error' => [ + 'type' => 'string', + 'example' => 'Invalid input data', + ], + ], + ], + ], + ], + ], + ]) + ->withSummary('Install a webhook for OgLive') + ->withRequestBody( + (new Model\RequestBody()) + ->withDescription('Data required for installing the webhook') + ->withContent(new \ArrayObject([ + 'application/json' => new Model\MediaType(new \ArrayObject([ + 'type' => 'object', + 'properties' => [ + 'da' => [ + 'type' => 'string', + 'description' => 'The URL to set for the webhook', + 'example' => 'https://example.com/webhook', + ], + ], + 'required' => ['url'], + ])) + ])) + ->withRequired(true) + ) + )); + } + } \ No newline at end of file