├── .gitignore ├── LICENSE ├── Properties └── AssemblyInfo.cs ├── README.md ├── doc └── api-suggest.png ├── src ├── SuggestClient.cs ├── SuggestClientTest.cs └── SuggestModel.cs ├── suggestions-csharp.csproj └── suggestions-csharp.sln /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | [Rr]eleases/ 14 | x64/ 15 | x86/ 16 | build/ 17 | bld/ 18 | lib/ 19 | [Bb]in/ 20 | [Oo]bj/ 21 | 22 | # Roslyn cache directories 23 | *.ide/ 24 | 25 | # MSTest test Results 26 | [Tt]est[Rr]esult*/ 27 | [Bb]uild[Ll]og.* 28 | 29 | #NUNIT 30 | *.VisualState.xml 31 | TestResult.xml 32 | 33 | # Build Results of an ATL Project 34 | [Dd]ebugPS/ 35 | [Rr]eleasePS/ 36 | dlldata.c 37 | 38 | *_i.c 39 | *_p.c 40 | *_i.h 41 | *.ilk 42 | *.meta 43 | *.obj 44 | *.pch 45 | *.pdb 46 | *.pgc 47 | *.pgd 48 | *.rsp 49 | *.sbr 50 | *.tlb 51 | *.tli 52 | *.tlh 53 | *.tmp 54 | *.tmp_proj 55 | *.log 56 | *.vspscc 57 | *.vssscc 58 | .builds 59 | *.pidb 60 | *.svclog 61 | *.scc 62 | *.userprefs 63 | 64 | # Chutzpah Test files 65 | _Chutzpah* 66 | 67 | # Visual C++ cache files 68 | ipch/ 69 | *.aps 70 | *.ncb 71 | *.opensdf 72 | *.sdf 73 | *.cachefile 74 | 75 | # Visual Studio profiler 76 | *.psess 77 | *.vsp 78 | *.vspx 79 | 80 | # TFS 2012 Local Workspace 81 | $tf/ 82 | 83 | # Guidance Automation Toolkit 84 | *.gpState 85 | 86 | # ReSharper is a .NET coding add-in 87 | _ReSharper*/ 88 | *.[Rr]e[Ss]harper 89 | *.DotSettings.user 90 | 91 | # JustCode is a .NET coding addin-in 92 | .JustCode 93 | 94 | # TeamCity is a build add-in 95 | _TeamCity* 96 | 97 | # DotCover is a Code Coverage Tool 98 | *.dotCover 99 | 100 | # NCrunch 101 | _NCrunch_* 102 | .*crunch*.local.xml 103 | 104 | # MightyMoose 105 | *.mm.* 106 | AutoTest.Net/ 107 | 108 | # Web workbench (sass) 109 | .sass-cache/ 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.[Pp]ublish.xml 129 | *.azurePubxml 130 | # TODO: Comment the next line if you want to checkin your web deploy settings 131 | # but database connection strings (with potential passwords) will be unencrypted 132 | *.pubxml 133 | 134 | # NuGet Packages 135 | *.nupkg 136 | # The packages folder can be ignored because of Package Restore 137 | **/packages/* 138 | # except build/, which is used as an MSBuild target. 139 | !**/packages/build/ 140 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 141 | #!**/packages/repositories.config 142 | 143 | # Windows Azure Build Output 144 | csx/ 145 | *.build.csdef 146 | 147 | # Windows Store app package directory 148 | AppPackages/ 149 | 150 | # Others 151 | sql/ 152 | *.Cache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | 163 | # RIA/Silverlight projects 164 | Generated_Code/ 165 | 166 | # Backup & report files from converting an old project file 167 | # to a newer Visual Studio version. Backup files are not needed, 168 | # because we have git ;-) 169 | _UpgradeReport_Files/ 170 | Backup*/ 171 | UpgradeLog*.XML 172 | UpgradeLog*.htm 173 | 174 | # SQL Server files 175 | *.mdf 176 | *.ldf 177 | 178 | # Business Intelligence projects 179 | *.rdl.data 180 | *.bim.layout 181 | *.bim_*.settings 182 | 183 | # Microsoft Fakes 184 | FakesAssemblies/ 185 | 186 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Human Factor Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle ("suggestions-csharp")] 8 | [assembly: AssemblyDescription ("DaData.ru Suggestions client for C# / .NET")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("HFLabs")] 11 | [assembly: AssemblyProduct ("DaData.ru")] 12 | [assembly: AssemblyCopyright ("HFLabs")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion ("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Библиотека не поддерживается 2 | ==================== 3 | 4 | Используйте актуальную версию: https://github.com/hflabs/dadata-csharp 5 | -------------------------------------------------------------------------------- /doc/api-suggest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hflabs/suggestions-csharp/3114a9bf31df5aab484c6078537343d363a47450/doc/api-suggest.png -------------------------------------------------------------------------------- /src/SuggestClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Collections.Generic; 4 | using RestSharp; 5 | 6 | namespace suggestionscsharp { 7 | 8 | public class SuggestClient { 9 | const string SUGGESTIONS_URL = "{0}/suggest"; 10 | const string ADDRESS_RESOURCE = "address"; 11 | const string PARTY_RESOURCE = "party"; 12 | const string BANK_RESOURCE = "bank"; 13 | const string FIO_RESOURCE = "fio"; 14 | const string EMAIL_RESOURCE = "email"; 15 | 16 | RestClient client; 17 | string token; 18 | ContentType contentType = ContentType.JSON; 19 | 20 | public IWebProxy Proxy { 21 | get { return client.Proxy; } 22 | set { client.Proxy = value; } 23 | } 24 | 25 | static SuggestClient() { 26 | // use SSL v3 27 | ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; 28 | } 29 | 30 | public SuggestClient(string token, string baseUrl) { 31 | this.token = token; 32 | this.client = new RestClient (String.Format (SUGGESTIONS_URL, baseUrl)); 33 | } 34 | 35 | public SuggestAddressResponse QueryAddress(string address) { 36 | return QueryAddress(new AddressSuggestQuery(address)); 37 | } 38 | 39 | public SuggestAddressResponse QueryAddress(AddressSuggestQuery query) { 40 | var request = new RestRequest(ADDRESS_RESOURCE, Method.POST); 41 | return Execute(request, query); 42 | } 43 | 44 | public SuggestBankResponse QueryBank(string bank) { 45 | return QueryBank(new BankSuggestQuery(bank)); 46 | } 47 | 48 | public SuggestBankResponse QueryBank(BankSuggestQuery query) { 49 | var request = new RestRequest(BANK_RESOURCE, Method.POST); 50 | return Execute(request, query); 51 | } 52 | 53 | public SuggestEmailResponse QueryEmail(string email) { 54 | var request = new RestRequest(EMAIL_RESOURCE, Method.POST); 55 | var query = new SuggestQuery(email); 56 | return Execute(request, query); 57 | } 58 | 59 | public SuggestFioResponse QueryFio(string fio) { 60 | return QueryFio(new FioSuggestQuery(fio)); 61 | } 62 | 63 | public SuggestFioResponse QueryFio(FioSuggestQuery query) { 64 | var request = new RestRequest(FIO_RESOURCE, Method.POST); 65 | return Execute(request, query); 66 | } 67 | 68 | public SuggestPartyResponse QueryParty(string party) { 69 | return QueryParty(new PartySuggestQuery(party)); 70 | } 71 | 72 | public SuggestPartyResponse QueryParty(PartySuggestQuery query) { 73 | var request = new RestRequest(PARTY_RESOURCE, Method.POST); 74 | return Execute(request, query); 75 | } 76 | 77 | private T Execute(RestRequest request, SuggestQuery query) where T : new() { 78 | request.AddHeader("Authorization", "Token " + this.token); 79 | request.AddHeader("Content-Type", contentType.Name); 80 | request.AddHeader("Accept", contentType.Name); 81 | request.RequestFormat = contentType.Format; 82 | request.XmlSerializer.ContentType = contentType.Name; 83 | request.AddBody(query); 84 | var response = client.Execute(request); 85 | 86 | if (response.ErrorException != null) { 87 | throw response.ErrorException; 88 | } 89 | return response.Data; 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /src/SuggestClientTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using RestSharp; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace suggestionscsharp { 7 | 8 | [TestFixture] 9 | public class SuggestionsClientTest { 10 | 11 | public SuggestClient api { get; set; } 12 | 13 | [SetUp] 14 | public void SetUp() { 15 | var token = Environment.GetEnvironmentVariable("DADATA_API_KEY"); 16 | var url = "https://suggestions.dadata.ru/suggestions/api/4_1/rs"; 17 | this.api = new SuggestClient(token, url); 18 | } 19 | 20 | [Test] 21 | public void SuggestAddressTest() { 22 | var query = "москва турчанинов 6с2"; 23 | var response = api.QueryAddress(query); 24 | var address_data = response.suggestions[0].data; 25 | Assert.AreEqual("119034", address_data.postal_code); 26 | Assert.AreEqual("7704", address_data.tax_office); 27 | Assert.AreEqual("Кропоткинская", address_data.metro[0].name); 28 | Console.WriteLine(string.Join("\n", response.suggestions)); 29 | } 30 | 31 | [Test] 32 | public void SuggestAddressLocationsKladrTest() { 33 | var query = new AddressSuggestQuery("ватутина"); 34 | var location = new AddressData(); 35 | location.kladr_id = "65"; 36 | query.locations = new AddressData[] { location }; 37 | var response = api.QueryAddress(query); 38 | Assert.AreEqual("693022", response.suggestions[0].data.postal_code); 39 | Console.WriteLine(string.Join("\n", response.suggestions)); 40 | } 41 | 42 | [Test] 43 | public void SuggestAddressLocationsMultipleLocationsTest() { 44 | var query = new AddressSuggestQuery("зеленоград"); 45 | query.locations = new[] { 46 | new AddressData() { kladr_id = "50" }, 47 | new AddressData() { kladr_id = "77" } 48 | }; 49 | var response = api.QueryAddress(query); 50 | Assert.AreEqual("Зеленоград", response.suggestions[0].data.city); 51 | Console.WriteLine(string.Join("\n", response.suggestions)); 52 | } 53 | 54 | [Test] 55 | public void SuggestAddressLocationsFiasCityTest() { 56 | var query = new AddressSuggestQuery("ватутина"); 57 | var location = new AddressData(); 58 | location.city_fias_id = "44388ad0-06aa-49b0-bbf9-1704629d1d68"; // Южно-Сахалинск 59 | query.locations = new AddressData[] { location }; 60 | var response = api.QueryAddress(query); 61 | Assert.AreEqual("693022", response.suggestions[0].data.postal_code); 62 | Console.WriteLine(string.Join("\n", response.suggestions)); 63 | } 64 | 65 | [Test] 66 | public void SuggestAddressBoundsTest() { 67 | var query = new AddressSuggestQuery("ново"); 68 | query.from_bound = new AddressBound("city"); 69 | query.to_bound = new AddressBound("city"); 70 | var response = api.QueryAddress(query); 71 | Assert.AreEqual("Новосибирск", response.suggestions[0].data.city); 72 | Console.WriteLine(string.Join("\n", response.suggestions)); 73 | } 74 | 75 | [Test] 76 | public void SuggestAddressHistoryTest() { 77 | var query = "москва хабар"; 78 | var response = api.QueryAddress(query); 79 | var address_data = response.suggestions[0].data; 80 | Assert.AreEqual("ул Черненко", address_data.history_values[0]); 81 | Console.WriteLine(string.Join("\n", response.suggestions)); 82 | } 83 | 84 | [Test] 85 | public void SuggestBankTest() { 86 | var query = "сбербанк"; 87 | var response = api.QueryBank(query); 88 | Assert.AreEqual("044525225", response.suggestions[0].data.bic); 89 | Assert.AreEqual("Москва", response.suggestions[0].data.address.data.city); 90 | Console.WriteLine(response.suggestions[0].data.opf.type); 91 | Console.WriteLine(response.suggestions[0].data.state.status); 92 | Console.WriteLine(string.Join("\n", response.suggestions)); 93 | } 94 | 95 | [Test] 96 | public void SuggestBankStatusTest() { 97 | var query = new BankSuggestQuery("витас"); 98 | query.status = new PartyStatus[] { PartyStatus.LIQUIDATED }; 99 | var response = api.QueryBank(query); 100 | Assert.AreEqual("044585398", response.suggestions[0].data.bic); 101 | Console.WriteLine(string.Join("\n", response.suggestions)); 102 | } 103 | 104 | [Test] 105 | public void SuggestBankTypeTest() { 106 | var query = new BankSuggestQuery("я"); 107 | query.type = new BankType[] { BankType.NKO }; 108 | var response = api.QueryBank(query); 109 | Assert.AreEqual("044525444", response.suggestions[0].data.bic); 110 | Console.WriteLine(string.Join("\n", response.suggestions)); 111 | } 112 | 113 | [Test] 114 | public void SuggestEmailTest() { 115 | var query = "anton@m"; 116 | var response = api.QueryEmail(query); 117 | Assert.AreEqual("anton@mail.ru", response.suggestions[0].value); 118 | Console.WriteLine(string.Join("\n", response.suggestions)); 119 | } 120 | 121 | [Test] 122 | public void SuggestFioTest() { 123 | var query = "викт"; 124 | var response = api.QueryFio(query); 125 | Assert.AreEqual("Виктор", response.suggestions[0].data.name); 126 | Console.WriteLine(string.Join("\n", response.suggestions)); 127 | } 128 | 129 | [Test] 130 | public void SuggestFioPartsTest() { 131 | var query = new FioSuggestQuery("викт"); 132 | query.parts = new FioPart [] { FioPart.SURNAME }; 133 | var response = api.QueryFio(query); 134 | Assert.AreEqual("Викторова", response.suggestions[0].data.surname); 135 | Console.WriteLine(string.Join ("\n", response.suggestions)); 136 | } 137 | 138 | [Test] 139 | public void SuggestPartyTest() { 140 | var query = "7707083893"; 141 | var response = api.QueryParty(query); 142 | var party = response.suggestions[0]; 143 | var address = response.suggestions[0].data.address; 144 | Assert.AreEqual("7707083893", party.data.inn); 145 | Assert.AreEqual("г Москва, ул Вавилова, д 19", address.value); 146 | Assert.AreEqual("117997 ГОРОД МОСКВА, УЛИЦА ВАВИЛОВА, дом 19", address.data.source); 147 | Assert.AreEqual("117312", address.data.postal_code); 148 | Console.WriteLine(string.Join("\n", response.suggestions)); 149 | } 150 | 151 | [Test] 152 | public void SuggestPartyStatusTest() { 153 | var query = new PartySuggestQuery("витас"); 154 | query.status = new PartyStatus[] { PartyStatus.LIQUIDATED }; 155 | var response = api.QueryParty(query); 156 | Assert.AreEqual("4713008497", response.suggestions[0].data.inn); 157 | Console.WriteLine(string.Join("\n", response.suggestions)); 158 | } 159 | 160 | [Test] 161 | public void SuggestPartyTypeTest() { 162 | var query = new PartySuggestQuery("витас"); 163 | query.type = PartyType.INDIVIDUAL; 164 | var response = api.QueryParty(query); 165 | Assert.AreEqual("773165008890", response.suggestions[0].data.inn); 166 | Console.WriteLine(string.Join("\n", response.suggestions)); 167 | } 168 | } 169 | } 170 | 171 | -------------------------------------------------------------------------------- /src/SuggestModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using RestSharp; 4 | 5 | namespace suggestionscsharp { 6 | 7 | public sealed class ContentType { 8 | readonly string name; 9 | readonly DataFormat format; 10 | 11 | public string Name { 12 | get { return this.name; } 13 | } 14 | 15 | public DataFormat Format { 16 | get { return this.format; } 17 | } 18 | 19 | public static readonly ContentType JSON = new ContentType("application/json", DataFormat.Json); 20 | public static readonly ContentType XML = new ContentType("application/xml", DataFormat.Xml); 21 | 22 | private ContentType(string name, DataFormat format) { 23 | this.name = name; 24 | this.format = format; 25 | } 26 | 27 | public override string ToString () { 28 | return name; 29 | } 30 | } 31 | 32 | public class SuggestQuery { 33 | public string query { get; set; } 34 | public int count { get; set; } 35 | public SuggestQuery(string query) { 36 | this.query = query; 37 | } 38 | } 39 | 40 | public class AddressSuggestQuery : SuggestQuery { 41 | public AddressData[] locations { get; set; } 42 | public AddressData[] locations_boost { get; set; } 43 | public AddressBound from_bound { get; set; } 44 | public AddressBound to_bound { get; set; } 45 | public bool restrict_value { get; set; } 46 | public AddressSuggestQuery(string query) : base(query) { } 47 | } 48 | 49 | public class BankSuggestQuery : SuggestQuery { 50 | public PartyStatus[] status { get; set; } 51 | public BankType[] type { get; set; } 52 | public BankSuggestQuery(string query) : base(query) { } 53 | } 54 | 55 | public class FioSuggestQuery : SuggestQuery { 56 | public FioPart[] parts { get; set; } 57 | public FioSuggestQuery(string query) : base(query) { } 58 | } 59 | 60 | public class PartySuggestQuery : SuggestQuery { 61 | public AddressData[] locations { get; set; } 62 | public AddressData[] locations_boost { get; set; } 63 | public PartyStatus[] status { get; set; } 64 | public PartyType? type { get; set; } 65 | public PartySuggestQuery(string query) : base(query) { } 66 | } 67 | 68 | public class AddressData { 69 | public string source { get; set; } 70 | public string postal_code { get; set; } 71 | public string country { get; set; } 72 | 73 | public string region_fias_id { get; set; } 74 | public string region_kladr_id { get; set; } 75 | public string region_with_type { get; set; } 76 | public string region_type { get; set; } 77 | public string region_type_full { get; set; } 78 | public string region { get; set; } 79 | 80 | public string area_fias_id { get; set; } 81 | public string area_kladr_id { get; set; } 82 | public string area_with_type { get; set; } 83 | public string area_type { get; set; } 84 | public string area_type_full { get; set; } 85 | public string area { get; set; } 86 | 87 | public string city_fias_id { get; set; } 88 | public string city_kladr_id { get; set; } 89 | public string city_with_type { get; set; } 90 | public string city_type { get; set; } 91 | public string city_type_full { get; set; } 92 | public string city { get; set; } 93 | 94 | public string city_area { get; set; } 95 | 96 | public string city_district_fias_id { get; set; } 97 | public string city_district_kladr_id { get; set; } 98 | public string city_district_with_type { get; set; } 99 | public string city_district_type { get; set; } 100 | public string city_district_type_full { get; set; } 101 | public string city_district { get; set; } 102 | 103 | public string settlement_fias_id { get; set; } 104 | public string settlement_kladr_id { get; set; } 105 | public string settlement_with_type { get; set; } 106 | public string settlement_type { get; set; } 107 | public string settlement_type_full { get; set; } 108 | public string settlement { get; set; } 109 | 110 | public string street_fias_id { get; set; } 111 | public string street_kladr_id { get; set; } 112 | public string street_with_type { get; set; } 113 | public string street_type { get; set; } 114 | public string street_type_full { get; set; } 115 | public string street { get; set; } 116 | 117 | public string house_fias_id { get; set; } 118 | public string house_kladr_id { get; set; } 119 | public string house_type { get; set; } 120 | public string house_type_full { get; set; } 121 | public string house { get; set; } 122 | 123 | public string block_type { get; set; } 124 | public string block_type_full { get; set; } 125 | public string block { get; set; } 126 | 127 | public string flat_type { get; set; } 128 | public string flat_type_full { get; set; } 129 | public string flat { get; set; } 130 | public string flat_area { get; set; } 131 | public string square_meter_price { get; set; } 132 | public string flat_price { get; set; } 133 | 134 | public string postal_box { get; set; } 135 | public string fias_id { get; set; } 136 | public string fias_level { get; set; } 137 | public string kladr_id { get; set; } 138 | public string capital_marker { get; set; } 139 | 140 | public string okato { get; set; } 141 | public string oktmo { get; set; } 142 | public string tax_office { get; set; } 143 | public string tax_office_legal { get; set; } 144 | 145 | public string timezone { get; set; } 146 | 147 | public string geo_lat { get; set; } 148 | public string geo_lon { get; set; } 149 | public string qc_geo { get; set; } 150 | 151 | public string beltway_hit { get; set; } 152 | public string beltway_distance { get; set; } 153 | 154 | public List history_values { get; set; } 155 | 156 | public List metro { get; set; } 157 | } 158 | 159 | public class MetroData { 160 | public string name { get; set; } 161 | public string line { get; set; } 162 | public decimal distance { get; set; } 163 | } 164 | 165 | public class AddressBound { 166 | public string value { get; set; } 167 | public AddressBound(string name) { 168 | this.value = name; 169 | } 170 | } 171 | 172 | public class BankData { 173 | public SuggestAddressResponse.Suggestions address { get; set; } 174 | 175 | public string bic { get; set; } 176 | public string swift { get; set; } 177 | public string registration_number { get; set; } 178 | public string correspondent_account { get; set; } 179 | 180 | public BankNameData name { get; set; } 181 | public string okpo { get; set; } 182 | public BankOpfData opf { get; set; } 183 | public string phone { get; set; } 184 | public string rkc { get; set; } 185 | public PartyStateData state { get; set; } 186 | 187 | } 188 | 189 | public class BankNameData { 190 | public string payment { get; set; } 191 | public string full { get; set; } 192 | public string @short { get; set; } 193 | } 194 | 195 | public class BankOpfData { 196 | public BankType type { get; set; } 197 | public string full { get; set; } 198 | public string @short { get; set; } 199 | } 200 | 201 | public enum BankType { 202 | BANK, 203 | NKO, 204 | BANK_BRANCH, 205 | NKO_BRANCH, 206 | RKC, 207 | OTHER 208 | } 209 | 210 | public class EmailData { 211 | public string value { get; set; } 212 | public string local { get; set; } 213 | public string domain { get; set; } 214 | } 215 | 216 | public class FioData { 217 | public string surname { get; set; } 218 | public string name { get; set; } 219 | public string patronymic { get; set; } 220 | public string gender { get; set; } 221 | } 222 | 223 | public enum FioPart { 224 | SURNAME, 225 | NAME, 226 | PATRONYMIC 227 | } 228 | 229 | public class PartyData { 230 | public SuggestAddressResponse.Suggestions address { get; set; } 231 | 232 | public string branch_count { get; set; } 233 | public PartyBranchType branch_type { get; set; } 234 | 235 | public string inn { get; set; } 236 | public string kpp { get; set; } 237 | public string ogrn { get; set; } 238 | public string ogrn_date { get; set; } 239 | public string hid { get; set; } 240 | 241 | public PartyManagementData management { get; set; } 242 | public PartyNameData name { get; set; } 243 | 244 | public string okpo { get; set; } 245 | public string okved { get; set; } 246 | public string okved_type { get; set; } 247 | 248 | public PartyOpfData opf { get; set; } 249 | public PartyStateData state { get; set; } 250 | public PartyType type { get; set; } 251 | } 252 | 253 | public enum PartyBranchType { 254 | MAIN, 255 | BRANCH 256 | } 257 | 258 | public class PartyManagementData { 259 | public string name { get; set; } 260 | public string post { get; set; } 261 | } 262 | 263 | public class PartyNameData { 264 | public string full_with_opf { get; set; } 265 | public string short_with_opf { get; set; } 266 | public string latin { get; set; } 267 | public string full { get; set; } 268 | public string @short { get; set; } 269 | } 270 | 271 | public class PartyOpfData { 272 | public string code { get; set; } 273 | public string full { get; set; } 274 | public string @short { get; set; } 275 | } 276 | 277 | public class PartyStateData { 278 | public string actuality_date { get; set; } 279 | public string registration_date { get; set; } 280 | public string liquidation_date { get; set; } 281 | public PartyStatus status { get; set; } 282 | } 283 | 284 | public enum PartyStatus { 285 | ACTIVE, 286 | LIQUIDATING, 287 | LIQUIDATED 288 | } 289 | 290 | public enum PartyType { 291 | LEGAL, 292 | INDIVIDUAL 293 | } 294 | 295 | public abstract class Suggestion { 296 | public string value { get; set; } 297 | public string unrestricted_value { get; set; } 298 | 299 | public override string ToString() { 300 | return value; 301 | } 302 | } 303 | 304 | public class SuggestAddressResponse { 305 | public class Suggestions: Suggestion { 306 | public AddressData data { get; set; } 307 | } 308 | public List suggestions { get; set; } 309 | } 310 | 311 | public class SuggestBankResponse { 312 | public class Suggestions: Suggestion { 313 | public BankData data { get; set; } 314 | } 315 | public List suggestions { get; set; } 316 | } 317 | 318 | public class SuggestEmailResponse { 319 | public class Suggestions: Suggestion { 320 | public EmailData data { get; set; } 321 | } 322 | public List suggestions { get; set; } 323 | } 324 | 325 | public class SuggestFioResponse { 326 | public class Suggestions: Suggestion { 327 | public FioData data { get; set; } 328 | } 329 | public List suggestions { get; set; } 330 | } 331 | 332 | public class SuggestPartyResponse { 333 | public class Suggestions: Suggestion { 334 | public PartyData data { get; set; } 335 | } 336 | public List suggestions { get; set; } 337 | } 338 | } 339 | -------------------------------------------------------------------------------- /suggestions-csharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {30BEACDE-1B2A-498A-AA8C-5C56A92EAB51} 7 | Library 8 | suggestionscsharp 9 | suggestions-csharp 10 | 8.0.30703 11 | 2.0 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | true 22 | AnyCPU 23 | 24 | 25 | full 26 | true 27 | bin\Release 28 | prompt 29 | 4 30 | true 31 | AnyCPU 32 | 33 | 34 | 35 | 36 | lib\RestSharp.dll 37 | 38 | 39 | lib\nunit.framework.dll 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /suggestions-csharp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "suggestions-csharp", "suggestions-csharp.csproj", "{30BEACDE-1B2A-498A-AA8C-5C56A92EAB51}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {30BEACDE-1B2A-498A-AA8C-5C56A92EAB51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {30BEACDE-1B2A-498A-AA8C-5C56A92EAB51}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {30BEACDE-1B2A-498A-AA8C-5C56A92EAB51}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {30BEACDE-1B2A-498A-AA8C-5C56A92EAB51}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | EndGlobal 18 | --------------------------------------------------------------------------------