This PR contains the work on implementing some public interfaces that were forgotten during the development of this app and, of course, improves the text of the README file a bit more. To give further details about the work done: - [x] implemented the `Service` protocol in the `Persistence` library and conformed the `PersistenceService` service to it; - [x] implemented the `Service` protocol in the `Remote` library and conformed the `RemoteService` service to it; - [x] implemented the `Application` protocol in the `Core` library and conformed the `UIApplication` class to it; - [x] improved the dependency keys used by the `DependencyService` service to use these protocols instead; - [x] tweaked the text of the README file. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#14
46 lines
854 B
Swift
46 lines
854 B
Swift
//
|
|
// RemoteService.swift
|
|
// Remote
|
|
//
|
|
// Created by Javier Cicchelli on 10/04/2023.
|
|
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import APICore
|
|
import Foundation
|
|
|
|
public struct RemoteService {
|
|
|
|
// MARK: Properties
|
|
|
|
private let client: Client
|
|
|
|
// MARK: Initialisers
|
|
|
|
public init(configuration: URLSessionConfiguration = .default) {
|
|
self.client = RemoteClient(configuration: configuration)
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Service
|
|
|
|
extension RemoteService: Service {
|
|
|
|
// MARK: Functions
|
|
|
|
public func getLocations() async throws -> [Location] {
|
|
try await client.request(
|
|
endpoint: GetLocationsEndpoint(),
|
|
for: Locations.self
|
|
).locations
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Models
|
|
|
|
struct Locations: Decodable, Equatable {
|
|
public let locations: [Location]
|
|
}
|