This projects is a C# wrapper library to obtain Belgian city data from bpost (Belgian national mail service).
Table of Contents
Use Visual Studio 2022 to build the project.
Get the NuGet packages from nuget.org or search for MichelMichels.BpostSharp
in the GUI package manager in Visual Studio.
You can also use the cli of the package manager with one of following commands:
Install-Package MichelMichels.BpostSharp.Excel
Install-Package MichelMichels.BpostSharp.Web
Above commands will also add a dependency to MichelMichels.BpostSharp
. This nuget package contains the core code.
There are 2 versions of BpostSharp:
Name | Nuget | Description |
---|---|---|
MichelMichels.BpostSharp.Excel |
Excel cache (offline) | |
MichelMichels.BpostSharp.Web |
Html cache (online) |
These 2 versions have following dependency:
Name | Nuget | Description |
---|---|---|
MichelMichels.BpostSharp |
This is the core package which contains all interfaces and models. |
To use the excel version, use any version of the files at the official bpost website. To use the web version, grab one of the HTML versions on the same page.
Creating a web instance:
ICacheBuilder<CityData> webCacheBuilder = new WebCacheBuilder(BpostWebConstants.DutchEndpoint);
ICityDataService cityDataService = new BelgianCityDataService(webCacheBuilder);
Creating an excel instance:
ICacheBuilder<CityData> webCacheBuilder = new ExcelCacheBuilder("excel-from-bpost.xls");
ICityDataService cityDataService = new BelgianCityDataService(webCacheBuilder);
Querying data:
// Querying by postal code
List<CityData> data = await cityDataService.GetByPostalCode("9000");
// Querying by city name
List<CityData> data = await cityDataService.GetByCityName("Gent");
The querying uses StartsWith(...)
and ignores casing.
Data is saved into cache after executing Build()
on the ICacheBuilder
or after first query, whichever comes earlier. You can clear the cache with Clear()
.
Written by Michel Michels.