Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiliankoe/parkkit
π ParkAPI wrapper
https://github.com/kiliankoe/parkkit
open-data parking
Last synced: 3 months ago
JSON representation
π ParkAPI wrapper
- Host: GitHub
- URL: https://github.com/kiliankoe/parkkit
- Owner: kiliankoe
- License: mit
- Created: 2017-01-03T00:55:57.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2020-07-19T05:25:47.000Z (over 4 years ago)
- Last Synced: 2024-10-19T17:58:25.041Z (3 months ago)
- Topics: open-data, parking
- Language: Swift
- Homepage:
- Size: 118 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# π ParkKit
[![Travis](https://img.shields.io/travis/kiliankoe/ParkKit.svg?style=flat-square)](https://travis-ci.org/kiliankoe/ParkKit)
[![Version](https://img.shields.io/cocoapods/v/ParkKit.svg?style=flat-square)](http://cocoapods.org/pods/ParkKit)
[![License](https://img.shields.io/cocoapods/l/ParkKit.svg?style=flat-square)](http://cocoapods.org/pods/ParkKit)
[![Platform](https://img.shields.io/cocoapods/p/ParkKit.svg?style=flat-square)](http://cocoapods.org/pods/ParkKit)
[![Docs](https://img.shields.io/cocoapods/metrics/doc-percent/ParkKit.svg?style=flat-square)](http://cocoadocs.org/docsets/ParkKit)
[![Codecov](https://img.shields.io/codecov/c/github/kiliankoe/ParkKit.svg?style=flat-square)](https://codecov.io/gh/kiliankoe/ParkKit)This is a wrapper for the API provided by [ParkAPI](https://github.com/offenesdresden/ParkAPI) for anything written in Swift. It's primary purpose is to be used by [ParkenDD](https://github.com/kiliankoe/ParkenDD).
## Example
```swift
let park = ParkKit() // uses the default server at parkendd.de
// let park = ParkKit(withURL: URL(string: "https://your_server.com")!) // uses your server
``````swift
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
// ...
``````swift
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")
// ...
``````swift
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 nowpark.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:
```ruby
pod "ParkKit"
```Cartfile:
```
github "kiliankoe/ParkKit"
```Package.swift:
```swift
.Package(url: "https://github.com/kiliankoe/ParkKit", majorVersion: 0)
```## Contributors
Kilian Koeltzsch, [@kiliankoe](https://github.com/kiliankoe)
## License
ParkKit is available under the MIT license. See the LICENSE file for more info.