package fr.titionfire.ffsaf.net2.request;

import fr.titionfire.ffsaf.net2.Client_Thread;
import fr.titionfire.ffsaf.net2.data.SimpleCompet;
import fr.titionfire.ffsaf.utils.JsonConsumer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.CompletableFuture;

public class SReqCompet {

    public static void sendUpdate(ArrayList<Client_Thread> client_Thread, SimpleCompet compet) {
        for (Client_Thread client : client_Thread) {
            client.sendNotify(compet, "sendConfig");
        }
    }

    public static void getConfig(ArrayList<Client_Thread> client_Thread, long id_compet,
                                 CompletableFuture<SimpleCompet> future) {
        if (client_Thread.isEmpty()) return;
        client_Thread.get(0).sendReq(id_compet, "getConfig",
                new JsonConsumer<>(SimpleCompet.class, future::complete));
    }

    public static void getAllHaveAccess(ArrayList<Client_Thread> client_Thread, String userId,
                                 CompletableFuture<HashMap<String, String>> future) {
        if (client_Thread.isEmpty()) return;
        client_Thread.get(0).sendReq(userId, "getAllHaveAccess",
                new JsonConsumer<>(HashMap.class, future::complete));
    }

    public static void rmCompet(ArrayList<Client_Thread> client_Thread, long id_compet) {
        for (Client_Thread client : client_Thread) {
            client.sendNotify(id_compet, "rmCompet");
        }
    }


}
