package org.tio.sitexxx.service.service.jpush.huawei.util;

import org.tio.sitexxx.service.service.jpush.huawei.messaging.HuaweiApp;
import org.tio.sitexxx.service.service.jpush.huawei.messaging.HuaweiCredential;
import org.tio.sitexxx.service.service.jpush.huawei.messaging.HuaweiOption;

/**
 * <pre>
 *    @author : vagrancy
 *    e-mail : 18050829067@163.com
 *    time   : 2025-02-21 10:33
 *    desc   :
 * </pre>
 */
public class InitAppUtils {
    /**
     * @return HuaweiApp
     */
    public static HuaweiApp initializeApp() {
        String appId = "113226577";
        String appSecret = "7f5d09fd6559feab0f3f461964e4ffb58e2bc35472230b89674038ec6aed2ff1";
        // Create HuaweiCredential
        // This appId and appSecret come from Huawei Developer Alliance
        return initializeApp(appId, appSecret);
    }

    private static HuaweiApp initializeApp(String appId, String appSecret) {
        HuaweiCredential credential = HuaweiCredential.builder()
                .setAppId(appId)
                .setAppSecret(appSecret)
                .build();

        // Create HuaweiOption
        HuaweiOption option = HuaweiOption.builder()
                .setCredential(credential)
                .build();

        // Initialize HuaweiApp
//        return HuaweiApp.initializeApp(option);
        return HuaweiApp.getInstance(option);
    }

}
