caseyscarborough/brewerydb-api


Java Client for the BreweryDB API. http://www.brewerydb.com/developers

Download


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 ""]]
        
        

Readme


BreweryDB API Client

This repository contains the Java Client for the BreweryDB API. It is currently a work in progress.

Usage

Creating a client

BreweryDBClient client = new BreweryDBClient("api-key");

Operating on a 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.

Retrieving a list of beers

GetBeersRequest request = BeerRequest.getBeers()
            .withName("Newcastle*")
            .withBreweries()
            .withOrder(BeerOrder.NAME)
            .withSort(SortDirection.DESC)
            .build();

GetBeersResult result = client.getBeers(request);
List<Beer> beers = result.getData();

Retrieve a beer by ID

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();

Retrieve a random beer

GetRandomBeerResult result = client.getRandomBeer();
Beer beer = result.getData();

Retrieve a list of breweries

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();

Retrieve a single brewery

GetBreweryResult result = client.getBrewery("breweryId");
Brewery brewery = result.getData();

Asynchronous usage

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.