package com.getbubblenow.android.viewmodel;

import android.content.Context;

import com.getbubblenow.android.repository.DataRepository;
import com.getbubblenow.android.resource.StatusResource;
import com.getbubblenow.android.util.UserStore;

import androidx.lifecycle.MutableLiveData;

public class LoginViewModel extends BaseViewModel {

    @Override protected void onCleared() {
        super.onCleared();
        DataRepository.getRepositoryInstance().clearDisposable();
    }

    public static void setHostName(final Context context, final String hostname){
        DataRepository.getRepositoryInstance().setHostName(context,hostname);
    }

    public static MutableLiveData<StatusResource<byte[]>> loginToSage(final Context context, final String username, final String password){
       return DataRepository.getRepositoryInstance().loginToSage(context, username, password);
    }

    public static MutableLiveData<StatusResource<String>> getConfig(final Context context){
        return DataRepository.getRepositoryInstance().getConfig(context);
    }

    public static MutableLiveData<StatusResource<String>> getSignUpSage(final Context context){
        return DataRepository.getRepositoryInstance().getSignUpSage(context);
    }

    public static String getHostNameForAccount(final Context context){
        return UserStore.getInstance(context).getHostNameForAccount();
    }
}
