<?php
declare (strict_types=1);

namespace App\ApiResources\Mobyt;

use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use App\ApiResources\ApiResourcesInterface;
use App\State\Provider\Mobyt\MobytUserStatusProvider;

/**
 * Statut de l'utilisateur Mobyt correspondant à l'organization donnée en paramètre
 */
#[ApiResource(
    operations: [
        new Get(
            uriTemplate: '/mobyt/status/{organizationId}',
            requirements: ['organizationId' => '\\d+'],
            security: '(is_granted("ROLE_ADMIN_CORE") or
                            is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE") or
                            is_granted("ROLE_PEDAGOGICS_MANAGER_CORE") or
                            is_granted("ROLE_FINANCIAL_MANAGER_CORE") or
                            is_granted("ROLE_TEXTO")
                           ) and object.getOrganizationId() == user.getOrganization().getId()',
            provider: MobytUserStatusProvider::class
        )
    ]
)]
class MobytUserStatus implements ApiResourcesInterface
{
    #[ApiProperty(identifier: true)]
    private int $organizationId;

    /**
     * Is there a Mobyt account active for this user
     */
    private bool $active = false;

    /**
     * Amount of sms remaining
     */
    private int $amount = 0;

    /**
     * Money remaining
     */
    private float $money = 0;

    public function getOrganizationId(): int
    {
        return $this->organizationId;
    }

    public function setOrganizationId(int $organizationId): void
    {
        $this->organizationId = $organizationId;
    }

    public function isActive(): bool
    {
        return $this->active;
    }

    public function setActive(bool $active): void
    {
        $this->active = $active;
    }

    public function getAmount(): int
    {
        return $this->amount;
    }

    public function setAmount(int $amount): void
    {
        $this->amount = $amount;
    }

    public function getMoney(): float
    {
        return $this->money;
    }

    public function setMoney(float $money): void
    {
        $this->money = $money;
    }
}
