private static async Task CreateSettingsAsync(string urlToSettingsWithBlockchainIntegrationSection, string blockchainSettingsUrl, string apiKey) { var uri = new Uri(urlToSettingsWithBlockchainIntegrationSection); var appSettings = Lykke.SettingsReader.SettingsReader.ReadGeneralSettings <AppSettings>(uri); var list = appSettings.BlockchainsIntegration.Blockchains.ToList(); var blockchainSettingsClientFactory = new BlockchainSettingsClientFactory(); var cacheManager = new ClientCacheManager(); var client = blockchainSettingsClientFactory.CreateNew(blockchainSettingsUrl, apiKey, true, cacheManager); try { var response = await client.GetIsAliveAsync(); if (response == null) { System.Console.WriteLine($"No access to {blockchainSettingsUrl}"); return; } } catch (Exception e) { System.Console.WriteLine($"No access to {blockchainSettingsUrl}"); return; } foreach (var item in list) { System.Console.WriteLine($"Processing {item.Type}"); var existing = await client.GetSettingsByTypeAsync(item.Type); if (existing != null) { System.Console.WriteLine($"{item.Type} setting already exists"); await client.UpdateAsync(new BlockchainSettingsUpdateRequest() { ETag = existing.ETag, Type = item.Type, HotWalletAddress = item.HotWalletAddress, SignServiceUrl = item.SignServiceUrl, ApiUrl = item.ApiUrl }); continue; } await client.CreateAsync(new BlockchainSettingsCreateRequest() { Type = item.Type, HotWalletAddress = item.HotWalletAddress, SignServiceUrl = item.SignServiceUrl, ApiUrl = item.ApiUrl, }); System.Console.WriteLine($"{item.Type} has been processed"); } }
public void Init() { Fixture = new TestFixture(); Factory = new BlockchainSettingsClientFactory(); }