Moved the GetUserUseCase use case to the UseCases target for the Libraries package.
This commit is contained in:
parent
e055f41b92
commit
ebee2ddcc0
@ -7,25 +7,26 @@
|
||||
//
|
||||
|
||||
import APIService
|
||||
import DataModels
|
||||
import DependencyInjection
|
||||
import Dependencies
|
||||
|
||||
struct GetUserUseCase {
|
||||
public struct GetUserUseCase {
|
||||
|
||||
// MARK: Dependencies
|
||||
|
||||
@Dependency(\.apiService) private var apiService
|
||||
|
||||
// MARK: Properties
|
||||
// MARK: Initialisers
|
||||
|
||||
let authenticated: AuthenticatedClosure
|
||||
public init() {}
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func callAsFunction(
|
||||
public func callAsFunction(
|
||||
username: String,
|
||||
password: String
|
||||
) async throws {
|
||||
) async throws -> User {
|
||||
let me = try await apiService.getUser(
|
||||
credentials: .init(
|
||||
username: username,
|
||||
@ -33,21 +34,15 @@ struct GetUserUseCase {
|
||||
)
|
||||
)
|
||||
|
||||
authenticated(
|
||||
.init(
|
||||
username: username,
|
||||
password: password
|
||||
return .init(
|
||||
profile: .init(
|
||||
firstName: me.firstName,
|
||||
lastName: me.lastName
|
||||
),
|
||||
.init(
|
||||
profile: .init(
|
||||
firstName: me.firstName,
|
||||
lastName: me.lastName
|
||||
),
|
||||
rootFolder: .init(
|
||||
id: me.rootItem.id,
|
||||
name: me.rootItem.name,
|
||||
lastModifiedAt: me.rootItem.lastModifiedAt
|
||||
)
|
||||
rootFolder: .init(
|
||||
id: me.rootItem.id,
|
||||
name: me.rootItem.name,
|
||||
lastModifiedAt: me.rootItem.lastModifiedAt
|
||||
)
|
||||
)
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
//
|
||||
// Typealiases.swift
|
||||
// Login
|
||||
//
|
||||
// Created by Javier Cicchelli on 12/12/2022.
|
||||
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import DataModels
|
||||
|
||||
public typealias AuthenticatedClosure = (Account, User) -> Void
|
Loading…
x
Reference in New Issue
Block a user