diff --git a/Sources/ElixxirDAppsSDK/LoadReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/LoadReceptionIdentity.swift new file mode 100644 index 0000000000000000000000000000000000000000..eeb1c8327644486fd5ff06099c6a29b308c1443e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/LoadReceptionIdentity.swift @@ -0,0 +1,33 @@ +import Bindings +import XCTestDynamicOverlay + +public struct LoadReceptionIdentity { + public var run: (String, Int) throws -> Data + + public func callAsFunction( + key: String, + cmixId: Int + ) throws -> Data { + try run(key, cmixId) + } +} + +extension LoadReceptionIdentity { + public static let live = LoadReceptionIdentity { key, cmixId in + var error: NSError? + let data = BindingsLoadReceptionIdentity(key, cmixId, &error) + if let error = error { + throw error + } + guard let data = data else { + fatalError("BindingsLoadReceptionIdentity returned `nil` without providing error") + } + return data + } +} + +extension LoadReceptionIdentity { + public static let unimplemented = LoadReceptionIdentity( + run: XCTUnimplemented("\(Self.self)") + ) +}