https://github.com/oni-zerone/punkapi
A wrapper around PunkAPI v2 by @samjbmason
https://github.com/oni-zerone/punkapi
api-client beer brewdog-punk-api ios punkapi swift
Last synced: 3 months ago
JSON representation
A wrapper around PunkAPI v2 by @samjbmason
- Host: GitHub
- URL: https://github.com/oni-zerone/punkapi
- Owner: Oni-zerone
- License: mit
- Created: 2019-02-17T10:34:54.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2022-01-20T16:13:26.000Z (over 3 years ago)
- Last Synced: 2025-01-10T08:23:30.054Z (5 months ago)
- Topics: api-client, beer, brewdog-punk-api, ios, punkapi, swift
- Language: Swift
- Homepage:
- Size: 257 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# PunkAPI
[](https://cocoapods.org/pods/PunkAPI)
[](https://travis-ci.com/Oni-zerone/PunkAPI)
[](https://codebeat.co/projects/github-com-oni-zerone-punkapi-develop)
[](https://coveralls.io/github/Oni-zerone/PunkAPI?branch=develop)
[](https://cocoapods.org/pods/PunkAPI)
[](https://cocoapods.org/pods/PunkAPI)
[](https://cocoapods.org/pods/PunkAPI)**This is a wrapper around PunkAPI v2 by [@samjbmason](https://twitter.com/samjbmason) you can find more informations about those APIs at https://punkapi.com/**
_Have you ever wanted to search through Brewdog's expansive back catalogue of beer in a programmatic way? Maybe build a tool that pairs beer with food, or search beers with an abv of more than 4%? Well now your prayers have been answered!_
_The Punk API takes Brewdog's DIY Dog and turns it into a searchable, filterable API that's completely free and open source._
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Usage
```swift
let punkApi = PunkApi(configuration: .default)punkApi.get(RandomBeerRequest(), queue: .main) { beersResult in }
punkApi.get(BeerRequest(id: 1), queue: .main) { beersResult in }
punkApi.get(RandomBeerRequest(), queue: .main) { beersResult in }
punkApi.get(BeersRequest(filter: [.abv(condition: .more, value: 3),
.beerName(value: "Punk")]),
queue: .main) { beersResult in }
```## API
#### `RandomBeerRequest()`
Get a random beer request
```swift
punkApi.get(RandomBeerRequest(), queue: .main) { beersResult in }
```#### `BeerRequest(id: 1)`
Get a beer from given id
```swift
punkApi.get(BeerRequest(id: 1), queue: .main) { beersResult in }
```#### `BeersRequest(filter: [BeersRequest.Parameter.beerName(value: "Punk IPA")])`
Get beers that match the passed in options, if no options are passed in it will return all beers in ascending order of `id`.
```swift
punkApi.get(RandomBeerRequest(), queue: .main) { beersResult in }
```
**Options**##### `BeersRequest.Parameter.abv(condition: .more, value: 3)`
Condition: `Condition`
Value: `Float`
Will return beers with an abv greater or lower than the passed in value.##### `BeersRequest.Parameter.ibu(condition: .more, value: 3)`
Condition: `Condition`
Value: `Float`
Will return beers with an ibu greater or lower than the passed in value.##### `BeersRequest.Parameter.ebc(condition: .more, value: 3)`
Condition: `Condition`
Value: `Float`
Will return beers with an ebc greater or lower than the passed in value.##### `BeersRequest.Parameter.beerName(value: "Punk")`
Value: `String`
Will return beers matching the string passed in (we use fuzzy matching to find the names).##### `BeersRequest.Parameter.yeast(value: "American Ale")`
Value: `String`
Will return beers which match the name of the yeast of the string passed in (we use fuzzy matching to find the yeast names).##### `BeersRequest.Parameter.brewed(condition: .more, value: 3)`
Condition: `Condition`
Value: `Date`
Will return beers brewed before or after the passed in date.##### `BeersRequest.Parameter.hops(value: "Ahtanum")`
Value: `String`
Will return beers which match the name of the hops of the string passed in (we use fuzzy matching to find the hop names).##### `BeersRequest.Parameter.malt(value: "Extra Pale")`
Value: `String`
Will return beers which match the name of the malt of the string passed in (we use fuzzy matching to find the hop names).##### `BeersRequest.Parameter.food(value: "Cheesecake")`
Value: `String`
Will return beers which match food pairings of the string passed in (we use fuzzy matching to find the foods).##### `BeersRequest.Parameter.ids(value: [1, 2, 4, 6])`
Value: `Array`
Will return beers which match the given ids.## Installation
PunkAPI is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'PunkAPI'
```## Author
[@Oni_zerone](https://twitter.com/Oni_zerone), [email protected]
## License
PunkAPI is available under the MIT license. See the LICENSE file for more info.