2019-03-13 06:40:11 +01:00
|
|
|
//
|
2019-05-05 14:49:59 +02:00
|
|
|
// AccountMetadata.swift
|
2019-03-13 06:40:11 +01:00
|
|
|
// Account
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 3/3/19.
|
|
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2019-05-05 15:44:57 +02:00
|
|
|
import RSWeb
|
2019-03-13 06:40:11 +01:00
|
|
|
|
2019-05-05 14:49:59 +02:00
|
|
|
protocol AccountMetadataDelegate: class {
|
|
|
|
func valueDidChange(_ accountMetadata: AccountMetadata, key: AccountMetadata.CodingKeys)
|
2019-05-05 14:21:26 +02:00
|
|
|
}
|
|
|
|
|
2019-05-05 14:49:59 +02:00
|
|
|
final class AccountMetadata: Codable {
|
2019-03-28 06:10:14 +01:00
|
|
|
|
2019-05-05 14:21:26 +02:00
|
|
|
enum CodingKeys: String, CodingKey {
|
|
|
|
case name
|
|
|
|
case isActive
|
|
|
|
case username
|
2019-05-05 15:44:57 +02:00
|
|
|
case conditionalGetInfo
|
2019-12-10 02:34:26 +01:00
|
|
|
case lastArticleFetchStartTime = "lastArticleFetch"
|
|
|
|
case lastArticleFetchEndTime
|
2019-05-29 21:16:09 +02:00
|
|
|
case endpointURL
|
2019-05-05 14:21:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var name: String? {
|
|
|
|
didSet {
|
|
|
|
if name != oldValue {
|
|
|
|
valueDidChange(.name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var isActive: Bool = true {
|
|
|
|
didSet {
|
|
|
|
if isActive != oldValue {
|
|
|
|
valueDidChange(.isActive)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var username: String? {
|
|
|
|
didSet {
|
|
|
|
if username != oldValue {
|
|
|
|
valueDidChange(.username)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-05 15:44:57 +02:00
|
|
|
|
|
|
|
var conditionalGetInfo = [String: HTTPConditionalGetInfo]() {
|
|
|
|
didSet {
|
|
|
|
if conditionalGetInfo != oldValue {
|
|
|
|
valueDidChange(.conditionalGetInfo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-13 01:32:32 +02:00
|
|
|
|
2019-12-10 02:34:26 +01:00
|
|
|
var lastArticleFetchStartTime: Date? {
|
2019-05-13 01:32:32 +02:00
|
|
|
didSet {
|
2019-12-10 02:34:26 +01:00
|
|
|
if lastArticleFetchStartTime != oldValue {
|
|
|
|
valueDidChange(.lastArticleFetchStartTime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var lastArticleFetchEndTime: Date? {
|
|
|
|
didSet {
|
|
|
|
if lastArticleFetchEndTime != oldValue {
|
|
|
|
valueDidChange(.lastArticleFetchEndTime)
|
2019-05-13 01:32:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-29 21:16:09 +02:00
|
|
|
|
|
|
|
var endpointURL: URL? {
|
|
|
|
didSet {
|
|
|
|
if endpointURL != oldValue {
|
|
|
|
valueDidChange(.endpointURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-05 14:21:26 +02:00
|
|
|
|
2019-05-05 14:49:59 +02:00
|
|
|
weak var delegate: AccountMetadataDelegate?
|
2019-05-05 14:21:26 +02:00
|
|
|
|
|
|
|
func valueDidChange(_ key: CodingKeys) {
|
|
|
|
delegate?.valueDidChange(self, key: key)
|
|
|
|
}
|
2019-03-21 06:10:22 +01:00
|
|
|
}
|