From 9fb269f091c8f3c1139a110d0fd9ac4b62cab969 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 23 Oct 2020 00:25:16 -0300 Subject: [PATCH 1/5] Add .NET Standard 2.0 support --- Src/ViaCEP/ViaCEP.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Src/ViaCEP/ViaCEP.csproj b/Src/ViaCEP/ViaCEP.csproj index 0b270f7..2cc24c0 100644 --- a/Src/ViaCEP/ViaCEP.csproj +++ b/Src/ViaCEP/ViaCEP.csproj @@ -2,13 +2,13 @@ A251D320-410E-48F1-889D-9F59EB8CFEB9 - netstandard2.1 + netstandard2.0;netstandard2.1 true Guilherme Branco Stracini © 2020 Guilherme Branco Stracini. All rights reserved. The ViaCEP WebService client for .NET projects (both .NET Core and .NET Framework) - https://github.com/guibranco/ViaCEP/ - https://github.com/guibranco/ViaCEP + https://guibranco.github.io/ViaCEP/ + https://github.com/guibranco/ViaCEP/ GIT cep zipcode postalcode postal zip address location api webservice brasil brazil correios ibge gia mf fazenda https://raw.githubusercontent.com/guibranco/ViaCEP/master/logo.png?v=1 From fb0988dbbf1d803dcb34d4984bf600c19392d2f9 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 23 Oct 2020 00:25:52 -0300 Subject: [PATCH 2/5] Add autoMerge workflow --- .github/workflows/autoMerge.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/autoMerge.yml diff --git a/.github/workflows/autoMerge.yml b/.github/workflows/autoMerge.yml new file mode 100644 index 0000000..570bb8a --- /dev/null +++ b/.github/workflows/autoMerge.yml @@ -0,0 +1,27 @@ +name: Auto merge approved pull requests +on: + pull_request: + types: + - labeled + - unlabeled + - synchronize + - opened + - edited + - ready_for_review + - reopened + - unlocked + pull_request_review: + types: + - submitted + check_suite: + types: + - completed + status: {} +jobs: + autoMerge: + runs-on: ubuntu-latest + steps: + - name: autoMerge + uses: "pascalgn/automerge-action@f81beb99aef41bb55ad072857d43073fba833a98" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" From 6d5013512c1e973b8adac4be1095ff56b990fa20 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 23 Oct 2020 00:26:34 -0300 Subject: [PATCH 3/5] Update version from 3.0 to 3.1 --- Tests/ViaCEP.Tests/ResultsFixture.cs | 22 +++++++++++++++++++++- ViaCEP.sln.DotSettings | 7 +++++++ appveyor.yml | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 ViaCEP.sln.DotSettings diff --git a/Tests/ViaCEP.Tests/ResultsFixture.cs b/Tests/ViaCEP.Tests/ResultsFixture.cs index eb3f0bd..21386b0 100644 --- a/Tests/ViaCEP.Tests/ResultsFixture.cs +++ b/Tests/ViaCEP.Tests/ResultsFixture.cs @@ -1,9 +1,29 @@ -using System.Collections.Generic; +// *********************************************************************** +// Assembly : ViaCep.Tests +// Author : Guilherme Branco Stracini +// Created : 10-23-2020 +// +// Last Modified By : Guilherme Branco Stracini +// Last Modified On : 10-23-2020 +// *********************************************************************** +// +// Copyright (c) Guilherme Branco Stracini ME. All rights reserved. +// +// +// *********************************************************************** +using System.Collections.Generic; namespace ViaCep.Tests { + /// + /// Class ResultsFixture. + /// internal static class ResultsFixture { + /// + /// Gets the sample results. + /// + /// ICollection<ViaCepResult>. public static ICollection GetSampleResults() => new List { diff --git a/ViaCEP.sln.DotSettings b/ViaCEP.sln.DotSettings new file mode 100644 index 0000000..df084fb --- /dev/null +++ b/ViaCEP.sln.DotSettings @@ -0,0 +1,7 @@ + + IBGE + True + True + True + True + True \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 1a6a722..f1caaa5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 3.0.{build} +version: 3.1.{build} skip_tags: true image: Visual Studio 2019 configuration: Release From f8bbcc795ab5b8e216e93112ff33f3e052122ea8 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 23 Oct 2020 00:38:15 -0300 Subject: [PATCH 4/5] Update readme.md --- README.md | 40 ++++++++++------- Src/ViaCep/VIaCEPResult.cs | 91 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 17 deletions(-) create mode 100644 Src/ViaCep/VIaCEPResult.cs diff --git a/README.md b/README.md index 1f0e649..b8229ec 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,18 @@ A .NET client wrapper for both .NET Core & .NET Framework projects of [Via CEP API](https://viacep.com.br) +[![GitHub license](https://img.shields.io/github/license/guibranco/ViaCep)](https://github.com/guibranco/ViaCep) +[![time tracker](https://wakatime.com/badge/github/guibranco/ViaCEP.svg)](https://wakatime.com/badge/github/guibranco/ViaCEP) + ![Via CEP](https://raw.githubusercontent.com/guibranco/viacep/master/logo.png) + ## CI/CD -[![Build status](https://ci.appveyor.com/api/projects/status/9jnsy1e08jhyxl7j?svg=true)](https://ci.appveyor.com/project/guibranco/viacep) -[![SMSDev NuGet Version](https://img.shields.io/nuget/v/ViaCEP.svg?style=flat)](https://www.nuget.org/packages/ViaCEP/) -[![SMSDev NuGet Downloads](https://img.shields.io/nuget/dt/ViaCEP.svg?style=flat)](https://www.nuget.org/packages/ViaCEP/) -[![Github All Releases](https://img.shields.io/github/downloads/guibranco/ViaCEP/total.svg?style=flat)](https://github.com/guibranco/ViaCEP) -[![Last release](https://img.shields.io/github/release-date/guibranco/ViaCEP.svg?style=flat)](https://github.com/guibranco/ViaCEP) +| Branch | Build status | Last commit | Tests | +|--------|--------------|-------------|-------| +| Master | [![Build status](https://ci.appveyor.com/api/projects/status/9jnsy1e08jhyxl7j/branch/master?svg=true)](https://ci.appveyor.com/project/guibranco/ViaCEP) | [![GitHub last commit](https://img.shields.io/github/last-commit/guibranco/ViaCEP/master)](https://github.com/guibranco/ViaCEP) | ![AppVeyor tests (branch)](https://img.shields.io/appveyor/tests/guibranco/ViaCEP/master?compact_message) | +| Develop | [![Build status](https://ci.appveyor.com/api/projects/status/9jnsy1e08jhyxl7j/branch/develop?svg=true)](https://ci.appveyor.com/project/guibranco/ViaCEP/branch/develop) | [![GitHub last commit](https://img.shields.io/github/last-commit/guibranco/ViaCEP/develop)](https://github.com/guibranco/ViaCEP) | ![AppVeyor tests (branch)](https://img.shields.io/appveyor/tests/guibranco/ViaCEP/develop?compact_message) | ## Code Quality @@ -34,17 +37,17 @@ A .NET client wrapper for both .NET Core & .NET Framework projects of [Via CEP A ## Installation -Download the latest zip file from the [Release pages](https://github.com/guibranco/ViaCEP/releases) or simple install from [NuGet](https://www.nuget.org/packages/ViaCEP) package manager - -NuGet URL: [https://www.nuget.org/packages/ViaCEP](https://www.nuget.org/packages/ViaCEP) +### Github Releases -NuGet installation via *Package Manager Console*: +[![GitHub last release](https://img.shields.io/github/release-date/guibranco/ViaCEP.svg?style=flat)](https://github.com/guibranco/ViaCEP) [![Github All Releases](https://img.shields.io/github/downloads/guibranco/ViaCEP/total.svg?style=flat)](https://github.com/guibranco/ViaCEP) -```ps +Download the latest zip file from the [Release](https://github.com/GuiBranco/ViaCEP/releases) page. -Install-Package ViaCEP +### Nuget package manager -``` +| Package | Version | Downloads | +|------------------|:-------:|:-------:| +| **ViaCEP** | [![ViaCEP NuGet Version](https://img.shields.io/nuget/v/ViaCEP.svg?style=flat)](https://www.nuget.org/packages/ViaCEP/) | [![ViaCEP NuGet Downloads](https://img.shields.io/nuget/dt/ViaCEP.svg?style=flat)](https://www.nuget.org/packages/ViaCEP/) | --- @@ -59,9 +62,7 @@ This package is fully compatible with Dependency Injection. Use the interface *I ```cs //your DI container -services.AddHttpClient(client => { - client.BaseAddress = new Uri("https://viacep.com.br/"); -}); +services.AddHttpClient(client => { client.BaseAddress = new Uri("https://viacep.com.br/"); }); //then use in your domain service, handler, controller... var viaCepClient = container.GetService(); @@ -70,7 +71,7 @@ var result = await viaCepClient.SearchAsync("01001000", cancellationToken); You can search using the zip code/postal code (AKA CEP) or using the address data (state initials - UF, city name and location name - street, avenue, park, square). Both methods support async and sync! -## Querying by zip code / postal code (single result) +### Querying by zip code / postal code (single result) ```cs var result = new ViaCepClient().Search("01001000"); //searches for the postal code 01001-000 @@ -79,7 +80,7 @@ var city = reuslt.City; //São Paulo //do what you need with 'result' instance of ViaCEPResult. ``` -## Querying by address (list result) +### Querying by address (list result) ```cs var results = new ViaCepClient().Search("SP", "São Paulo", "Avenida Paulista"); //search for the Avenida Paulista in São Paulo / SP @@ -90,3 +91,8 @@ foreach(var result in results){ //do what you need with 'result' instance of ViaCEPResult. } ``` + +## Changelog + +- 2020-10-23 - Version 3.1: + - Add support to .NET Standard 2.0 and .NET Framework v4.6.1 and above - [@guibranco](https://github.com/guibranco) \ No newline at end of file diff --git a/Src/ViaCep/VIaCEPResult.cs b/Src/ViaCep/VIaCEPResult.cs new file mode 100644 index 0000000..3c20f56 --- /dev/null +++ b/Src/ViaCep/VIaCEPResult.cs @@ -0,0 +1,91 @@ +namespace ViaCep +{ + using Newtonsoft.Json; + + /// + /// The Via CEP result class. + /// + public sealed class ViaCepResult + { + /// + /// Gets or sets the zip code. + /// + /// + /// The zip code. + /// + [JsonProperty("cep")] + public string ZipCode { get; set; } + + /// + /// Gets or sets the street. + /// + /// + /// The street. + /// + [JsonProperty("logradouro")] + public string Street { get; set; } + + /// + /// Gets or sets the complement. + /// + /// + /// The complement. + /// + [JsonProperty("complemento")] + public string Complement { get; set; } + + /// + /// Gets or sets the neighborhood. + /// + /// + /// The neighborhood. + /// + [JsonProperty("bairro")] + public string Neighborhood { get; set; } + + /// + /// Gets or sets the city. + /// + /// + /// The city. + /// + [JsonProperty("localidade")] + public string City { get; set; } + + /// + /// Gets or sets the state initials. + /// + /// + /// The state initials. + /// + [JsonProperty("uf")] + public string StateInitials { get; set; } + + /// + /// Gets or sets the unit. + /// + /// + /// The unit. + /// + [JsonProperty("unidade")] + public string Unit { get; set; } + + /// + /// Gets or sets the ibge code. + /// + /// + /// The ibge code. + /// + [JsonProperty("ibge")] + public int IBGECode { get; set; } + + /// + /// Gets or sets the gia code. + /// + /// + /// The gia code. + /// + [JsonProperty("gia")] + public int? GIACode { get; set; } + } +} From 43b2a7105b7a2f8d37d8a0b341444a8cdf3e0df7 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Fri, 23 Oct 2020 00:39:50 -0300 Subject: [PATCH 5/5] Update appveyor.yml --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f1caaa5..aa6906a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ before_build: - cmd: nuget restore - cmd: choco install opencover.portable - cmd: choco install codecov -- cmd: curl -L https://github.com/codacy/codacy-coverage-reporter/releases/download/7.7.0/codacy-coverage-reporter-assembly-7.7.0.jar > ./codacy-test-reporter.jar +- cmd: curl -L https://github.com/codacy/codacy-coverage-reporter/releases/download/11.2.3/codacy-coverage-reporter-assembly-11.2.3.jar > ./codacy-test-reporter.jar - cmd: dotnet tool install --global dotnet-sonarscanner build: @@ -65,7 +65,7 @@ build_script: /d:sonar.login="$env:SONAR_TOKEN" }' after_build: -- xcopy %CD%\Src\%SOLUTION_NAME%\bin\Release\netstandard2.1\*.* %CD%\Build\ +- xcopy %CD%\Src\%SOLUTION_NAME%\bin\Release\netstandard2.0\*.* %CD%\Build\ - copy %CD%\Src\%SOLUTION_NAME%\bin\Release\%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg %SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg - rd /s /q %CD%\Src\%SOLUTION_NAME%\bin\Release\ - xcopy %CD%\Tests\%SOLUTION_NAME%.Tests\*.xml %CD%\Coverage\