From 985857793050afddf32acf7dbdcb56248ecdc255 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Tue, 26 Jul 2022 17:06:24 +0100 Subject: [PATCH] Refactor --- Sources/ElixxirDAppsSDK/Models/EventReport.swift | 2 +- Sources/ElixxirDAppsSDK/Models/Fact.swift | 4 ++-- Sources/ElixxirDAppsSDK/Models/Message.swift | 2 +- Sources/ElixxirDAppsSDK/Models/MessageSendReport.swift | 2 +- Sources/ElixxirDAppsSDK/Models/ReceptionIdentity.swift | 2 +- Sources/ElixxirDAppsSDK/Models/RestlikeMessage.swift | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/ElixxirDAppsSDK/Models/EventReport.swift b/Sources/ElixxirDAppsSDK/Models/EventReport.swift index 9802daa0..e4374803 100644 --- a/Sources/ElixxirDAppsSDK/Models/EventReport.swift +++ b/Sources/ElixxirDAppsSDK/Models/EventReport.swift @@ -27,7 +27,7 @@ extension EventReport: Codable { case details = "Details" } - public static func decode(_ data: Data) throws -> EventReport { + public static func decode(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) } diff --git a/Sources/ElixxirDAppsSDK/Models/Fact.swift b/Sources/ElixxirDAppsSDK/Models/Fact.swift index 7d8dc591..456ad36c 100644 --- a/Sources/ElixxirDAppsSDK/Models/Fact.swift +++ b/Sources/ElixxirDAppsSDK/Models/Fact.swift @@ -19,7 +19,7 @@ extension Fact: Codable { case type = "Type" } - public static func decode(_ data: Data) throws -> Fact { + public static func decode(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) } @@ -29,7 +29,7 @@ extension Fact: Codable { } extension Array where Element == Fact { - public static func decode(_ data: Data) throws -> [Fact] { + public static func decode(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) } diff --git a/Sources/ElixxirDAppsSDK/Models/Message.swift b/Sources/ElixxirDAppsSDK/Models/Message.swift index c554d119..3abaec65 100644 --- a/Sources/ElixxirDAppsSDK/Models/Message.swift +++ b/Sources/ElixxirDAppsSDK/Models/Message.swift @@ -47,7 +47,7 @@ extension Message: Codable { case roundId = "RoundId" } - public static func decode(_ data: Data) throws -> Message { + public static func decode(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) } diff --git a/Sources/ElixxirDAppsSDK/Models/MessageSendReport.swift b/Sources/ElixxirDAppsSDK/Models/MessageSendReport.swift index 0e3a6bf0..be8d3833 100644 --- a/Sources/ElixxirDAppsSDK/Models/MessageSendReport.swift +++ b/Sources/ElixxirDAppsSDK/Models/MessageSendReport.swift @@ -23,7 +23,7 @@ extension MessageSendReport: Codable { case timestamp = "Timestamp" } - public static func decode(_ data: Data) throws -> MessageSendReport { + public static func decode(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) } diff --git a/Sources/ElixxirDAppsSDK/Models/ReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Models/ReceptionIdentity.swift index d0c1571e..312ec2c3 100644 --- a/Sources/ElixxirDAppsSDK/Models/ReceptionIdentity.swift +++ b/Sources/ElixxirDAppsSDK/Models/ReceptionIdentity.swift @@ -27,7 +27,7 @@ extension ReceptionIdentity: Codable { case dhKeyPrivate = "DHKeyPrivate" } - public static func decode(_ data: Data) throws -> ReceptionIdentity { + public static func decode(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) } diff --git a/Sources/ElixxirDAppsSDK/Models/RestlikeMessage.swift b/Sources/ElixxirDAppsSDK/Models/RestlikeMessage.swift index 65b63786..4c33ec5a 100644 --- a/Sources/ElixxirDAppsSDK/Models/RestlikeMessage.swift +++ b/Sources/ElixxirDAppsSDK/Models/RestlikeMessage.swift @@ -35,7 +35,7 @@ extension RestlikeMessage: Codable { case error = "Error" } - public static func decode(_ data: Data) throws -> RestlikeMessage { + public static func decode(_ data: Data) throws -> Self { try JSONDecoder().decode(Self.self, from: data) } -- GitLab