Over the weekend I decided to look at a project which hasn’t recieved much love since I orginally wrote it earlier in the year. That project is PCL for interacting with the awesome beer database that is BreweryDB.
My orginal implementation was very simplistic in its design, only exposed a handful of the endpoint, lacked any error checking and also had a few too little unit tests. With BeerDrinkin’s development coming along nicey, I thought it time to take a look at some of its dependencies and see how I could improve them. First up was BreweryDB and so I set about improving the PCL to hopefully make it useful for other .NET developers.
Supported enpoints
This new version of BreweryDB includes many more supported endpoints. Its now possible to query almost all of BreweryDB using .NET.
- Adjuncts
- Beers
- Breweries
- Categories
- Events
- Features
- Fermentables
- FluidSizes
- Guilds
- SocialSites
- Yeasts
Getting Started
Beers
- GET/beers
- GET/beer/beerId
- GET/search/
Get all
This returns a list of all beers but will be paginated with 50 beers per page.
[sourcecode language=”csharp”] //Will return the first pagevar response = await client.Beers.GetAll();
//Will return the fourth page
var response = await client.Beers.GetAll(4);
[/sourcecode]
Get by id
This returns a single beer
[sourcecode language=”csharp”] var response = awaitclient.Beers.Get(“cBLTUw”);[/sourcecode]
Using request parameters
This returns a list of beers
[sourcecode language=”csharp”] var parameters = new NameValueCollection {{BeerRequestParameters.Name, “duvel single”}};var response = await client.Beers.Get(parameters);
[/sourcecode]
Search by name
This returns a list of beers
[sourcecode language=”csharp”] var response = await client.Beers.Search(“duvel”);[/sourcecode]
Breweries
- GET/breweries
- GET/brewery/breweryId
- GET/search/
Get all
This returns a list of all breweries but will be paginated with 50 breweries per page.
[sourcecode language=”csharp”] //Will return the first pagevar response = await client.Breweries.GetAll();
//Will return the forth page
var response = await client.Breweries.GetAll(4);
[/sourcecode]
Get by Id
This returns a single Brewery
[sourcecode language=”csharp”] var response = await client.Breweries.Get(“YXDiJk”);[/sourcecode]
Search by name
This returns a list of breweries
[sourcecode language=”csharp”] var response = await client.Breweries.Search(“duvel”);[/sourcecode]
Naturally its open source
As always, I’ve made this avaiaible on GitHub and Nuget for you to use in your own apps.