<?php

declare(strict_types=1);

namespace OCA\Mitgliederverwaltung\Db;

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

/**
 * Address entity mapping all columns from oc_mv_addresses.
 *
 * @method int getMemberId()
 * @method void setMemberId(int $memberId)
 * @method string|null getLabel()
 * @method void setLabel(?string $label)
 * @method string getStrasse()
 * @method void setStrasse(string $strasse)
 * @method string getPlz()
 * @method void setPlz(string $plz)
 * @method string getOrt()
 * @method void setOrt(string $ort)
 * @method string getLand()
 * @method void setLand(string $land)
 * @method bool getIsPrimary()
 * @method void setIsPrimary(bool $isPrimary)
 */
class Address extends Entity implements JsonSerializable {

    protected int $memberId = 0;
    protected ?string $label = null;
    protected string $strasse = '';
    protected string $plz = '';
    protected string $ort = '';
    protected string $land = 'Deutschland';
    protected bool $isPrimary = false;

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

    public function jsonSerialize(): array {
        return [
            'id' => $this->id,
            'memberId' => $this->memberId,
            'label' => $this->label,
            'strasse' => $this->strasse,
            'plz' => $this->plz,
            'ort' => $this->ort,
            'land' => $this->land,
            'isPrimary' => $this->isPrimary,
        ];
    }
}
