<?php

namespace Opencart\Extension\Alsendo\Providers;

use Opencart\Extension\Alsendo\Repositories\ShippingSettingsRepository;

class ShippingSettingsDataProvider
{
    private ShippingSettingsRepository $shippingSettingsRepository;

    public function __construct(ShippingSettingsRepository $shippingSettingsRepository)
    {
        $this->shippingSettingsRepository = $shippingSettingsRepository;
    }

    public function getData(): array
    {
        $templates = $this->shippingSettingsRepository->getAllTemplates();
        $hasMain = $this->shippingSettingsRepository->hasMainTemplate();

        return [
            'shipping_settings_templates' => array_map(function($template) {
                return $template->toArray();
            }, $templates),
            'has_main_shipping_template' => $hasMain
        ];
    }
} 