package com.kospo.talk.config.flux;

import com.kospo.talk.payload.PushDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

import java.util.List;
import java.util.Map;

@Component
public class FluxClient {
    private final WebClient webClient;
    @Value("${server.push.url}")
    private String pushUrl;

    public FluxClient(WebClient.Builder builder) {
        this.webClient = builder.baseUrl(pushUrl).build();
    }

    public void sendPush(List<PushDto> pushDto) {
        String result = webClient.post().uri(pushUrl+"/api/push").accept(MediaType.APPLICATION_JSON)
                .bodyValue(pushDto)
                .retrieve()
                .bodyToMono(String.class)
                .block();
//        System.out.println(result);
    }
}
