<?php

declare(strict_types=1);

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Commerce\Catalog\Api\Resource;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use CpCreation\VitiCore\Commerce\Catalog\Api\State\CatalogInstanceProvider;

#[ApiResource(
    operations: [
        new Get(
            uriTemplate: '/commerce/v1/instance',
            uriVariables: [],
            stateless: true,
            security: 'is_granted("ROLE_COMMERCE_SYNC")',
            provider: CatalogInstanceProvider::class,
            name: 'viti_commerce_instance_get',
        ),
    ],
    formats: ['json' => ['application/json']],
    normalizationContext: ['skip_null_values' => false],
)]
final readonly class CatalogInstanceResource
{
    /**
     * @param list<string> $locales
     * @param list<string> $capabilities
     */
    public function __construct(
        public string $schema_version,
        #[ApiProperty(identifier: true)]
        public string $instance_id,
        public string $generated_at,
        public CatalogSeller $seller,
        public array $locales,
        public string $currency,
        public array $capabilities,
    ) {}
}
