Project

punkapi

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A wrapper for the PunkAPI API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0

Runtime

~> 0.10.0
 Project Readme

punkapi Build Status

A ruby wrapper for the PunkAPI, an API that takes Brewdog's DIY Dog and makes it into a JSON API. Read more about it here

Installation

Add this line to your application's Gemfile:

gem 'punkapi', '~> 2.0.0'

Or install it yourself as:

$ gem install punkapi

Usage

Initialize

client = PunkAPI::Client.new

Get a Beer

client.beer(2)

=> #<PunkAPI::Entity id=2, name="Trashy Blonde", tagline="You Know You Shouldn't", first_brewed="April 2008", ...

Get a random Beer

client.random_beer

=> #<PunkAPI::Entity id=138, name="Dog A", tagline="Cacao, Coffee, Chili Imperial Anniversary Stout.", first_brewed="May 2012", ...

Get Beers

This will return an array of PunkAPI::Entity objects in chronological order from first_brewed date. You can also pass any of the query paramters from the docs as an argument.

client.beers(beer_name: 'Dog A')

=> [#<PunkAPI::Entity id=138, name="Dog A", tagline="Cacao, Coffee, Chili Imperial Anniversary Stout.", first_brewed="May 2012", ...]

Accessing data

You can access the attributes using the ruby dot notation

beers = client.beers(beer_name: 'Dog A')

beers.first.name

=> "Dog A"

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/samjbmason/punkapi-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.