From 6120e12021797e961dcd93e2e71631f1e08f62d5 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 31 Aug 2022 01:58:56 +0100 Subject: [PATCH] Add GetNotificationsReport function wrapper --- .../Functors/GetNotificationsReport.swift | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Sources/XXClient/Functors/GetNotificationsReport.swift diff --git a/Sources/XXClient/Functors/GetNotificationsReport.swift b/Sources/XXClient/Functors/GetNotificationsReport.swift new file mode 100644 index 00000000..0b5d31f8 --- /dev/null +++ b/Sources/XXClient/Functors/GetNotificationsReport.swift @@ -0,0 +1,41 @@ +import Bindings +import XCTestDynamicOverlay + +public struct GetNotificationsReport { + public var run: (Int, String, Data) throws -> NotificationReport + + public func callAsFunction( + e2eId: Int, + notificationCSV: String, + marshaledServices: Data + ) throws -> NotificationReport { + try run(e2eId, notificationCSV, marshaledServices) + } +} + +extension GetNotificationsReport { + public static func live() -> GetNotificationsReport { + GetNotificationsReport { e2eId, notificationCSV, marshaledServices in + var error: NSError? + let result = BindingsGetNotificationsReport( + e2eId, + notificationCSV, + marshaledServices, + &error + ) + if let error = error { + throw error + } + guard let result = result else { + fatalError("BindingsGetNotificationsReport returned nil without providing error") + } + return try NotificationReport.decode(result) + } + } +} + +extension GetNotificationsReport { + public static let unimplemented = GetNotificationsReport( + run: XCTUnimplemented("\(Self.self)") + ) +} -- GitLab