NetNewsWire/Frameworks/Account/NewsBlur/Models/NewsBlurStory.swift

58 lines
1.3 KiB
Swift
Raw Normal View History

2020-03-11 02:08:56 +01:00
//
// NewsBlurStory.swift
2020-03-11 02:08:56 +01:00
// Account
//
// Created by Anh Quang Do on 2020-03-10.
// Copyright (c) 2020 Ranchero Software, LLC. All rights reserved.
//
import Foundation
import RSCore
import RSParser
typealias NewsBlurStory = NewsBlurStoriesResponse.Story
2020-03-13 23:18:47 +01:00
struct NewsBlurStoriesResponse: Decodable {
let stories: [Story]
2020-03-13 23:18:47 +01:00
struct Story: Decodable {
2020-03-13 23:57:38 +01:00
let storyID: String
let feedID: Int
2020-03-13 23:18:47 +01:00
let title: String?
let url: String?
let authorName: String?
let contentHTML: String?
2020-03-14 23:19:50 +01:00
var imageURL: String? {
return imageURLs?.first
}
var tags: [String]?
var datePublished: Date? {
let interval = (publishedTimestamp as NSString).doubleValue
return Date(timeIntervalSince1970: interval)
}
2020-03-14 23:19:50 +01:00
private var imageURLs: [String]?
private var publishedTimestamp: String
2020-03-11 02:08:56 +01:00
}
}
extension NewsBlurStoriesResponse {
2020-03-11 02:08:56 +01:00
private enum CodingKeys: String, CodingKey {
case stories = "stories"
2020-03-11 02:08:56 +01:00
}
2020-03-13 23:18:47 +01:00
}
2020-03-11 02:08:56 +01:00
extension NewsBlurStoriesResponse.Story {
2020-03-13 23:18:47 +01:00
private enum CodingKeys: String, CodingKey {
2020-03-13 23:57:38 +01:00
case storyID = "story_hash"
case feedID = "story_feed_id"
2020-03-13 23:18:47 +01:00
case title = "story_title"
case url = "story_permalink"
case authorName = "story_authors"
case contentHTML = "story_content"
2020-03-14 23:19:50 +01:00
case imageURLs = "image_urls"
case tags = "story_tags"
case publishedTimestamp = "story_timestamp"
2020-03-11 02:08:56 +01:00
}
}