51 lines
971 B
Swift
51 lines
971 B
Swift
//
|
|
// UploadFileUseCase.swift
|
|
// Browse
|
|
//
|
|
// Created by Javier Cicchelli on 17/12/2022.
|
|
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import APIService
|
|
import DependencyInjection
|
|
import Dependencies
|
|
import Foundation
|
|
|
|
struct UploadFileUseCase {
|
|
|
|
// MARK: Properties
|
|
|
|
let apiService: APIService
|
|
|
|
private let fileAdapter: FileAdapter = .init()
|
|
|
|
// MARK: Functions
|
|
|
|
func callAsFunction(
|
|
id: String,
|
|
url: URL,
|
|
username: String,
|
|
password: String
|
|
) async throws {
|
|
_ = try await apiService.uploadFile(
|
|
id: id,
|
|
file: fileAdapter(url: url),
|
|
credentials: .init(
|
|
username: username,
|
|
password: password
|
|
)
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Initialisers
|
|
|
|
extension UploadFileUseCase {
|
|
init() {
|
|
@Dependency(\.apiService) var apiService
|
|
|
|
self.init(apiService: apiService)
|
|
}
|
|
}
|