using System.Collections.Generic;
using System.Threading.Tasks;
var client = new HttpClient() { BaseAddress = new Uri("https://api.jsonbin.io/b/5fb62f9404be4f05c9272f9b/2") };
client.DefaultRequestHeaders.Add("secret-key", "$2b$10$FRKBdPsyV27ReVeMpo83U.BYS0Jko5KUjctlj0A865qRkEYVf49ty");
var dataService = new DataService(client);
var items = await dataService.GetItemsAsync();
var nodes = items.ToTree();
var display = nodes.MakeFormattedString();
Console.WriteLine(display);
public static class NeedToImplementThisвыавыавыаыва
public static Node ToTree(this IEnumerable<Item> items)
=> throw new NotImplementedException();
public static string MakeFormattedString(this Node node)
=> throw new NotImplementedException();
public int Id { get; set; }
public string Text { get; set; }
public List<Node> Childs { get; set; }
public bool IsRoot => Id == 0;
public bool HasChilds => Childs != null && Childs.Any();
private readonly HttpClient _httpClient;
public DataService(HttpClient httpClient) => _httpClient = httpClient;
public async Task<IEnumerable<Item>> GetItemsAsync() {
using var resp = await _httpClient.GetAsync("");
var json = await resp.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<Item[]>(json);
public string Text { get; }
public int Parent { get; }