<?php

namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;


use App\Classes\General\Interfaces\DataTransferObject;
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceCurrenciesConfigurations;
use App\Classes\ValueObjects\Constants\SegmentConstants;
use App\Models\SegmentConstant;
use App\Models\ServiceType;
use Illuminate\Support\Collection;

class ServiceConfigurationsObject implements DataTransferObject
{

    /** @var ServiceType */
    private $service;

    /** @var SegmentConstant  */
    private $configurations;

    /** @var Collection */
    private $customOptions;

    /**
     * ServiceConfigurationsObject constructor.
     * @param ServiceType $service
     * @param SegmentConstant $configurations
     * @param Collection $customOptions
     */
    public function __construct(ServiceType $service, SegmentConstant $configurations, Collection $customOptions)
    {
        $this->service = $service;
        $this->configurations = $configurations;
        $this->customOptions = $customOptions;
    }

    /**
     * @return ServiceType
     */
    public function getService(): ServiceType
    {
        return $this->service;
    }



    /**
     * @return SegmentConstant
     */
    public function getConfigurations(): SegmentConstant
    {
        return $this->configurations;
    }

    /**
     * @return Collection
     */
    public function getCustomOptions(): Collection
    {
        return $this->customOptions->map(function($value){
            return new CustomConfigurationsObject($this->getConfigurations(), $value);
        });
    }

    public function getBaseCurrencyRates(){
        return (App()->make(FetchesServiceCurrenciesConfigurations::class))->execute($this->configurations, SegmentConstants::SERVICE_TYPE);
    }


}