advplyr.audiobookshelf-app/ios/App/Shared/models/ServerConnectionConfig.swift

50 lines
1.1 KiB
Swift
Raw Normal View History

2022-04-11 16:29:19 +02:00
//
// ServerConnectionConfig.swift
// App
//
// Created by Rasmus Krämer on 11.04.22.
//
import Foundation
import RealmSwift
import Unrealm
2022-04-11 16:29:19 +02:00
struct ServerConnectionConfig: Realmable {
var id: String = UUID().uuidString
2022-08-02 17:10:45 -04:00
var index: Int = 1
var name: String = ""
var address: String = ""
var userId: String = ""
var username: String = ""
var token: String = ""
static func primaryKey() -> String? {
return "id"
}
static func indexedProperties() -> [String] {
return ["index"]
}
2022-04-11 16:29:19 +02:00
}
2022-04-15 10:16:11 +02:00
struct ServerConnectionConfigActiveIndex: Realmable {
// This could overflow, but you really would have to try
var index: Int?
2022-08-02 17:10:45 -04:00
static func primaryKey() -> String? {
return "index"
}
2022-04-15 10:16:11 +02:00
}
2022-04-11 16:29:19 +02:00
2022-04-11 18:31:14 +02:00
func convertServerConnectionConfigToJSON(config: ServerConnectionConfig) -> Dictionary<String, Any> {
2022-08-07 17:46:13 -04:00
return [
"id": config.id,
"name": config.name,
"index": config.index,
"address": config.address,
"userId": config.userId,
"username": config.username,
"token": config.token,
]
2022-04-11 16:29:19 +02:00
}