From e6382d29f24febf113a95afdb478942a93c9fc14 Mon Sep 17 00:00:00 2001 From: Gustavo Francisco Frizzo Date: Thu, 17 Feb 2022 01:54:21 -0700 Subject: [PATCH 1/7] Upgrading tests to .NET 6. --- BinInfo.Tests/BinInfo.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BinInfo.Tests/BinInfo.Tests.csproj b/BinInfo.Tests/BinInfo.Tests.csproj index 17ee479..6f8a2e8 100644 --- a/BinInfo.Tests/BinInfo.Tests.csproj +++ b/BinInfo.Tests/BinInfo.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + net6.0 false From 9cf1c04f09a421289c1c75c4322a5080a3f55039 Mon Sep 17 00:00:00 2001 From: Gustavo Francisco Frizzo Date: Thu, 17 Feb 2022 01:54:48 -0700 Subject: [PATCH 2/7] Removing legacy TargetFrameworks. --- BinInfo/BinInfo.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BinInfo/BinInfo.csproj b/BinInfo/BinInfo.csproj index 1737c5a..e103cc2 100644 --- a/BinInfo/BinInfo.csproj +++ b/BinInfo/BinInfo.csproj @@ -1,7 +1,7 @@  - net40;net45;netstandard2.0 + netstandard2.0 BinInfo BinInfo BinInfo From eb58f101a3dc5536b793718f4e5ace3faba836b8 Mon Sep 17 00:00:00 2001 From: Gustavo Francisco Frizzo Date: Thu, 17 Feb 2022 01:56:51 -0700 Subject: [PATCH 3/7] Updating test dependencies. --- BinInfo.Tests/BinInfo.Tests.csproj | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BinInfo.Tests/BinInfo.Tests.csproj b/BinInfo.Tests/BinInfo.Tests.csproj index 6f8a2e8..aac7e02 100644 --- a/BinInfo.Tests/BinInfo.Tests.csproj +++ b/BinInfo.Tests/BinInfo.Tests.csproj @@ -7,10 +7,16 @@ - - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + From 1014de1c62cb83950b4ee55ae360cb09929b168a Mon Sep 17 00:00:00 2001 From: Gustavo Francisco Frizzo Date: Thu, 17 Feb 2022 02:16:41 -0700 Subject: [PATCH 4/7] Organizing and cleaning up code. --- BinInfo/BinList.cs | 83 +++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/BinInfo/BinList.cs b/BinInfo/BinList.cs index d8201d5..021d1e4 100644 --- a/BinInfo/BinList.cs +++ b/BinInfo/BinList.cs @@ -24,36 +24,23 @@ public static class BinList /// IssuerInformation public static IssuerInformation Find(string bin) { - if (bin == null) - throw new ArgumentNullException("bin"); - - if (!bin.Trim().All(c => char.IsNumber(c)) || string.IsNullOrWhiteSpace(bin)) - throw new ArgumentException("Make sure to enter a valid BIN/IIN number."); + BinSanityCheck(bin); - using (WebClient web = new WebClient()) + try { - try - { - string json = web.DownloadString(BaseUrl + bin); - - DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(IssuerInformation)); - - using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json))) - { - var issuerInfo = (IssuerInformation)serializer.ReadObject(stream); - return issuerInfo; - } - } - catch (WebException ex) + using (var web = new WebClient()) { - string addInfo = $"No results for {bin}. Make sure you enter a valid BIN/IIN number. --- "; - throw new WebException(addInfo + ex.Message, ex, ex.Status, ex.Response); + var json = web.DownloadString($"{BaseUrl}{bin}"); + return GetIssuerInformation(json); } } + catch (WebException ex) + { + var addInfo = $"No results for {bin}. Make sure you enter a valid BIN/IIN number. --- "; + throw new WebException(addInfo + ex.Message, ex, ex.Status, ex.Response); + } } -#if !NET40 - /// /// binlist.net is a public web service for searching Issuer Identification Numbers (IIN). /// This webservice has an internal database with IIN/BIN information. @@ -65,34 +52,40 @@ public static IssuerInformation Find(string bin) /// IssuerInformation public async static Task FindAsync(string bin) { - if (bin == null) - throw new ArgumentNullException("bin"); + BinSanityCheck(bin); - if (!bin.Trim().All(c => char.IsNumber(c)) || string.IsNullOrWhiteSpace(bin)) - throw new ArgumentException("Make sure to enter a valid BIN/IIN number."); - - using (WebClient web = new WebClient()) + try { - try + using (var web = new WebClient()) { - string json = await web.DownloadStringTaskAsync(BaseUrl + bin); - - DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(IssuerInformation)); - - using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json))) - { - var issuerInfo = (IssuerInformation)serializer.ReadObject(stream); - return issuerInfo; - } - } - catch (WebException ex) - { - string addInfo = $"No results for {bin}. Make sure you enter a valid BIN/IIN number. --- "; - throw new WebException(addInfo + ex.Message, ex, ex.Status, ex.Response); + var json = await web.DownloadStringTaskAsync($"{BaseUrl}{bin}"); + return GetIssuerInformation(json); } } + catch (WebException ex) + { + var addInfo = $"No results for {bin}. Make sure you enter a valid BIN/IIN number. --- "; + throw new WebException(addInfo + ex.Message, ex, ex.Status, ex.Response); + } } -#endif + private static IssuerInformation GetIssuerInformation(string json) + { + using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json))) + { + var serializer = new DataContractJsonSerializer(typeof(IssuerInformation)); + var issuerInfo = (IssuerInformation)serializer.ReadObject(stream); + return issuerInfo; + } + } + + private static void BinSanityCheck(string bin) + { + if (bin == null) + throw new ArgumentNullException("bin"); + + if (!bin.Trim().All(c => char.IsNumber(c)) || string.IsNullOrWhiteSpace(bin)) + throw new ArgumentException("Make sure to enter a valid BIN/IIN number."); + } } } From 59c9aaa94f72258fddc44f40d8f91bdd83f39781 Mon Sep 17 00:00:00 2001 From: Gustavo Francisco Frizzo Date: Thu, 17 Feb 2022 02:20:54 -0700 Subject: [PATCH 5/7] Updating github workflows. --- .github/workflows/dotnet-build-and-tests.yml | 26 ++++++++++++++++++++ .github/workflows/dotnetcore.yml | 23 ----------------- 2 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/dotnet-build-and-tests.yml delete mode 100644 .github/workflows/dotnetcore.yml diff --git a/.github/workflows/dotnet-build-and-tests.yml b/.github/workflows/dotnet-build-and-tests.yml new file mode 100644 index 0000000..89e69d7 --- /dev/null +++ b/.github/workflows/dotnet-build-and-tests.yml @@ -0,0 +1,26 @@ +name: Build & Tests + +on: [push] + +jobs: + build: + + name: Run Build & Tests + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ubuntu-latest] + dotnet-version: ['6.0.x'] + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET ${{ matrix.dotnet-version }} + uses: actions/setup-dotnet@v1.7.2 + with: + dotnet-version: ${{ matrix.dotnet-version }} + - name: Install dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration Release --no-restore + - name: Test + run: dotnet test --no-restore --verbosity normal diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml deleted file mode 100644 index a0f1b1d..0000000 --- a/.github/workflows/dotnetcore.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: .NET Core - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 2.2.108 - - name: Build Projects - run: dotnet build --configuration Release - - name: Run Tests - run: dotnet test --configuration Release From 4566f690c0092e09ffb14d5ffbc7b04b7fd44abd Mon Sep 17 00:00:00 2001 From: Gustavo Frizzo Date: Thu, 17 Feb 2022 02:24:43 -0700 Subject: [PATCH 6/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2513f6b..b6de620 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# BinInfo ![.NET Core](https://github.com/gustavofrizzo/BinInfo/workflows/.NET%20Core/badge.svg?branch=master) +# BinInfo [![Build & Tests](https://github.com/gustavofrizzo/BinInfo/actions/workflows/dotnet-build-and-tests.yml/badge.svg)](https://github.com/gustavofrizzo/BinInfo/actions/workflows/dotnet-build-and-tests.yml) BinInfo gets information about Credit Card Issuers through [binlist.net](http://binlist.net) public REST API. From 48374321e10638fc2385ab89f65a23df81ebc876 Mon Sep 17 00:00:00 2001 From: Gustavo Frizzo Date: Sat, 5 Mar 2022 23:44:30 -0700 Subject: [PATCH 7/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6de620..8c412d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # BinInfo [![Build & Tests](https://github.com/gustavofrizzo/BinInfo/actions/workflows/dotnet-build-and-tests.yml/badge.svg)](https://github.com/gustavofrizzo/BinInfo/actions/workflows/dotnet-build-and-tests.yml) -BinInfo gets information about Credit Card Issuers through [binlist.net](http://binlist.net) public REST API. +BinInfo is an API wrapper that retrieves information about Credit Card Issuers through [binlist.net](http://binlist.net) public REST API. NuGet Package -> https://www.nuget.org/packages/BinInfo