Skip to content

Instantly share code, notes, and snippets.

@rhart
Created October 28, 2016 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhart/83c158cfe5336cc1a6d2ba7d40d224c9 to your computer and use it in GitHub Desktop.
Save rhart/83c158cfe5336cc1a6d2ba7d40d224c9 to your computer and use it in GitHub Desktop.
public Promise<String> getBookRequest(final String isbn) {
def uri = "${config.host}/api/v2/json/${config.apikey}/book/$isbn".toURI()
httpClient
.get(uri)
.map { ReceivedResponse resp ->
if (resp.body.text.contains("Daily request limit exceeded")) {
throw new RuntimeException("ISBNDB daily request limit exceeded.")
}
resp.body.text
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment