Пример #1
0
        public async Task <IDictionary <string, IEnumerable <Operator> > > GetOperatorsAsync(IEnumerable <string> profileIds, EPlatform platform, EOperatorStatisticsType statisticsType)
        {
            if (profileIds == null)
            {
                throw new ArgumentNullException(nameof(profileIds));
            }

            if (!Enum.IsDefined(typeof(EPlatform), platform))
            {
                throw new InvalidEnumArgumentException(nameof(platform), (int)platform, typeof(EPlatform));
            }

            if (!Enum.IsDefined(typeof(EOperatorStatisticsType), statisticsType))
            {
                throw new InvalidEnumArgumentException(nameof(statisticsType), (int)statisticsType,
                                                       typeof(EOperatorStatisticsType));
            }

            var operatorsRequest = new OperatorsRequest
            {
                UbiAppId       = _settings.UbiAppId,
                Ticket         = _ticket,
                SessionId      = _sessionId,
                ProfileIds     = profileIds,
                Platform       = platform,
                StatisticsType = statisticsType
            };

            var response = await _apiManager.GetOperatorsResponseAsync(operatorsRequest);

            return(response.OperatorModels.ToDictionary(o => o.Key, o => o.Value.Select(ApiMapper.GetMappedOperator)));
        }
Пример #2
0
        public async Task <KeyValuePair <string, IEnumerable <Operator> > > GetOperatorsAsync(string profileId, EPlatform platform, EOperatorStatisticsType statisticsType)
        {
            var operators = await GetOperatorsAsync(new[] { profileId }, platform, statisticsType);

            return(operators.FirstOrDefault());
        }