Add extended mode for Feedbin entries to get avatar url. Issue #669
This commit is contained in:
parent
9f6b2bc63f
commit
7e6db47956
|
@ -358,9 +358,9 @@ final class FeedbinAPICaller: NSObject {
|
||||||
let concatIDs = articleIDs.reduce("") { param, articleID in return param + ",\(articleID)" }
|
let concatIDs = articleIDs.reduce("") { param, articleID in return param + ",\(articleID)" }
|
||||||
let paramIDs = String(concatIDs.dropFirst())
|
let paramIDs = String(concatIDs.dropFirst())
|
||||||
|
|
||||||
var callURL = URLComponents(url: feedbinBaseURL.appendingPathComponent("entries.json"), resolvingAgainstBaseURL: false)!
|
var callComponents = URLComponents(url: feedbinBaseURL.appendingPathComponent("entries.json"), resolvingAgainstBaseURL: false)!
|
||||||
callURL.queryItems = [URLQueryItem(name: "ids", value: paramIDs)]
|
callComponents.queryItems = [URLQueryItem(name: "ids", value: paramIDs), URLQueryItem(name: "mode", value: "extended")]
|
||||||
let request = URLRequest(url: callURL.url!, credentials: credentials)
|
let request = URLRequest(url: callComponents.url!, credentials: credentials)
|
||||||
|
|
||||||
transport.send(request: request, resultType: [FeedbinEntry].self) { result in
|
transport.send(request: request, resultType: [FeedbinEntry].self) { result in
|
||||||
|
|
||||||
|
@ -380,9 +380,9 @@ final class FeedbinAPICaller: NSObject {
|
||||||
let since = Calendar.current.date(byAdding: .month, value: -3, to: Date()) ?? Date()
|
let since = Calendar.current.date(byAdding: .month, value: -3, to: Date()) ?? Date()
|
||||||
let sinceString = FeedbinDate.formatter.string(from: since)
|
let sinceString = FeedbinDate.formatter.string(from: since)
|
||||||
|
|
||||||
var callURL = URLComponents(url: feedbinBaseURL.appendingPathComponent("/feeds/\(feedID)/entries.json"), resolvingAgainstBaseURL: false)!
|
var callComponents = URLComponents(url: feedbinBaseURL.appendingPathComponent("feeds/\(feedID)/entries.json"), resolvingAgainstBaseURL: false)!
|
||||||
callURL.queryItems = [URLQueryItem(name: "since", value: sinceString), URLQueryItem(name: "per_page", value: "100")]
|
callComponents.queryItems = [URLQueryItem(name: "since", value: sinceString), URLQueryItem(name: "per_page", value: "100"), URLQueryItem(name: "mode", value: "extended")]
|
||||||
let request = URLRequest(url: callURL.url!, credentials: credentials)
|
let request = URLRequest(url: callComponents.url!, credentials: credentials)
|
||||||
|
|
||||||
transport.send(request: request, resultType: [FeedbinEntry].self) { result in
|
transport.send(request: request, resultType: [FeedbinEntry].self) { result in
|
||||||
|
|
||||||
|
@ -411,9 +411,9 @@ final class FeedbinAPICaller: NSObject {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let sinceString = FeedbinDate.formatter.string(from: since)
|
let sinceString = FeedbinDate.formatter.string(from: since)
|
||||||
var callURL = URLComponents(url: feedbinBaseURL.appendingPathComponent("entries.json"), resolvingAgainstBaseURL: false)!
|
var callComponents = URLComponents(url: feedbinBaseURL.appendingPathComponent("entries.json"), resolvingAgainstBaseURL: false)!
|
||||||
callURL.queryItems = [URLQueryItem(name: "since", value: sinceString), URLQueryItem(name: "per_page", value: "100")]
|
callComponents.queryItems = [URLQueryItem(name: "since", value: sinceString), URLQueryItem(name: "per_page", value: "100"), URLQueryItem(name: "mode", value: "extended")]
|
||||||
let request = URLRequest(url: callURL.url!, credentials: credentials)
|
let request = URLRequest(url: callComponents.url!, credentials: credentials)
|
||||||
|
|
||||||
transport.send(request: request, resultType: [FeedbinEntry].self) { result in
|
transport.send(request: request, resultType: [FeedbinEntry].self) { result in
|
||||||
|
|
||||||
|
@ -438,12 +438,13 @@ final class FeedbinAPICaller: NSObject {
|
||||||
|
|
||||||
func retrieveEntries(page: String, completion: @escaping (Result<([FeedbinEntry]?, String?), Error>) -> Void) {
|
func retrieveEntries(page: String, completion: @escaping (Result<([FeedbinEntry]?, String?), Error>) -> Void) {
|
||||||
|
|
||||||
guard let callURL = URL(string: page) else {
|
guard let url = URL(string: page), var callComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else {
|
||||||
completion(.success((nil, nil)))
|
completion(.success((nil, nil)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let request = URLRequest(url: callURL, credentials: credentials)
|
callComponents.queryItems?.append(URLQueryItem(name: "mode", value: "extended"))
|
||||||
|
let request = URLRequest(url: callComponents.url!, credentials: credentials)
|
||||||
|
|
||||||
transport.send(request: request, resultType: [FeedbinEntry].self) { result in
|
transport.send(request: request, resultType: [FeedbinEntry].self) { result in
|
||||||
|
|
||||||
|
|
|
@ -1098,7 +1098,7 @@ private extension FeedbinAccountDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
let parsedItems: [ParsedItem] = entries.map { entry in
|
let parsedItems: [ParsedItem] = entries.map { entry in
|
||||||
let authors = Set([ParsedAuthor(name: entry.authorName, url: nil, avatarURL: nil, emailAddress: nil)])
|
let authors = Set([ParsedAuthor(name: entry.authorName, url: entry.jsonFeed?.jsonFeedAuthor?.url, avatarURL: entry.jsonFeed?.jsonFeedAuthor?.avatarURL, emailAddress: nil)])
|
||||||
return ParsedItem(syncServiceID: String(entry.articleID), uniqueID: String(entry.articleID), feedURL: String(entry.feedID), url: nil, externalURL: entry.url, title: entry.title, contentHTML: entry.contentHTML, contentText: nil, summary: entry.summary, imageURL: nil, bannerImageURL: nil, datePublished: entry.parseDatePublished(), dateModified: nil, authors: authors, tags: nil, attachments: nil)
|
return ParsedItem(syncServiceID: String(entry.articleID), uniqueID: String(entry.articleID), feedURL: String(entry.feedID), url: nil, externalURL: entry.url, title: entry.title, contentHTML: entry.contentHTML, contentText: nil, summary: entry.summary, imageURL: nil, bannerImageURL: nil, datePublished: entry.parseDatePublished(), dateModified: nil, authors: authors, tags: nil, attachments: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ struct FeedbinEntry: Codable {
|
||||||
let summary: String?
|
let summary: String?
|
||||||
let datePublished: String?
|
let datePublished: String?
|
||||||
let dateArrived: String?
|
let dateArrived: String?
|
||||||
|
let jsonFeed: FeedbinEntryJSONFeed?
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case articleID = "id"
|
case articleID = "id"
|
||||||
|
@ -32,6 +33,7 @@ struct FeedbinEntry: Codable {
|
||||||
case summary = "summary"
|
case summary = "summary"
|
||||||
case datePublished = "published"
|
case datePublished = "published"
|
||||||
case dateArrived = "created_at"
|
case dateArrived = "created_at"
|
||||||
|
case jsonFeed = "json_feed"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Feedbin dates can't be decoded by the JSONDecoding 8601 decoding strategy. Feedbin
|
// Feedbin dates can't be decoded by the JSONDecoding 8601 decoding strategy. Feedbin
|
||||||
|
@ -47,3 +49,19 @@ struct FeedbinEntry: Codable {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct FeedbinEntryJSONFeed: Codable {
|
||||||
|
let jsonFeedAuthor: FeedbinEntryJSONFeedAuthor?
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case jsonFeedAuthor = "author"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FeedbinEntryJSONFeedAuthor: Codable {
|
||||||
|
let url: String?
|
||||||
|
let avatarURL: String?
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case url = "url"
|
||||||
|
case avatarURL = "avatar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue