You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
//
|
|
// SyncedStorable.swift
|
|
// LeStorage
|
|
//
|
|
// Created by Laurent Morvillier on 11/10/2024.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public enum SharingStatus: Int, Codable {
|
|
case shared = 1
|
|
case granted
|
|
}
|
|
|
|
public protocol SyncedStorable: Storable {
|
|
|
|
var lastUpdate: Date { get set }
|
|
var sharing: SharingStatus? { get set }
|
|
|
|
init()
|
|
|
|
/// Returns HTTP methods that do not need to pass the token to the request
|
|
static func tokenExemptedMethods() -> [HTTPMethod]
|
|
|
|
/// Returns whether we should copy the server response into the local instance
|
|
static var copyServerResponse: Bool { get }
|
|
|
|
}
|
|
|
|
protocol URLParameterConvertible {
|
|
func queryParameters(storeCenter: StoreCenter) -> [String : String]
|
|
}
|
|
|
|
public protocol SideStorable {
|
|
var storeId: String? { get set }
|
|
}
|
|
|
|
extension Storable {
|
|
|
|
func getStoreId() -> String? {
|
|
if let alt = self as? SideStorable {
|
|
return alt.storeId
|
|
}
|
|
return nil
|
|
}
|
|
|
|
}
|
|
|
|
public extension SyncedStorable {
|
|
|
|
func copy() -> Self {
|
|
let copy = Self()
|
|
copy.copy(from: self)
|
|
return copy
|
|
}
|
|
|
|
}
|
|
|