/** * JSON TO OBJECT * Hilo de conexión */ static async Task <GettingStarted> GetObjectAsync(string path) { GettingStarted obj = null; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { obj = await response.Content.ReadAsAsync <GettingStarted>(); } return(obj); }
/* * ListProject */ static void ShowProject(GettingStarted obj) { Console.WriteLine("# LISTADO DE PROYECTOS #"); Console.WriteLine("--------------------------------------"); foreach (Result item in obj.Results) { Console.WriteLine(" "); Console.WriteLine($"Created: {item.Created}"); Console.WriteLine($"Description: {item.Description}"); Console.WriteLine($"Name: {item.Name}"); Console.WriteLine($"Organization: {item.Organization}"); Console.WriteLine($"Status: {item.Status}"); ShowAttributes(item); Console.WriteLine("--------------------------------------"); } }
/** * Método que accede a la API */ static async Task RunAsync() { String url_api = "http://manager.rinnolab.cl/ra/api/project/"; try { // Get the object GettingStarted obj = await GetObjectAsync(url_api); ShowProject(obj); } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadLine(); }
public static string ToJson(this GettingStarted self) => JsonConvert.SerializeObject(self, Converter.Settings);
/** * Método que muestra el Json obtenido */ static void ShowJson(GettingStarted obj) { Console.WriteLine($"Json: {obj.ToJson()}"); }
/** * Método de impresión */ static void ShowObject(GettingStarted obj) { Console.WriteLine($"Count: {obj.Count}"); }