From 46e21f57e8c3bf5c831efbe0d0ee7aa47d922e55 Mon Sep 17 00:00:00 2001 From: Jeremy Beker Date: Thu, 30 May 2019 16:01:56 -0400 Subject: [PATCH] Decoding of tags working. --- .../GoogleReaderCompatibleAPICaller.swift | 6 +++--- .../GoogleReaderCompatibleAccountDelegate.swift | 2 ++ .../GoogleReaderCompatibleTag.swift | 14 +++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAPICaller.swift b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAPICaller.swift index b8617f5e8..ca16ea9e7 100644 --- a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAPICaller.swift +++ b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAPICaller.swift @@ -181,12 +181,12 @@ final class GoogleReaderCompatibleAPICaller: NSObject { //let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.tags] let request = URLRequest(url: callURL, credentials: credentials) - transport.send(request: request, resultType: [GoogleReaderCompatibleTag].self) { result in + transport.send(request: request, resultType: GoogleReaderCompatibleTagWrapper.self) { result in switch result { - case .success(let (response, tags)): + case .success(let (response, wrapper)): self.storeConditionalGet(key: ConditionalGetKeys.tags, headers: response.allHeaderFields) - completion(.success(tags)) + completion(.success(wrapper?.tags)) case .failure(let error): completion(.failure(error)) } diff --git a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAccountDelegate.swift b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAccountDelegate.swift index a5b905893..979a5c4bd 100644 --- a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAccountDelegate.swift +++ b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAccountDelegate.swift @@ -574,6 +574,8 @@ private extension GoogleReaderCompatibleAccountDelegate { os_log(.debug, log: log, "Syncing folders with %ld tags.", tags.count) + // TODO: filter on folder tag type + // TODO: filter names to get rid of prefixes let tagNames = tags.map { $0.tagID } // Delete any folders not at GoogleReaderCompatible diff --git a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleTag.swift b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleTag.swift index 3daf9f0eb..f2b1252f8 100644 --- a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleTag.swift +++ b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleTag.swift @@ -8,14 +8,22 @@ import Foundation +struct GoogleReaderCompatibleTagWrapper: Codable { + let tags: [GoogleReaderCompatibleTag] + + enum CodingKeys: String, CodingKey { + case tags = "tags" + } +} + struct GoogleReaderCompatibleTag: Codable { - let tagID: Int - let name: String + let tagID: String + let type: String? enum CodingKeys: String, CodingKey { case tagID = "id" - case name = "name" + case type = "type" } }