ParkingAPIClient
public final class ParkingAPIClient : NSObject, URLSessionDelegate
An http client to query data from the server
-
Default initializer
Declaration
Swift
public init(configuration: URLSessionConfiguration = .default, pageSize: UInt = 10)
Parameters
configuration
The
URLSessionConfiguration
to use. Default toURLSession.default
pageSize
The pagination value to use. Default to
10
.
-
Retrieve the parkings’ locations with the legacy API
Declaration
Swift
@discardableResult public func getLegacyLocation(completion: @escaping (Result<LocationResponse, ParkingAPIClientError>) -> Void) -> CancelableRequest
Parameters
completion
The result when the request completed
Return Value
A
CancelableRequest
compatible element -
Retrieve the parkings’ statuses with the legacy API
Declaration
Swift
@discardableResult public func getLegacyStatus(completion: @escaping (Result<StatusResponse, ParkingAPIClientError>) -> Void) -> CancelableRequest
Parameters
completion
The result when the request completed
Return Value
A
CancelableRequest
compatible element -
Retrieve the parkings’ locations with the open data API
Declaration
Swift
@discardableResult public func getLocations(completion: @escaping (Result<[LocationOpenData], ParkingAPIClientError>) -> Void) -> CancelableRequest
Parameters
completion
The result when the request completed
Return Value
A
CancelableRequest
compatible element -
Retrieve the parkings’ status with the open data API
Declaration
Swift
@discardableResult public func getStatus(completion: @escaping (Result<[StatusOpenData], ParkingAPIClientError>) -> Void) -> CancelableRequest
Parameters
completion
The result when the request completed
Return Value
A
CancelableRequest
compatible element
-
Retrieve the parkings’ locations with the legacy API
Declaration
Swift
public func getLegacyLocationPublisher() -> AnyPublisher<LocationResponse, ParkingAPIClientError>
Return Value
A
AnyPublisher
answering oneLocationResponse
element. -
Retrieve the parkings’ statuses with the legacy API
Declaration
Swift
public func getLegacyStatusPublisher() -> AnyPublisher<StatusResponse, ParkingAPIClientError>
Return Value
A
AnyPublisher
answering oneStatusResponse
element. -
Retrieve the parkings’ locations using the open data API
Declaration
Swift
public func getLocationsPublisher() -> AnyPublisher<[LocationOpenData], ParkingAPIClientError>
Return Value
A
AnyPublisher
answering one[LocationOpenData]
. -
Retrieve the parkings’ statuses with the opendata API
Declaration
Swift
public func getStatusPublisher() -> AnyPublisher<[StatusOpenData], ParkingAPIClientError>
Return Value
A
AnyPublisher
answering one[StatusOpenData]
element.
-
fetchLegacyLocation()
AsynchronousRetrieve the parkings’ location with the legacy API
Declaration
Swift
public func fetchLegacyLocation() async throws -> LocationResponse
Return Value
An array of
LocationResponse
-
fetchLegacyStatus()
AsynchronousRetrieve the parkings’ statuses with the legacy API
Declaration
Swift
public func fetchLegacyStatus() async throws -> StatusResponse
Return Value
An array of
StatusResponse
-
fetchLocations()
AsynchronousRetrieve the parkings’ location with the open data API
Declaration
Swift
public func fetchLocations() async throws -> [LocationOpenData]
Return Value
An array of
LocationOpenData
-
fetchStatus()
AsynchronousRetrieve the parkings’ statuses with the open data API
Declaration
Swift
public func fetchStatus() async throws -> [StatusOpenData]
Return Value
An array of
StatusResponse