Esempio n. 1
0
        static async Task Main()
        {
            Console.OutputEncoding = Encoding.UTF8;

            //HttpClient client = new HttpClient(); // Створюємо клієн для відправки запросів
            //HttpResponseMessage response = await client.GetAsync("https://api.thecatapi.com/v1/images/search?breed_id=beng");
            //var json = await response.Content.ReadAsStringAsync();
            //Console.WriteLine($"Отримана відповідь - {json}");

            ICatAPI catApi = RestService.For <ICatAPI>("https://api.thecatapi.com");
            //List<CatInfoObject> catInfos = await catApi.GetCatDescription();
            //CatInfoObject firstCatInfo = catInfos[0];
            //string url = firstCatInfo.Url;

            //Console.WriteLine($"{firstCatInfo.Id}, { firstCatInfo.Url}, {firstCatInfo.Width}");

            //ProcessStartInfo procStartInfo = new ProcessStartInfo(@"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe", url);
            //Process.Start(procStartInfo);

            List <Categories> catInfos = await catApi.GetCategories();

            foreach (var item in catInfos)
            {
                Console.WriteLine($"{item.Id} - {item.Name}");
            }
        }
Esempio n. 2
0
        public ApiService()
        {
            var httpClient = CreateHttpClient();

            catAPI = RestService.For <ICatAPI>(httpClient);
        }