2022-12-16 01:47:06 +01:00
|
|
|
//
|
|
|
|
// GetDataUseCase.swift
|
|
|
|
// Browse
|
|
|
|
//
|
|
|
|
// Created by Javier Cicchelli on 16/12/2022.
|
|
|
|
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import APIService
|
|
|
|
import DependencyInjection
|
|
|
|
import Dependencies
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
struct GetDataUseCase {
|
|
|
|
|
2022-12-16 16:37:49 +01:00
|
|
|
// MARK: Properties
|
2022-12-16 01:47:06 +01:00
|
|
|
|
2022-12-16 16:37:49 +01:00
|
|
|
let apiService: APIService
|
2022-12-16 01:47:06 +01:00
|
|
|
|
|
|
|
// MARK: Functions
|
|
|
|
|
|
|
|
func callAsFunction(
|
|
|
|
id: String,
|
|
|
|
username: String,
|
|
|
|
password: String
|
|
|
|
) async throws -> Data {
|
|
|
|
return try await apiService.getData(
|
|
|
|
id: id,
|
|
|
|
credentials: .init(
|
|
|
|
username: username,
|
|
|
|
password: password
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-12-16 16:37:49 +01:00
|
|
|
|
|
|
|
// MARK: - Initialisers
|
|
|
|
|
|
|
|
extension GetDataUseCase {
|
|
|
|
init() {
|
|
|
|
@Dependency(\.apiService) var apiService
|
|
|
|
|
|
|
|
self.init(apiService: apiService)
|
|
|
|
}
|
|
|
|
}
|