Пример #1
0
        public async Task <GetSummonerByNameResponse> GetSummonerByName(string summonerName)
        {
            if (ShouldThrow)
            {
                var apiException = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, new HttpResponseMessage(), null);;
                throw apiException;
            }
            var summoner = new GetSummonerByNameResponse()
            {
                AccountId     = "9OnF1YN-vTD7-vzFmVafiDk31yudiaRF1V9RaQR-ygE",
                ProfileIconId = 4568,
                RevisionDate  = 1620858743000,
                Name          = "Kaelsin",
                Id            = "M_uI3RI7JlQlY2kZXz4LuvmR7ilm6OlvPKcJHfycM7ih",
                Puuid         = "6WWJyoBhf9xdkCAWnypkUcy08U7lQORIPWqymtUf-7v_NWqqCfry7P5Eotgh-gJBDkejlX4eP_MLLg",
                SummonerLevel = 107
            };

            return(summoner);
        }
Пример #2
0
        public async Task <OneOf <GetSummonerByNameResult, GetSummonerByNameNotFound, GetSummonerByNameError> > GetBySummonerName(GetSummonerByNameRequest request)
        {
            try
            {
                GetSummonerByNameResponse response = await _riotApi.GetSummonerByName(request.SummonerName);

                return(new GetSummonerByNameResult
                {
                    AccountId = response.AccountId,
                    ProfileIconId = response.ProfileIconId,
                    RevisionDate = response.RevisionDate,
                    Name = response.Name,
                    Id = response.Id,
                    PUuid = response.Puuid,
                    SummonerLevel = response.SummonerLevel
                });
            }
            catch (ApiException exception)
            {
                return(exception.StatusCode switch
                {
                    HttpStatusCode.NotFound => new GetSummonerByNameNotFound(),
                    _ => new GetSummonerByNameError(new[] { Errors.UnexpectedError }),
                });