Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.
/ punkapi-ruby Public archive

A ruby wrapper for the PunkAPI, well... API

License

Notifications You must be signed in to change notification settings

sammdec/punkapi-ruby

Repository files navigation

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.

About

A ruby wrapper for the PunkAPI, well... API

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published