<?php

declare(strict_types=1);

namespace OCA\Mitgliederverwaltung\Db;

use JsonSerializable;
use OCP\AppFramework\Db\Entity;

/**
 * Stock item entity mapping all columns from oc_mv_inventory_stock_items.
 *
 * Part of Issue #165 (Inventory Tracking).
 *
 * @method int|null getId()
 * @method void setId(int $id)
 * @method string getName()
 * @method void setName(string $name)
 * @method string|null getProviderUrlsJson()
 * @method void setProviderUrlsJson(?string $providerUrlsJson)
 * @method string getCreatedAt()
 * @method void setCreatedAt(string $createdAt)
 * @method string getUpdatedAt()
 * @method void setUpdatedAt(string $updatedAt)
 */
class StockItem extends Entity implements JsonSerializable {

    protected int $id = 0;
    protected string $name = '';
    protected ?string $providerUrlsJson = null;
    protected string $createdAt = '';
    protected string $updatedAt = '';

    public function __construct() {
        $this->addType('id', 'integer');
    }

    public function jsonSerialize(): array {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'provider_urls_json' => $this->providerUrlsJson,
            'created_at' => $this->createdAt,
            'updated_at' => $this->updatedAt,
        ];
    }
}
