/* * * 41. Отримати список пов'язаних з компанією бенеціціарів, керівників, адрес, власників пакетів акцій * [POST] /api/1.0/organizations/getrelations * * curl --location --request POST 'https://vkursi-api.azurewebsites.net/api/1.0/organizations/getrelations' \ * --header 'ContentType: application/json' \ * --header 'Authorization: Bearer eyJhbGciOiJIUzI1Ni...' \ * --header 'Content-Type: application/json' \ * --data-raw '{"Edrpou":["00131305"],"RelationId":null}' * */ public static GetRelationsResponseModel GetRelations(ref string token, string edrpou, string relationId) { if (String.IsNullOrEmpty(token)) { token = AuthorizeClass.Authorize(); } string responseString = string.Empty; while (string.IsNullOrEmpty(responseString)) { GetRelationsRequestBodyModel GRRequestBody = new GetRelationsRequestBodyModel { Edrpou = new List <string> // Перелік кодів ЄДРПОУ (обмеження 1) { edrpou } //RelationId = new List<string> //{ // edrpou //} }; string body = JsonConvert.SerializeObject(GRRequestBody); // Example Body: {"Edrpou":["00131305"],"RelationId":null} RestClient client = new RestClient("https://vkursi-api.azurewebsites.net/api/1.0/organizations/getrelations"); RestRequest request = new RestRequest(Method.POST); 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"); token = AuthorizeClass.Authorize(); } else if ((int)response.StatusCode != 200 || response.ErrorMessage == "The operation has timed out.") { Console.WriteLine("Запит не успішний"); return(null); } } GetRelationsResponseModel GRResponseRow = new GetRelationsResponseModel(); GRResponseRow = JsonConvert.DeserializeObject <GetRelationsResponseModel>(responseString); return(GRResponseRow); }
/* * * Метод: * 41. Отримати список пов'язаних з компанією бенеціціарів, керівників, адрес, власників пакетів акцій * [POST] /api/1.0/organizations/getrelations * * cURL запиту: * curl --location --request POST 'https://vkursi-api.azurewebsites.net/api/1.0/organizations/getrelations' \ * --header 'ContentType: application/json' \ * --header 'Authorization: Bearer eyJhbGciOiJIUzI1Ni...' \ * --header 'Content-Type: application/json' \ * --data-raw '{"Edrpou":["42556505"],"RelationId":null,"FilterRelationType":null,"MaxRelationLevel":3}' * * Приклад відповіді: * https://github.com/vkursi-pro/API/blob/master/vkursi-api-example/responseExample/GetRelationsResponse.json * */ public static GetRelationsResponseModel GetRelations(ref string token, string edrpou, string relationId) { if (string.IsNullOrEmpty(token)) { AuthorizeClass _authorize = new AuthorizeClass(); token = _authorize.Authorize(); } string responseString = string.Empty; while (string.IsNullOrEmpty(responseString)) { GetRelationsRequestBodyModel GRRequestBody = new GetRelationsRequestBodyModel { Edrpou = new List <string> // Перелік кодів ЄДРПОУ (обмеження 1) { edrpou }, MaxRelationLevel = 1, // Фільтр по к-ті рівнів зв'язків які будуть отриммані в відповіді //FilterRelationType = new List<int> // Фільтр по типам зв'язків //{ // 1,2,3 //}, //RelationId = new List<string> // Перелік Id зв'язків за якими буде проведений пошук зв'язків //{ // edrpou //} }; string body = JsonConvert.SerializeObject(GRRequestBody); // Example Body: {"Edrpou":["42556505"],"RelationId":null,"FilterRelationType":null,"MaxRelationLevel":3} RestClient client = new RestClient("https://vkursi-api.azurewebsites.net/api/1.0/organizations/getrelations"); RestRequest request = new RestRequest(Method.POST); 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 || response.ErrorMessage == "The operation has timed out.") { Console.WriteLine("Запит не успішний"); return(null); } } GetRelationsResponseModel GRResponseRow = new GetRelationsResponseModel(); GRResponseRow = JsonConvert.DeserializeObject <GetRelationsResponseModel>(responseString); return(GRResponseRow); }