Skip to content
Snippets Groups Projects
Commit 3e1a515f authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Use MessageSendReport in MessageDeliveryWaiter

parent 5c954bab
No related branches found
No related tags found
1 merge request!12Use codable models in API
......@@ -6,22 +6,24 @@ public struct MessageDeliveryWaiter {
case notDelivered(timedOut: Bool)
}
public var wait: (Data, Int, @escaping (Result) -> Void) throws -> Void
public var wait: (MessageSendReport, Int, @escaping (Result) -> Void) throws -> Void
public func callAsFunction(
roundList: Data,
report: MessageSendReport,
timeoutMS: Int,
callback: @escaping (Result) -> Void
) throws -> Void {
try wait(roundList, timeoutMS, callback)
) throws {
try wait(report, timeoutMS, callback)
}
}
extension MessageDeliveryWaiter {
public static func live(bindingsClient: BindingsClient) -> MessageDeliveryWaiter {
MessageDeliveryWaiter { roundList, timeoutMS, callback in
MessageDeliveryWaiter { report, timeoutMS, callback in
let encoder = JSONEncoder()
let reportData = try encoder.encode(report)
try bindingsClient.wait(
forMessageDelivery: roundList,
forMessageDelivery: reportData,
mdc: Callback(onCallback: callback),
timeoutMS: timeoutMS
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment