From 46351d04ec5931097d906d85d43d219b43ec356d Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Mon, 25 Jul 2022 19:06:44 +0100 Subject: [PATCH] Make model en/decoding public --- Sources/ElixxirDAppsSDK/Fact.swift | 8 ++++---- Sources/ElixxirDAppsSDK/Message.swift | 4 ++-- Sources/ElixxirDAppsSDK/MessageSendReport.swift | 4 ++-- Sources/ElixxirDAppsSDK/ReceptionIdentity.swift | 4 ++-- Sources/ElixxirDAppsSDK/RestlikeMessage.swift | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Sources/ElixxirDAppsSDK/Fact.swift b/Sources/ElixxirDAppsSDK/Fact.swift index ecf0e64d..7d8dc591 100644 --- a/Sources/ElixxirDAppsSDK/Fact.swift +++ b/Sources/ElixxirDAppsSDK/Fact.swift @@ -19,21 +19,21 @@ extension Fact: Codable { case type = "Type" } - static func decode(_ data: Data) throws -> Fact { + public static func decode(_ data: Data) throws -> Fact { try JSONDecoder().decode(Self.self, from: data) } - func encode() throws -> Data { + public func encode() throws -> Data { try JSONEncoder().encode(self) } } extension Array where Element == Fact { - static func decode(_ data: Data) throws -> [Fact] { + public static func decode(_ data: Data) throws -> [Fact] { try JSONDecoder().decode(Self.self, from: data) } - func encode() throws -> Data { + public func encode() throws -> Data { try JSONEncoder().encode(self) } } diff --git a/Sources/ElixxirDAppsSDK/Message.swift b/Sources/ElixxirDAppsSDK/Message.swift index b2c13b7d..c554d119 100644 --- a/Sources/ElixxirDAppsSDK/Message.swift +++ b/Sources/ElixxirDAppsSDK/Message.swift @@ -47,11 +47,11 @@ extension Message: Codable { case roundId = "RoundId" } - static func decode(_ data: Data) throws -> Message { + public static func decode(_ data: Data) throws -> Message { try JSONDecoder().decode(Self.self, from: data) } - func encode() throws -> Data { + public func encode() throws -> Data { try JSONEncoder().encode(self) } } diff --git a/Sources/ElixxirDAppsSDK/MessageSendReport.swift b/Sources/ElixxirDAppsSDK/MessageSendReport.swift index 8ac2038b..0e3a6bf0 100644 --- a/Sources/ElixxirDAppsSDK/MessageSendReport.swift +++ b/Sources/ElixxirDAppsSDK/MessageSendReport.swift @@ -23,11 +23,11 @@ extension MessageSendReport: Codable { case timestamp = "Timestamp" } - static func decode(_ data: Data) throws -> MessageSendReport { + public static func decode(_ data: Data) throws -> MessageSendReport { try JSONDecoder().decode(Self.self, from: data) } - func encode() throws -> Data { + public func encode() throws -> Data { try JSONEncoder().encode(self) } } diff --git a/Sources/ElixxirDAppsSDK/ReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/ReceptionIdentity.swift index ed11ddca..d0c1571e 100644 --- a/Sources/ElixxirDAppsSDK/ReceptionIdentity.swift +++ b/Sources/ElixxirDAppsSDK/ReceptionIdentity.swift @@ -27,11 +27,11 @@ extension ReceptionIdentity: Codable { case dhKeyPrivate = "DHKeyPrivate" } - static func decode(_ data: Data) throws -> ReceptionIdentity { + public static func decode(_ data: Data) throws -> ReceptionIdentity { try JSONDecoder().decode(Self.self, from: data) } - func encode() throws -> Data { + public func encode() throws -> Data { try JSONEncoder().encode(self) } } diff --git a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift b/Sources/ElixxirDAppsSDK/RestlikeMessage.swift index 414a74b4..65b63786 100644 --- a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift +++ b/Sources/ElixxirDAppsSDK/RestlikeMessage.swift @@ -35,11 +35,11 @@ extension RestlikeMessage: Codable { case error = "Error" } - static func decode(_ data: Data) throws -> RestlikeMessage { + public static func decode(_ data: Data) throws -> RestlikeMessage { try JSONDecoder().decode(Self.self, from: data) } - func encode() throws -> Data { + public func encode() throws -> Data { try JSONEncoder().encode(self) } } -- GitLab