import UIKit import SBRouterService import SBDependency import SBDependencyInterface import SBAnalyticsInterface import SBLoggerInterface /* Caso seja utilizado os mocks de Network, descomentar: - Imports abaixo - Linha 41 - Mocks a partir da linha 97 import SBNetwork import Fetcher import SBSecurityInterface import SBUserSessionInterface */ class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? let container = Container() lazy var routerService = RouterService(store: container) func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } registerDependency() registerHandler() injectDependencies() setupRootViewController(windowScene: windowScene) } } extension SceneDelegate { func setupRootViewController(windowScene: UIWindowScene){ window = UIWindow(windowScene: windowScene) window?.rootViewController = ViewController() window?.makeKeyAndVisible() } func registerDependency(){ // SBNetwork.configure(shellBoxService: ServiceInjection()) } func registerHandler(){ // TODO: Implementar routerHandler } } // ########################### // MOCK // ########################### extension SceneDelegate { private func injectDependencies() { __registerDependencies {[ AnalyticsDependency.self, LoggerDependency.self ]} } } public struct LoggerDependency: Assembly { public init(){} public func assemble(registry: Registry) { registry.register(LoggerProtocol.self) { _ in LoggerAssembler() } } } final class LoggerAssembler: LoggerProtocol { func log(level: LogLevel, rawMessage: Message, error: Error?, file: String, function: String, line: Int) { print(rawMessage) } } public struct AnalyticsDependency: Assembly { public init(){} public func assemble(registry: Registry) { registry.register(AnalyticsLoggerProtocol.self) { _ in AnalyticsLoggerAssembler() } } } class AnalyticsLoggerAssembler: AnalyticsLoggerProtocol { func logEvent(_ event: SBAnalyticsInterface.AnalyticsEvent) {} } /* public struct SecurityDependency: Assembly { public init(){} public func assemble(registry: Registry) { registry.register(SecurityStoreManaging.self) { _ in SecurityAssembler() } } } class SecurityAssembler: SecurityStoreManaging { func delete(service: String, account: String) {} func delete(_ metadata: SBSecurityInterface.StorableMetadata) {} func save(_ item: T, service: String, account: String) throws where T : Decodable, T : Encodable {} func save(item: T, _ metadata: SBSecurityInterface.StorableMetadata) throws where T : Decodable, T : Encodable {} func read(service: String, account: String, type: T.Type) throws -> T? where T : Decodable, T : Encodable { nil } func read(_ metadata: SBSecurityInterface.StorableMetadata) -> String? { nil } } class SecurityUtils: SecurityUtilsProtocol { func uuidString() -> String? { UUID().uuidString } } public struct UserSessionDependency: Assembly { public init(){} public func assemble(registry: Registry) { registry.register(UserSessionProvider.self, name: "SessionTokenProvider") { _ in UserSessionAssembler() } } } class UserSessionAssembler: UserSessionProvider { func getIdentifier() -> String? { UUID().uuidString } func getToken() -> String? { "TESTE" } } class ServiceInjection: ShellBoxServiceProtocol { func shellBoxServiceAtomantBaseURL() -> SBNetwork.AtomantEnvironment { return .development } func shellBoxServiceRufusBaseURL() -> SBNetwork.RufusEnvironment { return .development } func shellBoxServiceBFFBaseURL() -> SBNetwork.BFFEnvironment { return .unit } func shellBoxServiceUseCredential(trust: SecTrust, session: URLSession, completion: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { completion(.useCredential, nil) } func shellBoxServiceGetInterceptors() -> [Interceptor] { return [] } func shellBoxServiceDidCreate(sessionConfiguration: URLSessionConfiguration) { } func shellBoxServiceHandleRequestError(request: URLRequest, response: URLResponse, error: ShellBoxError, completion: @escaping (URLRequest?) -> Void) { completion(nil) } } */