<?php
/**
 * @author Daniel Knudsen <d.knudsen@spawntree.de>
 * @date 12.12.23
 */


namespace App\ApiResource;

use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Doctrine\Orm\State\Options;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\Comment;
use App\Interface\OwnerInterface;
use App\State\EntityClassDtoStateProcessor;
use App\State\EntityToDtoStateProvider;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use App\State\SaleSummaryStateProvider;
use App\Validator\IsValidOwner;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Validator\Constraints\NotBlank;

#[ApiResource(
    shortName: 'SaleSummary',
    operations: [
        new Get(),
        new GetCollection(),
    ],
    security: 'is_granted("ROLE_USER")',
    provider: SaleSummaryStateProvider::class,
)]
class SaleSummary
{
    #[ApiProperty(identifier: true)]
    public int $userId;

    /**
     * @param int $userId
     */
    public function __construct(int $userId)
    {
        $this->userId = $userId;
    }

    /**
     * @var $owner ?UserApi
     */
    #[ApiProperty(
        writable: false,
        readableLink: true,
        writableLink: false,
        builtinTypes: [
            new Type(
                'object',
                class: UserApi::class,
            )
        ]
    )]
    public ?UserApi $owner = null;

    public ?int $turnover = null;

    public ?int $profit = null;


}