<?php

namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;

use App\Classes\General\Interfaces\DataTransferObject;

class ServiceDetailObject implements DataTransferObject
{

    /** @var int */
    private $id;

    /** @var int|null */
    private $bankId;

    /** @var array|null */
    private $serviceCharge;

    /** @var array|null */
    private $minimumCharge;

    /** @var array|null */
    private $tax;

    /** @var array|null */
    private $poLimit;

    /** @var array|null */
    private $currencies;

    /** @var boolean */
    private $isActive;

    /** @var boolean */
    private $isBillable;

    /**
     * ServiceDetailObject constructor.
     * @param int $id
     * @param int|null $bankId
     * @param array|null $serviceCharge
     * @param array|null $minimumCharge
     * @param array|null $tax
     * @param array|null $poLimit
     * @param array|null $currencies
     * @param bool $isActive
     * @param bool $isBillable
     */
    public function __construct(int $id, ?int $bankId, ?array $serviceCharge, ?array $minimumCharge, ?array $tax, ?array $poLimit, ?array $currencies, bool $isActive, bool $isBillable)
    {
        $this->id = $id;
        $this->bankId = $bankId;
        $this->serviceCharge = $serviceCharge;
        $this->minimumCharge = $minimumCharge;
        $this->tax = $tax;
        $this->poLimit = $poLimit;
        $this->currencies = $currencies;
        $this->isActive = $isActive;
        $this->isBillable = $isBillable;
    }

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

    /**
     * @return int|null
     */
    public function getBankId(): ?int
    {
        return $this->bankId;
    }

    /**
     * @return array|null
     */
    public function getServiceCharge(): ?array
    {
        return $this->serviceCharge;
    }

    /**
     * @return array|null
     */
    public function getMinimumCharge(): ?array
    {
        return $this->minimumCharge;
    }

    /**
     * @return array|null
     */
    public function getTax(): ?array
    {
        return $this->tax;
    }

    /**
     * @return array|null
     */
    public function getPoLimit(): ?array
    {
        return $this->poLimit;
    }

    /**
     * @return bool
     */
    public function isActive(): bool
    {
        return $this->isActive;
    }

    /**
     * @return bool
     */
    public function isBillable(): bool
    {
        return $this->isBillable;
    }


    /**
     * @return array|null
     */
    public function getCurrencies(): ?array
    {
        return array_map(function($currency){
            return new ServiceCurrenciesObject($currency['id'], $currency['active'], $currency['maximum_limit'], $currency['minimum_limit'], $currency['rates']);
        }, $this->currencies);
    }


}