Skip to content

Commit

Permalink
Merge pull request #7 from gustavofrizzo/move-to-dotnet-6
Browse files Browse the repository at this point in the history
Move to dotnet 6
  • Loading branch information
gustavofrizzo authored Mar 6, 2022
2 parents 740259b + 3fe03eb commit 22b4a76
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 76 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/dotnet-build-and-tests.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
23 changes: 0 additions & 23 deletions .github/workflows/dotnetcore.yml

This file was deleted.

16 changes: 11 additions & 5 deletions BinInfo.Tests/BinInfo.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion BinInfo/BinInfo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net40;net45;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>BinInfo</AssemblyName>
<RootNamespace>BinInfo</RootNamespace>
<PackageId>BinInfo</PackageId>
Expand Down
83 changes: 38 additions & 45 deletions BinInfo/BinList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,23 @@ public static class BinList
/// <returns>IssuerInformation</returns>
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

/// <summary>
/// binlist.net is a public web service for searching Issuer Identification Numbers (IIN).
/// <para>This webservice has an internal database with IIN/BIN information.</para>
Expand All @@ -65,34 +52,40 @@ public static IssuerInformation Find(string bin)
/// <returns>IssuerInformation</returns>
public async static Task<IssuerInformation> 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.");
}
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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](https://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

Expand Down

0 comments on commit 22b4a76

Please sign in to comment.