package cn.hztech.sdk.api;

import cn.hztech.sdk.client.SdkHttpClient;
import cn.hztech.sdk.model.entity.MessageBatchSendResult;
import cn.hztech.sdk.model.entity.MessageSendResult;
import cn.hztech.sdk.model.request.MessageBatchSendRequest;
import cn.hztech.sdk.model.request.MessageSendRequest;
import lombok.extern.slf4j.Slf4j;

/**
 * 消息发送API客户端
 *
 * 提供以下接口：
 * - send: 发送单条消息
 * - batchSend: 批量发送消息
 */
@Slf4j
public class MessageApiClient {

    private static final String API_PREFIX = "/hztech-message";

    private final SdkHttpClient httpClient;

    public MessageApiClient(SdkHttpClient httpClient) {
        this.httpClient = httpClient;
    }

    /**
     * 发送单条消息
     *
     * @param request 发送请求
     * @return 发送结果
     */
    public MessageSendResult send(MessageSendRequest request) {
        log.info("发送单条消息, request: {}", request);
        return httpClient.post(API_PREFIX + "/send", request, MessageSendResult.class);
    }

    /**
     * 批量发送消息
     *
     * @param request 批量发送请求
     * @return 发送结果
     */
    public MessageBatchSendResult batchSend(MessageBatchSendRequest request) {
        log.info("批量发送消息, request: {}", request);
        return httpClient.post(API_PREFIX + "/batch-send", request, MessageBatchSendResult.class);
    }
}
