Skip to content

Commit

Permalink
add: url attribute to OPML.Outline
Browse files Browse the repository at this point in the history
  • Loading branch information
devahmedshendy committed Sep 18, 2023
1 parent 5dfd095 commit f7b45dd
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions Sources/SyndiKit/Formats/OPML/OPMLOutline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,53 @@ import Foundation
public extension OPML {
struct Outline: Codable, Equatable {
public let text: String
public let description: String?
public let htmlUrl: String?
public let language: String?
public let title: String?
public let description: String?
public let type: String?
public let version: String?
public let url: [String]
public let htmlUrl: String?
public let xmlUrl: String?
public let language: String?
public let created: String?
public let categories: [String]?
public let version: String?

public let outlines: [Outline]?

enum CodingKeys: String, CodingKey {
case text
case description
case htmlUrl
case language
case title
case description
case type
case version
case url
case htmlUrl
case xmlUrl
case language
case created
case categories = "category"
case version

case outlines = ""
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.text = try container.decode(String.self, forKey: CodingKeys.text)
self.description = try container.decodeIfPresent(String.self, forKey: .description)
self.htmlUrl = try container.decodeIfPresent(String.self, forKey: .htmlUrl)
self.language = try container.decodeIfPresent(String.self, forKey: .language)

self.text = try container.decode(String.self, forKey: .text)
self.title = try container.decodeIfPresent(String.self, forKey: .title)
self.description = try container.decodeIfPresent(String.self, forKey: .description)
self.type = try container.decodeIfPresent(String.self, forKey: .type)
self.version = try container.decodeIfPresent(String.self, forKey: .version)
self.url = try container.decode([String].self, forKey: .url)
self.htmlUrl = try container.decodeIfPresent(String.self, forKey: .htmlUrl)
self.xmlUrl = try container.decodeIfPresent(String.self, forKey: .xmlUrl)
self.language = try container.decodeIfPresent(String.self, forKey: .language)
self.created = try container.decodeIfPresent(String.self, forKey: .created)
self.version = try container.decodeIfPresent(String.self, forKey: .version)
self.outlines = try container.decodeIfPresent([Outline].self, forKey: .outlines)

let category = try container.decodeIfPresent(String.self, forKey: .categories)
self.categories = category?.components(separatedBy: ",")
self.categories = try container
.decodeIfPresent(String.self, forKey: .categories)?
.components(separatedBy: ",")

Check warning on line 52 in Sources/SyndiKit/Formats/OPML/OPMLOutline.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SyndiKit/Formats/OPML/OPMLOutline.swift#L35-L52

Added lines #L35 - L52 were not covered by tests
}
}
}

0 comments on commit f7b45dd

Please sign in to comment.