<?php

namespace support\OpenImSdk;

use support\OpenImSdk\Api\Auth;
use support\OpenImSdk\Api\Conversation;
use support\OpenImSdk\Api\Friend;
use support\OpenImSdk\Api\Group;
use support\OpenImSdk\Api\Message;
use support\OpenImSdk\Api\User;
use support\OpenImSdk\Core\Config;
use support\OpenImSdk\Core\TokenManager;
use support\OpenImSdk\Core\Utils;

class Client
{
    /**
     * 认证相关
     * @var Auth
     */
    public $auth;

    /**
     * 好友相关
     * @var Friend
     */
    public $friend;

    /**
     * 群组相关
     * @var Group
     */
    public $group;

    /**
     * 消息相关
     * @var Message
     */
    public $message;

    /**
     * 用户相关
     * @var User
     */
    public $user;

    /**
     * 会话相关
     * @var Conversation
     */
    public $conversation;

    /**
     * 初始化客户端
     * @param array $config 配置信息
     */
    public function __construct(array $config)
    {
        // 设置基本配置
        Config::setConfig($config);
        
        $tokenManager = new TokenManager();

        // 设置TokenManager
        Utils::setTokenManager($tokenManager);

        // 初始化API类
        $this->auth = new Auth();
        $this->friend = new Friend();
        $this->group = new Group();
        $this->message = new Message();
        $this->user = new User();
        $this->conversation = new Conversation();
    }
}
