An iOS Swift library for communicating with the BreweryDB api (v2). This library simplifies the task of sending and receiving data between your app and the BreweryDB server. This library is able to construct correct BreweryDB URL's, perform the network request and then serialise the response JSON into objects ready for use in your app.
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. Full instructions for integrating frameworks using Carthage are avaliable within the readme.md on their GitHub Repository.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate BreweryDB into your Xcode project using Carthage, specify it in your Cartfile:
github "jwelton/BreweryDB"
Run carthage update to build the framework and drag the built BreweryDB.framework into your Xcode project. (you also need to add a custom run script too, please see the Carthage instructions for details on this)
The interface within this library is designed to be simple and easy to use. Below are examples of how to request beers and breweries using this service.
Before attempting any requests, you need to set your API key (you will need to register on the BreweryDB website to get this). You only need to set this once and its done as follows:
breweryDBApiKey = "MyKeyHere"
We recommend setting this in the AppDelegate, so it has always been called before any request might take place.
let beerRequest = BeerRequest(params: [.identifier: "cBLTUw"])
let requestMan = RequestManager<Beer>(request: beerRequest)
requestMan?.fetch() { beers in
/// Access your array of beers here (or nil if nothing was found)
}
let beerRequest = BeerRequest(params: [.identifier: "cBLTUw"], orderBy: .name)
let requestMan = RequestManager<Beer>(request: beerRequest)
requestMan?.fetch() { beers in
/// Access your array of beers here (or nil if nothing was found)
}
public enum BeerRequestParam: String {
case identifier
case name
case abv
case ibu
case isOrganic
case hasLabels
case since
case status
case randomCount
case pageNumber
case styleId
case withBreweries
}
public enum BeerRequestOrderParam : String {
case name
case description
case abv
case ibu
case isOrganic
case status
case createDate
case updateDate
case random
}
let breweryRequest = BreweryRequest(params: [.identifier: "YXDiJk"])
let requestMan = RequestManager<Beer>(request: breweryRequest)
requestMan?.fetch() { breweries in
/// Access your array of breweries here (or nil if nothing was found)
}
let breweryRequest = BreweryRequest(params: [.identifier: "YXDiJk"], orderBy: .name)
let requestMan = RequestManager<Beer>(request: breweryRequest)
requestMan?.fetch() { breweries in
/// Access your array of breweries here (or nil if nothing was found)
}
public enum BreweryRequestParam: String {
case identifier
case name
case abv
case ibu
case glasswareId
case srmId
case avaliableId
case styleId
case isOrganic
case hasLabels
case year
case since
case status
case randomCount
case pageNumber
}
public enum BreweryRequestOrderParam : String {
case name
case description
case website
case established
case mailingListURL
case isOrganic
case status
case createDate
case updateDate
case random
}
let searchRequest = SearchRequest(params: [.searchTerm: "Dead Pony", .resultType: "beer", .withBreweries: "Y"])
let requestMan = RequestManager<Search>(request: searchRequest)
requestMan?.fetch() { results in
/// Access your array of results here (or nil if nothing was found)
}
public enum SearchRequestParam : String {
case searchTerm
case resultType
case pageNumber
case withBreweries
}
Other request types (which work in the same way as above) include:
- Glass Request
- Style Request
- Category Request
Contributing is easy, simply decide on a bug you want to fix or feature you want to implement (or preferably pick one from the issues list) then follow the instructions below:
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
This BreweryDB library is owned and maintained by Jake Welton.
This library is released under the MIT license. See LICENSE for details.