Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Sources/CloudModels/Applications/Application/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ public final class Application: Extensible, Identifiable {
public var name: String // A more human readable name, can contain special chars etc.
public var extend: [String: Any]
public var cost: Cost?
public var publicKey: String?
public var secretKey: String?

public init(
id: Identifier? = nil,
project: ModelOrIdentifier<Project>,
repoName: String,
name: String
name: String,
publicKey: String? = nil,
secretKey: String? = nil
) {
self.id = id
self.project = project
self.repoName = repoName
self.name = name
self.publicKey = publicKey
self.secretKey = secretKey
self.extend = [:]
}
}
Expand All @@ -29,7 +35,9 @@ extension Application: JSONConvertible {
id: json.get("id"),
project: .identifier(json.get("project.id")),
repoName: json.get("repoName"),
name: json.get("name")
name: json.get("name"),
publicKey: json.get("publicKey"),
secretKey: json.get("secretKey")
)
cost = try json.get("cost")
}
Expand All @@ -40,7 +48,9 @@ extension Application: JSONConvertible {
try json.set("project.id", project.getIdentifier())
try json.set("repoName", repoName)
try json.set("name", name)
try json.set("cost", cost?.makeJSON())
try json.set("cost", cost)
try json.set("publicKey", publicKey)
try json.set("secretKey", secretKey)
return json
}
}
43 changes: 43 additions & 0 deletions Sources/CloudModels/Localization/Language.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
public final class Language: Extensible, Identifiable {
public var id: Identifier?
public var name: String
public var locale: String
public var direction: String
public var extend: [String: Any]

public init(
id: Identifier? = nil,
name: String,
locale: String,
direction: String
) {
self.id = id
self.name = name
self.locale = locale
self.direction = direction
self.extend = [:]
}
}

// MARK: JSON
import JSON

extension Language: JSONConvertible {
public convenience init(json: JSON) throws {
try self.init(
id: json.get("id"),
name: json.get("name"),
locale: json.get("locale"),
direction: json.get("direction")
)
}

public func makeJSON() throws -> JSON {
var json = JSON()
try json.set("id", id)
try json.set("name", name)
try json.set("locale", locale)
try json.set("direction", direction)
return json
}
}
38 changes: 38 additions & 0 deletions Sources/CloudModels/Localization/Localization.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
public final class Localization: Extensible, Identifiable {
public var id: Identifier?
public var application: ModelOrIdentifier<Application>
public var isProduction: Bool
public var extend: [String: Any]

public init(
id: Identifier? = nil,
application: ModelOrIdentifier<Application>,
isProduction: Bool
) {
self.id = id
self.application = application
self.isProduction = isProduction
self.extend = [:]
}
}

// MARK: JSON
import JSON

extension Localization: JSONConvertible {
public convenience init(json: JSON) throws {
try self.init(
id: json.get("id"),
application: ModelOrIdentifier(json: json.get("application")),
isProduction: json.get("isProduction")
)
}

public func makeJSON() throws -> JSON {
var json = JSON()
try json.set("id", id)
try json.set("application", application.makeJSON())
try json.set("isProduction", isProduction)
return json
}
}
49 changes: 49 additions & 0 deletions Sources/CloudModels/Localization/LocalizationCache.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
public final class LocalizationCache: Extensible, Identifiable {
public var id: Identifier?
public var localization: ModelOrIdentifier<Localization>
public var language: ModelOrIdentifier<Language>
public var version: Int
public var data: String
public var extend: [String: Any]

public init(
id: Identifier? = nil,
localization: ModelOrIdentifier<Localization>,
language: ModelOrIdentifier<Language>,
version: Int,
data: String
) {
self.id = id
self.localization = localization
self.language = language
self.version = version
self.data = data
self.extend = [:]
}
}

// MARK: JSON
import JSON

extension LocalizationCache: JSONConvertible {
public convenience init(json: JSON) throws {
try self.init(
id: json.get("id"),
localization: json.get("localization"),
language: json.get("language"),
version: json.get("version"),
data: json.get("data")
)
}

public func makeJSON() throws -> JSON {
var json = JSON()
try json.set("id", id)
try json.set("version", version)
try json.set("data", data)
try json.set("localization", localization)
try json.set("language", language)
return json
}
}

43 changes: 43 additions & 0 deletions Sources/CloudModels/Localization/LocalizationKey.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
public final class LocalizationKey: Extensible, Identifiable {
public var id: Identifier?
public var localization: ModelOrIdentifier<Localization>
public var key: String
public var type: String
public var extend: [String: Any]

public init(
id: Identifier? = nil,
localization: ModelOrIdentifier<Localization>,
key: String,
type: String
) {
self.id = id
self.localization = localization
self.key = key
self.type = type
self.extend = [:]
}
}

// MARK: JSON
import JSON

extension LocalizationKey: JSONConvertible {
public convenience init(json: JSON) throws {
try self.init(
id: json.get("id"),
localization: json.get("localization"),
key: json.get("key"),
type: json.get("type")
)
}

public func makeJSON() throws -> JSON {
var json = JSON()
try json.set("id", id)
try json.set("key", key)
try json.set("type", type)
try json.set("localization", localization)
return json
}
}
44 changes: 44 additions & 0 deletions Sources/CloudModels/Localization/LocalizationValue.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
public final class LocalizationValue: Extensible, Identifiable {
public var id: Identifier?
public var key: ModelOrIdentifier<LocalizationKey>
public var language: ModelOrIdentifier<Language>
public var string: String
public var extend: [String: Any]

public init(
id: Identifier? = nil,
key: ModelOrIdentifier<LocalizationKey>,
language: ModelOrIdentifier<Language>,
string: String
) {
self.id = id
self.key = key
self.language = language
self.string = string
self.extend = [:]
}
}

// MARK: JSON
import JSON

extension LocalizationValue: JSONConvertible {
public convenience init(json: JSON) throws {
try self.init(
id: json.get("id"),
key: json.get("key"),
language: json.get("language"),
string: json.get("string")
)
}

public func makeJSON() throws -> JSON {
var json = JSON()
try json.set("id", id)
try json.set("key", key)
try json.set("language", language)
try json.set("string", string)
return json
}
}