Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.caseyscarborough:brewerydb-api:'
}
dependencies {
implementation("com.github.caseyscarborough:brewerydb-api:")
}
<dependency>
<groupId>com.github.caseyscarborough</groupId>
<artifactId>brewerydb-api</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.caseyscarborough" % "brewerydb-api" % ""
:dependencies [[com.github.caseyscarborough/brewerydb-api ""]]
This repository contains the Java Client for the BreweryDB API. It is currently a work in progress.
BreweryDBClient client = new BreweryDBClient("api-key");
Result
All client methods return a Result
. Each result has metadata about the request, such as the page number, total results, total number of pages, a message, and a status.
To retrieve the data from a result, call the getData()
method.
GetBeersRequest request = BeerRequest.getBeers()
.withName("Newcastle*")
.withBreweries()
.withOrder(BeerOrder.NAME)
.withSort(SortDirection.DESC)
.build();
GetBeersResult result = client.getBeers(request);
List<Beer> beers = result.getData();
GetBeerResult result = client.getBeer("beerId");
Beer beer = result.getData();
// Customize the request
GetBeerRequest request = BeerRequest.getBeer()
.withBreweries()
.withIngredients()
.build();
GetBeerResult result = client.getBeer("7ET5OY", request);
Beer beer = result.getData();
GetRandomBeerResult result = client.getRandomBeer();
Beer beer = result.getData();
GetBreweriesRequest request = BreweryRequest.getBreweries()
.withName("*")
.withEstablished("2016")
.withOrder(BreweryOrder.NAME)
.withSort(SortDirection.ASC)
.withLocations()
.build();
GetBreweriesResult result = client.getBreweries(request);
List<Brewery> breweries = result.getData();
GetBreweryResult result = client.getBrewery("breweryId");
Brewery brewery = result.getData();
All methods also have an asynchronous implementation, which can be used by calling the xxxAsync
version of the method. For example:
Future<GetRandomBeerResult> future = client.getRandomBeerAsync();
// do some other work
GetRandomBeerResult result = future.get();
Beer beer = result.getData();
For a full list of methods see the BreweryDBClient class.