From d7c4b91fb17f1781cbe15eee782f8dbe32daadc0 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Sat, 28 Mar 2020 22:04:54 -0300 Subject: [PATCH] Update README.md --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c53517c..5636109 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,15 @@ 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. -``` +```cs //your DI container -services.AddHttpClient(client =>{ +services.AddHttpClient(client => { client.BaseAddress = new Uri("https://viacep.com.br/"); -}) +}); +//then use in your domain service, handler, controller... +var viaCepClient = container.GetService(); +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! @@ -68,9 +71,9 @@ You can search using the zip code/postal code (AKA CEP) or using the address dat ## Querying by zip code / postal code (single result) ```cs -var result = new ViaCepClient().Search("01234567"); //searches for the postal code 01234-567 -var address = result.Address; -var neighborhood = result.Neighborhood +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. ```