Update postman collection
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -75,9 +75,8 @@ function bodyFor(string $method, string $uri): ?array
|
|||||||
'POST api/clients' => ['code' => 'cliente-demo', 'name' => 'Cliente Demo'],
|
'POST api/clients' => ['code' => 'cliente-demo', 'name' => 'Cliente Demo'],
|
||||||
'PUT api/clients/{client}' => ['code' => 'cliente-demo', 'name' => 'Cliente Demo Actualizado'],
|
'PUT api/clients/{client}' => ['code' => 'cliente-demo', 'name' => 'Cliente Demo Actualizado'],
|
||||||
'PATCH api/clients/{client}' => ['name' => 'Cliente Demo Actualizado'],
|
'PATCH api/clients/{client}' => ['name' => 'Cliente Demo Actualizado'],
|
||||||
'POST api/integrations' => ['integration_code' => 'telepagos', 'name' => 'Telepagos', 'url' => 'https://api.example.com', 'integration_data_schema' => ['api_key' => ['required', 'string']], 'requires_client_configuration' => true],
|
|
||||||
'PUT api/integrations/{integration}' => ['name' => 'Telepagos', 'url' => 'https://api.example.com', 'requires_client_configuration' => true],
|
|
||||||
'PUT api/clients/{client}/integrations/{integration_code}' => ['integration_data' => ['api_key' => 'replace-me']],
|
'PUT api/clients/{client}/integrations/{integration_code}' => ['integration_data' => ['api_key' => 'replace-me']],
|
||||||
|
'PUT api/website-types/{websiteType:codigo}/integrations/{integration_code}' => ['integration_data' => ['api_key' => 'replace-me']],
|
||||||
'POST api/menues' => ['code' => 'demo', 'label' => 'Demo', 'parent_menu_code' => null, 'content_type' => 'static', 'static_content_schema' => ['title' => ['required', 'string']], 'route' => '/demo'],
|
'POST api/menues' => ['code' => 'demo', 'label' => 'Demo', 'parent_menu_code' => null, 'content_type' => 'static', 'static_content_schema' => ['title' => ['required', 'string']], 'route' => '/demo'],
|
||||||
'PUT api/menues/{menue}' => ['label' => 'Demo actualizado', 'route' => '/demo'],
|
'PUT api/menues/{menue}' => ['label' => 'Demo actualizado', 'route' => '/demo'],
|
||||||
'PATCH api/menues/{menue}' => ['label' => 'Demo actualizado'],
|
'PATCH api/menues/{menue}' => ['label' => 'Demo actualizado'],
|
||||||
@@ -276,7 +275,8 @@ function requestName(string $method, string $action, bool $multiMethod): string
|
|||||||
function pathFor(string $uri): string
|
function pathFor(string $uri): string
|
||||||
{
|
{
|
||||||
$variables = [
|
$variables = [
|
||||||
'tenant:codigo' => 'tenant_code', 'tenant' => 'tenant_id', 'client' => 'client_id',
|
'tenant:codigo' => 'tenant_code', 'tenant' => 'tenant_id', 'client' => 'client_code',
|
||||||
|
'websiteType:codigo' => 'website_type_code',
|
||||||
'integration_code' => 'integration_code', 'integration' => 'integration_id', 'menue' => 'menu_id',
|
'integration_code' => 'integration_code', 'integration' => 'integration_id', 'menue' => 'menu_id',
|
||||||
'menu_code' => 'menu_code', 'tenant_code' => 'tenant_code', 'catalogItem' => 'catalog_item_id',
|
'menu_code' => 'menu_code', 'tenant_code' => 'tenant_code', 'catalogItem' => 'catalog_item_id',
|
||||||
'featuredGroup' => 'featured_group_id', 'category' => 'category_id', 'cartItem' => 'cart_item_id',
|
'featuredGroup' => 'featured_group_id', 'category' => 'category_id', 'cartItem' => 'cart_item_id',
|
||||||
@@ -331,6 +331,111 @@ function tokenCaptureEvent(string $uri): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return array<string, array{name: string, description: string, integration_data: array<string, mixed>}> */
|
||||||
|
function integrationConfigurationPresets(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email' => [
|
||||||
|
'name' => 'Email (SMTP)',
|
||||||
|
'description' => 'Configura el transporte SMTP usado para el envío de correos.',
|
||||||
|
'integration_data' => [
|
||||||
|
'MAIL_MAILER' => 'smtp',
|
||||||
|
'MAIL_SCHEME' => 'smtp',
|
||||||
|
'MAIL_HOST' => 'smtp.example.com',
|
||||||
|
'MAIL_PORT' => 587,
|
||||||
|
'MAIL_USERNAME' => 'usuario@example.com',
|
||||||
|
'MAIL_PASSWORD' => 'replace-me',
|
||||||
|
'MAIL_FROM_ADDRESS' => 'no-reply@example.com',
|
||||||
|
'MAIL_FROM_NAME' => 'ShopIt',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'telepagos' => [
|
||||||
|
'name' => 'Telepagos Producción',
|
||||||
|
'description' => 'Configura las credenciales productivas de Telepagos.',
|
||||||
|
'integration_data' => [
|
||||||
|
'username' => 'replace-me',
|
||||||
|
'password' => 'replace-me',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'telepagos_homo' => [
|
||||||
|
'name' => 'Telepagos Homologación',
|
||||||
|
'description' => 'Configura las credenciales del entorno de homologación de Telepagos.',
|
||||||
|
'integration_data' => [
|
||||||
|
'username' => 'replace-me',
|
||||||
|
'password' => 'replace-me',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<int, array<string, mixed>> $requests
|
||||||
|
* @return array<int, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
function integrationOwnerFolders(array $requests): array
|
||||||
|
{
|
||||||
|
$owners = [
|
||||||
|
'Client' => '/api/clients/',
|
||||||
|
'Website Type' => '/api/website-types/',
|
||||||
|
];
|
||||||
|
$folders = [];
|
||||||
|
|
||||||
|
foreach ($owners as $ownerName => $pathFragment) {
|
||||||
|
$ownerRequests = array_values(array_filter(
|
||||||
|
$requests,
|
||||||
|
fn (array $item): bool => str_contains($item['request']['url']['raw'], $pathFragment),
|
||||||
|
));
|
||||||
|
$putTemplate = null;
|
||||||
|
foreach ($ownerRequests as $ownerRequest) {
|
||||||
|
if ($ownerRequest['request']['method'] === 'PUT') {
|
||||||
|
$putTemplate = $ownerRequest;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($putTemplate === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($ownerRequests as &$request) {
|
||||||
|
if ($request['request']['method'] === 'PUT') {
|
||||||
|
$request['name'] = 'Configure Integration (generic)';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($request);
|
||||||
|
|
||||||
|
$ownerItems = [[
|
||||||
|
'name' => 'Management',
|
||||||
|
'description' => 'Consulta, configura o desvincula cualquier integración usando `{{integration_code}}`.',
|
||||||
|
'item' => $ownerRequests,
|
||||||
|
]];
|
||||||
|
|
||||||
|
foreach (integrationConfigurationPresets() as $integrationCode => $preset) {
|
||||||
|
$request = $putTemplate;
|
||||||
|
$request['name'] = 'Configure '.$preset['name'];
|
||||||
|
$request['request']['description'] .= "\n\nPreset: `{$integrationCode}`. {$preset['description']}";
|
||||||
|
$request['request']['url']['raw'] = str_replace('{{integration_code}}', $integrationCode, $request['request']['url']['raw']);
|
||||||
|
$request['request']['url']['path'] = array_map(
|
||||||
|
fn (string $segment): string => $segment === '{{integration_code}}' ? $integrationCode : $segment,
|
||||||
|
$request['request']['url']['path'],
|
||||||
|
);
|
||||||
|
$request['request']['body'] = jsonBody(['integration_data' => $preset['integration_data']]);
|
||||||
|
|
||||||
|
$ownerItems[] = [
|
||||||
|
'name' => $preset['name'],
|
||||||
|
'description' => $preset['description'],
|
||||||
|
'item' => [$request],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$folders[] = [
|
||||||
|
'name' => $ownerName,
|
||||||
|
'item' => $ownerItems,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $folders;
|
||||||
|
}
|
||||||
|
|
||||||
$tree = [];
|
$tree = [];
|
||||||
$registeredOperations = 0;
|
$registeredOperations = 0;
|
||||||
|
|
||||||
@@ -412,7 +517,9 @@ $items = [];
|
|||||||
foreach ($tree as $section => $folders) {
|
foreach ($tree as $section => $folders) {
|
||||||
$children = [];
|
$children = [];
|
||||||
foreach ($folders as $folder => $requests) {
|
foreach ($folders as $folder => $requests) {
|
||||||
$children[] = ['name' => humanize($folder), 'item' => $requests];
|
$children[] = $section === 'Platform Management' && $folder === 'Integration'
|
||||||
|
? ['name' => 'Integration', 'item' => integrationOwnerFolders($requests)]
|
||||||
|
: ['name' => humanize($folder), 'item' => $requests];
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[] = [
|
$items[] = [
|
||||||
@@ -430,7 +537,8 @@ $variables = [
|
|||||||
'admin_email' => 'admin@example.com', 'admin_password' => 'Password!123',
|
'admin_email' => 'admin@example.com', 'admin_password' => 'Password!123',
|
||||||
'scanner_email' => 'scanner@example.com', 'scanner_password' => 'Password!123',
|
'scanner_email' => 'scanner@example.com', 'scanner_password' => 'Password!123',
|
||||||
'tenant_code' => 'demo', 'tenant_id' => '1', 'tenant_domain' => 'demo.test',
|
'tenant_code' => 'demo', 'tenant_id' => '1', 'tenant_domain' => 'demo.test',
|
||||||
'client_id' => '1', 'integration_id' => '1', 'integration_code' => 'telepagos',
|
'client_id' => '1', 'client_code' => 'cliente-demo', 'website_type_code' => 'shopit',
|
||||||
|
'integration_code' => 'telepagos',
|
||||||
'menu_id' => '1', 'menu_code' => 'demo', 'catalog_item_id' => '1', 'variant_id' => '1',
|
'menu_id' => '1', 'menu_code' => 'demo', 'catalog_item_id' => '1', 'variant_id' => '1',
|
||||||
'category_id' => '1', 'featured_group_id' => '1', 'cart_id' => '1', 'cart_item_id' => '1',
|
'category_id' => '1', 'featured_group_id' => '1', 'cart_id' => '1', 'cart_item_id' => '1',
|
||||||
'purchase_id' => '1', 'purchase_item_id' => '1', 'sale_id' => '1', 'staff_id' => '1',
|
'purchase_id' => '1', 'purchase_item_id' => '1', 'sale_id' => '1', 'staff_id' => '1',
|
||||||
@@ -444,7 +552,7 @@ $collection = [
|
|||||||
'info' => [
|
'info' => [
|
||||||
'_postman_id' => '76fd6fd2-53b9-4d92-8e02-1ddcc6207fa2',
|
'_postman_id' => '76fd6fd2-53b9-4d92-8e02-1ddcc6207fa2',
|
||||||
'name' => 'ShopIt API — Complete',
|
'name' => 'ShopIt API — Complete',
|
||||||
'description' => "Colección canónica generada desde las rutas reales de Laravel. Incluye {$registeredOperations} operaciones HTTP, ejemplos de payload, filtros, archivos y tokens separados para Storefront, Admin App y Scanner.\n\nUso rápido:\n1. Ajustá `base_url` y las credenciales.\n2. Ejecutá el Login de la aplicación correspondiente; el token se guarda automáticamente.\n3. Ajustá los IDs y códigos de las variables de colección.\n\nRegeneración: `php postman/generate-shopit-collection.php`.",
|
'description' => "Colección canónica generada desde las rutas reales de Laravel. Incluye {$registeredOperations} operaciones HTTP, presets de configuración para cada integración, ejemplos de payload, filtros, archivos y tokens separados para Storefront, Admin App y Scanner.\n\nUso rápido:\n1. Ajustá `base_url` y las credenciales.\n2. Ejecutá el Login de la aplicación correspondiente; el token se guarda automáticamente.\n3. Ajustá los IDs y códigos de las variables de colección.\n\nRegeneración: `php postman/generate-shopit-collection.php`.",
|
||||||
'schema' => 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',
|
'schema' => 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',
|
||||||
],
|
],
|
||||||
'item' => $items,
|
'item' => $items,
|
||||||
|
|||||||
Reference in New Issue
Block a user