public void Load(SpecializationJson specializationJson) { if (CheckJson(specializationJson)) { BlizzardId = specializationJson.Id; Name = specializationJson.Name; if (specializationJson.Class != null) { ClassId = specializationJson.Class.Id; } if (specializationJson.GenderDescriptions != null) { MaleDescription = specializationJson.GenderDescriptions.Male; FemaleDescription = specializationJson.GenderDescriptions.Female; } if (specializationJson.Role != null) { Role = specializationJson.Role.Type.ParseCode <Role>(); } if (specializationJson.Media != null && specializationJson.Media.Assets != null && specializationJson.Media.Assets.Any(x => x.Key == "icon")) { Icon = new Uri(specializationJson.Media.Assets.Find(x => x.Key == "icon").Value); } } }
public async Task GetSpec_Test() { uint id = 71; string query = $"data/wow/playable-specialization/{id}"; SpecializationJson result = await Api.GetAsync <SpecializationJson>(query, Namespace.Static).ConfigureAwait(false); MediaJson media = await Api.GetAsync <MediaJson>($"data/wow/media/playable-specialization/{id}", Namespace.Static).ConfigureAwait(false); Assert.Equal(HttpStatusCode.OK, result.ResultCode); Assert.True(result.DirectlyCalled); Assert.Equal(id, result.Id); Assert.Equal(HttpStatusCode.OK, media.ResultCode); Assert.True(media.DirectlyCalled); Assert.NotEmpty(media.Assets); Assert.NotNull(media.Assets.Find(x => x.Key == "icon").Key); }
private async Task FillSpecialization(SpecializationJson specializationJson) { SpecializationJson result = await _blizzardApiReader.GetAsync <SpecializationJson>($"data/wow/playable-specialization/{specializationJson.Id}", Namespace.Static).ConfigureAwait(false); if (result.ResultCode != HttpStatusCode.OK) { specializationJson.ResultCode = result.ResultCode; result = specializationJson; await _dbManager.Log(new LogEvent { Message = "Unabled to reach BlizzardAPI", Description = $"Return code {result.ResultCode}", Collection = "Specialization", BlizzardId = specializationJson.Id, Severity = LogLevel.Warning }).ConfigureAwait(false); } else { result.Media = await _blizzardApiReader.GetAsync <MediaJson>($"data/wow/media/playable-specialization/{specializationJson.Id}", Namespace.Static).ConfigureAwait(false); } await _dbManager.Insert(new Specialization(result)).ConfigureAwait(false); }
public Specialization(SpecializationJson specializationJson) : this() { Load(specializationJson); }