<?php

namespace Opencart\Extension\Alsendo\DTO\ConfigurationRequests;

require_once(DIR_EXTENSION . 'alsendo/src/DTO/ConfigurationRequests/CoreConfigurationRequestDTO.php');

class UpdateSenderTemplateRequestDTO
{
    public ?int $id = null;
    public ?string $companyName = null;
    public ?string $fullName = null;
    public ?string $street = null;
    public ?string $buildingNumber = null;
    public ?string $apartmentNumber = null;
    public ?string $block = null;
    public ?string $entrance = null;
    public ?string $floor = null;
    public ?string $postalCode = null;
    public ?string $city = null;
    public ?string $country = null;
    public ?string $phoneNumber = null;
    public ?string $email = null;
    public ?string $bankAccountNumber = null;
    public ?string $bankCode = null;
    public ?string $additionalBankAccountNumber = null;
    public ?string $addressType = null;
    public ?string $externalId = null;

    public static function fromCoreConfigurationRequestDTO(CoreConfigurationRequestDTO $coreDto): self
    {
        $dto = new self();
        $dto->id = $coreDto->id;
        $dto->companyName = $coreDto->companyName;
        $dto->fullName = $coreDto->fullName;
        $dto->street = $coreDto->street;
        $dto->buildingNumber = $coreDto->buildingNumber;
        $dto->apartmentNumber = $coreDto->apartmentNumber;
        $dto->block = $coreDto->block;
        $dto->entrance = $coreDto->entrance;
        $dto->floor = $coreDto->floor;
        $dto->postalCode = $coreDto->postalCode;
        $dto->city = $coreDto->city;
        $dto->country = $coreDto->country;
        $dto->phoneNumber = $coreDto->phoneNumber;
        $dto->email = $coreDto->email;
        $dto->bankAccountNumber = $coreDto->bankAccountNumber;
        $dto->bankCode = $coreDto->bankCode;
        $dto->additionalBankAccountNumber = $coreDto->additionalBankAccountNumber;
        $dto->addressType = $coreDto->addressType;
        $dto->externalId = $coreDto->externalId;
        return $dto;
    }

    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'company_name' => $this->companyName,
            'full_name' => $this->fullName,
            'street' => $this->street,
            'building_number' => $this->buildingNumber,
            'apartment_number' => $this->apartmentNumber,
            'block' => $this->block,
            'entrance' => $this->entrance,
            'floor' => $this->floor,
            'postal_code' => $this->postalCode,
            'city' => $this->city,
            'country' => $this->country,
            'phone_number' => $this->phoneNumber,
            'email' => $this->email,
            'bank_account_number' => $this->bankAccountNumber,
            'bank_code' => $this->bankCode,
            'additional_bank_account_number' => $this->additionalBankAccountNumber,
            'address_type' => $this->addressType,
            'external_id' => $this->externalId,
        ];
    }
}
