/// <summary>
        /// Get Stats for One or More Users
        /// </summary>
        /// <param name="userIds">User IDs</param>
        /// <returns>The Users' Stats</returns>
        public static List <UserStats> GetUserStats(Guid[] userIds = null, string[] hashes = null, string[] ifcNames = null)
        {
            if (userIds == null && hashes == null && ifcNames == null)
            {
                throw new ArgumentNullException();
            }

            var contentObj = new UserStatsRequest();

            if (userIds != null)
            {
                contentObj.UserIds = userIds;
            }
            if (hashes != null)
            {
                contentObj.Hashes = hashes;
            }
            if (ifcNames != null)
            {
                contentObj.IfcNames = ifcNames;
            }

            var contentJson = JsonConvert.SerializeObject(contentObj);
            var content     = new StringContent(contentJson, Encoding.UTF8, "application/json");

            var resJson = _httpClient.PostAsync(_baseUrl + $"/user/stats?apikey={_apiKey}", content).Result.Content.ReadAsStringAsync().Result;
            var resData = JsonConvert.DeserializeObject <ApiResponse <List <UserStats> > >(resJson);

            if (resData.ErrorCode != ResponseCode.Ok)
            {
                throw new Exception($"Invalid API Response Code. Expected Ok, received {resData.ErrorCode}");
            }

            return(resData.Result);
        }
示例#2
0
        public async Task <IEnumerable <UserStatsDto> > GetTutorStatsAsync([FromQuery] UserStatsRequest request, CancellationToken token)
        {
            var userId = _userManager.GetLongUserId(User);
            var query  = new UserStatsQuery(userId, request.Days);
            var result = await _queryBus.QueryAsync(query, token);

            return(result);
        }