51 lines
1.1 KiB
Swift
Raw Normal View History

//
// GetUserUseCase.swift
// Login
//
// Created by Javier Cicchelli on 12/12/2022.
// Copyright © 2022 Röck+Cöde. All rights reserved.
//
import APIService
import DataModels
import DependencyInjection
import Dependencies
public struct GetUserUseCase {
// MARK: Dependencies
@Dependency(\.apiService) private var apiService
// MARK: Initialisers
public init() {}
// MARK: Functions
public func callAsFunction(
username: String,
password: String
) async throws -> User {
let me = try await apiService.getUser(
credentials: .init(
username: username,
password: password
)
)
return .init(
profile: .init(
firstName: me.firstName,
lastName: me.lastName
),
rootFolder: .init(
id: me.rootItem.id,
name: me.rootItem.name,
lastModifiedAt: me.rootItem.lastModifiedAt
)
)
}
}