metatext/ServiceLayer/Sources/ServiceLayer/Entities/AppEnvironment.swift

35 lines
1.1 KiB
Swift
Raw Normal View History

2020-08-02 22:23:01 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
2020-08-31 01:40:58 +00:00
import HTTP
2020-08-30 23:33:11 +00:00
import Mastodon
2020-08-02 22:23:01 +00:00
2020-08-31 10:21:01 +00:00
public struct AppEnvironment {
2020-08-12 07:24:39 +00:00
let session: Session
2020-08-12 09:01:21 +00:00
let webAuthSessionType: WebAuthSession.Type
let keychainServiceType: KeychainService.Type
2020-08-18 05:13:37 +00:00
let userDefaults: UserDefaults
let inMemoryContent: Bool
2020-08-31 10:21:01 +00:00
public init(session: Session,
webAuthSessionType: WebAuthSession.Type,
keychainServiceType: KeychainService.Type,
userDefaults: UserDefaults,
inMemoryContent: Bool) {
self.session = session
self.webAuthSessionType = webAuthSessionType
self.keychainServiceType = keychainServiceType
self.userDefaults = userDefaults
self.inMemoryContent = inMemoryContent
}
2020-08-12 07:24:39 +00:00
}
2020-08-31 10:21:01 +00:00
public extension AppEnvironment {
2020-08-12 07:24:39 +00:00
static let live: Self = Self(
session: Session(configuration: .default),
2020-08-12 09:01:21 +00:00
webAuthSessionType: LiveWebAuthSession.self,
2020-08-18 05:13:37 +00:00
keychainServiceType: LiveKeychainService.self,
userDefaults: .standard,
inMemoryContent: false)
2020-08-02 22:23:01 +00:00
}