package io.trustbuilder.mfa.android.demoapp.user_api;

import io.tb.userapi.api.MfaSecureTokensSelfManagementApi;
import io.tb.userapi.invoker.ApiException;
import io.tb.userapi.model.MfaBoolResponseMfaDeleteSecureTokenErrorsMfaApiResponse;
import io.tb.userapi.model.MfaBoolResponseMfaLockSecureTokenErrorsMfaApiResponse;
import io.tb.userapi.model.MfaBoolResponseMfaUnlockSecureTokenErrorsMfaApiResponse;
import io.tb.userapi.model.MfaSecureTokenDtoPaginatedList;
import io.trustbuilder.mfa.lib.definition.SecureTokenDTO;
import okhttp3.OkHttpClient;

public class UserApiService {
    public UserApiService()
    {

    }

    public MfaBoolResponseMfaLockSecureTokenErrorsMfaApiResponse Lock(SecureTokenDTO secureToken, String jwt, String tknAliasToLock) throws ApiException {
        UserClient userClient = new UserClient(secureToken.getServerUrl(), new OkHttpClient(),jwt);
        MfaSecureTokensSelfManagementApi api = userClient.secureTokensApi;
        return api.mfaSelfLockSecureToken(tknAliasToLock);
    }
    public MfaBoolResponseMfaUnlockSecureTokenErrorsMfaApiResponse UnLock(SecureTokenDTO secureToken, String jwt, String tknAliasToUnLock) throws ApiException {
        UserClient userClient = new UserClient(secureToken.getServerUrl(), new OkHttpClient(), jwt);
        MfaSecureTokensSelfManagementApi api = userClient.secureTokensApi;
        return api.mfaSelfUnlockSecureToken(tknAliasToUnLock);
    }
    public MfaBoolResponseMfaDeleteSecureTokenErrorsMfaApiResponse DeleteSecureToken(SecureTokenDTO secureToken, String jwt, String tknAliasToDelete) throws ApiException {
        UserClient userClient = new UserClient(secureToken.getServerUrl(), new OkHttpClient(), jwt);
        MfaSecureTokensSelfManagementApi api = userClient.secureTokensApi;
        return api.mfaSelfDeleteSecureToken(tknAliasToDelete, false);
    }
    public MfaSecureTokenDtoPaginatedList GetSecureTokens(SecureTokenDTO secureToken, String jwt) throws ApiException {
        UserClient userClient = new UserClient(secureToken.getServerUrl(), new OkHttpClient(), jwt);
        MfaSecureTokensSelfManagementApi api = userClient.secureTokensApi;
        MfaSecureTokenDtoPaginatedList res = api.mfaSelfGetSecureTokens(null,null,null,null);
        return res;
    }
}
