package com.ltgk.common.utils.push;

import com.getui.push.v2.sdk.ApiHelper;
import com.getui.push.v2.sdk.GtApiConfiguration;
import com.getui.push.v2.sdk.api.PushApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 公众端 个推配置
 *
 * @author Qi ChengBin
 * @date 2025-05-22
 */
@Configuration
public class PublicNuiPushConfig {
    @Value("${unipush.public.baseUrl}")
    private String baseUrl;

    @Value("${unipush.public.appId}")
    private String appId;

    @Value("${unipush.public.appKey}")
    private String appKey;

    @Value("${unipush.public.masterSecret}")
    private String masterSecret;

    @Bean(name = "publicUniPushApi")
    public PushApi pushApi() {
        GtApiConfiguration apiConfiguration = new GtApiConfiguration();
        //填写应用配置
        apiConfiguration.setAppId(appId);
        apiConfiguration.setAppKey(appKey);
        apiConfiguration.setMasterSecret(masterSecret);
        // 接口调用前缀，请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
        apiConfiguration.setDomain(baseUrl);
        // 实例化ApiHelper对象，用于创建接口对象
        ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
        // 创建对象，建议复用。目前有PushApi、StatisticApi、UserApi
        return apiHelper.creatApi(PushApi.class);
    }
}

