46 lines
854 B
Swift
Raw Permalink Normal View History

//
// 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]
}