diff --git a/README.md b/README.md index 5b4b75c..354b98e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies: ```swift dependencies: [ - .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "12.1.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "13.0.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 74ef9fd..45e3769 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -21,7 +21,7 @@ open class Client { "x-sdk-name": "Swift", "x-sdk-platform": "server", "x-sdk-language": "swift", - "x-sdk-version": "12.1.0", + "x-sdk-version": "13.0.0", "x-appwrite-response-format": "1.8.0" ] @@ -415,7 +415,7 @@ open class Client { if let warning = response.headers["x-appwrite-warning"].first { warning.split(separator: ";").forEach { warning in - print("Warning: \(warning)") + fputs("Warning: \(warning)\n", stderr) } } diff --git a/Sources/AppwriteEnums/AttributeStatus.swift b/Sources/AppwriteEnums/AttributeStatus.swift new file mode 100644 index 0000000..4c6544d --- /dev/null +++ b/Sources/AppwriteEnums/AttributeStatus.swift @@ -0,0 +1,13 @@ +import Foundation + +public enum AttributeStatus: String, CustomStringConvertible { + case available = "available" + case processing = "processing" + case deleting = "deleting" + case stuck = "stuck" + case failed = "failed" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/ColumnStatus.swift b/Sources/AppwriteEnums/ColumnStatus.swift new file mode 100644 index 0000000..1422356 --- /dev/null +++ b/Sources/AppwriteEnums/ColumnStatus.swift @@ -0,0 +1,13 @@ +import Foundation + +public enum ColumnStatus: String, CustomStringConvertible { + case available = "available" + case processing = "processing" + case deleting = "deleting" + case stuck = "stuck" + case failed = "failed" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/DatabaseType.swift b/Sources/AppwriteEnums/DatabaseType.swift new file mode 100644 index 0000000..664ccb4 --- /dev/null +++ b/Sources/AppwriteEnums/DatabaseType.swift @@ -0,0 +1,10 @@ +import Foundation + +public enum DatabaseType: String, CustomStringConvertible { + case legacy = "legacy" + case tablesdb = "tablesdb" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/DeploymentStatus.swift b/Sources/AppwriteEnums/DeploymentStatus.swift new file mode 100644 index 0000000..8d82e47 --- /dev/null +++ b/Sources/AppwriteEnums/DeploymentStatus.swift @@ -0,0 +1,13 @@ +import Foundation + +public enum DeploymentStatus: String, CustomStringConvertible { + case waiting = "waiting" + case processing = "processing" + case building = "building" + case ready = "ready" + case failed = "failed" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/ExecutionStatus.swift b/Sources/AppwriteEnums/ExecutionStatus.swift new file mode 100644 index 0000000..2f167a9 --- /dev/null +++ b/Sources/AppwriteEnums/ExecutionStatus.swift @@ -0,0 +1,12 @@ +import Foundation + +public enum ExecutionStatus: String, CustomStringConvertible { + case waiting = "waiting" + case processing = "processing" + case completed = "completed" + case failed = "failed" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/ExecutionTrigger.swift b/Sources/AppwriteEnums/ExecutionTrigger.swift new file mode 100644 index 0000000..8aecde3 --- /dev/null +++ b/Sources/AppwriteEnums/ExecutionTrigger.swift @@ -0,0 +1,11 @@ +import Foundation + +public enum ExecutionTrigger: String, CustomStringConvertible { + case http = "http" + case schedule = "schedule" + case event = "event" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/HealthAntivirusStatus.swift b/Sources/AppwriteEnums/HealthAntivirusStatus.swift new file mode 100644 index 0000000..8b1a814 --- /dev/null +++ b/Sources/AppwriteEnums/HealthAntivirusStatus.swift @@ -0,0 +1,11 @@ +import Foundation + +public enum HealthAntivirusStatus: String, CustomStringConvertible { + case disabled = "disabled" + case offline = "offline" + case online = "online" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/HealthCheckStatus.swift b/Sources/AppwriteEnums/HealthCheckStatus.swift new file mode 100644 index 0000000..551d951 --- /dev/null +++ b/Sources/AppwriteEnums/HealthCheckStatus.swift @@ -0,0 +1,10 @@ +import Foundation + +public enum HealthCheckStatus: String, CustomStringConvertible { + case pass = "pass" + case fail = "fail" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/IndexStatus.swift b/Sources/AppwriteEnums/IndexStatus.swift new file mode 100644 index 0000000..cfeb3ff --- /dev/null +++ b/Sources/AppwriteEnums/IndexStatus.swift @@ -0,0 +1,13 @@ +import Foundation + +public enum IndexStatus: String, CustomStringConvertible { + case available = "available" + case processing = "processing" + case deleting = "deleting" + case stuck = "stuck" + case failed = "failed" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteEnums/MessageStatus.swift b/Sources/AppwriteEnums/MessageStatus.swift new file mode 100644 index 0000000..b53e600 --- /dev/null +++ b/Sources/AppwriteEnums/MessageStatus.swift @@ -0,0 +1,13 @@ +import Foundation + +public enum MessageStatus: String, CustomStringConvertible { + case draft = "draft" + case processing = "processing" + case scheduled = "scheduled" + case sent = "sent" + case failed = "failed" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteModels/AttributeBoolean.swift b/Sources/AppwriteModels/AttributeBoolean.swift index ffc9325..c728671 100644 --- a/Sources/AppwriteModels/AttributeBoolean.swift +++ b/Sources/AppwriteModels/AttributeBoolean.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeBoolean open class AttributeBoolean: Codable { @@ -23,7 +24,7 @@ open class AttributeBoolean: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -47,7 +48,7 @@ open class AttributeBoolean: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -71,7 +72,7 @@ open class AttributeBoolean: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -85,7 +86,7 @@ open class AttributeBoolean: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -98,7 +99,7 @@ open class AttributeBoolean: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -112,7 +113,7 @@ open class AttributeBoolean: Codable { return AttributeBoolean( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeDatetime.swift b/Sources/AppwriteModels/AttributeDatetime.swift index 1aca4c2..a21433b 100644 --- a/Sources/AppwriteModels/AttributeDatetime.swift +++ b/Sources/AppwriteModels/AttributeDatetime.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeDatetime open class AttributeDatetime: Codable { @@ -24,7 +25,7 @@ open class AttributeDatetime: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -51,7 +52,7 @@ open class AttributeDatetime: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -77,7 +78,7 @@ open class AttributeDatetime: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -92,7 +93,7 @@ open class AttributeDatetime: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -106,7 +107,7 @@ open class AttributeDatetime: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -121,7 +122,7 @@ open class AttributeDatetime: Codable { return AttributeDatetime( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeEmail.swift b/Sources/AppwriteModels/AttributeEmail.swift index 1b8bd3f..1815b3f 100644 --- a/Sources/AppwriteModels/AttributeEmail.swift +++ b/Sources/AppwriteModels/AttributeEmail.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeEmail open class AttributeEmail: Codable { @@ -24,7 +25,7 @@ open class AttributeEmail: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -51,7 +52,7 @@ open class AttributeEmail: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -77,7 +78,7 @@ open class AttributeEmail: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -92,7 +93,7 @@ open class AttributeEmail: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -106,7 +107,7 @@ open class AttributeEmail: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -121,7 +122,7 @@ open class AttributeEmail: Codable { return AttributeEmail( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeEnum.swift b/Sources/AppwriteModels/AttributeEnum.swift index 7de4bc0..139308b 100644 --- a/Sources/AppwriteModels/AttributeEnum.swift +++ b/Sources/AppwriteModels/AttributeEnum.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeEnum open class AttributeEnum: Codable { @@ -25,7 +26,7 @@ open class AttributeEnum: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -55,7 +56,7 @@ open class AttributeEnum: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -83,7 +84,7 @@ open class AttributeEnum: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -99,7 +100,7 @@ open class AttributeEnum: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -114,7 +115,7 @@ open class AttributeEnum: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -130,7 +131,7 @@ open class AttributeEnum: Codable { return AttributeEnum( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeFloat.swift b/Sources/AppwriteModels/AttributeFloat.swift index e57a8c1..3a41dff 100644 --- a/Sources/AppwriteModels/AttributeFloat.swift +++ b/Sources/AppwriteModels/AttributeFloat.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeFloat open class AttributeFloat: Codable { @@ -25,7 +26,7 @@ open class AttributeFloat: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -55,7 +56,7 @@ open class AttributeFloat: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -83,7 +84,7 @@ open class AttributeFloat: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -99,7 +100,7 @@ open class AttributeFloat: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -114,7 +115,7 @@ open class AttributeFloat: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -130,7 +131,7 @@ open class AttributeFloat: Codable { return AttributeFloat( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeInteger.swift b/Sources/AppwriteModels/AttributeInteger.swift index f3251b7..5d793e5 100644 --- a/Sources/AppwriteModels/AttributeInteger.swift +++ b/Sources/AppwriteModels/AttributeInteger.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeInteger open class AttributeInteger: Codable { @@ -25,7 +26,7 @@ open class AttributeInteger: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -55,7 +56,7 @@ open class AttributeInteger: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -83,7 +84,7 @@ open class AttributeInteger: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -99,7 +100,7 @@ open class AttributeInteger: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -114,7 +115,7 @@ open class AttributeInteger: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -130,7 +131,7 @@ open class AttributeInteger: Codable { return AttributeInteger( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeIp.swift b/Sources/AppwriteModels/AttributeIp.swift index b4f628d..4d27dce 100644 --- a/Sources/AppwriteModels/AttributeIp.swift +++ b/Sources/AppwriteModels/AttributeIp.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeIP open class AttributeIp: Codable { @@ -24,7 +25,7 @@ open class AttributeIp: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -51,7 +52,7 @@ open class AttributeIp: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -77,7 +78,7 @@ open class AttributeIp: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -92,7 +93,7 @@ open class AttributeIp: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -106,7 +107,7 @@ open class AttributeIp: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -121,7 +122,7 @@ open class AttributeIp: Codable { return AttributeIp( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeLine.swift b/Sources/AppwriteModels/AttributeLine.swift index 8457304..74302bb 100644 --- a/Sources/AppwriteModels/AttributeLine.swift +++ b/Sources/AppwriteModels/AttributeLine.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeLine open class AttributeLine: Codable { @@ -23,7 +24,7 @@ open class AttributeLine: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -47,7 +48,7 @@ open class AttributeLine: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -71,7 +72,7 @@ open class AttributeLine: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -85,7 +86,7 @@ open class AttributeLine: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -98,7 +99,7 @@ open class AttributeLine: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -112,7 +113,7 @@ open class AttributeLine: Codable { return AttributeLine( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributePoint.swift b/Sources/AppwriteModels/AttributePoint.swift index 7c5fc2b..93835e5 100644 --- a/Sources/AppwriteModels/AttributePoint.swift +++ b/Sources/AppwriteModels/AttributePoint.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributePoint open class AttributePoint: Codable { @@ -23,7 +24,7 @@ open class AttributePoint: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -47,7 +48,7 @@ open class AttributePoint: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -71,7 +72,7 @@ open class AttributePoint: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -85,7 +86,7 @@ open class AttributePoint: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -98,7 +99,7 @@ open class AttributePoint: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -112,7 +113,7 @@ open class AttributePoint: Codable { return AttributePoint( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributePolygon.swift b/Sources/AppwriteModels/AttributePolygon.swift index 14cb7fd..7e4e8ba 100644 --- a/Sources/AppwriteModels/AttributePolygon.swift +++ b/Sources/AppwriteModels/AttributePolygon.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributePolygon open class AttributePolygon: Codable { @@ -23,7 +24,7 @@ open class AttributePolygon: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -47,7 +48,7 @@ open class AttributePolygon: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -71,7 +72,7 @@ open class AttributePolygon: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -85,7 +86,7 @@ open class AttributePolygon: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -98,7 +99,7 @@ open class AttributePolygon: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -112,7 +113,7 @@ open class AttributePolygon: Codable { return AttributePolygon( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeRelationship.swift b/Sources/AppwriteModels/AttributeRelationship.swift index 6a973aa..7e74095 100644 --- a/Sources/AppwriteModels/AttributeRelationship.swift +++ b/Sources/AppwriteModels/AttributeRelationship.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeRelationship open class AttributeRelationship: Codable { @@ -28,7 +29,7 @@ open class AttributeRelationship: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -67,7 +68,7 @@ open class AttributeRelationship: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -101,7 +102,7 @@ open class AttributeRelationship: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -120,7 +121,7 @@ open class AttributeRelationship: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -138,7 +139,7 @@ open class AttributeRelationship: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -157,7 +158,7 @@ open class AttributeRelationship: Codable { return AttributeRelationship( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeString.swift b/Sources/AppwriteModels/AttributeString.swift index b9d352b..1289873 100644 --- a/Sources/AppwriteModels/AttributeString.swift +++ b/Sources/AppwriteModels/AttributeString.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeString open class AttributeString: Codable { @@ -25,7 +26,7 @@ open class AttributeString: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -55,7 +56,7 @@ open class AttributeString: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -83,7 +84,7 @@ open class AttributeString: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -99,7 +100,7 @@ open class AttributeString: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -114,7 +115,7 @@ open class AttributeString: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -130,7 +131,7 @@ open class AttributeString: Codable { return AttributeString( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/AttributeUrl.swift b/Sources/AppwriteModels/AttributeUrl.swift index b6a7a41..5996b4a 100644 --- a/Sources/AppwriteModels/AttributeUrl.swift +++ b/Sources/AppwriteModels/AttributeUrl.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// AttributeURL open class AttributeUrl: Codable { @@ -24,7 +25,7 @@ open class AttributeUrl: Codable { public let type: String /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.AttributeStatus /// Error message. Displays error generated on failure of creating or deleting an attribute. public let error: String @@ -51,7 +52,7 @@ open class AttributeUrl: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.AttributeStatus, error: String, `required`: Bool, array: Bool?, @@ -77,7 +78,7 @@ open class AttributeUrl: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.AttributeStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -92,7 +93,7 @@ open class AttributeUrl: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -106,7 +107,7 @@ open class AttributeUrl: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -121,7 +122,7 @@ open class AttributeUrl: Codable { return AttributeUrl( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: AttributeStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnBoolean.swift b/Sources/AppwriteModels/ColumnBoolean.swift index 8a73ca0..37a0601 100644 --- a/Sources/AppwriteModels/ColumnBoolean.swift +++ b/Sources/AppwriteModels/ColumnBoolean.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnBoolean open class ColumnBoolean: Codable { @@ -23,7 +24,7 @@ open class ColumnBoolean: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -47,7 +48,7 @@ open class ColumnBoolean: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -71,7 +72,7 @@ open class ColumnBoolean: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -85,7 +86,7 @@ open class ColumnBoolean: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -98,7 +99,7 @@ open class ColumnBoolean: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -112,7 +113,7 @@ open class ColumnBoolean: Codable { return ColumnBoolean( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnDatetime.swift b/Sources/AppwriteModels/ColumnDatetime.swift index 00cdc6d..8ef9867 100644 --- a/Sources/AppwriteModels/ColumnDatetime.swift +++ b/Sources/AppwriteModels/ColumnDatetime.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnDatetime open class ColumnDatetime: Codable { @@ -24,7 +25,7 @@ open class ColumnDatetime: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -51,7 +52,7 @@ open class ColumnDatetime: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -77,7 +78,7 @@ open class ColumnDatetime: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -92,7 +93,7 @@ open class ColumnDatetime: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -106,7 +107,7 @@ open class ColumnDatetime: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -121,7 +122,7 @@ open class ColumnDatetime: Codable { return ColumnDatetime( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnEmail.swift b/Sources/AppwriteModels/ColumnEmail.swift index 940062e..c6e52a4 100644 --- a/Sources/AppwriteModels/ColumnEmail.swift +++ b/Sources/AppwriteModels/ColumnEmail.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnEmail open class ColumnEmail: Codable { @@ -24,7 +25,7 @@ open class ColumnEmail: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -51,7 +52,7 @@ open class ColumnEmail: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -77,7 +78,7 @@ open class ColumnEmail: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -92,7 +93,7 @@ open class ColumnEmail: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -106,7 +107,7 @@ open class ColumnEmail: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -121,7 +122,7 @@ open class ColumnEmail: Codable { return ColumnEmail( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnEnum.swift b/Sources/AppwriteModels/ColumnEnum.swift index ef78f80..570dc87 100644 --- a/Sources/AppwriteModels/ColumnEnum.swift +++ b/Sources/AppwriteModels/ColumnEnum.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnEnum open class ColumnEnum: Codable { @@ -25,7 +26,7 @@ open class ColumnEnum: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -55,7 +56,7 @@ open class ColumnEnum: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -83,7 +84,7 @@ open class ColumnEnum: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -99,7 +100,7 @@ open class ColumnEnum: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -114,7 +115,7 @@ open class ColumnEnum: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -130,7 +131,7 @@ open class ColumnEnum: Codable { return ColumnEnum( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnFloat.swift b/Sources/AppwriteModels/ColumnFloat.swift index 6cdd019..23ed59e 100644 --- a/Sources/AppwriteModels/ColumnFloat.swift +++ b/Sources/AppwriteModels/ColumnFloat.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnFloat open class ColumnFloat: Codable { @@ -25,7 +26,7 @@ open class ColumnFloat: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -55,7 +56,7 @@ open class ColumnFloat: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -83,7 +84,7 @@ open class ColumnFloat: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -99,7 +100,7 @@ open class ColumnFloat: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -114,7 +115,7 @@ open class ColumnFloat: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -130,7 +131,7 @@ open class ColumnFloat: Codable { return ColumnFloat( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnInteger.swift b/Sources/AppwriteModels/ColumnInteger.swift index 4451550..8a43e93 100644 --- a/Sources/AppwriteModels/ColumnInteger.swift +++ b/Sources/AppwriteModels/ColumnInteger.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnInteger open class ColumnInteger: Codable { @@ -25,7 +26,7 @@ open class ColumnInteger: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -55,7 +56,7 @@ open class ColumnInteger: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -83,7 +84,7 @@ open class ColumnInteger: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -99,7 +100,7 @@ open class ColumnInteger: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -114,7 +115,7 @@ open class ColumnInteger: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -130,7 +131,7 @@ open class ColumnInteger: Codable { return ColumnInteger( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnIp.swift b/Sources/AppwriteModels/ColumnIp.swift index 43ddaee..a9dee8c 100644 --- a/Sources/AppwriteModels/ColumnIp.swift +++ b/Sources/AppwriteModels/ColumnIp.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnIP open class ColumnIp: Codable { @@ -24,7 +25,7 @@ open class ColumnIp: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -51,7 +52,7 @@ open class ColumnIp: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -77,7 +78,7 @@ open class ColumnIp: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -92,7 +93,7 @@ open class ColumnIp: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -106,7 +107,7 @@ open class ColumnIp: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -121,7 +122,7 @@ open class ColumnIp: Codable { return ColumnIp( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnLine.swift b/Sources/AppwriteModels/ColumnLine.swift index 09c0543..f375b35 100644 --- a/Sources/AppwriteModels/ColumnLine.swift +++ b/Sources/AppwriteModels/ColumnLine.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnLine open class ColumnLine: Codable { @@ -23,7 +24,7 @@ open class ColumnLine: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -47,7 +48,7 @@ open class ColumnLine: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -71,7 +72,7 @@ open class ColumnLine: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -85,7 +86,7 @@ open class ColumnLine: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -98,7 +99,7 @@ open class ColumnLine: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -112,7 +113,7 @@ open class ColumnLine: Codable { return ColumnLine( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnPoint.swift b/Sources/AppwriteModels/ColumnPoint.swift index 96b1f65..c3c13c4 100644 --- a/Sources/AppwriteModels/ColumnPoint.swift +++ b/Sources/AppwriteModels/ColumnPoint.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnPoint open class ColumnPoint: Codable { @@ -23,7 +24,7 @@ open class ColumnPoint: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -47,7 +48,7 @@ open class ColumnPoint: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -71,7 +72,7 @@ open class ColumnPoint: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -85,7 +86,7 @@ open class ColumnPoint: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -98,7 +99,7 @@ open class ColumnPoint: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -112,7 +113,7 @@ open class ColumnPoint: Codable { return ColumnPoint( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnPolygon.swift b/Sources/AppwriteModels/ColumnPolygon.swift index 0f64db7..d786d29 100644 --- a/Sources/AppwriteModels/ColumnPolygon.swift +++ b/Sources/AppwriteModels/ColumnPolygon.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnPolygon open class ColumnPolygon: Codable { @@ -23,7 +24,7 @@ open class ColumnPolygon: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -47,7 +48,7 @@ open class ColumnPolygon: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -71,7 +72,7 @@ open class ColumnPolygon: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -85,7 +86,7 @@ open class ColumnPolygon: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -98,7 +99,7 @@ open class ColumnPolygon: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -112,7 +113,7 @@ open class ColumnPolygon: Codable { return ColumnPolygon( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnRelationship.swift b/Sources/AppwriteModels/ColumnRelationship.swift index b4c388c..76076e0 100644 --- a/Sources/AppwriteModels/ColumnRelationship.swift +++ b/Sources/AppwriteModels/ColumnRelationship.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnRelationship open class ColumnRelationship: Codable { @@ -28,7 +29,7 @@ open class ColumnRelationship: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -67,7 +68,7 @@ open class ColumnRelationship: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -101,7 +102,7 @@ open class ColumnRelationship: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -120,7 +121,7 @@ open class ColumnRelationship: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -138,7 +139,7 @@ open class ColumnRelationship: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -157,7 +158,7 @@ open class ColumnRelationship: Codable { return ColumnRelationship( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnString.swift b/Sources/AppwriteModels/ColumnString.swift index 6dd146b..8cae67e 100644 --- a/Sources/AppwriteModels/ColumnString.swift +++ b/Sources/AppwriteModels/ColumnString.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnString open class ColumnString: Codable { @@ -25,7 +26,7 @@ open class ColumnString: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -55,7 +56,7 @@ open class ColumnString: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -83,7 +84,7 @@ open class ColumnString: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -99,7 +100,7 @@ open class ColumnString: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -114,7 +115,7 @@ open class ColumnString: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -130,7 +131,7 @@ open class ColumnString: Codable { return ColumnString( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/ColumnUrl.swift b/Sources/AppwriteModels/ColumnUrl.swift index 29ef440..ee54f27 100644 --- a/Sources/AppwriteModels/ColumnUrl.swift +++ b/Sources/AppwriteModels/ColumnUrl.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// ColumnURL open class ColumnUrl: Codable { @@ -24,7 +25,7 @@ open class ColumnUrl: Codable { public let type: String /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.ColumnStatus /// Error message. Displays error generated on failure of creating or deleting an column. public let error: String @@ -51,7 +52,7 @@ open class ColumnUrl: Codable { init( key: String, type: String, - status: String, + status: AppwriteEnums.ColumnStatus, error: String, `required`: Bool, array: Bool?, @@ -77,7 +78,7 @@ open class ColumnUrl: Codable { self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.ColumnStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.`required` = try container.decode(Bool.self, forKey: .`required`) self.array = try container.decodeIfPresent(Bool.self, forKey: .array) @@ -92,7 +93,7 @@ open class ColumnUrl: Codable { try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(`required`, forKey: .`required`) try container.encodeIfPresent(array, forKey: .array) @@ -106,7 +107,7 @@ open class ColumnUrl: Codable { return [ "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "required": `required` as Any, "array": array as Any, @@ -121,7 +122,7 @@ open class ColumnUrl: Codable { return ColumnUrl( key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: ColumnStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, required: map["required"] as! Bool, array: map["array"] as? Bool, diff --git a/Sources/AppwriteModels/Database.swift b/Sources/AppwriteModels/Database.swift index c3e5a10..d23aa8f 100644 --- a/Sources/AppwriteModels/Database.swift +++ b/Sources/AppwriteModels/Database.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// Database open class Database: Codable { @@ -29,7 +30,7 @@ open class Database: Codable { public let enabled: Bool /// Database type. - public let type: String + public let type: AppwriteEnums.DatabaseType init( @@ -38,7 +39,7 @@ open class Database: Codable { createdAt: String, updatedAt: String, enabled: Bool, - type: String + type: AppwriteEnums.DatabaseType ) { self.id = id self.name = name @@ -56,7 +57,7 @@ open class Database: Codable { self.createdAt = try container.decode(String.self, forKey: .createdAt) self.updatedAt = try container.decode(String.self, forKey: .updatedAt) self.enabled = try container.decode(Bool.self, forKey: .enabled) - self.type = try container.decode(String.self, forKey: .type) + self.type = AppwriteEnums.DatabaseType(rawValue: try container.decode(String.self, forKey: .type))! } public func encode(to encoder: Encoder) throws { @@ -67,7 +68,7 @@ open class Database: Codable { try container.encode(createdAt, forKey: .createdAt) try container.encode(updatedAt, forKey: .updatedAt) try container.encode(enabled, forKey: .enabled) - try container.encode(type, forKey: .type) + try container.encode(type.rawValue, forKey: .type) } public func toMap() -> [String: Any] { @@ -77,7 +78,7 @@ open class Database: Codable { "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "enabled": enabled as Any, - "type": type as Any + "type": type.rawValue as Any ] } @@ -88,7 +89,7 @@ open class Database: Codable { createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, enabled: map["enabled"] as! Bool, - type: map["type"] as! String + type: DatabaseType(rawValue: map["type"] as! String)! ) } } diff --git a/Sources/AppwriteModels/Deployment.swift b/Sources/AppwriteModels/Deployment.swift index 888239f..c6e22da 100644 --- a/Sources/AppwriteModels/Deployment.swift +++ b/Sources/AppwriteModels/Deployment.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// Deployment open class Deployment: Codable { @@ -77,7 +78,7 @@ open class Deployment: Codable { public let screenshotDark: String /// The deployment status. Possible values are "waiting", "processing", "building", "ready", and "failed". - public let status: String + public let status: AppwriteEnums.DeploymentStatus /// The build logs. public let buildLogs: String @@ -131,7 +132,7 @@ open class Deployment: Codable { activate: Bool, screenshotLight: String, screenshotDark: String, - status: String, + status: AppwriteEnums.DeploymentStatus, buildLogs: String, buildDuration: Int, providerRepositoryName: String, @@ -191,7 +192,7 @@ open class Deployment: Codable { self.activate = try container.decode(Bool.self, forKey: .activate) self.screenshotLight = try container.decode(String.self, forKey: .screenshotLight) self.screenshotDark = try container.decode(String.self, forKey: .screenshotDark) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.DeploymentStatus(rawValue: try container.decode(String.self, forKey: .status))! self.buildLogs = try container.decode(String.self, forKey: .buildLogs) self.buildDuration = try container.decode(Int.self, forKey: .buildDuration) self.providerRepositoryName = try container.decode(String.self, forKey: .providerRepositoryName) @@ -223,7 +224,7 @@ open class Deployment: Codable { try container.encode(activate, forKey: .activate) try container.encode(screenshotLight, forKey: .screenshotLight) try container.encode(screenshotDark, forKey: .screenshotDark) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(buildLogs, forKey: .buildLogs) try container.encode(buildDuration, forKey: .buildDuration) try container.encode(providerRepositoryName, forKey: .providerRepositoryName) @@ -254,7 +255,7 @@ open class Deployment: Codable { "activate": activate as Any, "screenshotLight": screenshotLight as Any, "screenshotDark": screenshotDark as Any, - "status": status as Any, + "status": status.rawValue as Any, "buildLogs": buildLogs as Any, "buildDuration": buildDuration as Any, "providerRepositoryName": providerRepositoryName as Any, @@ -286,7 +287,7 @@ open class Deployment: Codable { activate: map["activate"] as! Bool, screenshotLight: map["screenshotLight"] as! String, screenshotDark: map["screenshotDark"] as! String, - status: map["status"] as! String, + status: DeploymentStatus(rawValue: map["status"] as! String)!, buildLogs: map["buildLogs"] as! String, buildDuration: map["buildDuration"] as! Int, providerRepositoryName: map["providerRepositoryName"] as! String, diff --git a/Sources/AppwriteModels/Document.swift b/Sources/AppwriteModels/Document.swift index f076cc5..763db10 100644 --- a/Sources/AppwriteModels/Document.swift +++ b/Sources/AppwriteModels/Document.swift @@ -107,7 +107,7 @@ open class Document: Codable { createdAt: map["$createdAt"] as? String ?? "", updatedAt: map["$updatedAt"] as? String ?? "", permissions: map["$permissions"] as? [String] ?? [], - data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"] as? [String: Any] ?? map, options: [])) ) } } diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 069264b..47d7734 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// Execution open class Execution: Codable { @@ -44,10 +45,10 @@ open class Execution: Codable { public let deploymentId: String /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - public let trigger: String + public let trigger: AppwriteEnums.ExecutionTrigger /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - public let status: String + public let status: AppwriteEnums.ExecutionStatus /// HTTP request method type. public let requestMethod: String @@ -87,8 +88,8 @@ open class Execution: Codable { permissions: [String], functionId: String, deploymentId: String, - trigger: String, - status: String, + trigger: AppwriteEnums.ExecutionTrigger, + status: AppwriteEnums.ExecutionStatus, requestMethod: String, requestPath: String, requestHeaders: [Headers], @@ -129,8 +130,8 @@ open class Execution: Codable { self.permissions = try container.decode([String].self, forKey: .permissions) self.functionId = try container.decode(String.self, forKey: .functionId) self.deploymentId = try container.decode(String.self, forKey: .deploymentId) - self.trigger = try container.decode(String.self, forKey: .trigger) - self.status = try container.decode(String.self, forKey: .status) + self.trigger = AppwriteEnums.ExecutionTrigger(rawValue: try container.decode(String.self, forKey: .trigger))! + self.status = AppwriteEnums.ExecutionStatus(rawValue: try container.decode(String.self, forKey: .status))! self.requestMethod = try container.decode(String.self, forKey: .requestMethod) self.requestPath = try container.decode(String.self, forKey: .requestPath) self.requestHeaders = try container.decode([Headers].self, forKey: .requestHeaders) @@ -152,8 +153,8 @@ open class Execution: Codable { try container.encode(permissions, forKey: .permissions) try container.encode(functionId, forKey: .functionId) try container.encode(deploymentId, forKey: .deploymentId) - try container.encode(trigger, forKey: .trigger) - try container.encode(status, forKey: .status) + try container.encode(trigger.rawValue, forKey: .trigger) + try container.encode(status.rawValue, forKey: .status) try container.encode(requestMethod, forKey: .requestMethod) try container.encode(requestPath, forKey: .requestPath) try container.encode(requestHeaders, forKey: .requestHeaders) @@ -174,8 +175,8 @@ open class Execution: Codable { "$permissions": permissions as Any, "functionId": functionId as Any, "deploymentId": deploymentId as Any, - "trigger": trigger as Any, - "status": status as Any, + "trigger": trigger.rawValue as Any, + "status": status.rawValue as Any, "requestMethod": requestMethod as Any, "requestPath": requestPath as Any, "requestHeaders": requestHeaders.map { $0.toMap() } as Any, @@ -197,8 +198,8 @@ open class Execution: Codable { permissions: map["$permissions"] as! [String], functionId: map["functionId"] as! String, deploymentId: map["deploymentId"] as! String, - trigger: map["trigger"] as! String, - status: map["status"] as! String, + trigger: ExecutionTrigger(rawValue: map["trigger"] as! String)!, + status: ExecutionStatus(rawValue: map["status"] as! String)!, requestMethod: map["requestMethod"] as! String, requestPath: map["requestPath"] as! String, requestHeaders: (map["requestHeaders"] as! [[String: Any]]).map { Headers.from(map: $0) }, diff --git a/Sources/AppwriteModels/HealthAntivirus.swift b/Sources/AppwriteModels/HealthAntivirus.swift index 745f2f8..e92d47a 100644 --- a/Sources/AppwriteModels/HealthAntivirus.swift +++ b/Sources/AppwriteModels/HealthAntivirus.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// Health Antivirus open class HealthAntivirus: Codable { @@ -13,12 +14,12 @@ open class HealthAntivirus: Codable { public let version: String /// Antivirus status. Possible values are: `disabled`, `offline`, `online` - public let status: String + public let status: AppwriteEnums.HealthAntivirusStatus init( version: String, - status: String + status: AppwriteEnums.HealthAntivirusStatus ) { self.version = version self.status = status @@ -28,27 +29,27 @@ open class HealthAntivirus: Codable { let container = try decoder.container(keyedBy: CodingKeys.self) self.version = try container.decode(String.self, forKey: .version) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.HealthAntivirusStatus(rawValue: try container.decode(String.self, forKey: .status))! } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(version, forKey: .version) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) } public func toMap() -> [String: Any] { return [ "version": version as Any, - "status": status as Any + "status": status.rawValue as Any ] } public static func from(map: [String: Any] ) -> HealthAntivirus { return HealthAntivirus( version: map["version"] as! String, - status: map["status"] as! String + status: HealthAntivirusStatus(rawValue: map["status"] as! String)! ) } } diff --git a/Sources/AppwriteModels/HealthStatus.swift b/Sources/AppwriteModels/HealthStatus.swift index 5a5f4b0..c7bdebd 100644 --- a/Sources/AppwriteModels/HealthStatus.swift +++ b/Sources/AppwriteModels/HealthStatus.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// Health Status open class HealthStatus: Codable { @@ -17,13 +18,13 @@ open class HealthStatus: Codable { public let ping: Int /// Service status. Possible values are: `pass`, `fail` - public let status: String + public let status: AppwriteEnums.HealthCheckStatus init( name: String, ping: Int, - status: String + status: AppwriteEnums.HealthCheckStatus ) { self.name = name self.ping = ping @@ -35,7 +36,7 @@ open class HealthStatus: Codable { self.name = try container.decode(String.self, forKey: .name) self.ping = try container.decode(Int.self, forKey: .ping) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.HealthCheckStatus(rawValue: try container.decode(String.self, forKey: .status))! } public func encode(to encoder: Encoder) throws { @@ -43,14 +44,14 @@ open class HealthStatus: Codable { try container.encode(name, forKey: .name) try container.encode(ping, forKey: .ping) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) } public func toMap() -> [String: Any] { return [ "name": name as Any, "ping": ping as Any, - "status": status as Any + "status": status.rawValue as Any ] } @@ -58,7 +59,7 @@ open class HealthStatus: Codable { return HealthStatus( name: map["name"] as! String, ping: map["ping"] as! Int, - status: map["status"] as! String + status: HealthCheckStatus(rawValue: map["status"] as! String)! ) } } diff --git a/Sources/AppwriteModels/Index.swift b/Sources/AppwriteModels/Index.swift index a2cc1c8..475b3c4 100644 --- a/Sources/AppwriteModels/Index.swift +++ b/Sources/AppwriteModels/Index.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// Index open class Index: Codable { @@ -33,7 +34,7 @@ open class Index: Codable { public let type: String /// Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - public let status: String + public let status: AppwriteEnums.IndexStatus /// Error message. Displays error generated on failure of creating or deleting an index. public let error: String @@ -54,7 +55,7 @@ open class Index: Codable { updatedAt: String, key: String, type: String, - status: String, + status: AppwriteEnums.IndexStatus, error: String, attributes: [String], lengths: [Int], @@ -80,7 +81,7 @@ open class Index: Codable { self.updatedAt = try container.decode(String.self, forKey: .updatedAt) self.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.IndexStatus(rawValue: try container.decode(String.self, forKey: .status))! self.error = try container.decode(String.self, forKey: .error) self.attributes = try container.decode([String].self, forKey: .attributes) self.lengths = try container.decode([Int].self, forKey: .lengths) @@ -95,7 +96,7 @@ open class Index: Codable { try container.encode(updatedAt, forKey: .updatedAt) try container.encode(key, forKey: .key) try container.encode(type, forKey: .type) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) try container.encode(error, forKey: .error) try container.encode(attributes, forKey: .attributes) try container.encode(lengths, forKey: .lengths) @@ -109,7 +110,7 @@ open class Index: Codable { "$updatedAt": updatedAt as Any, "key": key as Any, "type": type as Any, - "status": status as Any, + "status": status.rawValue as Any, "error": error as Any, "attributes": attributes as Any, "lengths": lengths as Any, @@ -124,7 +125,7 @@ open class Index: Codable { updatedAt: map["$updatedAt"] as! String, key: map["key"] as! String, type: map["type"] as! String, - status: map["status"] as! String, + status: IndexStatus(rawValue: map["status"] as! String)!, error: map["error"] as! String, attributes: map["attributes"] as! [String], lengths: map["lengths"] as! [Int], diff --git a/Sources/AppwriteModels/Message.swift b/Sources/AppwriteModels/Message.swift index 442d7c8..c358c50 100644 --- a/Sources/AppwriteModels/Message.swift +++ b/Sources/AppwriteModels/Message.swift @@ -1,5 +1,6 @@ import Foundation import JSONCodable +import AppwriteEnums /// Message open class Message: Codable { @@ -57,7 +58,7 @@ open class Message: Codable { public let data: [String: AnyCodable] /// Status of delivery. - public let status: String + public let status: AppwriteEnums.MessageStatus init( @@ -73,7 +74,7 @@ open class Message: Codable { deliveryErrors: [String]?, deliveredTotal: Int, data: [String: AnyCodable], - status: String + status: AppwriteEnums.MessageStatus ) { self.id = id self.createdAt = createdAt @@ -105,7 +106,7 @@ open class Message: Codable { self.deliveryErrors = try container.decodeIfPresent([String].self, forKey: .deliveryErrors) self.deliveredTotal = try container.decode(Int.self, forKey: .deliveredTotal) self.data = try container.decode([String: AnyCodable].self, forKey: .data) - self.status = try container.decode(String.self, forKey: .status) + self.status = AppwriteEnums.MessageStatus(rawValue: try container.decode(String.self, forKey: .status))! } public func encode(to encoder: Encoder) throws { @@ -123,7 +124,7 @@ open class Message: Codable { try container.encodeIfPresent(deliveryErrors, forKey: .deliveryErrors) try container.encode(deliveredTotal, forKey: .deliveredTotal) try container.encode(data, forKey: .data) - try container.encode(status, forKey: .status) + try container.encode(status.rawValue, forKey: .status) } public func toMap() -> [String: Any] { @@ -140,7 +141,7 @@ open class Message: Codable { "deliveryErrors": deliveryErrors as Any, "deliveredTotal": deliveredTotal as Any, "data": data as Any, - "status": status as Any + "status": status.rawValue as Any ] } @@ -158,7 +159,7 @@ open class Message: Codable { deliveryErrors: map["deliveryErrors"] as? [String], deliveredTotal: map["deliveredTotal"] as! Int, data: map["data"] as! [String: AnyCodable], - status: map["status"] as! String + status: MessageStatus(rawValue: map["status"] as! String)! ) } } diff --git a/Sources/AppwriteModels/Preferences.swift b/Sources/AppwriteModels/Preferences.swift index 41f94e6..aff6dfe 100644 --- a/Sources/AppwriteModels/Preferences.swift +++ b/Sources/AppwriteModels/Preferences.swift @@ -37,7 +37,7 @@ open class Preferences: Codable { public static func from(map: [String: Any] ) -> Preferences { return Preferences( - data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"] as? [String: Any] ?? map, options: [])) ) } } diff --git a/Sources/AppwriteModels/Row.swift b/Sources/AppwriteModels/Row.swift index 6e94a9e..5c6a215 100644 --- a/Sources/AppwriteModels/Row.swift +++ b/Sources/AppwriteModels/Row.swift @@ -107,7 +107,7 @@ open class Row: Codable { createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, permissions: map["$permissions"] as! [String], - data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"] as? [String: Any] ?? map, options: [])) ) } }