using Newtonsoft.Json; using RhSolutions.AddIn; using RhSolutions.Models; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks; namespace RhSolutions.Services { public static class RhDatabaseClient { private static HttpClient httpClient = RhSolutionsAddIn.httpClient; public static async Task GetProduct(string line) { string request = @"https://rh.cebotari.ru/api/search?query=" + line; string response = await httpClient.GetStringAsync(request); var products = JsonConvert.DeserializeObject>(response); var product = products.FirstOrDefault(); if (product == null) { return null; } else { return $"{product.ProductSku} {product.Name}"; } } } }