<?php

declare(strict_types=1);

namespace App\Application\Backend\RapidMail;

use App\Framework\Attributes\Route;
use App\Framework\Http\HttpResponse;
use App\Framework\Http\Response;
use App\Infrastructure\Api\RapidMail\Commands\UpdateRecipientCommand;
use App\Infrastructure\Api\RapidMail\RapidMailClient;
use App\Infrastructure\Api\RapidMail\RecipientId;

final readonly class Dashbord
{
    public function __construct(
        private RapidMailClient $rapidMailClient
    ) {
    }

    #[Route(path: '/rapidmail', name: 'rapidmail')]
    public function __invoke(): Response
    {
        $all = $this->rapidMailClient->recipients->get(RecipientId::fromInt(629237));
        #debug($all);


        #debug($all->email);

        $command = new UpdateRecipientCommand(
            $all->id,
            $all->email,
            'Test',
        );

        #$user = $this->rapidMailClient->recipients->updateWithCommand($command);

        #$user = $this->rapidMailClient->recipients->update(629237, Recipient::fromArray($array));

        #$data = $this->rapidMailClient->recipientLists->getAll(); //->get(776);

        #$name = $data[0]->name;

        #$data = $this->rapidMailClient->statistics->getMailingStats(776);

        #debug($user);

        return new HttpResponse(body: 'Hello World!');
        // TODO: Return proper response
    }
}
