StrasbourgParkAPI

4.0.0

:parking: A simple swift package used to access the Strasbourg open data related to the parking
yageek/StrasbourgParkAPI

What's New

4.0.0 (Combine + Async)

2021-11-19T15:04:05Z

4.0.0

  • Add Combine API methods
  • Add Swift async methods
  • Use ParkingAPIClient error failure type everywhere for more cohesion

StrasbourgParkAPI

A simple swift package giving access to the strasbourg park open api.

Reference can be found here.

Usage

You can interact with the framework using callback closures responses, Combine or async methods

Callback closures

let client = ParkingAPIClient()
client.getLocations { (result) in
    switch result {
        case .success(let locations):
            print("Locations: \(locations)")
        case .failure(let error):
            print("Error during the download: \(error)")
    }
}

Combine

let client = ParkingAPIClient()
client.getLocationsPublisher().sink { result in
    if case .failure(let error) = result {
        print("Error: \(result)")
    }   
} receiveValue: { result in
    print("Response: \(result)")

}

async

let client = ParkingAPIClient()

do {
    let response = try await client.fetchLocations()
    print("Response: \(response)")
} catch let error {
    print("Error: \(error)")
}

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

Last updated: Mon Mar 18 2024 08:28:20 GMT-0900 (Hawaii-Aleutian Daylight Time)