2023-04-10 15:31:22 +00:00
|
|
|
//
|
2023-04-11 22:14:40 +00:00
|
|
|
// RemoteService.swift
|
|
|
|
// Remote
|
2023-04-10 15:31:22 +00:00
|
|
|
//
|
|
|
|
// Created by Javier Cicchelli on 10/04/2023.
|
|
|
|
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import APICore
|
|
|
|
import Foundation
|
|
|
|
|
2023-04-11 22:14:40 +00:00
|
|
|
public struct RemoteService {
|
2023-04-10 15:31:22 +00:00
|
|
|
|
|
|
|
// MARK: Properties
|
|
|
|
|
|
|
|
private let client: Client
|
|
|
|
|
|
|
|
// MARK: Initialisers
|
|
|
|
|
|
|
|
public init(configuration: URLSessionConfiguration = .default) {
|
2023-04-11 22:14:40 +00:00
|
|
|
self.client = RemoteClient(configuration: configuration)
|
2023-04-10 15:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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]
|
|
|
|
}
|