private UserInfo GetTokenInfo(AuthProtocol result)
 {
     if (result.Response.HasFlag(AuthProtocolResponseType.Error))
     {
         throw new Exception("Error in auth: " + result.ErrorCode + " ( " + result.ErrorStatus + " )");
     }
     if (result.Response.HasFlag(AuthProtocolResponseType.True))
     {
         return(new UserInfo {
             Ok = true, Expire = result.Expire, Login = result.Login, Token = result.Token
         });
     }
     return(new UserInfo());
 }
        /// <summary>
        /// </summary>
        /// <param name="login"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        public async Task <UserInfo> AuthAsync(string login, string pass)
        {
            AuthProtocol req = GetAuthReq(login, pass);

            return(GetTokenInfo(await ExecuteAsync(req)));
        }
 /// <summary>
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public AuthProtocol Execute(AuthProtocol request)
 {
     return(_client.Call(request));
 }
        /// <summary>
        /// </summary>
        /// <param name="login"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        public UserInfo Auth(string login, string pass)
        {
            AuthProtocol req = GetAuthReq(login, pass);

            return(GetTokenInfo(Execute(req)));
        }
 /// <summary>
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <AuthProtocol> ExecuteAsync(AuthProtocol request)
 {
     return(await _client.CallAsync(request));
 }