<?php

namespace Opencart\Extension\Alsendo\Providers;

use Opencart\Extension\Alsendo\Repositories\SenderAddressRepository;

class SenderAddressDataProvider
{
    private SenderAddressRepository $senderAddressRepository;

    public function __construct(SenderAddressRepository $senderAddressRepository)
    {
        $this->senderAddressRepository = $senderAddressRepository;
    }

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

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