diff --git a/Examples/xx-messenger/Sources/AppCore/Models/MessagePayload.swift b/Examples/xx-messenger/Sources/AppCore/Models/MessagePayload.swift new file mode 100644 index 0000000000000000000000000000000000000000..67fb94d905b06ad25816ca8c4d11081c72053f19 --- /dev/null +++ b/Examples/xx-messenger/Sources/AppCore/Models/MessagePayload.swift @@ -0,0 +1,23 @@ +import Foundation + +public struct MessagePayload: Equatable { + public init(text: String) { + self.text = text + } + + public var text: String +} + +extension MessagePayload: Codable { + enum CodingKeys: String, CodingKey { + case text + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +}