<?php

declare(strict_types=1);

namespace App\Infrastructure\Api\RapidMail;

use App\Framework\Http\Method;

final readonly class BlacklistService
{
    public function __construct(
        private RapidMailApiClient $apiClient
    ) {
    }

    /**
     * Holt die Blacklist
     */
    public function getAll(int $page = 1, int $perPage = 50): array
    {
        return $this->apiClient->request(Method::GET, 'blacklist', [], [
            'page' => $page,
            'per_page' => $perPage,
        ]);
    }

    /**
     * Fügt eine E-Mail zur Blacklist hinzu
     */
    public function add(string $email): array
    {
        return $this->apiClient->request(Method::POST, 'blacklist', ['email' => $email]);
    }

    /**
     * Entfernt eine E-Mail von der Blacklist
     */
    public function remove(int $blacklistId): void
    {
        $this->apiClient->sendRawRequest(Method::DELETE, "blacklist/{$blacklistId}");
    }
}
