From 1b6fb7ba9312c7cea0abd596b54925d77a3a4a76 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 22 Mar 2022 08:02:47 -0700 Subject: [PATCH] create ArticleCOntent model --- .../Sources/Models/ArticleContent.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 apple/OmnivoreKit/Sources/Models/ArticleContent.swift diff --git a/apple/OmnivoreKit/Sources/Models/ArticleContent.swift b/apple/OmnivoreKit/Sources/Models/ArticleContent.swift new file mode 100644 index 000000000..c3113a3c7 --- /dev/null +++ b/apple/OmnivoreKit/Sources/Models/ArticleContent.swift @@ -0,0 +1,22 @@ +import Foundation + +public struct ArticleContent { + public let htmlContent: String + public let highlights: [Highlight] + + public init( + htmlContent: String, + highlights: [Highlight] + ) { + self.htmlContent = htmlContent + self.highlights = highlights + + print(highlightsJSONString) + } + + public var highlightsJSONString: String { + let jsonData = try? JSONEncoder().encode(highlights) + guard let jsonData = jsonData else { return "[]" } + return String(data: jsonData, encoding: .utf8) ?? "[]" + } +}