From bd34e3c04dbeb251160cb353fd3c033f74d983bb Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 14 Sep 2022 12:21:13 +0200 Subject: [PATCH] Add MessagePayload model --- .../AppCore/Models/MessagePayload.swift | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Examples/xx-messenger/Sources/AppCore/Models/MessagePayload.swift 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 00000000..67fb94d9 --- /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) + } +} -- GitLab