Skip to content

Commit

Permalink
Merge pull request #34 from guibranco/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
guibranco committed Oct 23, 2020
2 parents 6b8f732 + 3c4b5d6 commit 04a94cb
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 24 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/autoMerge.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/) |

---

Expand All @@ -59,9 +62,7 @@ This package is fully compatible with Dependency Injection. Use the interface *I

```cs
//your DI container
services.AddHttpClient<IViaCepClient, ViaCepClient>(client => {
client.BaseAddress = new Uri("https://viacep.com.br/");
});
services.AddHttpClient<IViaCepClient, ViaCepClient>(client => { client.BaseAddress = new Uri("https://viacep.com.br/"); });

//then use in your domain service, handler, controller...
var viaCepClient = container.GetService<IViaCepClient>();
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
6 changes: 3 additions & 3 deletions Src/ViaCEP/ViaCEP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<ProjectGuid>A251D320-410E-48F1-889D-9F59EB8CFEB9</ProjectGuid>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Guilherme Branco Stracini</Authors>
<Copyright>© 2020 Guilherme Branco Stracini. All rights reserved.</Copyright>
<Description>The ViaCEP WebService client for .NET projects (both .NET Core and .NET Framework)</Description>
<PackageProjectUrl>https://github.com/guibranco/ViaCEP/</PackageProjectUrl>
<RepositoryUrl>https://github.com/guibranco/ViaCEP</RepositoryUrl>
<PackageProjectUrl>https://guibranco.github.io/ViaCEP/</PackageProjectUrl>
<RepositoryUrl>https://github.com/guibranco/ViaCEP/</RepositoryUrl>
<RepositoryType>GIT</RepositoryType>
<PackageTags>cep zipcode postalcode postal zip address location api webservice brasil brazil correios ibge gia mf fazenda</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/guibranco/ViaCEP/master/logo.png?v=1</PackageIconUrl>
Expand Down
91 changes: 91 additions & 0 deletions Src/ViaCep/VIaCEPResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
namespace ViaCep
{
using Newtonsoft.Json;

/// <summary>
/// The Via CEP result class.
/// </summary>
public sealed class ViaCepResult
{
/// <summary>
/// Gets or sets the zip code.
/// </summary>
/// <value>
/// The zip code.
/// </value>
[JsonProperty("cep")]
public string ZipCode { get; set; }

/// <summary>
/// Gets or sets the street.
/// </summary>
/// <value>
/// The street.
/// </value>
[JsonProperty("logradouro")]
public string Street { get; set; }

/// <summary>
/// Gets or sets the complement.
/// </summary>
/// <value>
/// The complement.
/// </value>
[JsonProperty("complemento")]
public string Complement { get; set; }

/// <summary>
/// Gets or sets the neighborhood.
/// </summary>
/// <value>
/// The neighborhood.
/// </value>
[JsonProperty("bairro")]
public string Neighborhood { get; set; }

/// <summary>
/// Gets or sets the city.
/// </summary>
/// <value>
/// The city.
/// </value>
[JsonProperty("localidade")]
public string City { get; set; }

/// <summary>
/// Gets or sets the state initials.
/// </summary>
/// <value>
/// The state initials.
/// </value>
[JsonProperty("uf")]
public string StateInitials { get; set; }

/// <summary>
/// Gets or sets the unit.
/// </summary>
/// <value>
/// The unit.
/// </value>
[JsonProperty("unidade")]
public string Unit { get; set; }

/// <summary>
/// Gets or sets the ibge code.
/// </summary>
/// <value>
/// The ibge code.
/// </value>
[JsonProperty("ibge")]
public int IBGECode { get; set; }

/// <summary>
/// Gets or sets the gia code.
/// </summary>
/// <value>
/// The gia code.
/// </value>
[JsonProperty("gia")]
public int? GIACode { get; set; }
}
}
22 changes: 21 additions & 1 deletion Tests/ViaCEP.Tests/ResultsFixture.cs
Original file line number Diff line number Diff line change
@@ -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 file="ResultsFixture.cs" company="Guilherme Branco Stracini ME">
// Copyright (c) Guilherme Branco Stracini ME. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Collections.Generic;

namespace ViaCep.Tests
{
/// <summary>
/// Class ResultsFixture.
/// </summary>
internal static class ResultsFixture
{
/// <summary>
/// Gets the sample results.
/// </summary>
/// <returns>ICollection&lt;ViaCepResult&gt;.</returns>
public static ICollection<ViaCepResult> GetSampleResults() =>
new List<ViaCepResult>
{
Expand Down
7 changes: 7 additions & 0 deletions ViaCEP.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IBGE/@EntryIndexedValue">IBGE</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Centro/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Direita/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=IBGE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Paulo/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unidade/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 3.0.{build}
version: 3.1.{build}
skip_tags: true
image: Visual Studio 2019
configuration: Release
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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\
Expand Down

0 comments on commit 04a94cb

Please sign in to comment.