public async Task <MyGetApiResponse> GetPackagesAsync() { if (_response != null) { return(_response); } try { var client = _cliHttpClientFactory.CreateClient(); using (var responseMessage = await client.GetAsync( $"{CliUrls.WwwAbpIo}api/myget/packages/", _cliHttpClientFactory.GetCancellationToken(TimeSpan.FromMinutes(10)))) { _response = JsonConvert.DeserializeObject <MyGetApiResponse>( Encoding.Default.GetString(await responseMessage.Content.ReadAsByteArrayAsync()) ); } } catch (Exception ex) { Logger.LogError("Unable to get latest preview version. Error: " + ex.Message); throw; } return(_response); }
protected virtual async Task <ModuleWithMastersInfo> GetModuleInfoAsync(string moduleName, bool newTemplate, bool newProTemplate = false) { if (newTemplate || newProTemplate) { return(GetEmptyModuleProjectInfo(moduleName, newProTemplate)); } var url = $"{CliUrls.WwwAbpIo}api/app/module/byNameWithDetails/?name=" + moduleName; var client = _cliHttpClientFactory.CreateClient(); using (var response = await client.GetAsync(url, _cliHttpClientFactory.GetCancellationToken())) { if (!response.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.NotFound) { throw new CliUsageException($"ERROR: '{moduleName}' module could not be found!"); } await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response); } var responseContent = await response.Content.ReadAsStringAsync(); return(JsonSerializer.Deserialize <ModuleWithMastersInfo>(responseContent)); } }
protected virtual async Task <NugetPackageInfo> FindNugetPackageInfoAsync(string packageName) { var url = $"{CliUrls.WwwAbpIo}api/app/nugetPackage/byName/?name=" + packageName; var client = _cliHttpClientFactory.CreateClient(); using (var response = await client.GetAsync(url, _cliHttpClientFactory.GetCancellationToken())) { if (!response.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.NotFound) { throw new CliUsageException($"'{packageName}' nuget package could not be found!"); } await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response); } var responseContent = await response.Content.ReadAsStringAsync(); return(JsonSerializer.Deserialize <NugetPackageInfo>(responseContent)); } }