Skip to content
Snippets Groups Projects

Use codable models in API

1 file
+ 5
3
Compare changes
  • Side-by-side
  • Inline
import Bindings
import Bindings
public struct IdentityMaker {
public struct IdentityMaker {
public var make: () throws -> Data
public var make: () throws -> Identity
public func callAsFunction() throws -> Data {
public func callAsFunction() throws -> Identity {
try make()
try make()
}
}
}
}
@@ -11,7 +11,9 @@ public struct IdentityMaker {
@@ -11,7 +11,9 @@ public struct IdentityMaker {
extension IdentityMaker {
extension IdentityMaker {
public static func live(bindingsClient: BindingsClient) -> IdentityMaker {
public static func live(bindingsClient: BindingsClient) -> IdentityMaker {
IdentityMaker {
IdentityMaker {
try bindingsClient.makeIdentity()
let data = try bindingsClient.makeIdentity()
 
let decoder = JSONDecoder()
 
return try decoder.decode(Identity.self, from: data)
}
}
}
}
}
}
Loading