Swiftpack.co - Package - kiliankoe/ParkKit

🚘 ParkKit

Travis Version License Platform Docs Codecov

This is a wrapper for the API provided by ParkAPI for anything written in Swift. It's primary purpose is to be used by ParkenDD.

Example

let park = ParkKit() // uses the default server at parkendd.de
// let park = ParkKit(withURL: URL(string: "https://your_server.com")!) // uses your server
park.fetchCities { result in
    guard let response = result.success else { return }
    print(response.cities)
}

// ▿ 13 elements
//   ▿ ParkKit.City
//     - name: "Aarhus"
//     ▿ coordinate: __C.CLLocationCoordinate2D
//       - latitude: 56.153005
//       - longitude: 10.203201
//       ...
park.fetchLots(forCity: "Dresden") { result in
    guard let response = result.success else { return }
    print(response.lots)
}

// ▿ 48 elements
//   ▿ ParkKit.Lot
//     ▿ address: Optional("Wilsdruffer Straße")
//       ...
let centrum = "dresdencentrumgalerie"
let dresden = "Dresden"

// Fetch forecast info for today
park.fetchForecast(forLot: centrum, inCity: dresden) { result in
    guard let response = result.success else { return }
    print(response.forecast)
}

park.fetchForecast(forLot: centrum, inCity: dresden, forDay: .today) { _ in
    // Same as above, `forDay` accepts either `.today`, `.offsetFromToday(Int)` 
    // or any `Date` value which will be used to infer the day.
}

// You can also specify a custom start and end day if you want more than a single day's worth of data:

let startingDate = Date()
let endingDate = startingDate.addingTimeInterval(7 * 24 * 60 * 60) // one week from now

park.fetchForecast(forLot: centrum, inCity: dresden, startingAt: startingDate, endingAt: endingDate) { _ in
    // ...
}

// ▿ 97 elements
//   ▿ (2 elements)
//     - .0: 2017-01-11 00:00:00 +0000
//     - .1: 13
//   ▿ (2 elements)
//     - .0: 2017-01-11 00:15:00 +0000
//     - .1: 12
//   ...

Requirements

Should you be hosting your own version of the ParkAPI server and using this on iOS, you might have to set up an ATS exception if you don't serve the data via HTTPS.

Using your own server is definitely recommended should you be planning on executing a large amount of requests (e.g. through a multitude of client applications).

Installation

ParkKit is available through Cocoapods, Carthage/Punic and Swift Package Manager, take your pick.

Copypasta for your Podfile:

pod "ParkKit"

Cartfile:

github "kiliankoe/ParkKit"

Package.swift:

.Package(url: "https://github.com/kiliankoe/ParkKit", majorVersion: 0)

Contributors

Kilian Koeltzsch, @kiliankoe

License

ParkKit is available under the MIT license. See the LICENSE file for more info.

Github

link
Stars: 5
Help us keep the lights on

Dependencies

Used By

Total: 0