package com.sonic.pigeon.config;

import com.netease.nim.server.sdk.core.BizName;
import com.netease.nim.server.sdk.core.YunxinApiHttpClient;
import com.netease.nim.server.sdk.core.endpoint.Region;
import com.netease.nim.server.sdk.im.v2.YunxinV2ApiServices;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ImConfig {

    @Value("${im.appKey:xxx}")
    private String appKey;
    @Value("${im.appSecret:xxx}")
    private String appSecret;
    @Value("${im.timeoutMillis:5000}")
    private int timeoutMillis;

    @Bean
    public YunxinV2ApiServices yunxinV2ApiServices() {
        YunxinApiHttpClient client = new YunxinApiHttpClient.Builder(BizName.IM, appKey, appSecret)
                .region(Region.SG)
                .timeoutMillis(timeoutMillis)
                .build();
        // services
        return new YunxinV2ApiServices(client);
    }

}