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 { ...@@ -6,22 +6,24 @@ public struct MessageDeliveryWaiter {
case notDelivered(timedOut: Bool) 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( public func callAsFunction(
roundList: Data, report: MessageSendReport,
timeoutMS: Int, timeoutMS: Int,
callback: @escaping (Result) -> Void callback: @escaping (Result) -> Void
) throws -> Void { ) throws {
try wait(roundList, timeoutMS, callback) try wait(report, timeoutMS, callback)
} }
} }
extension MessageDeliveryWaiter { extension MessageDeliveryWaiter {
public static func live(bindingsClient: BindingsClient) -> 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( try bindingsClient.wait(
forMessageDelivery: roundList, forMessageDelivery: reportData,
mdc: Callback(onCallback: callback), mdc: Callback(onCallback: callback),
timeoutMS: timeoutMS 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