<?php

namespace Opencart\Extension\Alsendo\Models;

class SenderAddressTemplate
{
    private ?int $id;
    private ?string $externalId;
    private string $addressType;
    private string $companyName;
    private string $firstName;
    private string $lastName;
    private string $fullName;
    private ?string $street;
    private string $buildingNumber;
    private ?string $apartmentNumber;
    private ?string $block;
    private ?string $entrance;
    private ?string $floor;
    private string $postalCode;
    private string $city;
    private string $contactPerson;
    private string $phoneNumber;
    private string $email;
    private string $bankAccountNumber;
    private ?string $bankCode;
    private ?string $additionalBankAccountNumber;
    private bool $main;
    private ?array $pickupPoint = null;
    private string $country;

    public function __construct(
        ?int $id = null,
        ?string $externalId = null,
        string $addressType = 'company',
        string $companyName = '',
        string $firstName = '',
        string $lastName = '',
        string $fullName = '',
        ?string $street = null,
        string $buildingNumber = '',
        ?string $apartmentNumber = null,
        ?string $block = null,
        ?string $entrance = null,
        ?string $floor = null,
        string $postalCode = '',
        string $city = '',
        string $country = '',
        string $contactPerson = '',
        string $phoneNumber = '',
        string $email = '',
        string $bankAccountNumber = '',
        ?string $bankCode = null,
        ?string $additionalBankAccountNumber = null,
        bool $main = false,
        ?string $pickupPoint = null,
    ) {
        $this->id = $id;
        $this->externalId = $externalId;
        $this->addressType = $addressType;
        $this->companyName = $companyName;
        $this->firstName = $firstName;
        $this->lastName = $lastName;
        $this->fullName = $fullName;
        $this->street = $street;
        $this->buildingNumber = $buildingNumber;
        $this->apartmentNumber = $apartmentNumber;
        $this->block = $block;
        $this->entrance = $entrance;
        $this->floor = $floor;
        $this->postalCode = $postalCode;
        $this->city = $city;
        $this->contactPerson = $contactPerson;
        $this->phoneNumber = $phoneNumber;
        $this->email = $email;
        $this->bankAccountNumber = $bankAccountNumber;
        $this->bankCode = $bankCode;
        $this->additionalBankAccountNumber = $additionalBankAccountNumber;
        $this->main = $main;
        $this->country = $country;

        if (!empty($pickupPoint)) {
            $this->pickupPoint = json_decode($pickupPoint, true);
        }

    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getExternalId(): ?string
    {
        return $this->externalId;
    }

    public function setExternalId(?string $externalId): void
    {
        $this->externalId = $externalId;
    }

    public function setId(int $id): void
    {
        $this->id = $id;
    }

    public function getCompanyName(): string
    {
        return $this->companyName;
    }

    public function setCompanyName(string $companyName): void
    {
        $this->companyName = $companyName;
    }

    public function getFullName(): string
    {
        return $this->fullName;
    }

    public function setFullName(string $fullName): void
    {
        $this->fullName = $fullName;
    }

    public function getCountry(): string
    {
        return $this->country;
    }

    public function setCountry(string $country): void
    {
        $this->country = $country;
    }

    public function getFirstName(): string
    {
        return $this->firstName;
    }

    public function setFirstName(string $firstName): void
    {
        $this->firstName = $firstName;
    }

    public function getLastName(): string
    {
        return $this->lastName;
    }

    public function setLastName(string $lastName): void
    {
        $this->lastName = $lastName;
    }

    public function getStreet(): ?string
    {
        return $this->street;
    }

    public function setStreet(?string $street): void
    {
        $this->street = $street;
    }

    public function getBuildingNumber(): string
    {
        return $this->buildingNumber;
    }

    public function setBuildingNumber(string $buildingNumber): void
    {
        $this->buildingNumber = $buildingNumber;
    }

    public function getApartmentNumber(): ?string
    {
        return $this->apartmentNumber;
    }

    public function setApartmentNumber(?string $apartmentNumber): void
    {
        $this->apartmentNumber = $apartmentNumber;
    }

    public function getBlock(): ?string
    {
        return $this->block;
    }

    public function setBlock(?string $block): void
    {
        $this->block = $block;
    }

    public function getEntrance(): ?string
    {
        return $this->entrance;
    }

    public function setEntrance(?string $entrance): void
    {
        $this->entrance = $entrance;
    }

    public function getFloor(): ?string
    {
        return $this->floor;
    }

    public function setFloor(?string $floor): void
    {
        $this->floor = $floor;
    }

    public function getPostalCode(): string
    {
        return $this->postalCode;
    }

    public function setPostalCode(string $postalCode): void
    {
        $this->postalCode = $postalCode;
    }

    public function getAddressType(): string
    {
        return $this->addressType;
    }

    public function setAddressType(string $addressType): void
    {
        $this->addressType = $addressType;
    }

    public function getCity(): string
    {
        return $this->city;
    }

    public function setCity(string $city): void
    {
        $this->city = $city;
    }

    public function getContactPerson(): string
    {
        return $this->contactPerson;
    }

    public function setContactPerson(string $contactPerson): void
    {
        $this->contactPerson = $contactPerson;
    }

    public function getPhoneNumber(): string
    {
        return $this->phoneNumber;
    }

    public function setPhoneNumber(string $phoneNumber): void
    {
        $this->phoneNumber = $phoneNumber;
    }

    public function getEmail(): string
    {
        return $this->email;
    }

    public function setEmail(string $email): void
    {
        $this->email = $email;
    }

    public function getBankAccountNumber(): string
    {
        return $this->bankAccountNumber;
    }

    public function setBankAccountNumber(string $bankAccountNumber): void
    {
        $this->bankAccountNumber = $bankAccountNumber;
    }

    public function getBankCode(): ?string
    {
        return $this->bankCode;
    }

    public function setBankCode(?string $bankCode): void
    {
        $this->bankCode = $bankCode;
    }

    public function getAdditionalBankAccountNumber(): ?string
    {
        return $this->additionalBankAccountNumber;
    }

    public function setAdditionalBankAccountNumber(?string $additionalBankAccountNumber): void
    {
        $this->additionalBankAccountNumber = $additionalBankAccountNumber;
    }

    public function isMain(): bool
    {
        return $this->main;
    }

    public function setMain(bool $main): void
    {
        $this->main = $main;
    }

    public function isComplete(): bool
    {
        return !empty($this->companyName) &&
               !empty($this->fullName) &&
               !empty($this->buildingNumber) &&
               !empty($this->postalCode) &&
               !empty($this->city) &&
               !empty($this->contactPerson) &&
               !empty($this->phoneNumber) &&
               !empty($this->email) &&
               !empty($this->bankAccountNumber);
    }

    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'external_id' => $this->externalId,
            'address_type' => $this->addressType,
            'company_name' => $this->companyName,
            'first_name' => $this->firstName,
            'last_name' => $this->lastName,
            '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,
            'contact_person' => $this->contactPerson,
            'phone_number' => $this->phoneNumber,
            'email' => $this->email,
            'bank_account_number' => $this->bankAccountNumber,
            'bank_code' => $this->bankCode,
            'additional_bank_account_number' => $this->additionalBankAccountNumber,
            'main' => $this->main,
            'pickup_point' => $this->pickupPoint,
            'country' => $this->country,
        ];
    }
} 