From 9297bdefb5dbefb01fbe5502e6a6db541eed678a Mon Sep 17 00:00:00 2001 From: mahan Date: Wed, 15 Oct 2025 10:38:50 +0330 Subject: [PATCH] feat: add bank inquiry methods and UidBanks enum for bank identification --- 0_Framework/Application/UID/IUidService.cs | 45 ++++++- 0_Framework/Application/UID/UidBanks.cs | 117 ++++++++++++++++++ .../Application/UID/UidBanksExtension.cs | 27 ++++ .../Services/UidService.cs | 23 +++- 4 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 0_Framework/Application/UID/UidBanks.cs create mode 100644 0_Framework/Application/UID/UidBanksExtension.cs diff --git a/0_Framework/Application/UID/IUidService.cs b/0_Framework/Application/UID/IUidService.cs index c2c26bd5..a1ac1e4c 100644 --- a/0_Framework/Application/UID/IUidService.cs +++ b/0_Framework/Application/UID/IUidService.cs @@ -110,6 +110,46 @@ public interface IUidService { Task GetPersonalInfo(string nationalCode , string birthDate); Task IsMachPhoneWithNationalCode(string nationalCode , string phoneNumber); + Task IbanInquiry (string iban); + Task AccountToIban(string accountNumber, UidBanks bank); + Task CardToIban(string cardNumber); +} + +public class CardToNumberResponse:UidBaseResponse +{ + public string Iban { get; set; } +} + +public class AccountToIbanResponse:UidBaseResponse +{ + public string Iban { get; set; } +} + +public class IbanInquiryResponse:UidBaseResponse +{ + public IbanInquiryAccountBasicInformation AccountBasicInformation { get; set; } +} + +public class IbanInquiryAccountBasicInformation +{ + public string Iban { get; set; } + public string AccountNumber { get; set; } + public IbanInquiryBankInformation BankInformation { get; set; } + public string AccountStatus { get; set; } + public List Owners { get; set; } +} + +public class IbanInquiryBankInformation +{ + public string BankName { get; set; } +} + +public class IbanInquiryOwner +{ + public string FirstName { get; set; } + public string LastName { get; set; } + public string NationalIdentifier { get; set; } + public string CustomerType { get; set; } } public class MatchMobileWithNationalCodeResponse @@ -118,4 +158,7 @@ public class MatchMobileWithNationalCodeResponse public ResponseContext ResponseContext { get; set; } } - +public class UidBaseResponse +{ + public ResponseContext ResponseContext { get; set; } +} diff --git a/0_Framework/Application/UID/UidBanks.cs b/0_Framework/Application/UID/UidBanks.cs new file mode 100644 index 00000000..16e0c3d4 --- /dev/null +++ b/0_Framework/Application/UID/UidBanks.cs @@ -0,0 +1,117 @@ +using System.ComponentModel; + +namespace _0_Framework.Application.UID; + +public enum UidBanks +{ + [Description("بانک دی")] + BANK_DEY = 66, + + [Description("بانک سپه")] + BANK_SEPAH = 15, + + [Description("بانک شهر")] + BANK_SHAHR = 61, + + [Description("بانک ملت")] + BANK_MELAT = 12, + + [Description("بانک ملی")] + BANK_MELLI = 17, + + [Description("بانک رفاه کارگران")] + BANK_REFAH = 13, + + [Description("بانک سینا")] + BANK_SINA = 59, + + [Description("بانک مسکن")] + BANK_MASKAN = 14, + + [Description("بانک آینده")] + BANK_AYANDEH = 62, + + [Description("بانک انصار")] + BANK_ANSAR = 63, + + [Description("بانک تجارت")] + BANK_TEJARAT = 18, + + [Description("بانک رسالت")] + BANK_RESALAT = 70, + + [Description("بانک سامان")] + BANK_SAMAN = 56, + + [Description("بانک مرکزی")] + BANK_MARKAZI = 10, + + [Description("بانک سرمایه")] + BANK_SARMAYEH = 58, + + [Description("بانک صادرات")] + BANK_SADERAT = 19, + + [Description("بانک قوامین")] + BANK_GHAVAMIN = 52, + + [Description("بانک پارسیان")] + BANK_PARSIAN = 54, + + [Description("بانک کشاورزی")] + BANK_KESHAVARZI = 16, + + [Description("بانک گردشگری")] + BANK_GARDESHGARI = 64, + + [Description("پست بانک")] + BANK_POST_BANK = 21, + + [Description("بانک پاسارگاد")] + BANK_PASARGAD = 57, + + [Description("بانک کارآفرین")] + BANK_KARAFARIN = 53, + + [Description("بانک خاورمیانه")] + BANK_KHAVARMIANEH = 78, + + [Description("بانک ایران زمین")] + BANK_IRAN_ZAMIN = 69, + + [Description("بانک مهر اقتصاد")] + BANK_MEHR_EQTESAD = 79, + + [Description("بانک صنعت و معدن")] + BANK_SANAT_MADAN = 11, + + [Description("بانک اقتصاد نوین")] + BANK_EGHTESAD_NOVIN = 55, + + [Description("بانک توسعه تعاون")] + BANK_TOSSE_TAAVON = 22, + + [Description("بانک توسعه صادرات")] + BANK_TOSSE_SADERAT = 20, + + [Description("بانک ایران و ونزوئلا")] + BANK_IRAN_VENEZUELA = 95, + + [Description("بانک حکمت ایرانیان")] + BANK_HEKMAT_IRANIAN = 65, + + [Description("بانک قرض الحسنه مهر")] + BANK_GHARZOLHASANEH_MEHR = 60, + + [Description("موسسه مالی و اعتباری ملل")] + BANK_MOASSASE_MELLAL = 75, + + [Description("موسسه مالی و اعتباری نور")] + BANK_MOASSASE_NOOR = 80, + + [Description("موسسه مالی و اعتباری کوثر")] + BANK_MOASSASE_KOSAR = 73, + + [Description("موسسه مالی و اعتباری توسعه")] + BANK_MOASSASE_TOSSE = 51 +} \ No newline at end of file diff --git a/0_Framework/Application/UID/UidBanksExtension.cs b/0_Framework/Application/UID/UidBanksExtension.cs new file mode 100644 index 00000000..98a46f16 --- /dev/null +++ b/0_Framework/Application/UID/UidBanksExtension.cs @@ -0,0 +1,27 @@ +using System; +using System.ComponentModel; +using System.Reflection; + +namespace _0_Framework.Application.UID +{ + public static class UidBanksExtension + { + /// + /// دریافت نام فارسی بانک + /// + /// بانک + /// نام فارسی بانک + public static string GetPersianName(this UidBanks bank) + { + var fieldInfo = bank.GetType().GetField(bank.ToString()); + + if (fieldInfo == null) + return string.Empty; + + var attribute = (DescriptionAttribute)Attribute.GetCustomAttribute( + fieldInfo, typeof(DescriptionAttribute)); + + return attribute?.Description ?? bank.ToString(); + } + } +} diff --git a/CompanyManagment.EFCore/Services/UidService.cs b/CompanyManagment.EFCore/Services/UidService.cs index f6abc73b..e05023f4 100644 --- a/CompanyManagment.EFCore/Services/UidService.cs +++ b/CompanyManagment.EFCore/Services/UidService.cs @@ -14,7 +14,11 @@ public class UidService : IUidService { private readonly HttpClient _httpClient; private readonly IAuthorizedPersonApplication _authorizedPersonApplication; - private const string BaseUrl = "https://json-api.uid.ir/api/inquiry/"; + private const string BaseUrl = "https://json-api.uid.ir/api/"; + + public const string BusinessToken = "5e03dd4e-999d-466f-92d8-7c0b1f66a8e9"; + public const string BusinessId = "98ed67ca-d441-4978-a748-e8bebce010eb"; + public UidService(IAuthorizedPersonApplication authorizedPersonApplication) { @@ -53,7 +57,7 @@ public class UidService : IUidService try { - var requestResult = await _httpClient.PostAsync("person/v2", contentType); + var requestResult = await _httpClient.PostAsync("inquiry/person/v2", contentType); if (!requestResult.IsSuccessStatusCode) return null; var responseResult = await requestResult.Content.ReadFromJsonAsync(); @@ -145,4 +149,19 @@ public class UidService : IUidService var responseResult = await requestResult.Content.ReadFromJsonAsync(); return responseResult; } + + public Task IbanInquiry(string iban) + { + throw new NotImplementedException(); + } + + public Task AccountToIban(string accountNumber, UidBanks bank) + { + throw new NotImplementedException(); + } + + public Task CardToIban(string cardNumber) + { + throw new NotImplementedException(); + } }