ParkKit

main

🚘 ParkAPI wrapper
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.

Description

  • Swift Tools 5.2.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Apr 05 2024 02:04:29 GMT-0900 (Hawaii-Aleutian Daylight Time)