<?php

namespace FSPoster\App\TelegramNotification\App\Mappers;

use FSPoster\App\Providers\DB\Collection;
use FSPoster\App\TelegramNotification\App\DTOs\Response\TelegramNotificationResponse;

class TelegramNotificationMapper
{
    public function toAvailableChannel(Collection $channel): array
    {
        return [
            'id'   => (int) $channel->id,
            'name' => $channel->name,
        ];
    }

    public function toResponse(array $data, array $shortCodes, array $availableChannels, bool $isActive): TelegramNotificationResponse
    {
        $response = new TelegramNotificationResponse();

        $response->setChannels($data['channels'] ?? []);
        $response->setMessage($data['message'] ?? '');
        $response->setShortCodes($shortCodes);
        $response->setAvailableChannels($availableChannels);
        $response->setIsActive($isActive);

        return $response;
    }
}
