/* * * // 52. Оригінальний метод пошуку нерухомості Nais (короткі дані) * // [POST] api/1.0/Estate/GetEstatesAdvancedSearch * */ public static GetEstatesResponseModel GetEstatesAdvancedSearch(string token) { if (string.IsNullOrEmpty(token)) { AuthorizeClass _authorize = new AuthorizeClass(); token = _authorize.Authorize(); } string responseString = string.Empty; while (string.IsNullOrEmpty(responseString)) { GetEstatesAdvancedSearchBodyModel GEASBody = new GetEstatesAdvancedSearchBodyModel { RequestList = new List <SubjectSearchInfoAdvanced> { new SubjectSearchInfoAdvanced { sbjCode = "19124549", } } }; RestClient client = new RestClient("https://vkursi-api.azurewebsites.net/api/1.0/Estate/GetEstatesAdvancedSearch"); RestRequest request = new RestRequest(Method.POST); string body = JsonConvert.SerializeObject(GEASBody); // Example Body: {"RequestList":[{"dcSbjRlNames":null,"sbjType":"2","sbjCode":"19124549"}]} body = "{\"RequestList\":[{\"dcSbjRlNames\":null,\"sbjType\":\"2\",\"sbjCode\":\"19124549\"}]}"; request.AddHeader("ContentType", "application/json"); request.AddHeader("Authorization", "Bearer " + token); request.AddParameter("application/json", body, ParameterType.RequestBody); IRestResponse response = client.Execute(request); responseString = response.Content; if ((int)response.StatusCode == 401) { Console.WriteLine("Не авторизований користувач або закінчився термін дії токену. Отримайте новый token на api/1.0/token/authorize"); AuthorizeClass _authorize = new AuthorizeClass(); token = _authorize.Authorize(); } else if ((int)response.StatusCode != 200) { Console.WriteLine("Запит не успішний"); return(null); } } GetEstatesResponseModel GEASResponse = new GetEstatesResponseModel(); GEASResponse = JsonConvert.DeserializeObject <GetEstatesResponseModel>(responseString); return(GEASResponse); }
/* * * 24. ДРРП отримання скороченных данных по ІПН / ЄДРПОУ * [POST] /api/1.0/Estate/GetEstates * * curl --location --request POST 'https://vkursi-api.azurewebsites.net/api/1.0/Estate/GetEstates' \ * --header 'ContentType: application/json' \ * --header 'Authorization: Bearer eyJhbGciOiJIUzI1Ni...' \ * --header 'Content-Type: application/json' \ * --data-raw '{"Edrpou":["36679626"],"Ipn":["3006679626"]}' * */ public static GetEstatesResponseModel GetEstates(string token, string edrpou, string ipn) { if (string.IsNullOrEmpty(token)) { AuthorizeClass _authorize = new AuthorizeClass(); token = _authorize.Authorize(); } string responseString = string.Empty; while (string.IsNullOrEmpty(responseString)) { GetEstatesRequestBodyModel GERequestBodyRow = new GetEstatesRequestBodyModel { Edrpou = new List <string> { edrpou // Масив кодів ЄДРПОУ (обеження 1) } //Ipn = new List<string> { // ipn // Масив кодів ІПН (обеження 1) //} }; RestClient client = new RestClient("https://vkursi-api.azurewebsites.net/api/1.0/estate/getestates"); RestRequest request = new RestRequest(Method.POST); string body = JsonConvert.SerializeObject(GERequestBodyRow); // Example Body: {"Edrpou":["26444836"]} //body = "{\"Edrpou\":[\"26444836\"],\"EstateType\": 11}"; request.AddHeader("ContentType", "application/json"); request.AddHeader("Authorization", "Bearer " + token); request.AddParameter("application/json", body, ParameterType.RequestBody); IRestResponse response = client.Execute(request); responseString = response.Content; if ((int)response.StatusCode == 401) { Console.WriteLine("Не авторизований користувач або закінчився термін дії токену. Отримайте новый token на api/1.0/token/authorize"); AuthorizeClass _authorize = new AuthorizeClass(); token = _authorize.Authorize(); } else if ((int)response.StatusCode != 200) { Console.WriteLine("Запит не успішний"); return(null); } } GetEstatesResponseModel GEResponseRow = new GetEstatesResponseModel(); GEResponseRow = JsonConvert.DeserializeObject <GetEstatesResponseModel>(responseString); return(GEResponseRow); }