Create FeedbinSubscription struct.

This commit is contained in:
Brent Simmons 2017-12-10 14:04:14 -08:00
parent 1d956c619d
commit 6e93cc2718
1 changed files with 5 additions and 8 deletions

View File

@ -15,7 +15,7 @@ struct FeedbinSubscription {
let subscriptionID: String let subscriptionID: String
let feedID: String let feedID: String
let creationDate: Date? let creationDate: Date?
let name: String let name: String?
let url: String let url: String
let homePageURL: String? let homePageURL: String?
@ -54,6 +54,9 @@ struct FeedbinSubscription {
if let creationDateString = dictionary[Key.creationDate] as? String { if let creationDateString = dictionary[Key.creationDate] as? String {
self.creationDate = RSDateWithString(creationDateString) self.creationDate = RSDateWithString(creationDateString)
} }
else {
self.creationDate = nil
}
self.name = dictionary[Key.name] as? String self.name = dictionary[Key.name] as? String
self.homePageURL = dictionary[Key.homePageURL] as? String self.homePageURL = dictionary[Key.homePageURL] as? String
@ -61,13 +64,7 @@ struct FeedbinSubscription {
static func subscriptions(with array: JSONArray) -> [FeedbinSubscription]? { static func subscriptions(with array: JSONArray) -> [FeedbinSubscription]? {
let subs = array.flatMap { (jsonSubscription) -> FeedbinSubscription? in let subs = array.flatMap { FeedbinSubscription(dictionary: $0) }
if let dictionary = jsonSubscription as? JSONDictionary else {
return nil
}
return FeedbinSubscription(dictionary: dictionary)
}
return subs.isEmpty ? nil : subs return subs.isEmpty ? nil : subs
} }
} }