frenzy-ios/Fervor/ItemsSyncUpdate.swift

31 lines
805 B
Swift

//
// ItemsSyncUpdate.swift
// Fervor
//
// Created by Shadowfacts on 1/9/22.
//
@preconcurrency import Foundation
public struct ItemsSyncUpdate: Decodable, Sendable {
public let syncTimestamp: Date
public let delete: [FervorID]
public let upsert: [Item]
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.syncTimestamp = try container.decode(Date.self, forKey: .syncTimestamp)
self.delete = try container.decode([FervorID].self, forKey: .delete)
self.upsert = try container.decode([Item].self, forKey: .upsert)
}
private enum CodingKeys: String, CodingKey {
case syncTimestamp = "sync_timestamp"
case delete
case upsert
}
}