Skip to content
Snippets Groups Projects

Use codable models in API

1 file
+ 8
6
Compare changes
  • Side-by-side
  • Inline
@@ -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
)
)
Loading