<?php

namespace Opencart\Extension\Alsendo\Providers;

use Opencart\Extension\Alsendo\Models\Config;

class CommonDataProvider
{
    private object $language;
    private object $url;
    private object $session;

    public function __construct(
        object $language,
        object $url,
        object $session,
    ) {
        $this->language = $language;
        $this->url = $url;
        $this->session = $session;
    }

    public function getData(Config $config): array
    {
        return [
            'current_region' => $config->getRegion(),
            'current_app_id' => $config->getAppId(),
            'current_app_secret' => $config->getAppSecret(),
            'current_token' => $config->getToken(),
            'current_api_key' => $config->getApiKey(),
            'current_ro_client_id' => $config->getRoClientId(),
            'current_ro_client_secret' => $config->getRoClientSecret(),
            'current_sandbox' => $config->getSandbox(),
            'current_ro_sandbox' => $config->getRoSandbox(),
            'current_cz_sandbox' => $config->getCzSandbox(),
            'current_ro_auth_state_key' => !empty($config->getRoClientSecret()) ? md5(substr($config->getRoClientSecret(), 0, 10)) : '',
            'regions' => [
                'poland' => $this->language->get('text_region_poland'),
                'czechia' => $this->language->get('text_region_czechia'),
                'romania' => $this->language->get('text_region_romania')
            ],
            'save_region_url' => $this->url->link('extension/alsendo/module/alsendo', 'user_token=' . $this->session->data['user_token']),
            'user_token' => $this->session->data['user_token'],
        ];
    }
} 