From 4f448f203471a19a1444555a895f503515ad2fda Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 22 Mar 2023 08:36:13 +0300 Subject: Add basic test --- src/Services/RhDatabaseClient.cs | 52 ---------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 src/Services/RhDatabaseClient.cs (limited to 'src/Services/RhDatabaseClient.cs') diff --git a/src/Services/RhDatabaseClient.cs b/src/Services/RhDatabaseClient.cs deleted file mode 100644 index 70530ae..0000000 --- a/src/Services/RhDatabaseClient.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Newtonsoft.Json; -using RhSolutions.AddIn; -using RhSolutions.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; - -namespace RhSolutions.Services -{ - public static class RhDatabaseClient - { - public static async Task GetProduct(string line) - { - string request; - - if (Sku.TryParse(line, out var skus)) - { - request = @"https://rh.cebotari.ru/api/products/" + skus.FirstOrDefault().ToString(); - } - - else - { - request = @"https://rh.cebotari.ru/api/search?query=" + line; - } - - var response = await RhSolutionsAddIn.HttpClient.GetAsync(request); - - try - { - response.EnsureSuccessStatusCode(); - string json = await response.Content.ReadAsStringAsync(); - var product = JsonConvert.DeserializeObject>(json) - .FirstOrDefault(); - - if (product == null) - { - return null; - } - else - { - return $"{product.ProductSku} {product.Name}"; - } - } - catch - { - return $"Ошибка сервера {response.StatusCode}"; - } - } - } -} \ No newline at end of file -- cgit v1.2.3