diff --git a/Sources/ElixxirDAppsSDK/Cmix.swift b/Sources/ElixxirDAppsSDK/Cmix.swift index 527f5069aea94f660ff0296c56c1c8f90420831a..a8d867715a687b9d1c7c62700549461fb6b610be 100644 --- a/Sources/ElixxirDAppsSDK/Cmix.swift +++ b/Sources/ElixxirDAppsSDK/Cmix.swift @@ -13,6 +13,7 @@ public struct Cmix { public var registerClientErrorCallback: CmixRegisterClientErrorCallback public var addHealthCallback: CmixAddHealthCallback public var waitForMessageDelivery: CmixWaitForMessageDelivery + public var connect: CmixConnect } extension Cmix { @@ -29,7 +30,8 @@ extension Cmix { waitForNetwork: .live(bindingsCmix), registerClientErrorCallback: .live(bindingsCmix), addHealthCallback: .live(bindingsCmix), - waitForMessageDelivery: .live(bindingsCmix) + waitForMessageDelivery: .live(bindingsCmix), + connect: .live(bindingsCmix) ) } } @@ -47,6 +49,7 @@ extension Cmix { waitForNetwork: .unimplemented, registerClientErrorCallback: .unimplemented, addHealthCallback: .unimplemented, - waitForMessageDelivery: .unimplemented + waitForMessageDelivery: .unimplemented, + connect: .unimplemented ) } diff --git a/Sources/ElixxirDAppsSDK/CmixConnect.swift b/Sources/ElixxirDAppsSDK/CmixConnect.swift new file mode 100644 index 0000000000000000000000000000000000000000..ec795556f60bf877893c3eaf903708948745934c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CmixConnect.swift @@ -0,0 +1,41 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CmixConnect { + public var run: (Bool, Int, Data, Data) throws -> Connection + + public func callAsFunction( + withAuthentication: Bool, + e2eId: Int, + recipientContact: Data, + e2eParamsJSON: Data + ) throws -> Connection { + try run(withAuthentication, e2eId, recipientContact, e2eParamsJSON) + } +} + +extension CmixConnect { + public static func live(_ bindingsCmix: BindingsCmix) -> CmixConnect { + CmixConnect { withAuthentication, e2eId, recipientContact, e2eParamsJSON in + if withAuthentication { + return .live(try bindingsCmix.connect( + withAuthentication: e2eId, + recipientContact: recipientContact, + e2eParamsJSON: e2eParamsJSON + )) + } else { + return .live(try bindingsCmix.connect( + e2eId, + recipientContact: recipientContact, + e2eParamsJSON: e2eParamsJSON + )) + } + } + } +} + +extension CmixConnect { + public static let unimplemented = CmixConnect( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Connection.swift b/Sources/ElixxirDAppsSDK/Connection.swift new file mode 100644 index 0000000000000000000000000000000000000000..cd44343ab8056979a89bbfbc722f03018b934b2e --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Connection.swift @@ -0,0 +1,19 @@ +import Bindings + +public struct Connection { + // TODO: +} + +extension Connection { + public static func live(_ bindingsConnection: BindingsConnection) -> Connection { + Connection() + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> Connection { + Connection() + } +} + +extension Connection { + public static let unimplemented = Connection() +} diff --git a/Sources/ElixxirDAppsSDK/Legacy/Connection.swift b/Sources/ElixxirDAppsSDK/Legacy/Connection.swift deleted file mode 100644 index 97f3db747befd7f35e87a8853e2a787103383a2a..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/Legacy/Connection.swift +++ /dev/null @@ -1,51 +0,0 @@ -//import Bindings -// -//public struct Connection { -// public var getId: ConnectionIdProvider -// public var isAuthenticated: ConnectionAuthStatusProvider -// public var getPartner: ConnectionPartnerProvider -// public var send: MessageSender -// public var listen: MessageListener -// public var close: ConnectionCloser -//} -// -//extension Connection { -// public static func live( -// bindingsConnection: BindingsConnection -// ) -> Connection { -// Connection( -// getId: .live(bindingsConnection: bindingsConnection), -// isAuthenticated: .live(bindingsConnection: bindingsConnection), -// getPartner: .live(bindingsConnection: bindingsConnection), -// send: .live(bindingsConnection: bindingsConnection), -// listen: .live(bindingsConnection: bindingsConnection), -// close: .live(bindingsConnection: bindingsConnection) -// ) -// } -// -// public static func live( -// bindingsAuthenticatedConnection: BindingsAuthenticatedConnection -// ) -> Connection { -// Connection( -// getId: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), -// isAuthenticated: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), -// getPartner: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), -// send: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), -// listen: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), -// close: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection) -// ) -// } -//} -// -//#if DEBUG -//extension Connection { -// public static let failing = Connection( -// getId: .failing, -// isAuthenticated: .failing, -// getPartner: .failing, -// send: .failing, -// listen: .failing, -// close: .failing -// ) -//} -//#endif