<?php

namespace App\Classes\Modules\Companies\DataTransferObjects;

use App\Classes\General\Interfaces\DataTransferObject;

class EInvoiceInfoDTO implements DataTransferObject
{
    public string $tin;
    public string $msicCode;
    public int $districtId;
    public int $stateId;
    public int $companyId;
    public string $streetOne;
    public string $streetTwo;
    public string $postCode;

    public function __construct(array $data)
    {
        $this->tin = (string) ($data['tin'] ?? '');
        $this->msicCode = (string) ($data['msic_code'] ?? '');
        $this->districtId = (int) ($data['district_id'] ?? 0);
        $this->stateId = (int) ($data['state_id'] ?? 0);
        $this->companyId = (int) ($data['company_id'] ?? 0);
        $this->streetOne = (string) ($data['street_one'] ?? '');
        $this->streetTwo = (string) ($data['street_two'] ?? '');
        $this->postCode = (string) ($data['post_code'] ?? 0);
    }

    public function toArray(): array
    {
        return [
            'tin' => $this->tin,
            'msic_code' => $this->msicCode,
            'district_id' => $this->districtId,
            'state_id' => $this->stateId,
            'company_id' => $this->companyId,
            'street_one' => $this->streetOne,
            'street_two' => $this->streetTwo,
            'post_code' => $this->postCode,
        ];
    }
}
