private Addon CreateAddon( string folderName, AddonSearchResult searchResult, AddonSearchResultFile latestFile, WowClientType clientType, AddonChannelType?channelType = null) { if (latestFile == null) { return(null); } return(new Addon { Name = searchResult.Name, ThumbnailUrl = searchResult.ThumbnailUrl, LatestVersion = latestFile.Version, ClientType = clientType, ExternalId = searchResult.ExternalId, FolderName = folderName, GameVersion = latestFile.GameVersion, Author = searchResult.Author, DownloadUrl = latestFile.DownloadUrl, ExternalUrl = searchResult.ExternalUrl, ProviderName = searchResult.ProviderName, ChannelType = channelType ?? _wowUpService.GetDefaultAddonChannel() }); }
public async Task <Addon> Map(string addonName, string folderName, WowClientType clientType) { var searchResults = await Search(addonName, folderName, clientType); AddonSearchResult nearestResult = null; AddonSearchResultFile latestFile = null; foreach (var result in searchResults) { latestFile = GetLatestFile(result, AddonChannelType.Stable); if (latestFile == null) { continue; } nearestResult = result; break; } if (nearestResult == null || latestFile == null) { return(null); } return(CreateAddon(folderName, nearestResult, latestFile, clientType)); }
private Addon CreateAddon( string folderName, AddonSearchResult searchResult, AddonSearchResultFile latestFile, WowClientType clientType, AddonChannelType?channelType = null, IEnumerable <Addon> dependencies = null) { if (latestFile == null) { return(null); } return(new Addon { Name = searchResult.Name, ThumbnailUrl = searchResult.ThumbnailUrl, LatestVersion = latestFile.Version, ClientType = clientType, ExternalId = searchResult.ExternalId, FolderName = folderName, GameVersion = latestFile.GameVersion, Author = searchResult.Author, DownloadUrl = latestFile.DownloadUrl, ExternalUrl = searchResult.ExternalUrl, ProviderName = searchResult.ProviderName, ChannelType = channelType ?? _wowUpService.GetClientAddonChannelType(clientType), AutoUpdateEnabled = _wowUpService.GetClientDefaultAutoUpdate(clientType), Dependencies = dependencies }); }
public async Task <AddonSearchResult> GetById(string addonId, WowClientType clientType) { var results = await GetReleases(addonId); if (!results.Any()) { return(null); } var latestRelease = GetLatestRelease(results); if (latestRelease == null) { return(null); } var asset = GetValidAsset(latestRelease, clientType); if (asset == null) { return(null); } var repository = await GetRepository(addonId); var author = repository.Owner.Login; var authorImageUrl = repository.Owner.AvatarUrl; var name = GetAddonName(addonId); var searchResultFile = new AddonSearchResultFile { ChannelType = AddonChannelType.Stable, DownloadUrl = asset.BrowserDownloadUrl, Folders = new List <string> { name }, GameVersion = string.Empty, Version = asset.Name, ReleaseDate = asset.CreatedAt, Dependencies = Enumerable.Empty <AddonSearchResultDependency>() }; var searchResult = new AddonSearchResult { Author = author, ExternalId = addonId, ExternalUrl = asset.Url, Files = new List <AddonSearchResultFile> { searchResultFile }, Name = name, ProviderName = Name, ThumbnailUrl = authorImageUrl }; return(searchResult); }
private AddonSearchResult ToSearchResult(TukUiAddon addon, string folderName) { var latestFile = new AddonSearchResultFile { ChannelType = AddonChannelType.Stable, Folders = new[] { folderName }, DownloadUrl = addon.Url, GameVersion = addon.Patch, Version = addon.Version }; return(new AddonSearchResult { Author = addon.Author, ExternalId = addon.Id, Name = addon.Name, ThumbnailUrl = addon.ScreenshotUrl, ExternalUrl = addon.WebUrl, ProviderName = Name, Files = new[] { latestFile } }); }