package com.usoftchina.dingtalk.sdk.config;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author yingp
 */
public class DingTalkProperties {
    /**
     * 企业钉钉ID
     */
    private String corpId;
    /**
     * <应用CODE, 应用私钥>
     */
    private Map<String, Agent> agentMap;

    public String getCorpId() {
        return corpId;
    }

    public void setCorpId(String corpId) {
        this.corpId = corpId;
    }

    public Map<String, Agent> getAgentMap() {
        return agentMap;
    }

    public void setAgents(List<Agent> agents) {
        if (null == agents) {
            agentMap = new HashMap<>(0);
        } else {
            this.agentMap = agents.stream().collect(Collectors.toMap(Agent::getCode, a -> a));
        }
    }
}
