GithubHelp home page GithubHelp logo

guibranco / viacep Goto Github PK

View Code? Open in Web Editor NEW
36.0 2.0 10.0 396 KB

🇧🇷 :round_pushpin: ViaCEP client wrapper for .NET projects

Home Page: https://guibranco.github.io/ViaCEP/

License: MIT License

C# 97.74% Shell 2.26%
postal code zip zipcode postalcode correios ibge gia mf fazenda

viacep's Introduction

ViaCEP SDK .NET

A .NET client wrapper for both .NET Core & .NET Framework projects of Via CEP API

GitHub license time tracker

Via CEP

CI/CD

Build status Last commit Tests Coverage Code Smells LOC
Build status GitHub last commit AppVeyor tests (branch) Coverage Code Smells Lines of Code

Code Quality

Codacy Badge Codacy Badge

codecov CodeFactor

Maintainability Test Coverage

Quality Gate Status Maintainability Rating

Technical Debt Duplicated Lines (%)

Reliability Rating Security Rating

Bugs Vulnerabilities

DeepSource


Installation

Github Releases

GitHub last release Github All Releases

Download the latest zip file from the Release page.

Nuget package manager

Package Version Downloads
ViaCEP ViaCEP NuGet Version ViaCEP NuGet Downloads

Usage

The package has two classes:

This package is fully compatible with Dependency Injection. Use the interface IViaCepClient and the constructor with HttpClient parameter with a IHttpClientFactory instance.

//your DI container
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>();
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)

var result = new ViaCepClient().Search("01001000"); //searches for the postal code 01001-000
var address = result.Address; //Praça da Sé
var city = reuslt.City; //São Paulo
//do what you need with 'result' instance of ViaCEPResult.

Querying by address (list result)

var results = new ViaCepClient().Search("SP", "São Paulo", "Avenida Paulista"); //search for the Avenida Paulista in São Paulo / SP
foreach(var result in results){
    var address = result.Address;
    var neighborhood = result.Neighborhood;
    var zipCode = result.ZipCode;
    //do what you need with 'result' instance of ViaCEPResult.
}

Changelog

  • 2023-07-28: Add integration tests #71 by @Riju-bak
  • 2023-03-03: Update dependencies, change branch name, update logo. @guibranco
  • 2021-06-21: Update dependencies version. @guibranco
  • 2020-10-23: Add support to .NET Standard 2.0 and .NET Framework v4.6.1 and above. @guibranco

viacep's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar guibranco avatar riju-bak avatar snyk-bot avatar stacksharebot avatar viktoriussuwandi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

viacep's Issues

Depfu Error: No dependency files found

Hello,

We've tried to activate or update your repository on Depfu and couldn't find any supported dependency files. If we were to guess, we would say that this is not actually a project Depfu supports and has probably been activated by error.

Monorepos

Please note that Depfu currently only searches for your dependency files in the root folder. We do support monorepos and non-root files, but don't auto-detect them. If that's the case with this repo, please send us a quick email with the folder you want Depfu to work on and we'll set it up right away!

How to deactivate the project

  • Go to the Settings page of either your own account or the organization you've used
  • Go to "Installed Integrations"
  • Click the "Configure" button on the Depfu integration
  • Remove this repo (guibranco/ViaCEP) from the list of accessible repos.

Please note that using the "All Repositories" setting doesn't make a lot of sense with Depfu.

If you think that this is a mistake

Please let us know by sending an email to [email protected].


This is an automated issue by Depfu. You're getting it because someone configured Depfu to automatically update dependencies on this project.

Run all coverage formats at once per project

Is your feature request related to a problem? Please describe.
Run all coverage formats at once per project

Describe the solution you'd like
Replace the actual code:

- ps: $TEST_PROJECTS = (Get-ChildItem -Path .Tests** -Recurse -Include *.csproj).Fullname
- ps: $COVERLET_FORMATS = @('cobertura', 'lcov', 'opencover')
- ps: |
    foreach($testProject in $TEST_PROJECTS)
    {
        foreach($coverletFormat in $COVERLET_FORMATS)
        {
           dotnet test $testProject /p:CollectCoverage=true /p:CoverletOutputFormat="$coverletFormat"
        }
    }

With the following code:

- ps: $TEST_PROJECTS = (Get-ChildItem -Path .Tests** -Recurse -Include *.csproj).Fullname
- ps: |
    foreach($testProject in $TEST_PROJECTS)
    {
        dotnet test $testProject /p:CollectCoverage=true "/p:CoverletOutputFormat=`"cobertura,lcov,opencover`""
    }

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Add README to NuGet

Is your feature request related to a problem? Please describe.
Add README to NuGet

Describe the solution you'd like
Add README to NuGet

Erro na instalação no .NETFramework 4.6 ou superior

Tentei realizar a instalação do pacote utilizando a linguagem C#, no Visual Studio 2019 e .NETFramework 4.6 e 4.7.2, porém é exibido o seguinte erro:

Não foi possível instalar o pacote 'ViaCep 3.0.40'. Você está tentando instalar este pacote em um projeto que se destina a '.NETFramework,Version=v4.7.2', mas o pacote não contém nenhuma referência de assembly ou arquivo de conteúdo que seja compatível com essa estrutura. Para obter mais informações, entre em contato com o autor do pacote.

A instalação no .NetCore funcionou normalmente.

Pelo readme, não localizei nenhuma menção sobre a versão para utilização.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.