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 APIService
|
||||||
|
import DataModels
|
||||||
import DependencyInjection
|
import DependencyInjection
|
||||||
import Dependencies
|
import Dependencies
|
||||||
|
|
||||||
struct GetUserUseCase {
|
public struct GetUserUseCase {
|
||||||
|
|
||||||
// MARK: Dependencies
|
// MARK: Dependencies
|
||||||
|
|
||||||
@Dependency(\.apiService) private var apiService
|
@Dependency(\.apiService) private var apiService
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Initialisers
|
||||||
|
|
||||||
let authenticated: AuthenticatedClosure
|
public init() {}
|
||||||
|
|
||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
|
|
||||||
func callAsFunction(
|
public func callAsFunction(
|
||||||
username: String,
|
username: String,
|
||||||
password: String
|
password: String
|
||||||
) async throws {
|
) async throws -> User {
|
||||||
let me = try await apiService.getUser(
|
let me = try await apiService.getUser(
|
||||||
credentials: .init(
|
credentials: .init(
|
||||||
username: username,
|
username: username,
|
||||||
@ -33,21 +34,15 @@ struct GetUserUseCase {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated(
|
return .init(
|
||||||
.init(
|
profile: .init(
|
||||||
username: username,
|
firstName: me.firstName,
|
||||||
password: password
|
lastName: me.lastName
|
||||||
),
|
),
|
||||||
.init(
|
rootFolder: .init(
|
||||||
profile: .init(
|
id: me.rootItem.id,
|
||||||
firstName: me.firstName,
|
name: me.rootItem.name,
|
||||||
lastName: me.lastName
|
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