package com.mogo.cloud.passport;

import android.content.Context;

import com.mogo.cloud.passport.internal.InternalPassportManager;
import com.mogo.cloud.passport.third.ThirdPassportManager;

public class PassportManager {

    private static volatile PassportManager mInstance;
    private final MoGoAiCloudClientConfig cloudClientConfig;

    private PassportManager() {
        cloudClientConfig = MoGoAiCloudClient.getInstance().getAiCloudClientConfig();
    }

    public static PassportManager getInstance() {
        if (mInstance == null) {
            synchronized (PassportManager.class) {
                if (mInstance == null) {
                    mInstance = new PassportManager();
                }
            }
        }
        return mInstance;
    }

    public void refreshToken(Context context, IPassport passport) {
        if (cloudClientConfig.isThirdLogin()) {
            ThirdPassportManager.getInstance().refreshToken(context, passport);
        } else {
            InternalPassportManager.getInstance(context).refreshToken(passport);
        }
    }
}
