From 5d226b064a677cacfdeccc61c69de3b34aae6c2e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 4 Jun 2025 05:45:27 +0000 Subject: [PATCH 1/4] fix: enhance model property handling for array types --- README.md | 2 +- Sources/Appwrite/Client.swift | 2 +- Sources/Appwrite/Services/Databases.swift | 112 ++++++++++++++++++ Sources/Appwrite/Services/Tokens.swift | 2 +- Sources/AppwriteModels/AlgoArgon2.swift | 8 +- Sources/AppwriteModels/AlgoBcrypt.swift | 2 +- Sources/AppwriteModels/AlgoMd5.swift | 2 +- Sources/AppwriteModels/AlgoPhpass.swift | 2 +- Sources/AppwriteModels/AlgoScrypt.swift | 10 +- .../AppwriteModels/AlgoScryptModified.swift | 8 +- Sources/AppwriteModels/AlgoSha.swift | 2 +- Sources/AppwriteModels/AttributeBoolean.swift | 14 +-- .../AppwriteModels/AttributeDatetime.swift | 16 +-- Sources/AppwriteModels/AttributeEmail.swift | 16 +-- Sources/AppwriteModels/AttributeEnum.swift | 18 +-- Sources/AppwriteModels/AttributeFloat.swift | 14 +-- Sources/AppwriteModels/AttributeInteger.swift | 14 +-- Sources/AppwriteModels/AttributeIp.swift | 16 +-- Sources/AppwriteModels/AttributeList.swift | 4 +- .../AttributeRelationship.swift | 26 ++-- Sources/AppwriteModels/AttributeString.swift | 32 +++-- Sources/AppwriteModels/AttributeUrl.swift | 16 +-- Sources/AppwriteModels/Bucket.swift | 24 ++-- Sources/AppwriteModels/BucketList.swift | 4 +- Sources/AppwriteModels/Collection.swift | 20 ++-- Sources/AppwriteModels/CollectionList.swift | 4 +- Sources/AppwriteModels/Continent.swift | 4 +- Sources/AppwriteModels/ContinentList.swift | 4 +- Sources/AppwriteModels/Country.swift | 4 +- Sources/AppwriteModels/CountryList.swift | 4 +- Sources/AppwriteModels/Currency.swift | 14 +-- Sources/AppwriteModels/CurrencyList.swift | 4 +- Sources/AppwriteModels/Database.swift | 10 +- Sources/AppwriteModels/DatabaseList.swift | 4 +- Sources/AppwriteModels/Deployment.swift | 54 ++++----- Sources/AppwriteModels/DeploymentList.swift | 4 +- Sources/AppwriteModels/Document.swift | 14 +-- Sources/AppwriteModels/DocumentList.swift | 4 +- Sources/AppwriteModels/Execution.swift | 32 ++--- Sources/AppwriteModels/ExecutionList.swift | 4 +- Sources/AppwriteModels/File.swift | 22 ++-- Sources/AppwriteModels/FileList.swift | 4 +- Sources/AppwriteModels/Framework.swift | 10 +- Sources/AppwriteModels/FrameworkAdapter.swift | 10 +- Sources/AppwriteModels/FrameworkList.swift | 4 +- Sources/AppwriteModels/Function.swift | 56 ++++----- Sources/AppwriteModels/FunctionList.swift | 4 +- Sources/AppwriteModels/Headers.swift | 4 +- Sources/AppwriteModels/HealthAntivirus.swift | 4 +- .../AppwriteModels/HealthCertificate.swift | 12 +- Sources/AppwriteModels/HealthQueue.swift | 2 +- Sources/AppwriteModels/HealthStatus.swift | 6 +- Sources/AppwriteModels/HealthTime.swift | 6 +- Sources/AppwriteModels/Identity.swift | 20 ++-- Sources/AppwriteModels/IdentityList.swift | 4 +- Sources/AppwriteModels/Index.swift | 16 +-- Sources/AppwriteModels/IndexList.swift | 4 +- Sources/AppwriteModels/Jwt.swift | 2 +- Sources/AppwriteModels/Language.swift | 6 +- Sources/AppwriteModels/LanguageList.swift | 4 +- Sources/AppwriteModels/Locale.swift | 14 +-- Sources/AppwriteModels/LocaleCode.swift | 4 +- Sources/AppwriteModels/LocaleCodeList.swift | 4 +- Sources/AppwriteModels/Log.swift | 42 +++---- Sources/AppwriteModels/LogList.swift | 4 +- Sources/AppwriteModels/Membership.swift | 26 ++-- Sources/AppwriteModels/MembershipList.swift | 4 +- Sources/AppwriteModels/Message.swift | 20 ++-- Sources/AppwriteModels/MessageList.swift | 4 +- Sources/AppwriteModels/MfaChallenge.swift | 8 +- Sources/AppwriteModels/MfaFactors.swift | 8 +- Sources/AppwriteModels/MfaRecoveryCodes.swift | 2 +- Sources/AppwriteModels/MfaType.swift | 4 +- Sources/AppwriteModels/Phone.swift | 6 +- Sources/AppwriteModels/PhoneList.swift | 4 +- Sources/AppwriteModels/Preferences.swift | 2 +- Sources/AppwriteModels/Provider.swift | 16 +-- Sources/AppwriteModels/ProviderList.swift | 4 +- Sources/AppwriteModels/ResourceToken.swift | 14 +-- .../AppwriteModels/ResourceTokenList.swift | 4 +- Sources/AppwriteModels/Runtime.swift | 16 +-- Sources/AppwriteModels/RuntimeList.swift | 4 +- Sources/AppwriteModels/Session.swift | 58 ++++----- Sources/AppwriteModels/SessionList.swift | 4 +- Sources/AppwriteModels/Site.swift | 58 ++++----- Sources/AppwriteModels/SiteList.swift | 4 +- Sources/AppwriteModels/Specification.swift | 8 +- .../AppwriteModels/SpecificationList.swift | 4 +- Sources/AppwriteModels/Subscriber.swift | 18 +-- Sources/AppwriteModels/SubscriberList.swift | 4 +- Sources/AppwriteModels/Target.swift | 16 +-- Sources/AppwriteModels/TargetList.swift | 4 +- Sources/AppwriteModels/Team.swift | 12 +- Sources/AppwriteModels/TeamList.swift | 4 +- Sources/AppwriteModels/Token.swift | 12 +- Sources/AppwriteModels/Topic.swift | 16 +-- Sources/AppwriteModels/TopicList.swift | 4 +- Sources/AppwriteModels/User.swift | 32 ++--- Sources/AppwriteModels/UserList.swift | 4 +- Sources/AppwriteModels/Variable.swift | 16 +-- Sources/AppwriteModels/VariableList.swift | 4 +- docs/examples/databases/upsert-document.md | 17 +++ 102 files changed, 701 insertions(+), 562 deletions(-) create mode 100644 docs/examples/databases/upsert-document.md diff --git a/README.md b/README.md index 417f505..ee38ac2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 3829171..bc05149 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -257,7 +257,7 @@ open class Client { return output.addingPercentEncoding( withAllowedCharacters: .urlHostAllowed - ) ?? "" + )?.replacingOccurrences(of: "+", with: "%2B") ?? "" // since urlHostAllowed doesn't include + } /// diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index eb40d2a..aae760f 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -1656,6 +1656,10 @@ open class Databases: Service { } /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// /// Create new Documents. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1699,6 +1703,10 @@ open class Databases: Service { } /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// /// Create new Documents. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1724,6 +1732,10 @@ open class Databases: Service { } /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// /// Create or update Documents. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1768,6 +1780,10 @@ open class Databases: Service { } /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// /// Create or update Documents. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1866,6 +1882,10 @@ open class Databases: Service { } /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// /// Bulk delete documents using queries, if no queries are passed then all /// documents are deleted. /// @@ -1907,6 +1927,10 @@ open class Databases: Service { } /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// /// Bulk delete documents using queries, if no queries are passed then all /// documents are deleted. /// @@ -1997,6 +2021,94 @@ open class Databases: Service { ) } + /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// + /// Create or update a Document. Before using this route, you should create a + /// new collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + /// API or directly from your database console. + /// + /// @param String databaseId + /// @param String collectionId + /// @param String documentId + /// @param Any data + /// @param [String] permissions + /// @throws Exception + /// @return array + /// + open func upsertDocument( + databaseId: String, + collectionId: String, + documentId: String, + data: Any, + permissions: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Document { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + .replacingOccurrences(of: "{documentId}", with: documentId) + + let apiParams: [String: Any?] = [ + "data": data, + "permissions": permissions + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Document = { response in + return AppwriteModels.Document.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// + /// Create or update a Document. Before using this route, you should create a + /// new collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + /// API or directly from your database console. + /// + /// @param String databaseId + /// @param String collectionId + /// @param String documentId + /// @param Any data + /// @param [String] permissions + /// @throws Exception + /// @return array + /// + open func upsertDocument( + databaseId: String, + collectionId: String, + documentId: String, + data: Any, + permissions: [String]? = nil + ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { + return try await upsertDocument( + databaseId: databaseId, + collectionId: collectionId, + documentId: documentId, + data: data, + permissions: permissions, + nestedType: [String: AnyCodable].self + ) + } + /// /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. diff --git a/Sources/Appwrite/Services/Tokens.swift b/Sources/Appwrite/Services/Tokens.swift index 223a2a5..b579e0f 100644 --- a/Sources/Appwrite/Services/Tokens.swift +++ b/Sources/Appwrite/Services/Tokens.swift @@ -48,7 +48,7 @@ open class Tokens: Service { /// /// Create a new token. A token is linked to a file. Token can be passed as a - /// header or request get parameter. + /// request URL search parameter. /// /// @param String bucketId /// @param String fileId diff --git a/Sources/AppwriteModels/AlgoArgon2.swift b/Sources/AppwriteModels/AlgoArgon2.swift index fd88955..5411998 100644 --- a/Sources/AppwriteModels/AlgoArgon2.swift +++ b/Sources/AppwriteModels/AlgoArgon2.swift @@ -65,10 +65,10 @@ open class AlgoArgon2: Codable { public static func from(map: [String: Any] ) -> AlgoArgon2 { return AlgoArgon2( - type: map["type"] as! String, - memoryCost: map["memoryCost"] as! Int, - timeCost: map["timeCost"] as! Int, - threads: map["threads"] as! Int + type: map["type"] as? String ?? "", + memoryCost: map["memoryCost"] as? Int ?? 0, + timeCost: map["timeCost"] as? Int ?? 0, + threads: map["threads"] as? Int ?? 0 ) } } diff --git a/Sources/AppwriteModels/AlgoBcrypt.swift b/Sources/AppwriteModels/AlgoBcrypt.swift index b34095d..3bd7061 100644 --- a/Sources/AppwriteModels/AlgoBcrypt.swift +++ b/Sources/AppwriteModels/AlgoBcrypt.swift @@ -38,7 +38,7 @@ open class AlgoBcrypt: Codable { public static func from(map: [String: Any] ) -> AlgoBcrypt { return AlgoBcrypt( - type: map["type"] as! String + type: map["type"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/AlgoMd5.swift b/Sources/AppwriteModels/AlgoMd5.swift index 72fbb8d..2d8b6f5 100644 --- a/Sources/AppwriteModels/AlgoMd5.swift +++ b/Sources/AppwriteModels/AlgoMd5.swift @@ -38,7 +38,7 @@ open class AlgoMd5: Codable { public static func from(map: [String: Any] ) -> AlgoMd5 { return AlgoMd5( - type: map["type"] as! String + type: map["type"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/AlgoPhpass.swift b/Sources/AppwriteModels/AlgoPhpass.swift index 7bd0c99..20d70c1 100644 --- a/Sources/AppwriteModels/AlgoPhpass.swift +++ b/Sources/AppwriteModels/AlgoPhpass.swift @@ -38,7 +38,7 @@ open class AlgoPhpass: Codable { public static func from(map: [String: Any] ) -> AlgoPhpass { return AlgoPhpass( - type: map["type"] as! String + type: map["type"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/AlgoScrypt.swift b/Sources/AppwriteModels/AlgoScrypt.swift index 03ce541..21500cb 100644 --- a/Sources/AppwriteModels/AlgoScrypt.swift +++ b/Sources/AppwriteModels/AlgoScrypt.swift @@ -74,11 +74,11 @@ open class AlgoScrypt: Codable { public static func from(map: [String: Any] ) -> AlgoScrypt { return AlgoScrypt( - type: map["type"] as! String, - costCpu: map["costCpu"] as! Int, - costMemory: map["costMemory"] as! Int, - costParallel: map["costParallel"] as! Int, - length: map["length"] as! Int + type: map["type"] as? String ?? "", + costCpu: map["costCpu"] as? Int ?? 0, + costMemory: map["costMemory"] as? Int ?? 0, + costParallel: map["costParallel"] as? Int ?? 0, + length: map["length"] as? Int ?? 0 ) } } diff --git a/Sources/AppwriteModels/AlgoScryptModified.swift b/Sources/AppwriteModels/AlgoScryptModified.swift index 0b2fa4e..bede143 100644 --- a/Sources/AppwriteModels/AlgoScryptModified.swift +++ b/Sources/AppwriteModels/AlgoScryptModified.swift @@ -65,10 +65,10 @@ open class AlgoScryptModified: Codable { public static func from(map: [String: Any] ) -> AlgoScryptModified { return AlgoScryptModified( - type: map["type"] as! String, - salt: map["salt"] as! String, - saltSeparator: map["saltSeparator"] as! String, - signerKey: map["signerKey"] as! String + type: map["type"] as? String ?? "", + salt: map["salt"] as? String ?? "", + saltSeparator: map["saltSeparator"] as? String ?? "", + signerKey: map["signerKey"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/AlgoSha.swift b/Sources/AppwriteModels/AlgoSha.swift index ffc0e05..6a3be42 100644 --- a/Sources/AppwriteModels/AlgoSha.swift +++ b/Sources/AppwriteModels/AlgoSha.swift @@ -38,7 +38,7 @@ open class AlgoSha: Codable { public static func from(map: [String: Any] ) -> AlgoSha { return AlgoSha( - type: map["type"] as! String + type: map["type"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/AttributeBoolean.swift b/Sources/AppwriteModels/AttributeBoolean.swift index 31522c2..8d09404 100644 --- a/Sources/AppwriteModels/AttributeBoolean.swift +++ b/Sources/AppwriteModels/AttributeBoolean.swift @@ -110,14 +110,14 @@ open class AttributeBoolean: Codable { public static func from(map: [String: Any] ) -> AttributeBoolean { return AttributeBoolean( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", `default`: map["default"] as? Bool ) } diff --git a/Sources/AppwriteModels/AttributeDatetime.swift b/Sources/AppwriteModels/AttributeDatetime.swift index ac80231..b664628 100644 --- a/Sources/AppwriteModels/AttributeDatetime.swift +++ b/Sources/AppwriteModels/AttributeDatetime.swift @@ -119,15 +119,15 @@ open class AttributeDatetime: Codable { public static func from(map: [String: Any] ) -> AttributeDatetime { return AttributeDatetime( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - format: map["format"] as! String, + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + format: map["format"] as? String ?? "", `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/AttributeEmail.swift b/Sources/AppwriteModels/AttributeEmail.swift index 8e57b2c..8e2298a 100644 --- a/Sources/AppwriteModels/AttributeEmail.swift +++ b/Sources/AppwriteModels/AttributeEmail.swift @@ -119,15 +119,15 @@ open class AttributeEmail: Codable { public static func from(map: [String: Any] ) -> AttributeEmail { return AttributeEmail( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - format: map["format"] as! String, + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + format: map["format"] as? String ?? "", `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/AttributeEnum.swift b/Sources/AppwriteModels/AttributeEnum.swift index e232869..e2367ba 100644 --- a/Sources/AppwriteModels/AttributeEnum.swift +++ b/Sources/AppwriteModels/AttributeEnum.swift @@ -128,16 +128,16 @@ open class AttributeEnum: Codable { public static func from(map: [String: Any] ) -> AttributeEnum { return AttributeEnum( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - elements: map["elements"] as! [String], - format: map["format"] as! String, + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + elements: map["elements"] as? [String] ?? [], + format: map["format"] as? String ?? "", `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/AttributeFloat.swift b/Sources/AppwriteModels/AttributeFloat.swift index 676f317..fbcbdb3 100644 --- a/Sources/AppwriteModels/AttributeFloat.swift +++ b/Sources/AppwriteModels/AttributeFloat.swift @@ -128,14 +128,14 @@ open class AttributeFloat: Codable { public static func from(map: [String: Any] ) -> AttributeFloat { return AttributeFloat( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", min: map["min"] as? Double, max: map["max"] as? Double, `default`: map["default"] as? Double diff --git a/Sources/AppwriteModels/AttributeInteger.swift b/Sources/AppwriteModels/AttributeInteger.swift index 06d3a69..fd8ff33 100644 --- a/Sources/AppwriteModels/AttributeInteger.swift +++ b/Sources/AppwriteModels/AttributeInteger.swift @@ -128,14 +128,14 @@ open class AttributeInteger: Codable { public static func from(map: [String: Any] ) -> AttributeInteger { return AttributeInteger( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", min: map["min"] as? Int, max: map["max"] as? Int, `default`: map["default"] as? Int diff --git a/Sources/AppwriteModels/AttributeIp.swift b/Sources/AppwriteModels/AttributeIp.swift index 7904155..4c96f72 100644 --- a/Sources/AppwriteModels/AttributeIp.swift +++ b/Sources/AppwriteModels/AttributeIp.swift @@ -119,15 +119,15 @@ open class AttributeIp: Codable { public static func from(map: [String: Any] ) -> AttributeIp { return AttributeIp( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - format: map["format"] as! String, + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + format: map["format"] as? String ?? "", `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/AttributeList.swift b/Sources/AppwriteModels/AttributeList.swift index 2116477..fa252fa 100644 --- a/Sources/AppwriteModels/AttributeList.swift +++ b/Sources/AppwriteModels/AttributeList.swift @@ -47,8 +47,8 @@ open class AttributeList: Codable { public static func from(map: [String: Any] ) -> AttributeList { return AttributeList( - total: map["total"] as! Int, - attributes: map["attributes"] as! [AnyCodable] + total: map["total"] as? Int ?? 0, + attributes: (map["attributes"] as? [Any] ?? []).map { AnyCodable($0) } ) } } diff --git a/Sources/AppwriteModels/AttributeRelationship.swift b/Sources/AppwriteModels/AttributeRelationship.swift index a1f8cd7..73c1cb1 100644 --- a/Sources/AppwriteModels/AttributeRelationship.swift +++ b/Sources/AppwriteModels/AttributeRelationship.swift @@ -155,20 +155,20 @@ open class AttributeRelationship: Codable { public static func from(map: [String: Any] ) -> AttributeRelationship { return AttributeRelationship( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - relatedCollection: map["relatedCollection"] as! String, - relationType: map["relationType"] as! String, - twoWay: map["twoWay"] as! Bool, - twoWayKey: map["twoWayKey"] as! String, - onDelete: map["onDelete"] as! String, - side: map["side"] as! String + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + relatedCollection: map["relatedCollection"] as? String ?? "", + relationType: map["relationType"] as? String ?? "", + twoWay: map["twoWay"] as? Bool ?? false, + twoWayKey: map["twoWayKey"] as? String ?? "", + onDelete: map["onDelete"] as? String ?? "", + side: map["side"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/AttributeString.swift b/Sources/AppwriteModels/AttributeString.swift index 5aeead7..395c19b 100644 --- a/Sources/AppwriteModels/AttributeString.swift +++ b/Sources/AppwriteModels/AttributeString.swift @@ -15,6 +15,7 @@ open class AttributeString: Codable { case updatedAt = "$updatedAt" case size = "size" case `default` = "default" + case encrypt = "encrypt" } /// Attribute Key. @@ -47,6 +48,9 @@ open class AttributeString: Codable { /// Default value for attribute when not provided. Cannot be set when attribute is required. public let `default`: String? + /// Defines whether this attribute is encrypted or not. + public let encrypt: Bool? + init( key: String, @@ -58,7 +62,8 @@ open class AttributeString: Codable { createdAt: String, updatedAt: String, size: Int, - `default`: String? + `default`: String?, + encrypt: Bool? ) { self.key = key self.type = type @@ -70,6 +75,7 @@ open class AttributeString: Codable { self.updatedAt = updatedAt self.size = size self.`default` = `default` + self.encrypt = encrypt } public required init(from decoder: Decoder) throws { @@ -85,6 +91,7 @@ open class AttributeString: Codable { self.updatedAt = try container.decode(String.self, forKey: .updatedAt) self.size = try container.decode(Int.self, forKey: .size) self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + self.encrypt = try container.decodeIfPresent(Bool.self, forKey: .encrypt) } public func encode(to encoder: Encoder) throws { @@ -100,6 +107,7 @@ open class AttributeString: Codable { try container.encode(updatedAt, forKey: .updatedAt) try container.encode(size, forKey: .size) try container.encodeIfPresent(`default`, forKey: .`default`) + try container.encodeIfPresent(encrypt, forKey: .encrypt) } public func toMap() -> [String: Any] { @@ -113,22 +121,24 @@ open class AttributeString: Codable { "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "size": size as Any, - "`default`": `default` as Any + "`default`": `default` as Any, + "encrypt": encrypt as Any ] } public static func from(map: [String: Any] ) -> AttributeString { return AttributeString( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - size: map["size"] as! Int, - `default`: map["default"] as? String + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + size: map["size"] as? Int ?? 0, + `default`: map["default"] as? String, + encrypt: map["encrypt"] as? Bool ) } } diff --git a/Sources/AppwriteModels/AttributeUrl.swift b/Sources/AppwriteModels/AttributeUrl.swift index cfbeac5..7cd2900 100644 --- a/Sources/AppwriteModels/AttributeUrl.swift +++ b/Sources/AppwriteModels/AttributeUrl.swift @@ -119,15 +119,15 @@ open class AttributeUrl: Codable { public static func from(map: [String: Any] ) -> AttributeUrl { return AttributeUrl( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - `required`: map["required"] as! Bool, + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + `required`: map["required"] as? Bool ?? false, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - format: map["format"] as! String, + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + format: map["format"] as? String ?? "", `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/Bucket.swift b/Sources/AppwriteModels/Bucket.swift index be437f5..e33b59b 100644 --- a/Sources/AppwriteModels/Bucket.swift +++ b/Sources/AppwriteModels/Bucket.swift @@ -137,18 +137,18 @@ open class Bucket: Codable { public static func from(map: [String: Any] ) -> Bucket { return Bucket( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [String], - fileSecurity: map["fileSecurity"] as! Bool, - name: map["name"] as! String, - enabled: map["enabled"] as! Bool, - maximumFileSize: map["maximumFileSize"] as! Int, - allowedFileExtensions: map["allowedFileExtensions"] as! [String], - compression: map["compression"] as! String, - encryption: map["encryption"] as! Bool, - antivirus: map["antivirus"] as! Bool + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + permissions: map["$permissions"] as? [String] ?? [], + fileSecurity: map["fileSecurity"] as? Bool ?? false, + name: map["name"] as? String ?? "", + enabled: map["enabled"] as? Bool ?? false, + maximumFileSize: map["maximumFileSize"] as? Int ?? 0, + allowedFileExtensions: map["allowedFileExtensions"] as? [String] ?? [], + compression: map["compression"] as? String ?? "", + encryption: map["encryption"] as? Bool ?? false, + antivirus: map["antivirus"] as? Bool ?? false ) } } diff --git a/Sources/AppwriteModels/BucketList.swift b/Sources/AppwriteModels/BucketList.swift index 8fca4e4..c721674 100644 --- a/Sources/AppwriteModels/BucketList.swift +++ b/Sources/AppwriteModels/BucketList.swift @@ -47,8 +47,8 @@ open class BucketList: Codable { public static func from(map: [String: Any] ) -> BucketList { return BucketList( - total: map["total"] as! Int, - buckets: (map["buckets"] as! [[String: Any]]).map { Bucket.from(map: $0) } + total: map["total"] as? Int ?? 0, + buckets: (map["buckets"] as? [[String: Any]] ?? []).map { Bucket.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Collection.swift b/Sources/AppwriteModels/Collection.swift index 548af2f..2e8394c 100644 --- a/Sources/AppwriteModels/Collection.swift +++ b/Sources/AppwriteModels/Collection.swift @@ -119,16 +119,16 @@ open class Collection: Codable { public static func from(map: [String: Any] ) -> Collection { return Collection( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [String], - databaseId: map["databaseId"] as! String, - name: map["name"] as! String, - enabled: map["enabled"] as! Bool, - documentSecurity: map["documentSecurity"] as! Bool, - attributes: map["attributes"] as! [AnyCodable], - indexes: (map["indexes"] as! [[String: Any]]).map { Index.from(map: $0) } + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + permissions: map["$permissions"] as? [String] ?? [], + databaseId: map["databaseId"] as? String ?? "", + name: map["name"] as? String ?? "", + enabled: map["enabled"] as? Bool ?? false, + documentSecurity: map["documentSecurity"] as? Bool ?? false, + attributes: (map["attributes"] as? [Any] ?? []).map { AnyCodable($0) }, + indexes: (map["indexes"] as? [[String: Any]] ?? []).map { Index.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/CollectionList.swift b/Sources/AppwriteModels/CollectionList.swift index f5f383f..3c86ee8 100644 --- a/Sources/AppwriteModels/CollectionList.swift +++ b/Sources/AppwriteModels/CollectionList.swift @@ -47,8 +47,8 @@ open class CollectionList: Codable { public static func from(map: [String: Any] ) -> CollectionList { return CollectionList( - total: map["total"] as! Int, - collections: (map["collections"] as! [[String: Any]]).map { Collection.from(map: $0) } + total: map["total"] as? Int ?? 0, + collections: (map["collections"] as? [[String: Any]] ?? []).map { Collection.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Continent.swift b/Sources/AppwriteModels/Continent.swift index b8994d9..64836ae 100644 --- a/Sources/AppwriteModels/Continent.swift +++ b/Sources/AppwriteModels/Continent.swift @@ -47,8 +47,8 @@ open class Continent: Codable { public static func from(map: [String: Any] ) -> Continent { return Continent( - name: map["name"] as! String, - code: map["code"] as! String + name: map["name"] as? String ?? "", + code: map["code"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/ContinentList.swift b/Sources/AppwriteModels/ContinentList.swift index fa9a90f..a924595 100644 --- a/Sources/AppwriteModels/ContinentList.swift +++ b/Sources/AppwriteModels/ContinentList.swift @@ -47,8 +47,8 @@ open class ContinentList: Codable { public static func from(map: [String: Any] ) -> ContinentList { return ContinentList( - total: map["total"] as! Int, - continents: (map["continents"] as! [[String: Any]]).map { Continent.from(map: $0) } + total: map["total"] as? Int ?? 0, + continents: (map["continents"] as? [[String: Any]] ?? []).map { Continent.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Country.swift b/Sources/AppwriteModels/Country.swift index c24f7e9..353da83 100644 --- a/Sources/AppwriteModels/Country.swift +++ b/Sources/AppwriteModels/Country.swift @@ -47,8 +47,8 @@ open class Country: Codable { public static func from(map: [String: Any] ) -> Country { return Country( - name: map["name"] as! String, - code: map["code"] as! String + name: map["name"] as? String ?? "", + code: map["code"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/CountryList.swift b/Sources/AppwriteModels/CountryList.swift index 865cc19..c6526fa 100644 --- a/Sources/AppwriteModels/CountryList.swift +++ b/Sources/AppwriteModels/CountryList.swift @@ -47,8 +47,8 @@ open class CountryList: Codable { public static func from(map: [String: Any] ) -> CountryList { return CountryList( - total: map["total"] as! Int, - countries: (map["countries"] as! [[String: Any]]).map { Country.from(map: $0) } + total: map["total"] as? Int ?? 0, + countries: (map["countries"] as? [[String: Any]] ?? []).map { Country.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Currency.swift b/Sources/AppwriteModels/Currency.swift index 320337b..dc67525 100644 --- a/Sources/AppwriteModels/Currency.swift +++ b/Sources/AppwriteModels/Currency.swift @@ -92,13 +92,13 @@ open class Currency: Codable { public static func from(map: [String: Any] ) -> Currency { return Currency( - symbol: map["symbol"] as! String, - name: map["name"] as! String, - symbolNative: map["symbolNative"] as! String, - decimalDigits: map["decimalDigits"] as! Int, - rounding: map["rounding"] as! Double, - code: map["code"] as! String, - namePlural: map["namePlural"] as! String + symbol: map["symbol"] as? String ?? "", + name: map["name"] as? String ?? "", + symbolNative: map["symbolNative"] as? String ?? "", + decimalDigits: map["decimalDigits"] as? Int ?? 0, + rounding: map["rounding"] as? Double ?? 0.0, + code: map["code"] as? String ?? "", + namePlural: map["namePlural"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/CurrencyList.swift b/Sources/AppwriteModels/CurrencyList.swift index 1e0dff9..6c81124 100644 --- a/Sources/AppwriteModels/CurrencyList.swift +++ b/Sources/AppwriteModels/CurrencyList.swift @@ -47,8 +47,8 @@ open class CurrencyList: Codable { public static func from(map: [String: Any] ) -> CurrencyList { return CurrencyList( - total: map["total"] as! Int, - currencies: (map["currencies"] as! [[String: Any]]).map { Currency.from(map: $0) } + total: map["total"] as? Int ?? 0, + currencies: (map["currencies"] as? [[String: Any]] ?? []).map { Currency.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Database.swift b/Sources/AppwriteModels/Database.swift index c35c0b3..b987bef 100644 --- a/Sources/AppwriteModels/Database.swift +++ b/Sources/AppwriteModels/Database.swift @@ -74,11 +74,11 @@ open class Database: Codable { public static func from(map: [String: Any] ) -> Database { return Database( - id: map["$id"] as! String, - name: map["name"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - enabled: map["enabled"] as! Bool + id: map["$id"] as? String ?? "", + name: map["name"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + enabled: map["enabled"] as? Bool ?? false ) } } diff --git a/Sources/AppwriteModels/DatabaseList.swift b/Sources/AppwriteModels/DatabaseList.swift index 588cbaa..aa1d638 100644 --- a/Sources/AppwriteModels/DatabaseList.swift +++ b/Sources/AppwriteModels/DatabaseList.swift @@ -47,8 +47,8 @@ open class DatabaseList: Codable { public static func from(map: [String: Any] ) -> DatabaseList { return DatabaseList( - total: map["total"] as! Int, - databases: (map["databases"] as! [[String: Any]]).map { Database.from(map: $0) } + total: map["total"] as? Int ?? 0, + databases: (map["databases"] as? [[String: Any]] ?? []).map { Database.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Deployment.swift b/Sources/AppwriteModels/Deployment.swift index b2a183b..d41aa09 100644 --- a/Sources/AppwriteModels/Deployment.swift +++ b/Sources/AppwriteModels/Deployment.swift @@ -272,33 +272,33 @@ open class Deployment: Codable { public static func from(map: [String: Any] ) -> Deployment { return Deployment( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - type: map["type"] as! String, - resourceId: map["resourceId"] as! String, - resourceType: map["resourceType"] as! String, - entrypoint: map["entrypoint"] as! String, - sourceSize: map["sourceSize"] as! Int, - buildSize: map["buildSize"] as! Int, - totalSize: map["totalSize"] as! Int, - buildId: map["buildId"] as! String, - activate: map["activate"] as! Bool, - screenshotLight: map["screenshotLight"] as! String, - screenshotDark: map["screenshotDark"] as! String, - status: map["status"] as! String, - buildLogs: map["buildLogs"] as! String, - buildDuration: map["buildDuration"] as! Int, - providerRepositoryName: map["providerRepositoryName"] as! String, - providerRepositoryOwner: map["providerRepositoryOwner"] as! String, - providerRepositoryUrl: map["providerRepositoryUrl"] as! String, - providerBranch: map["providerBranch"] as! String, - providerCommitHash: map["providerCommitHash"] as! String, - providerCommitAuthorUrl: map["providerCommitAuthorUrl"] as! String, - providerCommitAuthor: map["providerCommitAuthor"] as! String, - providerCommitMessage: map["providerCommitMessage"] as! String, - providerCommitUrl: map["providerCommitUrl"] as! String, - providerBranchUrl: map["providerBranchUrl"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + type: map["type"] as? String ?? "", + resourceId: map["resourceId"] as? String ?? "", + resourceType: map["resourceType"] as? String ?? "", + entrypoint: map["entrypoint"] as? String ?? "", + sourceSize: map["sourceSize"] as? Int ?? 0, + buildSize: map["buildSize"] as? Int ?? 0, + totalSize: map["totalSize"] as? Int ?? 0, + buildId: map["buildId"] as? String ?? "", + activate: map["activate"] as? Bool ?? false, + screenshotLight: map["screenshotLight"] as? String ?? "", + screenshotDark: map["screenshotDark"] as? String ?? "", + status: map["status"] as? String ?? "", + buildLogs: map["buildLogs"] as? String ?? "", + buildDuration: map["buildDuration"] as? Int ?? 0, + providerRepositoryName: map["providerRepositoryName"] as? String ?? "", + providerRepositoryOwner: map["providerRepositoryOwner"] as? String ?? "", + providerRepositoryUrl: map["providerRepositoryUrl"] as? String ?? "", + providerBranch: map["providerBranch"] as? String ?? "", + providerCommitHash: map["providerCommitHash"] as? String ?? "", + providerCommitAuthorUrl: map["providerCommitAuthorUrl"] as? String ?? "", + providerCommitAuthor: map["providerCommitAuthor"] as? String ?? "", + providerCommitMessage: map["providerCommitMessage"] as? String ?? "", + providerCommitUrl: map["providerCommitUrl"] as? String ?? "", + providerBranchUrl: map["providerBranchUrl"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/DeploymentList.swift b/Sources/AppwriteModels/DeploymentList.swift index e218064..15b469b 100644 --- a/Sources/AppwriteModels/DeploymentList.swift +++ b/Sources/AppwriteModels/DeploymentList.swift @@ -47,8 +47,8 @@ open class DeploymentList: Codable { public static func from(map: [String: Any] ) -> DeploymentList { return DeploymentList( - total: map["total"] as! Int, - deployments: (map["deployments"] as! [[String: Any]]).map { Deployment.from(map: $0) } + total: map["total"] as? Int ?? 0, + deployments: (map["deployments"] as? [[String: Any]] ?? []).map { Deployment.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Document.swift b/Sources/AppwriteModels/Document.swift index a1c0326..8bd3416 100644 --- a/Sources/AppwriteModels/Document.swift +++ b/Sources/AppwriteModels/Document.swift @@ -91,13 +91,13 @@ open class Document: Codable { public static func from(map: [String: Any] ) -> Document { return Document( - id: map["$id"] as! String, - collectionId: map["$collectionId"] as! String, - databaseId: map["$databaseId"] as! String, - 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: [])) + id: map["$id"] as? String ?? "", + collectionId: map["$collectionId"] as? String ?? "", + databaseId: map["$databaseId"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + permissions: map["$permissions"] as? [String] ?? [], + data: map["data"] != nil ? try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"]!, options: [])) : try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) ) } } diff --git a/Sources/AppwriteModels/DocumentList.swift b/Sources/AppwriteModels/DocumentList.swift index a129182..93fc41d 100644 --- a/Sources/AppwriteModels/DocumentList.swift +++ b/Sources/AppwriteModels/DocumentList.swift @@ -47,8 +47,8 @@ open class DocumentList: Codable { public static func from(map: [String: Any] ) -> DocumentList { return DocumentList( - total: map["total"] as! Int, - documents: (map["documents"] as! [[String: Any]]).map { Document.from(map: $0) } + total: map["total"] as? Int ?? 0, + documents: (map["documents"] as? [[String: Any]] ?? []).map { Document.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 6e81532..59017e4 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -182,22 +182,22 @@ open class Execution: Codable { public static func from(map: [String: Any] ) -> Execution { return Execution( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [String], - functionId: map["functionId"] as! String, - trigger: map["trigger"] as! String, - status: 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) }, - responseStatusCode: map["responseStatusCode"] as! Int, - responseBody: map["responseBody"] as! String, - responseHeaders: (map["responseHeaders"] as! [[String: Any]]).map { Headers.from(map: $0) }, - logs: map["logs"] as! String, - errors: map["errors"] as! String, - duration: map["duration"] as! Double, + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + permissions: map["$permissions"] as? [String] ?? [], + functionId: map["functionId"] as? String ?? "", + trigger: map["trigger"] as? String ?? "", + status: 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) }, + responseStatusCode: map["responseStatusCode"] as? Int ?? 0, + responseBody: map["responseBody"] as? String ?? "", + responseHeaders: (map["responseHeaders"] as? [[String: Any]] ?? []).map { Headers.from(map: $0) }, + logs: map["logs"] as? String ?? "", + errors: map["errors"] as? String ?? "", + duration: map["duration"] as? Double ?? 0.0, scheduledAt: map["scheduledAt"] as? String ) } diff --git a/Sources/AppwriteModels/ExecutionList.swift b/Sources/AppwriteModels/ExecutionList.swift index 72d43a6..8b7559d 100644 --- a/Sources/AppwriteModels/ExecutionList.swift +++ b/Sources/AppwriteModels/ExecutionList.swift @@ -47,8 +47,8 @@ open class ExecutionList: Codable { public static func from(map: [String: Any] ) -> ExecutionList { return ExecutionList( - total: map["total"] as! Int, - executions: (map["executions"] as! [[String: Any]]).map { Execution.from(map: $0) } + total: map["total"] as? Int ?? 0, + executions: (map["executions"] as? [[String: Any]] ?? []).map { Execution.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/File.swift b/Sources/AppwriteModels/File.swift index 713c7ca..c68b701 100644 --- a/Sources/AppwriteModels/File.swift +++ b/Sources/AppwriteModels/File.swift @@ -128,17 +128,17 @@ open class File: Codable { public static func from(map: [String: Any] ) -> File { return File( - id: map["$id"] as! String, - bucketId: map["bucketId"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [String], - name: map["name"] as! String, - signature: map["signature"] as! String, - mimeType: map["mimeType"] as! String, - sizeOriginal: map["sizeOriginal"] as! Int, - chunksTotal: map["chunksTotal"] as! Int, - chunksUploaded: map["chunksUploaded"] as! Int + id: map["$id"] as? String ?? "", + bucketId: map["bucketId"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + permissions: map["$permissions"] as? [String] ?? [], + name: map["name"] as? String ?? "", + signature: map["signature"] as? String ?? "", + mimeType: map["mimeType"] as? String ?? "", + sizeOriginal: map["sizeOriginal"] as? Int ?? 0, + chunksTotal: map["chunksTotal"] as? Int ?? 0, + chunksUploaded: map["chunksUploaded"] as? Int ?? 0 ) } } diff --git a/Sources/AppwriteModels/FileList.swift b/Sources/AppwriteModels/FileList.swift index bec7b76..a20ba7a 100644 --- a/Sources/AppwriteModels/FileList.swift +++ b/Sources/AppwriteModels/FileList.swift @@ -47,8 +47,8 @@ open class FileList: Codable { public static func from(map: [String: Any] ) -> FileList { return FileList( - total: map["total"] as! Int, - files: (map["files"] as! [[String: Any]]).map { File.from(map: $0) } + total: map["total"] as? Int ?? 0, + files: (map["files"] as? [[String: Any]] ?? []).map { File.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Framework.swift b/Sources/AppwriteModels/Framework.swift index 9885e94..cbe3744 100644 --- a/Sources/AppwriteModels/Framework.swift +++ b/Sources/AppwriteModels/Framework.swift @@ -74,11 +74,11 @@ open class Framework: Codable { public static func from(map: [String: Any] ) -> Framework { return Framework( - key: map["key"] as! String, - name: map["name"] as! String, - buildRuntime: map["buildRuntime"] as! String, - runtimes: map["runtimes"] as! [String], - adapters: (map["adapters"] as! [[String: Any]]).map { FrameworkAdapter.from(map: $0) } + key: map["key"] as? String ?? "", + name: map["name"] as? String ?? "", + buildRuntime: map["buildRuntime"] as? String ?? "", + runtimes: map["runtimes"] as? [String] ?? [], + adapters: (map["adapters"] as? [[String: Any]] ?? []).map { FrameworkAdapter.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/FrameworkAdapter.swift b/Sources/AppwriteModels/FrameworkAdapter.swift index 59348b4..ec9b0bb 100644 --- a/Sources/AppwriteModels/FrameworkAdapter.swift +++ b/Sources/AppwriteModels/FrameworkAdapter.swift @@ -74,11 +74,11 @@ open class FrameworkAdapter: Codable { public static func from(map: [String: Any] ) -> FrameworkAdapter { return FrameworkAdapter( - key: map["key"] as! String, - installCommand: map["installCommand"] as! String, - buildCommand: map["buildCommand"] as! String, - outputDirectory: map["outputDirectory"] as! String, - fallbackFile: map["fallbackFile"] as! String + key: map["key"] as? String ?? "", + installCommand: map["installCommand"] as? String ?? "", + buildCommand: map["buildCommand"] as? String ?? "", + outputDirectory: map["outputDirectory"] as? String ?? "", + fallbackFile: map["fallbackFile"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/FrameworkList.swift b/Sources/AppwriteModels/FrameworkList.swift index 7aa2ce7..9674996 100644 --- a/Sources/AppwriteModels/FrameworkList.swift +++ b/Sources/AppwriteModels/FrameworkList.swift @@ -47,8 +47,8 @@ open class FrameworkList: Codable { public static func from(map: [String: Any] ) -> FrameworkList { return FrameworkList( - total: map["total"] as! Int, - frameworks: (map["frameworks"] as! [[String: Any]]).map { Framework.from(map: $0) } + total: map["total"] as? Int ?? 0, + frameworks: (map["frameworks"] as? [[String: Any]] ?? []).map { Framework.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Function.swift b/Sources/AppwriteModels/Function.swift index 8df6078..a5c9fbd 100644 --- a/Sources/AppwriteModels/Function.swift +++ b/Sources/AppwriteModels/Function.swift @@ -281,34 +281,34 @@ open class Function: Codable { public static func from(map: [String: Any] ) -> Function { return Function( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - execute: map["execute"] as! [String], - name: map["name"] as! String, - enabled: map["enabled"] as! Bool, - live: map["live"] as! Bool, - logging: map["logging"] as! Bool, - runtime: map["runtime"] as! String, - deploymentId: map["deploymentId"] as! String, - deploymentCreatedAt: map["deploymentCreatedAt"] as! String, - latestDeploymentId: map["latestDeploymentId"] as! String, - latestDeploymentCreatedAt: map["latestDeploymentCreatedAt"] as! String, - latestDeploymentStatus: map["latestDeploymentStatus"] as! String, - scopes: map["scopes"] as! [String], - vars: (map["vars"] as! [[String: Any]]).map { Variable.from(map: $0) }, - events: map["events"] as! [String], - schedule: map["schedule"] as! String, - timeout: map["timeout"] as! Int, - entrypoint: map["entrypoint"] as! String, - commands: map["commands"] as! String, - version: map["version"] as! String, - installationId: map["installationId"] as! String, - providerRepositoryId: map["providerRepositoryId"] as! String, - providerBranch: map["providerBranch"] as! String, - providerRootDirectory: map["providerRootDirectory"] as! String, - providerSilentMode: map["providerSilentMode"] as! Bool, - specification: map["specification"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + execute: map["execute"] as? [String] ?? [], + name: map["name"] as? String ?? "", + enabled: map["enabled"] as? Bool ?? false, + live: map["live"] as? Bool ?? false, + logging: map["logging"] as? Bool ?? false, + runtime: map["runtime"] as? String ?? "", + deploymentId: map["deploymentId"] as? String ?? "", + deploymentCreatedAt: map["deploymentCreatedAt"] as? String ?? "", + latestDeploymentId: map["latestDeploymentId"] as? String ?? "", + latestDeploymentCreatedAt: map["latestDeploymentCreatedAt"] as? String ?? "", + latestDeploymentStatus: map["latestDeploymentStatus"] as? String ?? "", + scopes: map["scopes"] as? [String] ?? [], + vars: (map["vars"] as? [[String: Any]] ?? []).map { Variable.from(map: $0) }, + events: map["events"] as? [String] ?? [], + schedule: map["schedule"] as? String ?? "", + timeout: map["timeout"] as? Int ?? 0, + entrypoint: map["entrypoint"] as? String ?? "", + commands: map["commands"] as? String ?? "", + version: map["version"] as? String ?? "", + installationId: map["installationId"] as? String ?? "", + providerRepositoryId: map["providerRepositoryId"] as? String ?? "", + providerBranch: map["providerBranch"] as? String ?? "", + providerRootDirectory: map["providerRootDirectory"] as? String ?? "", + providerSilentMode: map["providerSilentMode"] as? Bool ?? false, + specification: map["specification"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/FunctionList.swift b/Sources/AppwriteModels/FunctionList.swift index c00badb..e43b5b8 100644 --- a/Sources/AppwriteModels/FunctionList.swift +++ b/Sources/AppwriteModels/FunctionList.swift @@ -47,8 +47,8 @@ open class FunctionList: Codable { public static func from(map: [String: Any] ) -> FunctionList { return FunctionList( - total: map["total"] as! Int, - functions: (map["functions"] as! [[String: Any]]).map { Function.from(map: $0) } + total: map["total"] as? Int ?? 0, + functions: (map["functions"] as? [[String: Any]] ?? []).map { Function.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Headers.swift b/Sources/AppwriteModels/Headers.swift index ae468e5..c09d36e 100644 --- a/Sources/AppwriteModels/Headers.swift +++ b/Sources/AppwriteModels/Headers.swift @@ -47,8 +47,8 @@ open class Headers: Codable { public static func from(map: [String: Any] ) -> Headers { return Headers( - name: map["name"] as! String, - value: map["value"] as! String + name: map["name"] as? String ?? "", + value: map["value"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/HealthAntivirus.swift b/Sources/AppwriteModels/HealthAntivirus.swift index a68bb36..79aefbe 100644 --- a/Sources/AppwriteModels/HealthAntivirus.swift +++ b/Sources/AppwriteModels/HealthAntivirus.swift @@ -47,8 +47,8 @@ open class HealthAntivirus: Codable { public static func from(map: [String: Any] ) -> HealthAntivirus { return HealthAntivirus( - version: map["version"] as! String, - status: map["status"] as! String + version: map["version"] as? String ?? "", + status: map["status"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/HealthCertificate.swift b/Sources/AppwriteModels/HealthCertificate.swift index 1ef3837..4fe3c22 100644 --- a/Sources/AppwriteModels/HealthCertificate.swift +++ b/Sources/AppwriteModels/HealthCertificate.swift @@ -83,12 +83,12 @@ open class HealthCertificate: Codable { public static func from(map: [String: Any] ) -> HealthCertificate { return HealthCertificate( - name: map["name"] as! String, - subjectSN: map["subjectSN"] as! String, - issuerOrganisation: map["issuerOrganisation"] as! String, - validFrom: map["validFrom"] as! String, - validTo: map["validTo"] as! String, - signatureTypeSN: map["signatureTypeSN"] as! String + name: map["name"] as? String ?? "", + subjectSN: map["subjectSN"] as? String ?? "", + issuerOrganisation: map["issuerOrganisation"] as? String ?? "", + validFrom: map["validFrom"] as? String ?? "", + validTo: map["validTo"] as? String ?? "", + signatureTypeSN: map["signatureTypeSN"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/HealthQueue.swift b/Sources/AppwriteModels/HealthQueue.swift index 856a6d9..d5bf3cb 100644 --- a/Sources/AppwriteModels/HealthQueue.swift +++ b/Sources/AppwriteModels/HealthQueue.swift @@ -38,7 +38,7 @@ open class HealthQueue: Codable { public static func from(map: [String: Any] ) -> HealthQueue { return HealthQueue( - size: map["size"] as! Int + size: map["size"] as? Int ?? 0 ) } } diff --git a/Sources/AppwriteModels/HealthStatus.swift b/Sources/AppwriteModels/HealthStatus.swift index 8818778..b33d1e9 100644 --- a/Sources/AppwriteModels/HealthStatus.swift +++ b/Sources/AppwriteModels/HealthStatus.swift @@ -56,9 +56,9 @@ open class HealthStatus: Codable { public static func from(map: [String: Any] ) -> HealthStatus { return HealthStatus( - name: map["name"] as! String, - ping: map["ping"] as! Int, - status: map["status"] as! String + name: map["name"] as? String ?? "", + ping: map["ping"] as? Int ?? 0, + status: map["status"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/HealthTime.swift b/Sources/AppwriteModels/HealthTime.swift index aab020b..0323c07 100644 --- a/Sources/AppwriteModels/HealthTime.swift +++ b/Sources/AppwriteModels/HealthTime.swift @@ -56,9 +56,9 @@ open class HealthTime: Codable { public static func from(map: [String: Any] ) -> HealthTime { return HealthTime( - remoteTime: map["remoteTime"] as! Int, - localTime: map["localTime"] as! Int, - diff: map["diff"] as! Int + remoteTime: map["remoteTime"] as? Int ?? 0, + localTime: map["localTime"] as? Int ?? 0, + diff: map["diff"] as? Int ?? 0 ) } } diff --git a/Sources/AppwriteModels/Identity.swift b/Sources/AppwriteModels/Identity.swift index f93035d..3f211b3 100644 --- a/Sources/AppwriteModels/Identity.swift +++ b/Sources/AppwriteModels/Identity.swift @@ -119,16 +119,16 @@ open class Identity: Codable { public static func from(map: [String: Any] ) -> Identity { return Identity( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - userId: map["userId"] as! String, - provider: map["provider"] as! String, - providerUid: map["providerUid"] as! String, - providerEmail: map["providerEmail"] as! String, - providerAccessToken: map["providerAccessToken"] as! String, - providerAccessTokenExpiry: map["providerAccessTokenExpiry"] as! String, - providerRefreshToken: map["providerRefreshToken"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + userId: map["userId"] as? String ?? "", + provider: map["provider"] as? String ?? "", + providerUid: map["providerUid"] as? String ?? "", + providerEmail: map["providerEmail"] as? String ?? "", + providerAccessToken: map["providerAccessToken"] as? String ?? "", + providerAccessTokenExpiry: map["providerAccessTokenExpiry"] as? String ?? "", + providerRefreshToken: map["providerRefreshToken"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/IdentityList.swift b/Sources/AppwriteModels/IdentityList.swift index 6065fad..8665233 100644 --- a/Sources/AppwriteModels/IdentityList.swift +++ b/Sources/AppwriteModels/IdentityList.swift @@ -47,8 +47,8 @@ open class IdentityList: Codable { public static func from(map: [String: Any] ) -> IdentityList { return IdentityList( - total: map["total"] as! Int, - identities: (map["identities"] as! [[String: Any]]).map { Identity.from(map: $0) } + total: map["total"] as? Int ?? 0, + identities: (map["identities"] as? [[String: Any]] ?? []).map { Identity.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Index.swift b/Sources/AppwriteModels/Index.swift index 7b5fb13..f6f09e0 100644 --- a/Sources/AppwriteModels/Index.swift +++ b/Sources/AppwriteModels/Index.swift @@ -110,15 +110,15 @@ open class Index: Codable { public static func from(map: [String: Any] ) -> Index { return Index( - key: map["key"] as! String, - type: map["type"] as! String, - status: map["status"] as! String, - error: map["error"] as! String, - attributes: map["attributes"] as! [String], - lengths: map["lengths"] as! [Int], + key: map["key"] as? String ?? "", + type: map["type"] as? String ?? "", + status: map["status"] as? String ?? "", + error: map["error"] as? String ?? "", + attributes: map["attributes"] as? [String] ?? [], + lengths: map["lengths"] as? [Int] ?? [Int](), orders: map["orders"] as? [String], - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/IndexList.swift b/Sources/AppwriteModels/IndexList.swift index 2f3ae30..d81532a 100644 --- a/Sources/AppwriteModels/IndexList.swift +++ b/Sources/AppwriteModels/IndexList.swift @@ -47,8 +47,8 @@ open class IndexList: Codable { public static func from(map: [String: Any] ) -> IndexList { return IndexList( - total: map["total"] as! Int, - indexes: (map["indexes"] as! [[String: Any]]).map { Index.from(map: $0) } + total: map["total"] as? Int ?? 0, + indexes: (map["indexes"] as? [[String: Any]] ?? []).map { Index.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Jwt.swift b/Sources/AppwriteModels/Jwt.swift index fd7fb49..65e28af 100644 --- a/Sources/AppwriteModels/Jwt.swift +++ b/Sources/AppwriteModels/Jwt.swift @@ -38,7 +38,7 @@ open class Jwt: Codable { public static func from(map: [String: Any] ) -> Jwt { return Jwt( - jwt: map["jwt"] as! String + jwt: map["jwt"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/Language.swift b/Sources/AppwriteModels/Language.swift index d1e1a15..cb01df3 100644 --- a/Sources/AppwriteModels/Language.swift +++ b/Sources/AppwriteModels/Language.swift @@ -56,9 +56,9 @@ open class Language: Codable { public static func from(map: [String: Any] ) -> Language { return Language( - name: map["name"] as! String, - code: map["code"] as! String, - nativeName: map["nativeName"] as! String + name: map["name"] as? String ?? "", + code: map["code"] as? String ?? "", + nativeName: map["nativeName"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/LanguageList.swift b/Sources/AppwriteModels/LanguageList.swift index 13c6e4a..46d99a2 100644 --- a/Sources/AppwriteModels/LanguageList.swift +++ b/Sources/AppwriteModels/LanguageList.swift @@ -47,8 +47,8 @@ open class LanguageList: Codable { public static func from(map: [String: Any] ) -> LanguageList { return LanguageList( - total: map["total"] as! Int, - languages: (map["languages"] as! [[String: Any]]).map { Language.from(map: $0) } + total: map["total"] as? Int ?? 0, + languages: (map["languages"] as? [[String: Any]] ?? []).map { Language.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Locale.swift b/Sources/AppwriteModels/Locale.swift index 4d034f4..406c6b4 100644 --- a/Sources/AppwriteModels/Locale.swift +++ b/Sources/AppwriteModels/Locale.swift @@ -92,13 +92,13 @@ open class Locale: Codable { public static func from(map: [String: Any] ) -> Locale { return Locale( - ip: map["ip"] as! String, - countryCode: map["countryCode"] as! String, - country: map["country"] as! String, - continentCode: map["continentCode"] as! String, - continent: map["continent"] as! String, - eu: map["eu"] as! Bool, - currency: map["currency"] as! String + ip: map["ip"] as? String ?? "", + countryCode: map["countryCode"] as? String ?? "", + country: map["country"] as? String ?? "", + continentCode: map["continentCode"] as? String ?? "", + continent: map["continent"] as? String ?? "", + eu: map["eu"] as? Bool ?? false, + currency: map["currency"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/LocaleCode.swift b/Sources/AppwriteModels/LocaleCode.swift index d2678bb..0b645f6 100644 --- a/Sources/AppwriteModels/LocaleCode.swift +++ b/Sources/AppwriteModels/LocaleCode.swift @@ -47,8 +47,8 @@ open class LocaleCode: Codable { public static func from(map: [String: Any] ) -> LocaleCode { return LocaleCode( - code: map["code"] as! String, - name: map["name"] as! String + code: map["code"] as? String ?? "", + name: map["name"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/LocaleCodeList.swift b/Sources/AppwriteModels/LocaleCodeList.swift index 5ef0653..c91540f 100644 --- a/Sources/AppwriteModels/LocaleCodeList.swift +++ b/Sources/AppwriteModels/LocaleCodeList.swift @@ -47,8 +47,8 @@ open class LocaleCodeList: Codable { public static func from(map: [String: Any] ) -> LocaleCodeList { return LocaleCodeList( - total: map["total"] as! Int, - localeCodes: (map["localeCodes"] as! [[String: Any]]).map { LocaleCode.from(map: $0) } + total: map["total"] as? Int ?? 0, + localeCodes: (map["localeCodes"] as? [[String: Any]] ?? []).map { LocaleCode.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Log.swift b/Sources/AppwriteModels/Log.swift index 16c27ef..b2b1216 100644 --- a/Sources/AppwriteModels/Log.swift +++ b/Sources/AppwriteModels/Log.swift @@ -218,27 +218,27 @@ open class Log: Codable { public static func from(map: [String: Any] ) -> Log { return Log( - event: map["event"] as! String, - userId: map["userId"] as! String, - userEmail: map["userEmail"] as! String, - userName: map["userName"] as! String, - mode: map["mode"] as! String, - ip: map["ip"] as! String, - time: map["time"] as! String, - osCode: map["osCode"] as! String, - osName: map["osName"] as! String, - osVersion: map["osVersion"] as! String, - clientType: map["clientType"] as! String, - clientCode: map["clientCode"] as! String, - clientName: map["clientName"] as! String, - clientVersion: map["clientVersion"] as! String, - clientEngine: map["clientEngine"] as! String, - clientEngineVersion: map["clientEngineVersion"] as! String, - deviceName: map["deviceName"] as! String, - deviceBrand: map["deviceBrand"] as! String, - deviceModel: map["deviceModel"] as! String, - countryCode: map["countryCode"] as! String, - countryName: map["countryName"] as! String + event: map["event"] as? String ?? "", + userId: map["userId"] as? String ?? "", + userEmail: map["userEmail"] as? String ?? "", + userName: map["userName"] as? String ?? "", + mode: map["mode"] as? String ?? "", + ip: map["ip"] as? String ?? "", + time: map["time"] as? String ?? "", + osCode: map["osCode"] as? String ?? "", + osName: map["osName"] as? String ?? "", + osVersion: map["osVersion"] as? String ?? "", + clientType: map["clientType"] as? String ?? "", + clientCode: map["clientCode"] as? String ?? "", + clientName: map["clientName"] as? String ?? "", + clientVersion: map["clientVersion"] as? String ?? "", + clientEngine: map["clientEngine"] as? String ?? "", + clientEngineVersion: map["clientEngineVersion"] as? String ?? "", + deviceName: map["deviceName"] as? String ?? "", + deviceBrand: map["deviceBrand"] as? String ?? "", + deviceModel: map["deviceModel"] as? String ?? "", + countryCode: map["countryCode"] as? String ?? "", + countryName: map["countryName"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/LogList.swift b/Sources/AppwriteModels/LogList.swift index 7ff2d07..8e40eb5 100644 --- a/Sources/AppwriteModels/LogList.swift +++ b/Sources/AppwriteModels/LogList.swift @@ -47,8 +47,8 @@ open class LogList: Codable { public static func from(map: [String: Any] ) -> LogList { return LogList( - total: map["total"] as! Int, - logs: (map["logs"] as! [[String: Any]]).map { Log.from(map: $0) } + total: map["total"] as? Int ?? 0, + logs: (map["logs"] as? [[String: Any]] ?? []).map { Log.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Membership.swift b/Sources/AppwriteModels/Membership.swift index 8d26766..1886000 100644 --- a/Sources/AppwriteModels/Membership.swift +++ b/Sources/AppwriteModels/Membership.swift @@ -146,19 +146,19 @@ open class Membership: Codable { public static func from(map: [String: Any] ) -> Membership { return Membership( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - userId: map["userId"] as! String, - userName: map["userName"] as! String, - userEmail: map["userEmail"] as! String, - teamId: map["teamId"] as! String, - teamName: map["teamName"] as! String, - invited: map["invited"] as! String, - joined: map["joined"] as! String, - confirm: map["confirm"] as! Bool, - mfa: map["mfa"] as! Bool, - roles: map["roles"] as! [String] + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + userId: map["userId"] as? String ?? "", + userName: map["userName"] as? String ?? "", + userEmail: map["userEmail"] as? String ?? "", + teamId: map["teamId"] as? String ?? "", + teamName: map["teamName"] as? String ?? "", + invited: map["invited"] as? String ?? "", + joined: map["joined"] as? String ?? "", + confirm: map["confirm"] as? Bool ?? false, + mfa: map["mfa"] as? Bool ?? false, + roles: map["roles"] as? [String] ?? [] ) } } diff --git a/Sources/AppwriteModels/MembershipList.swift b/Sources/AppwriteModels/MembershipList.swift index a7b0cd6..abaa881 100644 --- a/Sources/AppwriteModels/MembershipList.swift +++ b/Sources/AppwriteModels/MembershipList.swift @@ -47,8 +47,8 @@ open class MembershipList: Codable { public static func from(map: [String: Any] ) -> MembershipList { return MembershipList( - total: map["total"] as! Int, - memberships: (map["memberships"] as! [[String: Any]]).map { Membership.from(map: $0) } + total: map["total"] as? Int ?? 0, + memberships: (map["memberships"] as? [[String: Any]] ?? []).map { Membership.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Message.swift b/Sources/AppwriteModels/Message.swift index 442d7c8..a19645e 100644 --- a/Sources/AppwriteModels/Message.swift +++ b/Sources/AppwriteModels/Message.swift @@ -146,19 +146,19 @@ open class Message: Codable { public static func from(map: [String: Any] ) -> Message { return Message( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - providerType: map["providerType"] as! String, - topics: map["topics"] as! [String], - users: map["users"] as! [String], - targets: map["targets"] as! [String], + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + providerType: map["providerType"] as? String ?? "", + topics: map["topics"] as? [String] ?? [], + users: map["users"] as? [String] ?? [], + targets: map["targets"] as? [String] ?? [], scheduledAt: map["scheduledAt"] as? String, deliveredAt: map["deliveredAt"] as? String, deliveryErrors: map["deliveryErrors"] as? [String], - deliveredTotal: map["deliveredTotal"] as! Int, - data: map["data"] as! [String: AnyCodable], - status: map["status"] as! String + deliveredTotal: map["deliveredTotal"] as? Int ?? 0, + data: map["data"] as? [String: AnyCodable] ?? [String: AnyCodable](), + status: map["status"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/MessageList.swift b/Sources/AppwriteModels/MessageList.swift index f62fcaa..d64e7bb 100644 --- a/Sources/AppwriteModels/MessageList.swift +++ b/Sources/AppwriteModels/MessageList.swift @@ -47,8 +47,8 @@ open class MessageList: Codable { public static func from(map: [String: Any] ) -> MessageList { return MessageList( - total: map["total"] as! Int, - messages: (map["messages"] as! [[String: Any]]).map { Message.from(map: $0) } + total: map["total"] as? Int ?? 0, + messages: (map["messages"] as? [[String: Any]] ?? []).map { Message.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/MfaChallenge.swift b/Sources/AppwriteModels/MfaChallenge.swift index c6b77a5..7550cce 100644 --- a/Sources/AppwriteModels/MfaChallenge.swift +++ b/Sources/AppwriteModels/MfaChallenge.swift @@ -65,10 +65,10 @@ open class MfaChallenge: Codable { public static func from(map: [String: Any] ) -> MfaChallenge { return MfaChallenge( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - userId: map["userId"] as! String, - expire: map["expire"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + userId: map["userId"] as? String ?? "", + expire: map["expire"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/MfaFactors.swift b/Sources/AppwriteModels/MfaFactors.swift index 4291fab..9fb46b5 100644 --- a/Sources/AppwriteModels/MfaFactors.swift +++ b/Sources/AppwriteModels/MfaFactors.swift @@ -65,10 +65,10 @@ open class MfaFactors: Codable { public static func from(map: [String: Any] ) -> MfaFactors { return MfaFactors( - totp: map["totp"] as! Bool, - phone: map["phone"] as! Bool, - email: map["email"] as! Bool, - recoveryCode: map["recoveryCode"] as! Bool + totp: map["totp"] as? Bool ?? false, + phone: map["phone"] as? Bool ?? false, + email: map["email"] as? Bool ?? false, + recoveryCode: map["recoveryCode"] as? Bool ?? false ) } } diff --git a/Sources/AppwriteModels/MfaRecoveryCodes.swift b/Sources/AppwriteModels/MfaRecoveryCodes.swift index bd2968f..ac67444 100644 --- a/Sources/AppwriteModels/MfaRecoveryCodes.swift +++ b/Sources/AppwriteModels/MfaRecoveryCodes.swift @@ -38,7 +38,7 @@ open class MfaRecoveryCodes: Codable { public static func from(map: [String: Any] ) -> MfaRecoveryCodes { return MfaRecoveryCodes( - recoveryCodes: map["recoveryCodes"] as! [String] + recoveryCodes: map["recoveryCodes"] as? [String] ?? [] ) } } diff --git a/Sources/AppwriteModels/MfaType.swift b/Sources/AppwriteModels/MfaType.swift index 8646385..fdcd119 100644 --- a/Sources/AppwriteModels/MfaType.swift +++ b/Sources/AppwriteModels/MfaType.swift @@ -47,8 +47,8 @@ open class MfaType: Codable { public static func from(map: [String: Any] ) -> MfaType { return MfaType( - secret: map["secret"] as! String, - uri: map["uri"] as! String + secret: map["secret"] as? String ?? "", + uri: map["uri"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/Phone.swift b/Sources/AppwriteModels/Phone.swift index fc90d49..2510956 100644 --- a/Sources/AppwriteModels/Phone.swift +++ b/Sources/AppwriteModels/Phone.swift @@ -56,9 +56,9 @@ open class Phone: Codable { public static func from(map: [String: Any] ) -> Phone { return Phone( - code: map["code"] as! String, - countryCode: map["countryCode"] as! String, - countryName: map["countryName"] as! String + code: map["code"] as? String ?? "", + countryCode: map["countryCode"] as? String ?? "", + countryName: map["countryName"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/PhoneList.swift b/Sources/AppwriteModels/PhoneList.swift index 6f3bee3..adf5287 100644 --- a/Sources/AppwriteModels/PhoneList.swift +++ b/Sources/AppwriteModels/PhoneList.swift @@ -47,8 +47,8 @@ open class PhoneList: Codable { public static func from(map: [String: Any] ) -> PhoneList { return PhoneList( - total: map["total"] as! Int, - phones: (map["phones"] as! [[String: Any]]).map { Phone.from(map: $0) } + total: map["total"] as? Int ?? 0, + phones: (map["phones"] as? [[String: Any]] ?? []).map { Phone.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Preferences.swift b/Sources/AppwriteModels/Preferences.swift index 41f94e6..707297d 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: map["data"] != nil ? try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"]!, options: [])) : try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) ) } } diff --git a/Sources/AppwriteModels/Provider.swift b/Sources/AppwriteModels/Provider.swift index 50e50d2..4d9accc 100644 --- a/Sources/AppwriteModels/Provider.swift +++ b/Sources/AppwriteModels/Provider.swift @@ -110,14 +110,14 @@ open class Provider: Codable { public static func from(map: [String: Any] ) -> Provider { return Provider( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - name: map["name"] as! String, - provider: map["provider"] as! String, - enabled: map["enabled"] as! Bool, - type: map["type"] as! String, - credentials: map["credentials"] as! [String: AnyCodable], + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + name: map["name"] as? String ?? "", + provider: map["provider"] as? String ?? "", + enabled: map["enabled"] as? Bool ?? false, + type: map["type"] as? String ?? "", + credentials: map["credentials"] as? [String: AnyCodable] ?? [String: AnyCodable](), options: map["options"] as? [String: AnyCodable] ) } diff --git a/Sources/AppwriteModels/ProviderList.swift b/Sources/AppwriteModels/ProviderList.swift index 76fd4eb..5853910 100644 --- a/Sources/AppwriteModels/ProviderList.swift +++ b/Sources/AppwriteModels/ProviderList.swift @@ -47,8 +47,8 @@ open class ProviderList: Codable { public static func from(map: [String: Any] ) -> ProviderList { return ProviderList( - total: map["total"] as! Int, - providers: (map["providers"] as! [[String: Any]]).map { Provider.from(map: $0) } + total: map["total"] as? Int ?? 0, + providers: (map["providers"] as? [[String: Any]] ?? []).map { Provider.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/ResourceToken.swift b/Sources/AppwriteModels/ResourceToken.swift index a3badb6..7826f69 100644 --- a/Sources/AppwriteModels/ResourceToken.swift +++ b/Sources/AppwriteModels/ResourceToken.swift @@ -92,13 +92,13 @@ open class ResourceToken: Codable { public static func from(map: [String: Any] ) -> ResourceToken { return ResourceToken( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - resourceId: map["resourceId"] as! String, - resourceType: map["resourceType"] as! String, - expire: map["expire"] as! String, - secret: map["secret"] as! String, - accessedAt: map["accessedAt"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + resourceId: map["resourceId"] as? String ?? "", + resourceType: map["resourceType"] as? String ?? "", + expire: map["expire"] as? String ?? "", + secret: map["secret"] as? String ?? "", + accessedAt: map["accessedAt"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/ResourceTokenList.swift b/Sources/AppwriteModels/ResourceTokenList.swift index 6d894b6..e2dcbff 100644 --- a/Sources/AppwriteModels/ResourceTokenList.swift +++ b/Sources/AppwriteModels/ResourceTokenList.swift @@ -47,8 +47,8 @@ open class ResourceTokenList: Codable { public static func from(map: [String: Any] ) -> ResourceTokenList { return ResourceTokenList( - total: map["total"] as! Int, - tokens: (map["tokens"] as! [[String: Any]]).map { ResourceToken.from(map: $0) } + total: map["total"] as? Int ?? 0, + tokens: (map["tokens"] as? [[String: Any]] ?? []).map { ResourceToken.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Runtime.swift b/Sources/AppwriteModels/Runtime.swift index f8e6950..be07b7c 100644 --- a/Sources/AppwriteModels/Runtime.swift +++ b/Sources/AppwriteModels/Runtime.swift @@ -101,14 +101,14 @@ open class Runtime: Codable { public static func from(map: [String: Any] ) -> Runtime { return Runtime( - id: map["$id"] as! String, - key: map["key"] as! String, - name: map["name"] as! String, - version: map["version"] as! String, - base: map["base"] as! String, - image: map["image"] as! String, - logo: map["logo"] as! String, - supports: map["supports"] as! [String] + id: map["$id"] as? String ?? "", + key: map["key"] as? String ?? "", + name: map["name"] as? String ?? "", + version: map["version"] as? String ?? "", + base: map["base"] as? String ?? "", + image: map["image"] as? String ?? "", + logo: map["logo"] as? String ?? "", + supports: map["supports"] as? [String] ?? [] ) } } diff --git a/Sources/AppwriteModels/RuntimeList.swift b/Sources/AppwriteModels/RuntimeList.swift index ab99ed1..a014115 100644 --- a/Sources/AppwriteModels/RuntimeList.swift +++ b/Sources/AppwriteModels/RuntimeList.swift @@ -47,8 +47,8 @@ open class RuntimeList: Codable { public static func from(map: [String: Any] ) -> RuntimeList { return RuntimeList( - total: map["total"] as! Int, - runtimes: (map["runtimes"] as! [[String: Any]]).map { Runtime.from(map: $0) } + total: map["total"] as? Int ?? 0, + runtimes: (map["runtimes"] as? [[String: Any]] ?? []).map { Runtime.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Session.swift b/Sources/AppwriteModels/Session.swift index b5c25a6..1ee01a4 100644 --- a/Sources/AppwriteModels/Session.swift +++ b/Sources/AppwriteModels/Session.swift @@ -290,35 +290,35 @@ open class Session: Codable { public static func from(map: [String: Any] ) -> Session { return Session( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - userId: map["userId"] as! String, - expire: map["expire"] as! String, - provider: map["provider"] as! String, - providerUid: map["providerUid"] as! String, - providerAccessToken: map["providerAccessToken"] as! String, - providerAccessTokenExpiry: map["providerAccessTokenExpiry"] as! String, - providerRefreshToken: map["providerRefreshToken"] as! String, - ip: map["ip"] as! String, - osCode: map["osCode"] as! String, - osName: map["osName"] as! String, - osVersion: map["osVersion"] as! String, - clientType: map["clientType"] as! String, - clientCode: map["clientCode"] as! String, - clientName: map["clientName"] as! String, - clientVersion: map["clientVersion"] as! String, - clientEngine: map["clientEngine"] as! String, - clientEngineVersion: map["clientEngineVersion"] as! String, - deviceName: map["deviceName"] as! String, - deviceBrand: map["deviceBrand"] as! String, - deviceModel: map["deviceModel"] as! String, - countryCode: map["countryCode"] as! String, - countryName: map["countryName"] as! String, - current: map["current"] as! Bool, - factors: map["factors"] as! [String], - secret: map["secret"] as! String, - mfaUpdatedAt: map["mfaUpdatedAt"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + userId: map["userId"] as? String ?? "", + expire: map["expire"] as? String ?? "", + provider: map["provider"] as? String ?? "", + providerUid: map["providerUid"] as? String ?? "", + providerAccessToken: map["providerAccessToken"] as? String ?? "", + providerAccessTokenExpiry: map["providerAccessTokenExpiry"] as? String ?? "", + providerRefreshToken: map["providerRefreshToken"] as? String ?? "", + ip: map["ip"] as? String ?? "", + osCode: map["osCode"] as? String ?? "", + osName: map["osName"] as? String ?? "", + osVersion: map["osVersion"] as? String ?? "", + clientType: map["clientType"] as? String ?? "", + clientCode: map["clientCode"] as? String ?? "", + clientName: map["clientName"] as? String ?? "", + clientVersion: map["clientVersion"] as? String ?? "", + clientEngine: map["clientEngine"] as? String ?? "", + clientEngineVersion: map["clientEngineVersion"] as? String ?? "", + deviceName: map["deviceName"] as? String ?? "", + deviceBrand: map["deviceBrand"] as? String ?? "", + deviceModel: map["deviceModel"] as? String ?? "", + countryCode: map["countryCode"] as? String ?? "", + countryName: map["countryName"] as? String ?? "", + current: map["current"] as? Bool ?? false, + factors: map["factors"] as? [String] ?? [], + secret: map["secret"] as? String ?? "", + mfaUpdatedAt: map["mfaUpdatedAt"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/SessionList.swift b/Sources/AppwriteModels/SessionList.swift index 13b6b3d..2dd724b 100644 --- a/Sources/AppwriteModels/SessionList.swift +++ b/Sources/AppwriteModels/SessionList.swift @@ -47,8 +47,8 @@ open class SessionList: Codable { public static func from(map: [String: Any] ) -> SessionList { return SessionList( - total: map["total"] as! Int, - sessions: (map["sessions"] as! [[String: Any]]).map { Session.from(map: $0) } + total: map["total"] as? Int ?? 0, + sessions: (map["sessions"] as? [[String: Any]] ?? []).map { Session.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Site.swift b/Sources/AppwriteModels/Site.swift index ef79e4a..249dc98 100644 --- a/Sources/AppwriteModels/Site.swift +++ b/Sources/AppwriteModels/Site.swift @@ -290,35 +290,35 @@ open class Site: Codable { public static func from(map: [String: Any] ) -> Site { return Site( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - name: map["name"] as! String, - enabled: map["enabled"] as! Bool, - live: map["live"] as! Bool, - logging: map["logging"] as! Bool, - framework: map["framework"] as! String, - deploymentId: map["deploymentId"] as! String, - deploymentCreatedAt: map["deploymentCreatedAt"] as! String, - deploymentScreenshotLight: map["deploymentScreenshotLight"] as! String, - deploymentScreenshotDark: map["deploymentScreenshotDark"] as! String, - latestDeploymentId: map["latestDeploymentId"] as! String, - latestDeploymentCreatedAt: map["latestDeploymentCreatedAt"] as! String, - latestDeploymentStatus: map["latestDeploymentStatus"] as! String, - vars: (map["vars"] as! [[String: Any]]).map { Variable.from(map: $0) }, - timeout: map["timeout"] as! Int, - installCommand: map["installCommand"] as! String, - buildCommand: map["buildCommand"] as! String, - outputDirectory: map["outputDirectory"] as! String, - installationId: map["installationId"] as! String, - providerRepositoryId: map["providerRepositoryId"] as! String, - providerBranch: map["providerBranch"] as! String, - providerRootDirectory: map["providerRootDirectory"] as! String, - providerSilentMode: map["providerSilentMode"] as! Bool, - specification: map["specification"] as! String, - buildRuntime: map["buildRuntime"] as! String, - adapter: map["adapter"] as! String, - fallbackFile: map["fallbackFile"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + name: map["name"] as? String ?? "", + enabled: map["enabled"] as? Bool ?? false, + live: map["live"] as? Bool ?? false, + logging: map["logging"] as? Bool ?? false, + framework: map["framework"] as? String ?? "", + deploymentId: map["deploymentId"] as? String ?? "", + deploymentCreatedAt: map["deploymentCreatedAt"] as? String ?? "", + deploymentScreenshotLight: map["deploymentScreenshotLight"] as? String ?? "", + deploymentScreenshotDark: map["deploymentScreenshotDark"] as? String ?? "", + latestDeploymentId: map["latestDeploymentId"] as? String ?? "", + latestDeploymentCreatedAt: map["latestDeploymentCreatedAt"] as? String ?? "", + latestDeploymentStatus: map["latestDeploymentStatus"] as? String ?? "", + vars: (map["vars"] as? [[String: Any]] ?? []).map { Variable.from(map: $0) }, + timeout: map["timeout"] as? Int ?? 0, + installCommand: map["installCommand"] as? String ?? "", + buildCommand: map["buildCommand"] as? String ?? "", + outputDirectory: map["outputDirectory"] as? String ?? "", + installationId: map["installationId"] as? String ?? "", + providerRepositoryId: map["providerRepositoryId"] as? String ?? "", + providerBranch: map["providerBranch"] as? String ?? "", + providerRootDirectory: map["providerRootDirectory"] as? String ?? "", + providerSilentMode: map["providerSilentMode"] as? Bool ?? false, + specification: map["specification"] as? String ?? "", + buildRuntime: map["buildRuntime"] as? String ?? "", + adapter: map["adapter"] as? String ?? "", + fallbackFile: map["fallbackFile"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/SiteList.swift b/Sources/AppwriteModels/SiteList.swift index 6c37fae..e1ecb9e 100644 --- a/Sources/AppwriteModels/SiteList.swift +++ b/Sources/AppwriteModels/SiteList.swift @@ -47,8 +47,8 @@ open class SiteList: Codable { public static func from(map: [String: Any] ) -> SiteList { return SiteList( - total: map["total"] as! Int, - sites: (map["sites"] as! [[String: Any]]).map { Site.from(map: $0) } + total: map["total"] as? Int ?? 0, + sites: (map["sites"] as? [[String: Any]] ?? []).map { Site.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Specification.swift b/Sources/AppwriteModels/Specification.swift index a84f617..b128974 100644 --- a/Sources/AppwriteModels/Specification.swift +++ b/Sources/AppwriteModels/Specification.swift @@ -65,10 +65,10 @@ open class Specification: Codable { public static func from(map: [String: Any] ) -> Specification { return Specification( - memory: map["memory"] as! Int, - cpus: map["cpus"] as! Double, - enabled: map["enabled"] as! Bool, - slug: map["slug"] as! String + memory: map["memory"] as? Int ?? 0, + cpus: map["cpus"] as? Double ?? 0.0, + enabled: map["enabled"] as? Bool ?? false, + slug: map["slug"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/SpecificationList.swift b/Sources/AppwriteModels/SpecificationList.swift index f2b9766..f21bf7d 100644 --- a/Sources/AppwriteModels/SpecificationList.swift +++ b/Sources/AppwriteModels/SpecificationList.swift @@ -47,8 +47,8 @@ open class SpecificationList: Codable { public static func from(map: [String: Any] ) -> SpecificationList { return SpecificationList( - total: map["total"] as! Int, - specifications: (map["specifications"] as! [[String: Any]]).map { Specification.from(map: $0) } + total: map["total"] as? Int ?? 0, + specifications: (map["specifications"] as? [[String: Any]] ?? []).map { Specification.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Subscriber.swift b/Sources/AppwriteModels/Subscriber.swift index ad6fa5d..f0a399c 100644 --- a/Sources/AppwriteModels/Subscriber.swift +++ b/Sources/AppwriteModels/Subscriber.swift @@ -110,15 +110,15 @@ open class Subscriber: Codable { public static func from(map: [String: Any] ) -> Subscriber { return Subscriber( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - targetId: map["targetId"] as! String, - target: Target.from(map: map["target"] as! [String: Any]), - userId: map["userId"] as! String, - userName: map["userName"] as! String, - topicId: map["topicId"] as! String, - providerType: map["providerType"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + targetId: map["targetId"] as? String ?? "", + target: map["target"] != nil ? Target.from(map: map["target"] as! [String: Any]) : Target(), + userId: map["userId"] as? String ?? "", + userName: map["userName"] as? String ?? "", + topicId: map["topicId"] as? String ?? "", + providerType: map["providerType"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/SubscriberList.swift b/Sources/AppwriteModels/SubscriberList.swift index 2d63f07..486938f 100644 --- a/Sources/AppwriteModels/SubscriberList.swift +++ b/Sources/AppwriteModels/SubscriberList.swift @@ -47,8 +47,8 @@ open class SubscriberList: Codable { public static func from(map: [String: Any] ) -> SubscriberList { return SubscriberList( - total: map["total"] as! Int, - subscribers: (map["subscribers"] as! [[String: Any]]).map { Subscriber.from(map: $0) } + total: map["total"] as? Int ?? 0, + subscribers: (map["subscribers"] as? [[String: Any]] ?? []).map { Subscriber.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Target.swift b/Sources/AppwriteModels/Target.swift index 0581a61..6e34abd 100644 --- a/Sources/AppwriteModels/Target.swift +++ b/Sources/AppwriteModels/Target.swift @@ -110,15 +110,15 @@ open class Target: Codable { public static func from(map: [String: Any] ) -> Target { return Target( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - name: map["name"] as! String, - userId: map["userId"] as! String, + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + name: map["name"] as? String ?? "", + userId: map["userId"] as? String ?? "", providerId: map["providerId"] as? String, - providerType: map["providerType"] as! String, - identifier: map["identifier"] as! String, - expired: map["expired"] as! Bool + providerType: map["providerType"] as? String ?? "", + identifier: map["identifier"] as? String ?? "", + expired: map["expired"] as? Bool ?? false ) } } diff --git a/Sources/AppwriteModels/TargetList.swift b/Sources/AppwriteModels/TargetList.swift index 6c9f247..f5fb597 100644 --- a/Sources/AppwriteModels/TargetList.swift +++ b/Sources/AppwriteModels/TargetList.swift @@ -47,8 +47,8 @@ open class TargetList: Codable { public static func from(map: [String: Any] ) -> TargetList { return TargetList( - total: map["total"] as! Int, - targets: (map["targets"] as! [[String: Any]]).map { Target.from(map: $0) } + total: map["total"] as? Int ?? 0, + targets: (map["targets"] as? [[String: Any]] ?? []).map { Target.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Team.swift b/Sources/AppwriteModels/Team.swift index 9ca7307..052debe 100644 --- a/Sources/AppwriteModels/Team.swift +++ b/Sources/AppwriteModels/Team.swift @@ -83,12 +83,12 @@ open class Team: Codable { public static func from(map: [String: Any] ) -> Team { return Team( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - name: map["name"] as! String, - total: map["total"] as! Int, - prefs: Preferences.from(map: map["prefs"] as! [String: Any]) + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + name: map["name"] as? String ?? "", + total: map["total"] as? Int ?? 0, + prefs: map["prefs"] != nil ? Preferences.from(map: map["prefs"] as! [String: Any]) : Preferences() ) } } diff --git a/Sources/AppwriteModels/TeamList.swift b/Sources/AppwriteModels/TeamList.swift index 384d9f6..aaa02af 100644 --- a/Sources/AppwriteModels/TeamList.swift +++ b/Sources/AppwriteModels/TeamList.swift @@ -47,8 +47,8 @@ open class TeamList: Codable { public static func from(map: [String: Any] ) -> TeamList { return TeamList( - total: map["total"] as! Int, - teams: (map["teams"] as! [[String: Any]]).map { Team.from(map: $0) } + total: map["total"] as? Int ?? 0, + teams: (map["teams"] as? [[String: Any]] ?? []).map { Team.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Token.swift b/Sources/AppwriteModels/Token.swift index f832402..1ded551 100644 --- a/Sources/AppwriteModels/Token.swift +++ b/Sources/AppwriteModels/Token.swift @@ -83,12 +83,12 @@ open class Token: Codable { public static func from(map: [String: Any] ) -> Token { return Token( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - userId: map["userId"] as! String, - secret: map["secret"] as! String, - expire: map["expire"] as! String, - phrase: map["phrase"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + userId: map["userId"] as? String ?? "", + secret: map["secret"] as? String ?? "", + expire: map["expire"] as? String ?? "", + phrase: map["phrase"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/Topic.swift b/Sources/AppwriteModels/Topic.swift index 4489abb..6c926f7 100644 --- a/Sources/AppwriteModels/Topic.swift +++ b/Sources/AppwriteModels/Topic.swift @@ -101,14 +101,14 @@ open class Topic: Codable { public static func from(map: [String: Any] ) -> Topic { return Topic( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - name: map["name"] as! String, - emailTotal: map["emailTotal"] as! Int, - smsTotal: map["smsTotal"] as! Int, - pushTotal: map["pushTotal"] as! Int, - subscribe: map["subscribe"] as! [String] + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + name: map["name"] as? String ?? "", + emailTotal: map["emailTotal"] as? Int ?? 0, + smsTotal: map["smsTotal"] as? Int ?? 0, + pushTotal: map["pushTotal"] as? Int ?? 0, + subscribe: map["subscribe"] as? [String] ?? [] ) } } diff --git a/Sources/AppwriteModels/TopicList.swift b/Sources/AppwriteModels/TopicList.swift index 66eae2c..58f264e 100644 --- a/Sources/AppwriteModels/TopicList.swift +++ b/Sources/AppwriteModels/TopicList.swift @@ -47,8 +47,8 @@ open class TopicList: Codable { public static func from(map: [String: Any] ) -> TopicList { return TopicList( - total: map["total"] as! Int, - topics: (map["topics"] as! [[String: Any]]).map { Topic.from(map: $0) } + total: map["total"] as? Int ?? 0, + topics: (map["topics"] as? [[String: Any]] ?? []).map { Topic.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/User.swift b/Sources/AppwriteModels/User.swift index 6e972d3..a519c76 100644 --- a/Sources/AppwriteModels/User.swift +++ b/Sources/AppwriteModels/User.swift @@ -200,25 +200,25 @@ open class User: Codable { public static func from(map: [String: Any] ) -> User { return User( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - name: map["name"] as! String, + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + name: map["name"] as? String ?? "", password: map["password"] as? String, hash: map["hash"] as? String, hashOptions: map["hashOptions"] as? [String: AnyCodable], - registration: map["registration"] as! String, - status: map["status"] as! Bool, - labels: map["labels"] as! [String], - passwordUpdate: map["passwordUpdate"] as! String, - email: map["email"] as! String, - phone: map["phone"] as! String, - emailVerification: map["emailVerification"] as! Bool, - phoneVerification: map["phoneVerification"] as! Bool, - mfa: map["mfa"] as! Bool, - prefs: Preferences.from(map: map["prefs"] as! [String: Any]), - targets: (map["targets"] as! [[String: Any]]).map { Target.from(map: $0) }, - accessedAt: map["accessedAt"] as! String + registration: map["registration"] as? String ?? "", + status: map["status"] as? Bool ?? false, + labels: map["labels"] as? [String] ?? [], + passwordUpdate: map["passwordUpdate"] as? String ?? "", + email: map["email"] as? String ?? "", + phone: map["phone"] as? String ?? "", + emailVerification: map["emailVerification"] as? Bool ?? false, + phoneVerification: map["phoneVerification"] as? Bool ?? false, + mfa: map["mfa"] as? Bool ?? false, + prefs: map["prefs"] != nil ? Preferences.from(map: map["prefs"] as! [String: Any]) : Preferences(), + targets: (map["targets"] as? [[String: Any]] ?? []).map { Target.from(map: $0) }, + accessedAt: map["accessedAt"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/UserList.swift b/Sources/AppwriteModels/UserList.swift index 7bf7413..55699c2 100644 --- a/Sources/AppwriteModels/UserList.swift +++ b/Sources/AppwriteModels/UserList.swift @@ -47,8 +47,8 @@ open class UserList: Codable { public static func from(map: [String: Any] ) -> UserList { return UserList( - total: map["total"] as! Int, - users: (map["users"] as! [[String: Any]]).map { User.from(map: $0) } + total: map["total"] as? Int ?? 0, + users: (map["users"] as? [[String: Any]] ?? []).map { User.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Variable.swift b/Sources/AppwriteModels/Variable.swift index 662e7a3..7dc0690 100644 --- a/Sources/AppwriteModels/Variable.swift +++ b/Sources/AppwriteModels/Variable.swift @@ -101,14 +101,14 @@ open class Variable: Codable { public static func from(map: [String: Any] ) -> Variable { return Variable( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - key: map["key"] as! String, - value: map["value"] as! String, - secret: map["secret"] as! Bool, - resourceType: map["resourceType"] as! String, - resourceId: map["resourceId"] as! String + id: map["$id"] as? String ?? "", + createdAt: map["$createdAt"] as? String ?? "", + updatedAt: map["$updatedAt"] as? String ?? "", + key: map["key"] as? String ?? "", + value: map["value"] as? String ?? "", + secret: map["secret"] as? Bool ?? false, + resourceType: map["resourceType"] as? String ?? "", + resourceId: map["resourceId"] as? String ?? "" ) } } diff --git a/Sources/AppwriteModels/VariableList.swift b/Sources/AppwriteModels/VariableList.swift index 8345d0b..efc84cf 100644 --- a/Sources/AppwriteModels/VariableList.swift +++ b/Sources/AppwriteModels/VariableList.swift @@ -47,8 +47,8 @@ open class VariableList: Codable { public static func from(map: [String: Any] ) -> VariableList { return VariableList( - total: map["total"] as! Int, - variables: (map["variables"] as! [[String: Any]]).map { Variable.from(map: $0) } + total: map["total"] as? Int ?? 0, + variables: (map["variables"] as? [[String: Any]] ?? []).map { Variable.from(map: $0) } ) } } diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md new file mode 100644 index 0000000..e78bd45 --- /dev/null +++ b/docs/examples/databases/upsert-document.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let databases = Databases(client) + +let document = try await databases.upsertDocument( + databaseId: "", + collectionId: "", + documentId: "", + data: [:], + permissions: ["read("any")"] // optional +) + From 748ce4a7d3bb56b119167bf8488b0cb74dc48579 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 4 Jun 2025 06:34:42 +0000 Subject: [PATCH 2/4] chore: regenerate sdk --- README.md | 2 +- Sources/Appwrite/Client.swift | 2 +- Sources/Appwrite/Services/Databases.swift | 76 --------------------- Sources/AppwriteEnums/BuildRuntime.swift | 2 + Sources/AppwriteEnums/Runtime.swift | 2 + docs/examples/databases/create-documents.md | 14 ---- 6 files changed, 6 insertions(+), 92 deletions(-) delete mode 100644 docs/examples/databases/create-documents.md diff --git a/README.md b/README.md index ee38ac2..7de6f65 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: "10.0.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "10.1.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index bc05149..0436599 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": "10.0.0", + "x-sdk-version": "10.1.0", "x-appwrite-response-format": "1.7.0" ] diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index aae760f..ffcccd8 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -1655,82 +1655,6 @@ open class Databases: Service { ) } - /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// - /// Create new Documents. Before using this route, you should create a new - /// collection resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) - /// API or directly from your database console. - /// - /// @param String databaseId - /// @param String collectionId - /// @param [Any] documents - /// @throws Exception - /// @return array - /// - open func createDocuments( - databaseId: String, - collectionId: String, - documents: [Any], - nestedType: T.Type - ) async throws -> AppwriteModels.DocumentList { - let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents" - .replacingOccurrences(of: "{databaseId}", with: databaseId) - .replacingOccurrences(of: "{collectionId}", with: collectionId) - - let apiParams: [String: Any?] = [ - "documents": documents - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.DocumentList = { response in - return AppwriteModels.DocumentList.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "POST", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// - /// Create new Documents. Before using this route, you should create a new - /// collection resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) - /// API or directly from your database console. - /// - /// @param String databaseId - /// @param String collectionId - /// @param [Any] documents - /// @throws Exception - /// @return array - /// - open func createDocuments( - databaseId: String, - collectionId: String, - documents: [Any] - ) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> { - return try await createDocuments( - databaseId: databaseId, - collectionId: collectionId, - documents: documents, - nestedType: [String: AnyCodable].self - ) - } - /// /// **WARNING: Experimental Feature** - This endpoint is experimental and not /// yet officially supported. It may be subject to breaking changes or removal diff --git a/Sources/AppwriteEnums/BuildRuntime.swift b/Sources/AppwriteEnums/BuildRuntime.swift index 90ca969..dc9b179 100644 --- a/Sources/AppwriteEnums/BuildRuntime.swift +++ b/Sources/AppwriteEnums/BuildRuntime.swift @@ -38,6 +38,7 @@ public enum BuildRuntime: String, CustomStringConvertible { case dart31 = "dart-3.1" case dart33 = "dart-3.3" case dart35 = "dart-3.5" + case dart38 = "dart-3.8" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" case dotnet80 = "dotnet-8.0" @@ -64,6 +65,7 @@ public enum BuildRuntime: String, CustomStringConvertible { case flutter324 = "flutter-3.24" case flutter327 = "flutter-3.27" case flutter329 = "flutter-3.29" + case flutter332 = "flutter-3.32" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/Runtime.swift b/Sources/AppwriteEnums/Runtime.swift index 5a6cccf..a461f31 100644 --- a/Sources/AppwriteEnums/Runtime.swift +++ b/Sources/AppwriteEnums/Runtime.swift @@ -38,6 +38,7 @@ public enum Runtime: String, CustomStringConvertible { case dart31 = "dart-3.1" case dart33 = "dart-3.3" case dart35 = "dart-3.5" + case dart38 = "dart-3.8" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" case dotnet80 = "dotnet-8.0" @@ -64,6 +65,7 @@ public enum Runtime: String, CustomStringConvertible { case flutter324 = "flutter-3.24" case flutter327 = "flutter-3.27" case flutter329 = "flutter-3.29" + case flutter332 = "flutter-3.32" public var description: String { return rawValue diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md deleted file mode 100644 index 39a58ab..0000000 --- a/docs/examples/databases/create-documents.md +++ /dev/null @@ -1,14 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setKey("") // Your secret API key - -let databases = Databases(client) - -let documentList = try await databases.createDocuments( - databaseId: "", - collectionId: "", - documents: [] -) - From a0b6b69a3cae071e98c0d89157d5acfd2a04aba1 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 4 Jun 2025 06:48:10 +0000 Subject: [PATCH 3/4] chore: regenerate sdk --- Sources/AppwriteModels/AlgoArgon2.swift | 8 +-- Sources/AppwriteModels/AlgoBcrypt.swift | 2 +- Sources/AppwriteModels/AlgoMd5.swift | 2 +- Sources/AppwriteModels/AlgoPhpass.swift | 2 +- Sources/AppwriteModels/AlgoScrypt.swift | 10 ++-- .../AppwriteModels/AlgoScryptModified.swift | 8 +-- Sources/AppwriteModels/AlgoSha.swift | 2 +- Sources/AppwriteModels/AttributeBoolean.swift | 14 ++--- .../AppwriteModels/AttributeDatetime.swift | 16 ++--- Sources/AppwriteModels/AttributeEmail.swift | 16 ++--- Sources/AppwriteModels/AttributeEnum.swift | 18 +++--- Sources/AppwriteModels/AttributeFloat.swift | 14 ++--- Sources/AppwriteModels/AttributeInteger.swift | 14 ++--- Sources/AppwriteModels/AttributeIp.swift | 16 ++--- Sources/AppwriteModels/AttributeList.swift | 4 +- .../AttributeRelationship.swift | 26 ++++----- Sources/AppwriteModels/AttributeString.swift | 16 ++--- Sources/AppwriteModels/AttributeUrl.swift | 16 ++--- Sources/AppwriteModels/Bucket.swift | 24 ++++---- Sources/AppwriteModels/BucketList.swift | 4 +- Sources/AppwriteModels/Collection.swift | 20 +++---- Sources/AppwriteModels/CollectionList.swift | 4 +- Sources/AppwriteModels/Continent.swift | 4 +- Sources/AppwriteModels/ContinentList.swift | 4 +- Sources/AppwriteModels/Country.swift | 4 +- Sources/AppwriteModels/CountryList.swift | 4 +- Sources/AppwriteModels/Currency.swift | 14 ++--- Sources/AppwriteModels/CurrencyList.swift | 4 +- Sources/AppwriteModels/Database.swift | 10 ++-- Sources/AppwriteModels/DatabaseList.swift | 4 +- Sources/AppwriteModels/Deployment.swift | 54 ++++++++--------- Sources/AppwriteModels/DeploymentList.swift | 4 +- Sources/AppwriteModels/Document.swift | 2 +- Sources/AppwriteModels/DocumentList.swift | 4 +- Sources/AppwriteModels/Execution.swift | 32 +++++----- Sources/AppwriteModels/ExecutionList.swift | 4 +- Sources/AppwriteModels/File.swift | 22 +++---- Sources/AppwriteModels/FileList.swift | 4 +- Sources/AppwriteModels/Framework.swift | 10 ++-- Sources/AppwriteModels/FrameworkAdapter.swift | 10 ++-- Sources/AppwriteModels/FrameworkList.swift | 4 +- Sources/AppwriteModels/Function.swift | 56 +++++++++--------- Sources/AppwriteModels/FunctionList.swift | 4 +- Sources/AppwriteModels/Headers.swift | 4 +- Sources/AppwriteModels/HealthAntivirus.swift | 4 +- .../AppwriteModels/HealthCertificate.swift | 12 ++-- Sources/AppwriteModels/HealthQueue.swift | 2 +- Sources/AppwriteModels/HealthStatus.swift | 6 +- Sources/AppwriteModels/HealthTime.swift | 6 +- Sources/AppwriteModels/Identity.swift | 20 +++---- Sources/AppwriteModels/IdentityList.swift | 4 +- Sources/AppwriteModels/Index.swift | 16 ++--- Sources/AppwriteModels/IndexList.swift | 4 +- Sources/AppwriteModels/Jwt.swift | 2 +- Sources/AppwriteModels/Language.swift | 6 +- Sources/AppwriteModels/LanguageList.swift | 4 +- Sources/AppwriteModels/Locale.swift | 14 ++--- Sources/AppwriteModels/LocaleCode.swift | 4 +- Sources/AppwriteModels/LocaleCodeList.swift | 4 +- Sources/AppwriteModels/Log.swift | 42 +++++++------- Sources/AppwriteModels/LogList.swift | 4 +- Sources/AppwriteModels/Membership.swift | 26 ++++----- Sources/AppwriteModels/MembershipList.swift | 4 +- Sources/AppwriteModels/Message.swift | 20 +++---- Sources/AppwriteModels/MessageList.swift | 4 +- Sources/AppwriteModels/MfaChallenge.swift | 8 +-- Sources/AppwriteModels/MfaFactors.swift | 8 +-- Sources/AppwriteModels/MfaRecoveryCodes.swift | 2 +- Sources/AppwriteModels/MfaType.swift | 4 +- Sources/AppwriteModels/Phone.swift | 6 +- Sources/AppwriteModels/PhoneList.swift | 4 +- Sources/AppwriteModels/Preferences.swift | 2 +- Sources/AppwriteModels/Provider.swift | 16 ++--- Sources/AppwriteModels/ProviderList.swift | 4 +- Sources/AppwriteModels/ResourceToken.swift | 14 ++--- .../AppwriteModels/ResourceTokenList.swift | 4 +- Sources/AppwriteModels/Runtime.swift | 16 ++--- Sources/AppwriteModels/RuntimeList.swift | 4 +- Sources/AppwriteModels/Session.swift | 58 +++++++++---------- Sources/AppwriteModels/SessionList.swift | 4 +- Sources/AppwriteModels/Site.swift | 58 +++++++++---------- Sources/AppwriteModels/SiteList.swift | 4 +- Sources/AppwriteModels/Specification.swift | 8 +-- .../AppwriteModels/SpecificationList.swift | 4 +- Sources/AppwriteModels/Subscriber.swift | 18 +++--- Sources/AppwriteModels/SubscriberList.swift | 4 +- Sources/AppwriteModels/Target.swift | 16 ++--- Sources/AppwriteModels/TargetList.swift | 4 +- Sources/AppwriteModels/Team.swift | 12 ++-- Sources/AppwriteModels/TeamList.swift | 4 +- Sources/AppwriteModels/Token.swift | 12 ++-- Sources/AppwriteModels/Topic.swift | 16 ++--- Sources/AppwriteModels/TopicList.swift | 4 +- Sources/AppwriteModels/User.swift | 32 +++++----- Sources/AppwriteModels/UserList.swift | 4 +- Sources/AppwriteModels/Variable.swift | 16 ++--- Sources/AppwriteModels/VariableList.swift | 4 +- 97 files changed, 550 insertions(+), 550 deletions(-) diff --git a/Sources/AppwriteModels/AlgoArgon2.swift b/Sources/AppwriteModels/AlgoArgon2.swift index 5411998..fd88955 100644 --- a/Sources/AppwriteModels/AlgoArgon2.swift +++ b/Sources/AppwriteModels/AlgoArgon2.swift @@ -65,10 +65,10 @@ open class AlgoArgon2: Codable { public static func from(map: [String: Any] ) -> AlgoArgon2 { return AlgoArgon2( - type: map["type"] as? String ?? "", - memoryCost: map["memoryCost"] as? Int ?? 0, - timeCost: map["timeCost"] as? Int ?? 0, - threads: map["threads"] as? Int ?? 0 + type: map["type"] as! String, + memoryCost: map["memoryCost"] as! Int, + timeCost: map["timeCost"] as! Int, + threads: map["threads"] as! Int ) } } diff --git a/Sources/AppwriteModels/AlgoBcrypt.swift b/Sources/AppwriteModels/AlgoBcrypt.swift index 3bd7061..b34095d 100644 --- a/Sources/AppwriteModels/AlgoBcrypt.swift +++ b/Sources/AppwriteModels/AlgoBcrypt.swift @@ -38,7 +38,7 @@ open class AlgoBcrypt: Codable { public static func from(map: [String: Any] ) -> AlgoBcrypt { return AlgoBcrypt( - type: map["type"] as? String ?? "" + type: map["type"] as! String ) } } diff --git a/Sources/AppwriteModels/AlgoMd5.swift b/Sources/AppwriteModels/AlgoMd5.swift index 2d8b6f5..72fbb8d 100644 --- a/Sources/AppwriteModels/AlgoMd5.swift +++ b/Sources/AppwriteModels/AlgoMd5.swift @@ -38,7 +38,7 @@ open class AlgoMd5: Codable { public static func from(map: [String: Any] ) -> AlgoMd5 { return AlgoMd5( - type: map["type"] as? String ?? "" + type: map["type"] as! String ) } } diff --git a/Sources/AppwriteModels/AlgoPhpass.swift b/Sources/AppwriteModels/AlgoPhpass.swift index 20d70c1..7bd0c99 100644 --- a/Sources/AppwriteModels/AlgoPhpass.swift +++ b/Sources/AppwriteModels/AlgoPhpass.swift @@ -38,7 +38,7 @@ open class AlgoPhpass: Codable { public static func from(map: [String: Any] ) -> AlgoPhpass { return AlgoPhpass( - type: map["type"] as? String ?? "" + type: map["type"] as! String ) } } diff --git a/Sources/AppwriteModels/AlgoScrypt.swift b/Sources/AppwriteModels/AlgoScrypt.swift index 21500cb..03ce541 100644 --- a/Sources/AppwriteModels/AlgoScrypt.swift +++ b/Sources/AppwriteModels/AlgoScrypt.swift @@ -74,11 +74,11 @@ open class AlgoScrypt: Codable { public static func from(map: [String: Any] ) -> AlgoScrypt { return AlgoScrypt( - type: map["type"] as? String ?? "", - costCpu: map["costCpu"] as? Int ?? 0, - costMemory: map["costMemory"] as? Int ?? 0, - costParallel: map["costParallel"] as? Int ?? 0, - length: map["length"] as? Int ?? 0 + type: map["type"] as! String, + costCpu: map["costCpu"] as! Int, + costMemory: map["costMemory"] as! Int, + costParallel: map["costParallel"] as! Int, + length: map["length"] as! Int ) } } diff --git a/Sources/AppwriteModels/AlgoScryptModified.swift b/Sources/AppwriteModels/AlgoScryptModified.swift index bede143..0b2fa4e 100644 --- a/Sources/AppwriteModels/AlgoScryptModified.swift +++ b/Sources/AppwriteModels/AlgoScryptModified.swift @@ -65,10 +65,10 @@ open class AlgoScryptModified: Codable { public static func from(map: [String: Any] ) -> AlgoScryptModified { return AlgoScryptModified( - type: map["type"] as? String ?? "", - salt: map["salt"] as? String ?? "", - saltSeparator: map["saltSeparator"] as? String ?? "", - signerKey: map["signerKey"] as? String ?? "" + type: map["type"] as! String, + salt: map["salt"] as! String, + saltSeparator: map["saltSeparator"] as! String, + signerKey: map["signerKey"] as! String ) } } diff --git a/Sources/AppwriteModels/AlgoSha.swift b/Sources/AppwriteModels/AlgoSha.swift index 6a3be42..ffc0e05 100644 --- a/Sources/AppwriteModels/AlgoSha.swift +++ b/Sources/AppwriteModels/AlgoSha.swift @@ -38,7 +38,7 @@ open class AlgoSha: Codable { public static func from(map: [String: Any] ) -> AlgoSha { return AlgoSha( - type: map["type"] as? String ?? "" + type: map["type"] as! String ) } } diff --git a/Sources/AppwriteModels/AttributeBoolean.swift b/Sources/AppwriteModels/AttributeBoolean.swift index 8d09404..31522c2 100644 --- a/Sources/AppwriteModels/AttributeBoolean.swift +++ b/Sources/AppwriteModels/AttributeBoolean.swift @@ -110,14 +110,14 @@ open class AttributeBoolean: Codable { public static func from(map: [String: Any] ) -> AttributeBoolean { return AttributeBoolean( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, `default`: map["default"] as? Bool ) } diff --git a/Sources/AppwriteModels/AttributeDatetime.swift b/Sources/AppwriteModels/AttributeDatetime.swift index b664628..ac80231 100644 --- a/Sources/AppwriteModels/AttributeDatetime.swift +++ b/Sources/AppwriteModels/AttributeDatetime.swift @@ -119,15 +119,15 @@ open class AttributeDatetime: Codable { public static func from(map: [String: Any] ) -> AttributeDatetime { return AttributeDatetime( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - format: map["format"] as? String ?? "", + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + format: map["format"] as! String, `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/AttributeEmail.swift b/Sources/AppwriteModels/AttributeEmail.swift index 8e2298a..8e57b2c 100644 --- a/Sources/AppwriteModels/AttributeEmail.swift +++ b/Sources/AppwriteModels/AttributeEmail.swift @@ -119,15 +119,15 @@ open class AttributeEmail: Codable { public static func from(map: [String: Any] ) -> AttributeEmail { return AttributeEmail( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - format: map["format"] as? String ?? "", + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + format: map["format"] as! String, `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/AttributeEnum.swift b/Sources/AppwriteModels/AttributeEnum.swift index e2367ba..e232869 100644 --- a/Sources/AppwriteModels/AttributeEnum.swift +++ b/Sources/AppwriteModels/AttributeEnum.swift @@ -128,16 +128,16 @@ open class AttributeEnum: Codable { public static func from(map: [String: Any] ) -> AttributeEnum { return AttributeEnum( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - elements: map["elements"] as? [String] ?? [], - format: map["format"] as? String ?? "", + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + elements: map["elements"] as! [String], + format: map["format"] as! String, `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/AttributeFloat.swift b/Sources/AppwriteModels/AttributeFloat.swift index fbcbdb3..676f317 100644 --- a/Sources/AppwriteModels/AttributeFloat.swift +++ b/Sources/AppwriteModels/AttributeFloat.swift @@ -128,14 +128,14 @@ open class AttributeFloat: Codable { public static func from(map: [String: Any] ) -> AttributeFloat { return AttributeFloat( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, min: map["min"] as? Double, max: map["max"] as? Double, `default`: map["default"] as? Double diff --git a/Sources/AppwriteModels/AttributeInteger.swift b/Sources/AppwriteModels/AttributeInteger.swift index fd8ff33..06d3a69 100644 --- a/Sources/AppwriteModels/AttributeInteger.swift +++ b/Sources/AppwriteModels/AttributeInteger.swift @@ -128,14 +128,14 @@ open class AttributeInteger: Codable { public static func from(map: [String: Any] ) -> AttributeInteger { return AttributeInteger( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, min: map["min"] as? Int, max: map["max"] as? Int, `default`: map["default"] as? Int diff --git a/Sources/AppwriteModels/AttributeIp.swift b/Sources/AppwriteModels/AttributeIp.swift index 4c96f72..7904155 100644 --- a/Sources/AppwriteModels/AttributeIp.swift +++ b/Sources/AppwriteModels/AttributeIp.swift @@ -119,15 +119,15 @@ open class AttributeIp: Codable { public static func from(map: [String: Any] ) -> AttributeIp { return AttributeIp( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - format: map["format"] as? String ?? "", + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + format: map["format"] as! String, `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/AttributeList.swift b/Sources/AppwriteModels/AttributeList.swift index fa252fa..8789c6c 100644 --- a/Sources/AppwriteModels/AttributeList.swift +++ b/Sources/AppwriteModels/AttributeList.swift @@ -47,8 +47,8 @@ open class AttributeList: Codable { public static func from(map: [String: Any] ) -> AttributeList { return AttributeList( - total: map["total"] as? Int ?? 0, - attributes: (map["attributes"] as? [Any] ?? []).map { AnyCodable($0) } + total: map["total"] as! Int, + attributes: (map["attributes"] as! [Any]).map { AnyCodable($0) } ) } } diff --git a/Sources/AppwriteModels/AttributeRelationship.swift b/Sources/AppwriteModels/AttributeRelationship.swift index 73c1cb1..a1f8cd7 100644 --- a/Sources/AppwriteModels/AttributeRelationship.swift +++ b/Sources/AppwriteModels/AttributeRelationship.swift @@ -155,20 +155,20 @@ open class AttributeRelationship: Codable { public static func from(map: [String: Any] ) -> AttributeRelationship { return AttributeRelationship( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - relatedCollection: map["relatedCollection"] as? String ?? "", - relationType: map["relationType"] as? String ?? "", - twoWay: map["twoWay"] as? Bool ?? false, - twoWayKey: map["twoWayKey"] as? String ?? "", - onDelete: map["onDelete"] as? String ?? "", - side: map["side"] as? String ?? "" + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + relatedCollection: map["relatedCollection"] as! String, + relationType: map["relationType"] as! String, + twoWay: map["twoWay"] as! Bool, + twoWayKey: map["twoWayKey"] as! String, + onDelete: map["onDelete"] as! String, + side: map["side"] as! String ) } } diff --git a/Sources/AppwriteModels/AttributeString.swift b/Sources/AppwriteModels/AttributeString.swift index 395c19b..9ed9acc 100644 --- a/Sources/AppwriteModels/AttributeString.swift +++ b/Sources/AppwriteModels/AttributeString.swift @@ -128,15 +128,15 @@ open class AttributeString: Codable { public static func from(map: [String: Any] ) -> AttributeString { return AttributeString( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - size: map["size"] as? Int ?? 0, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + size: map["size"] as! Int, `default`: map["default"] as? String, encrypt: map["encrypt"] as? Bool ) diff --git a/Sources/AppwriteModels/AttributeUrl.swift b/Sources/AppwriteModels/AttributeUrl.swift index 7cd2900..cfbeac5 100644 --- a/Sources/AppwriteModels/AttributeUrl.swift +++ b/Sources/AppwriteModels/AttributeUrl.swift @@ -119,15 +119,15 @@ open class AttributeUrl: Codable { public static func from(map: [String: Any] ) -> AttributeUrl { return AttributeUrl( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - `required`: map["required"] as? Bool ?? false, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + `required`: map["required"] as! Bool, array: map["array"] as? Bool, - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - format: map["format"] as? String ?? "", + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + format: map["format"] as! String, `default`: map["default"] as? String ) } diff --git a/Sources/AppwriteModels/Bucket.swift b/Sources/AppwriteModels/Bucket.swift index e33b59b..be437f5 100644 --- a/Sources/AppwriteModels/Bucket.swift +++ b/Sources/AppwriteModels/Bucket.swift @@ -137,18 +137,18 @@ open class Bucket: Codable { public static func from(map: [String: Any] ) -> Bucket { return Bucket( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - permissions: map["$permissions"] as? [String] ?? [], - fileSecurity: map["fileSecurity"] as? Bool ?? false, - name: map["name"] as? String ?? "", - enabled: map["enabled"] as? Bool ?? false, - maximumFileSize: map["maximumFileSize"] as? Int ?? 0, - allowedFileExtensions: map["allowedFileExtensions"] as? [String] ?? [], - compression: map["compression"] as? String ?? "", - encryption: map["encryption"] as? Bool ?? false, - antivirus: map["antivirus"] as? Bool ?? false + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + fileSecurity: map["fileSecurity"] as! Bool, + name: map["name"] as! String, + enabled: map["enabled"] as! Bool, + maximumFileSize: map["maximumFileSize"] as! Int, + allowedFileExtensions: map["allowedFileExtensions"] as! [String], + compression: map["compression"] as! String, + encryption: map["encryption"] as! Bool, + antivirus: map["antivirus"] as! Bool ) } } diff --git a/Sources/AppwriteModels/BucketList.swift b/Sources/AppwriteModels/BucketList.swift index c721674..8fca4e4 100644 --- a/Sources/AppwriteModels/BucketList.swift +++ b/Sources/AppwriteModels/BucketList.swift @@ -47,8 +47,8 @@ open class BucketList: Codable { public static func from(map: [String: Any] ) -> BucketList { return BucketList( - total: map["total"] as? Int ?? 0, - buckets: (map["buckets"] as? [[String: Any]] ?? []).map { Bucket.from(map: $0) } + total: map["total"] as! Int, + buckets: (map["buckets"] as! [[String: Any]]).map { Bucket.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Collection.swift b/Sources/AppwriteModels/Collection.swift index 2e8394c..ad7ab94 100644 --- a/Sources/AppwriteModels/Collection.swift +++ b/Sources/AppwriteModels/Collection.swift @@ -119,16 +119,16 @@ open class Collection: Codable { public static func from(map: [String: Any] ) -> Collection { return Collection( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - permissions: map["$permissions"] as? [String] ?? [], - databaseId: map["databaseId"] as? String ?? "", - name: map["name"] as? String ?? "", - enabled: map["enabled"] as? Bool ?? false, - documentSecurity: map["documentSecurity"] as? Bool ?? false, - attributes: (map["attributes"] as? [Any] ?? []).map { AnyCodable($0) }, - indexes: (map["indexes"] as? [[String: Any]] ?? []).map { Index.from(map: $0) } + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + databaseId: map["databaseId"] as! String, + name: map["name"] as! String, + enabled: map["enabled"] as! Bool, + documentSecurity: map["documentSecurity"] as! Bool, + attributes: (map["attributes"] as! [Any]).map { AnyCodable($0) }, + indexes: (map["indexes"] as! [[String: Any]]).map { Index.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/CollectionList.swift b/Sources/AppwriteModels/CollectionList.swift index 3c86ee8..f5f383f 100644 --- a/Sources/AppwriteModels/CollectionList.swift +++ b/Sources/AppwriteModels/CollectionList.swift @@ -47,8 +47,8 @@ open class CollectionList: Codable { public static func from(map: [String: Any] ) -> CollectionList { return CollectionList( - total: map["total"] as? Int ?? 0, - collections: (map["collections"] as? [[String: Any]] ?? []).map { Collection.from(map: $0) } + total: map["total"] as! Int, + collections: (map["collections"] as! [[String: Any]]).map { Collection.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Continent.swift b/Sources/AppwriteModels/Continent.swift index 64836ae..b8994d9 100644 --- a/Sources/AppwriteModels/Continent.swift +++ b/Sources/AppwriteModels/Continent.swift @@ -47,8 +47,8 @@ open class Continent: Codable { public static func from(map: [String: Any] ) -> Continent { return Continent( - name: map["name"] as? String ?? "", - code: map["code"] as? String ?? "" + name: map["name"] as! String, + code: map["code"] as! String ) } } diff --git a/Sources/AppwriteModels/ContinentList.swift b/Sources/AppwriteModels/ContinentList.swift index a924595..fa9a90f 100644 --- a/Sources/AppwriteModels/ContinentList.swift +++ b/Sources/AppwriteModels/ContinentList.swift @@ -47,8 +47,8 @@ open class ContinentList: Codable { public static func from(map: [String: Any] ) -> ContinentList { return ContinentList( - total: map["total"] as? Int ?? 0, - continents: (map["continents"] as? [[String: Any]] ?? []).map { Continent.from(map: $0) } + total: map["total"] as! Int, + continents: (map["continents"] as! [[String: Any]]).map { Continent.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Country.swift b/Sources/AppwriteModels/Country.swift index 353da83..c24f7e9 100644 --- a/Sources/AppwriteModels/Country.swift +++ b/Sources/AppwriteModels/Country.swift @@ -47,8 +47,8 @@ open class Country: Codable { public static func from(map: [String: Any] ) -> Country { return Country( - name: map["name"] as? String ?? "", - code: map["code"] as? String ?? "" + name: map["name"] as! String, + code: map["code"] as! String ) } } diff --git a/Sources/AppwriteModels/CountryList.swift b/Sources/AppwriteModels/CountryList.swift index c6526fa..865cc19 100644 --- a/Sources/AppwriteModels/CountryList.swift +++ b/Sources/AppwriteModels/CountryList.swift @@ -47,8 +47,8 @@ open class CountryList: Codable { public static func from(map: [String: Any] ) -> CountryList { return CountryList( - total: map["total"] as? Int ?? 0, - countries: (map["countries"] as? [[String: Any]] ?? []).map { Country.from(map: $0) } + total: map["total"] as! Int, + countries: (map["countries"] as! [[String: Any]]).map { Country.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Currency.swift b/Sources/AppwriteModels/Currency.swift index dc67525..320337b 100644 --- a/Sources/AppwriteModels/Currency.swift +++ b/Sources/AppwriteModels/Currency.swift @@ -92,13 +92,13 @@ open class Currency: Codable { public static func from(map: [String: Any] ) -> Currency { return Currency( - symbol: map["symbol"] as? String ?? "", - name: map["name"] as? String ?? "", - symbolNative: map["symbolNative"] as? String ?? "", - decimalDigits: map["decimalDigits"] as? Int ?? 0, - rounding: map["rounding"] as? Double ?? 0.0, - code: map["code"] as? String ?? "", - namePlural: map["namePlural"] as? String ?? "" + symbol: map["symbol"] as! String, + name: map["name"] as! String, + symbolNative: map["symbolNative"] as! String, + decimalDigits: map["decimalDigits"] as! Int, + rounding: map["rounding"] as! Double, + code: map["code"] as! String, + namePlural: map["namePlural"] as! String ) } } diff --git a/Sources/AppwriteModels/CurrencyList.swift b/Sources/AppwriteModels/CurrencyList.swift index 6c81124..1e0dff9 100644 --- a/Sources/AppwriteModels/CurrencyList.swift +++ b/Sources/AppwriteModels/CurrencyList.swift @@ -47,8 +47,8 @@ open class CurrencyList: Codable { public static func from(map: [String: Any] ) -> CurrencyList { return CurrencyList( - total: map["total"] as? Int ?? 0, - currencies: (map["currencies"] as? [[String: Any]] ?? []).map { Currency.from(map: $0) } + total: map["total"] as! Int, + currencies: (map["currencies"] as! [[String: Any]]).map { Currency.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Database.swift b/Sources/AppwriteModels/Database.swift index b987bef..c35c0b3 100644 --- a/Sources/AppwriteModels/Database.swift +++ b/Sources/AppwriteModels/Database.swift @@ -74,11 +74,11 @@ open class Database: Codable { public static func from(map: [String: Any] ) -> Database { return Database( - id: map["$id"] as? String ?? "", - name: map["name"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - enabled: map["enabled"] as? Bool ?? false + id: map["$id"] as! String, + name: map["name"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + enabled: map["enabled"] as! Bool ) } } diff --git a/Sources/AppwriteModels/DatabaseList.swift b/Sources/AppwriteModels/DatabaseList.swift index aa1d638..588cbaa 100644 --- a/Sources/AppwriteModels/DatabaseList.swift +++ b/Sources/AppwriteModels/DatabaseList.swift @@ -47,8 +47,8 @@ open class DatabaseList: Codable { public static func from(map: [String: Any] ) -> DatabaseList { return DatabaseList( - total: map["total"] as? Int ?? 0, - databases: (map["databases"] as? [[String: Any]] ?? []).map { Database.from(map: $0) } + total: map["total"] as! Int, + databases: (map["databases"] as! [[String: Any]]).map { Database.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Deployment.swift b/Sources/AppwriteModels/Deployment.swift index d41aa09..b2a183b 100644 --- a/Sources/AppwriteModels/Deployment.swift +++ b/Sources/AppwriteModels/Deployment.swift @@ -272,33 +272,33 @@ open class Deployment: Codable { public static func from(map: [String: Any] ) -> Deployment { return Deployment( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - type: map["type"] as? String ?? "", - resourceId: map["resourceId"] as? String ?? "", - resourceType: map["resourceType"] as? String ?? "", - entrypoint: map["entrypoint"] as? String ?? "", - sourceSize: map["sourceSize"] as? Int ?? 0, - buildSize: map["buildSize"] as? Int ?? 0, - totalSize: map["totalSize"] as? Int ?? 0, - buildId: map["buildId"] as? String ?? "", - activate: map["activate"] as? Bool ?? false, - screenshotLight: map["screenshotLight"] as? String ?? "", - screenshotDark: map["screenshotDark"] as? String ?? "", - status: map["status"] as? String ?? "", - buildLogs: map["buildLogs"] as? String ?? "", - buildDuration: map["buildDuration"] as? Int ?? 0, - providerRepositoryName: map["providerRepositoryName"] as? String ?? "", - providerRepositoryOwner: map["providerRepositoryOwner"] as? String ?? "", - providerRepositoryUrl: map["providerRepositoryUrl"] as? String ?? "", - providerBranch: map["providerBranch"] as? String ?? "", - providerCommitHash: map["providerCommitHash"] as? String ?? "", - providerCommitAuthorUrl: map["providerCommitAuthorUrl"] as? String ?? "", - providerCommitAuthor: map["providerCommitAuthor"] as? String ?? "", - providerCommitMessage: map["providerCommitMessage"] as? String ?? "", - providerCommitUrl: map["providerCommitUrl"] as? String ?? "", - providerBranchUrl: map["providerBranchUrl"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + type: map["type"] as! String, + resourceId: map["resourceId"] as! String, + resourceType: map["resourceType"] as! String, + entrypoint: map["entrypoint"] as! String, + sourceSize: map["sourceSize"] as! Int, + buildSize: map["buildSize"] as! Int, + totalSize: map["totalSize"] as! Int, + buildId: map["buildId"] as! String, + activate: map["activate"] as! Bool, + screenshotLight: map["screenshotLight"] as! String, + screenshotDark: map["screenshotDark"] as! String, + status: map["status"] as! String, + buildLogs: map["buildLogs"] as! String, + buildDuration: map["buildDuration"] as! Int, + providerRepositoryName: map["providerRepositoryName"] as! String, + providerRepositoryOwner: map["providerRepositoryOwner"] as! String, + providerRepositoryUrl: map["providerRepositoryUrl"] as! String, + providerBranch: map["providerBranch"] as! String, + providerCommitHash: map["providerCommitHash"] as! String, + providerCommitAuthorUrl: map["providerCommitAuthorUrl"] as! String, + providerCommitAuthor: map["providerCommitAuthor"] as! String, + providerCommitMessage: map["providerCommitMessage"] as! String, + providerCommitUrl: map["providerCommitUrl"] as! String, + providerBranchUrl: map["providerBranchUrl"] as! String ) } } diff --git a/Sources/AppwriteModels/DeploymentList.swift b/Sources/AppwriteModels/DeploymentList.swift index 15b469b..e218064 100644 --- a/Sources/AppwriteModels/DeploymentList.swift +++ b/Sources/AppwriteModels/DeploymentList.swift @@ -47,8 +47,8 @@ open class DeploymentList: Codable { public static func from(map: [String: Any] ) -> DeploymentList { return DeploymentList( - total: map["total"] as? Int ?? 0, - deployments: (map["deployments"] as? [[String: Any]] ?? []).map { Deployment.from(map: $0) } + total: map["total"] as! Int, + deployments: (map["deployments"] as! [[String: Any]]).map { Deployment.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Document.swift b/Sources/AppwriteModels/Document.swift index 8bd3416..744a03e 100644 --- a/Sources/AppwriteModels/Document.swift +++ b/Sources/AppwriteModels/Document.swift @@ -97,7 +97,7 @@ open class Document: Codable { createdAt: map["$createdAt"] as? String ?? "", updatedAt: map["$updatedAt"] as? String ?? "", permissions: map["$permissions"] as? [String] ?? [], - data: map["data"] != nil ? try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"]!, options: [])) : try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) ) } } diff --git a/Sources/AppwriteModels/DocumentList.swift b/Sources/AppwriteModels/DocumentList.swift index 93fc41d..a129182 100644 --- a/Sources/AppwriteModels/DocumentList.swift +++ b/Sources/AppwriteModels/DocumentList.swift @@ -47,8 +47,8 @@ open class DocumentList: Codable { public static func from(map: [String: Any] ) -> DocumentList { return DocumentList( - total: map["total"] as? Int ?? 0, - documents: (map["documents"] as? [[String: Any]] ?? []).map { Document.from(map: $0) } + total: map["total"] as! Int, + documents: (map["documents"] as! [[String: Any]]).map { Document.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 59017e4..6e81532 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -182,22 +182,22 @@ open class Execution: Codable { public static func from(map: [String: Any] ) -> Execution { return Execution( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - permissions: map["$permissions"] as? [String] ?? [], - functionId: map["functionId"] as? String ?? "", - trigger: map["trigger"] as? String ?? "", - status: 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) }, - responseStatusCode: map["responseStatusCode"] as? Int ?? 0, - responseBody: map["responseBody"] as? String ?? "", - responseHeaders: (map["responseHeaders"] as? [[String: Any]] ?? []).map { Headers.from(map: $0) }, - logs: map["logs"] as? String ?? "", - errors: map["errors"] as? String ?? "", - duration: map["duration"] as? Double ?? 0.0, + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + functionId: map["functionId"] as! String, + trigger: map["trigger"] as! String, + status: 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) }, + responseStatusCode: map["responseStatusCode"] as! Int, + responseBody: map["responseBody"] as! String, + responseHeaders: (map["responseHeaders"] as! [[String: Any]]).map { Headers.from(map: $0) }, + logs: map["logs"] as! String, + errors: map["errors"] as! String, + duration: map["duration"] as! Double, scheduledAt: map["scheduledAt"] as? String ) } diff --git a/Sources/AppwriteModels/ExecutionList.swift b/Sources/AppwriteModels/ExecutionList.swift index 8b7559d..72d43a6 100644 --- a/Sources/AppwriteModels/ExecutionList.swift +++ b/Sources/AppwriteModels/ExecutionList.swift @@ -47,8 +47,8 @@ open class ExecutionList: Codable { public static func from(map: [String: Any] ) -> ExecutionList { return ExecutionList( - total: map["total"] as? Int ?? 0, - executions: (map["executions"] as? [[String: Any]] ?? []).map { Execution.from(map: $0) } + total: map["total"] as! Int, + executions: (map["executions"] as! [[String: Any]]).map { Execution.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/File.swift b/Sources/AppwriteModels/File.swift index c68b701..713c7ca 100644 --- a/Sources/AppwriteModels/File.swift +++ b/Sources/AppwriteModels/File.swift @@ -128,17 +128,17 @@ open class File: Codable { public static func from(map: [String: Any] ) -> File { return File( - id: map["$id"] as? String ?? "", - bucketId: map["bucketId"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - permissions: map["$permissions"] as? [String] ?? [], - name: map["name"] as? String ?? "", - signature: map["signature"] as? String ?? "", - mimeType: map["mimeType"] as? String ?? "", - sizeOriginal: map["sizeOriginal"] as? Int ?? 0, - chunksTotal: map["chunksTotal"] as? Int ?? 0, - chunksUploaded: map["chunksUploaded"] as? Int ?? 0 + id: map["$id"] as! String, + bucketId: map["bucketId"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + name: map["name"] as! String, + signature: map["signature"] as! String, + mimeType: map["mimeType"] as! String, + sizeOriginal: map["sizeOriginal"] as! Int, + chunksTotal: map["chunksTotal"] as! Int, + chunksUploaded: map["chunksUploaded"] as! Int ) } } diff --git a/Sources/AppwriteModels/FileList.swift b/Sources/AppwriteModels/FileList.swift index a20ba7a..bec7b76 100644 --- a/Sources/AppwriteModels/FileList.swift +++ b/Sources/AppwriteModels/FileList.swift @@ -47,8 +47,8 @@ open class FileList: Codable { public static func from(map: [String: Any] ) -> FileList { return FileList( - total: map["total"] as? Int ?? 0, - files: (map["files"] as? [[String: Any]] ?? []).map { File.from(map: $0) } + total: map["total"] as! Int, + files: (map["files"] as! [[String: Any]]).map { File.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Framework.swift b/Sources/AppwriteModels/Framework.swift index cbe3744..9885e94 100644 --- a/Sources/AppwriteModels/Framework.swift +++ b/Sources/AppwriteModels/Framework.swift @@ -74,11 +74,11 @@ open class Framework: Codable { public static func from(map: [String: Any] ) -> Framework { return Framework( - key: map["key"] as? String ?? "", - name: map["name"] as? String ?? "", - buildRuntime: map["buildRuntime"] as? String ?? "", - runtimes: map["runtimes"] as? [String] ?? [], - adapters: (map["adapters"] as? [[String: Any]] ?? []).map { FrameworkAdapter.from(map: $0) } + key: map["key"] as! String, + name: map["name"] as! String, + buildRuntime: map["buildRuntime"] as! String, + runtimes: map["runtimes"] as! [String], + adapters: (map["adapters"] as! [[String: Any]]).map { FrameworkAdapter.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/FrameworkAdapter.swift b/Sources/AppwriteModels/FrameworkAdapter.swift index ec9b0bb..59348b4 100644 --- a/Sources/AppwriteModels/FrameworkAdapter.swift +++ b/Sources/AppwriteModels/FrameworkAdapter.swift @@ -74,11 +74,11 @@ open class FrameworkAdapter: Codable { public static func from(map: [String: Any] ) -> FrameworkAdapter { return FrameworkAdapter( - key: map["key"] as? String ?? "", - installCommand: map["installCommand"] as? String ?? "", - buildCommand: map["buildCommand"] as? String ?? "", - outputDirectory: map["outputDirectory"] as? String ?? "", - fallbackFile: map["fallbackFile"] as? String ?? "" + key: map["key"] as! String, + installCommand: map["installCommand"] as! String, + buildCommand: map["buildCommand"] as! String, + outputDirectory: map["outputDirectory"] as! String, + fallbackFile: map["fallbackFile"] as! String ) } } diff --git a/Sources/AppwriteModels/FrameworkList.swift b/Sources/AppwriteModels/FrameworkList.swift index 9674996..7aa2ce7 100644 --- a/Sources/AppwriteModels/FrameworkList.swift +++ b/Sources/AppwriteModels/FrameworkList.swift @@ -47,8 +47,8 @@ open class FrameworkList: Codable { public static func from(map: [String: Any] ) -> FrameworkList { return FrameworkList( - total: map["total"] as? Int ?? 0, - frameworks: (map["frameworks"] as? [[String: Any]] ?? []).map { Framework.from(map: $0) } + total: map["total"] as! Int, + frameworks: (map["frameworks"] as! [[String: Any]]).map { Framework.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Function.swift b/Sources/AppwriteModels/Function.swift index a5c9fbd..8df6078 100644 --- a/Sources/AppwriteModels/Function.swift +++ b/Sources/AppwriteModels/Function.swift @@ -281,34 +281,34 @@ open class Function: Codable { public static func from(map: [String: Any] ) -> Function { return Function( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - execute: map["execute"] as? [String] ?? [], - name: map["name"] as? String ?? "", - enabled: map["enabled"] as? Bool ?? false, - live: map["live"] as? Bool ?? false, - logging: map["logging"] as? Bool ?? false, - runtime: map["runtime"] as? String ?? "", - deploymentId: map["deploymentId"] as? String ?? "", - deploymentCreatedAt: map["deploymentCreatedAt"] as? String ?? "", - latestDeploymentId: map["latestDeploymentId"] as? String ?? "", - latestDeploymentCreatedAt: map["latestDeploymentCreatedAt"] as? String ?? "", - latestDeploymentStatus: map["latestDeploymentStatus"] as? String ?? "", - scopes: map["scopes"] as? [String] ?? [], - vars: (map["vars"] as? [[String: Any]] ?? []).map { Variable.from(map: $0) }, - events: map["events"] as? [String] ?? [], - schedule: map["schedule"] as? String ?? "", - timeout: map["timeout"] as? Int ?? 0, - entrypoint: map["entrypoint"] as? String ?? "", - commands: map["commands"] as? String ?? "", - version: map["version"] as? String ?? "", - installationId: map["installationId"] as? String ?? "", - providerRepositoryId: map["providerRepositoryId"] as? String ?? "", - providerBranch: map["providerBranch"] as? String ?? "", - providerRootDirectory: map["providerRootDirectory"] as? String ?? "", - providerSilentMode: map["providerSilentMode"] as? Bool ?? false, - specification: map["specification"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + execute: map["execute"] as! [String], + name: map["name"] as! String, + enabled: map["enabled"] as! Bool, + live: map["live"] as! Bool, + logging: map["logging"] as! Bool, + runtime: map["runtime"] as! String, + deploymentId: map["deploymentId"] as! String, + deploymentCreatedAt: map["deploymentCreatedAt"] as! String, + latestDeploymentId: map["latestDeploymentId"] as! String, + latestDeploymentCreatedAt: map["latestDeploymentCreatedAt"] as! String, + latestDeploymentStatus: map["latestDeploymentStatus"] as! String, + scopes: map["scopes"] as! [String], + vars: (map["vars"] as! [[String: Any]]).map { Variable.from(map: $0) }, + events: map["events"] as! [String], + schedule: map["schedule"] as! String, + timeout: map["timeout"] as! Int, + entrypoint: map["entrypoint"] as! String, + commands: map["commands"] as! String, + version: map["version"] as! String, + installationId: map["installationId"] as! String, + providerRepositoryId: map["providerRepositoryId"] as! String, + providerBranch: map["providerBranch"] as! String, + providerRootDirectory: map["providerRootDirectory"] as! String, + providerSilentMode: map["providerSilentMode"] as! Bool, + specification: map["specification"] as! String ) } } diff --git a/Sources/AppwriteModels/FunctionList.swift b/Sources/AppwriteModels/FunctionList.swift index e43b5b8..c00badb 100644 --- a/Sources/AppwriteModels/FunctionList.swift +++ b/Sources/AppwriteModels/FunctionList.swift @@ -47,8 +47,8 @@ open class FunctionList: Codable { public static func from(map: [String: Any] ) -> FunctionList { return FunctionList( - total: map["total"] as? Int ?? 0, - functions: (map["functions"] as? [[String: Any]] ?? []).map { Function.from(map: $0) } + total: map["total"] as! Int, + functions: (map["functions"] as! [[String: Any]]).map { Function.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Headers.swift b/Sources/AppwriteModels/Headers.swift index c09d36e..ae468e5 100644 --- a/Sources/AppwriteModels/Headers.swift +++ b/Sources/AppwriteModels/Headers.swift @@ -47,8 +47,8 @@ open class Headers: Codable { public static func from(map: [String: Any] ) -> Headers { return Headers( - name: map["name"] as? String ?? "", - value: map["value"] as? String ?? "" + name: map["name"] as! String, + value: map["value"] as! String ) } } diff --git a/Sources/AppwriteModels/HealthAntivirus.swift b/Sources/AppwriteModels/HealthAntivirus.swift index 79aefbe..a68bb36 100644 --- a/Sources/AppwriteModels/HealthAntivirus.swift +++ b/Sources/AppwriteModels/HealthAntivirus.swift @@ -47,8 +47,8 @@ open class HealthAntivirus: Codable { public static func from(map: [String: Any] ) -> HealthAntivirus { return HealthAntivirus( - version: map["version"] as? String ?? "", - status: map["status"] as? String ?? "" + version: map["version"] as! String, + status: map["status"] as! String ) } } diff --git a/Sources/AppwriteModels/HealthCertificate.swift b/Sources/AppwriteModels/HealthCertificate.swift index 4fe3c22..1ef3837 100644 --- a/Sources/AppwriteModels/HealthCertificate.swift +++ b/Sources/AppwriteModels/HealthCertificate.swift @@ -83,12 +83,12 @@ open class HealthCertificate: Codable { public static func from(map: [String: Any] ) -> HealthCertificate { return HealthCertificate( - name: map["name"] as? String ?? "", - subjectSN: map["subjectSN"] as? String ?? "", - issuerOrganisation: map["issuerOrganisation"] as? String ?? "", - validFrom: map["validFrom"] as? String ?? "", - validTo: map["validTo"] as? String ?? "", - signatureTypeSN: map["signatureTypeSN"] as? String ?? "" + name: map["name"] as! String, + subjectSN: map["subjectSN"] as! String, + issuerOrganisation: map["issuerOrganisation"] as! String, + validFrom: map["validFrom"] as! String, + validTo: map["validTo"] as! String, + signatureTypeSN: map["signatureTypeSN"] as! String ) } } diff --git a/Sources/AppwriteModels/HealthQueue.swift b/Sources/AppwriteModels/HealthQueue.swift index d5bf3cb..856a6d9 100644 --- a/Sources/AppwriteModels/HealthQueue.swift +++ b/Sources/AppwriteModels/HealthQueue.swift @@ -38,7 +38,7 @@ open class HealthQueue: Codable { public static func from(map: [String: Any] ) -> HealthQueue { return HealthQueue( - size: map["size"] as? Int ?? 0 + size: map["size"] as! Int ) } } diff --git a/Sources/AppwriteModels/HealthStatus.swift b/Sources/AppwriteModels/HealthStatus.swift index b33d1e9..8818778 100644 --- a/Sources/AppwriteModels/HealthStatus.swift +++ b/Sources/AppwriteModels/HealthStatus.swift @@ -56,9 +56,9 @@ open class HealthStatus: Codable { public static func from(map: [String: Any] ) -> HealthStatus { return HealthStatus( - name: map["name"] as? String ?? "", - ping: map["ping"] as? Int ?? 0, - status: map["status"] as? String ?? "" + name: map["name"] as! String, + ping: map["ping"] as! Int, + status: map["status"] as! String ) } } diff --git a/Sources/AppwriteModels/HealthTime.swift b/Sources/AppwriteModels/HealthTime.swift index 0323c07..aab020b 100644 --- a/Sources/AppwriteModels/HealthTime.swift +++ b/Sources/AppwriteModels/HealthTime.swift @@ -56,9 +56,9 @@ open class HealthTime: Codable { public static func from(map: [String: Any] ) -> HealthTime { return HealthTime( - remoteTime: map["remoteTime"] as? Int ?? 0, - localTime: map["localTime"] as? Int ?? 0, - diff: map["diff"] as? Int ?? 0 + remoteTime: map["remoteTime"] as! Int, + localTime: map["localTime"] as! Int, + diff: map["diff"] as! Int ) } } diff --git a/Sources/AppwriteModels/Identity.swift b/Sources/AppwriteModels/Identity.swift index 3f211b3..f93035d 100644 --- a/Sources/AppwriteModels/Identity.swift +++ b/Sources/AppwriteModels/Identity.swift @@ -119,16 +119,16 @@ open class Identity: Codable { public static func from(map: [String: Any] ) -> Identity { return Identity( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - userId: map["userId"] as? String ?? "", - provider: map["provider"] as? String ?? "", - providerUid: map["providerUid"] as? String ?? "", - providerEmail: map["providerEmail"] as? String ?? "", - providerAccessToken: map["providerAccessToken"] as? String ?? "", - providerAccessTokenExpiry: map["providerAccessTokenExpiry"] as? String ?? "", - providerRefreshToken: map["providerRefreshToken"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + userId: map["userId"] as! String, + provider: map["provider"] as! String, + providerUid: map["providerUid"] as! String, + providerEmail: map["providerEmail"] as! String, + providerAccessToken: map["providerAccessToken"] as! String, + providerAccessTokenExpiry: map["providerAccessTokenExpiry"] as! String, + providerRefreshToken: map["providerRefreshToken"] as! String ) } } diff --git a/Sources/AppwriteModels/IdentityList.swift b/Sources/AppwriteModels/IdentityList.swift index 8665233..6065fad 100644 --- a/Sources/AppwriteModels/IdentityList.swift +++ b/Sources/AppwriteModels/IdentityList.swift @@ -47,8 +47,8 @@ open class IdentityList: Codable { public static func from(map: [String: Any] ) -> IdentityList { return IdentityList( - total: map["total"] as? Int ?? 0, - identities: (map["identities"] as? [[String: Any]] ?? []).map { Identity.from(map: $0) } + total: map["total"] as! Int, + identities: (map["identities"] as! [[String: Any]]).map { Identity.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Index.swift b/Sources/AppwriteModels/Index.swift index f6f09e0..7b5fb13 100644 --- a/Sources/AppwriteModels/Index.swift +++ b/Sources/AppwriteModels/Index.swift @@ -110,15 +110,15 @@ open class Index: Codable { public static func from(map: [String: Any] ) -> Index { return Index( - key: map["key"] as? String ?? "", - type: map["type"] as? String ?? "", - status: map["status"] as? String ?? "", - error: map["error"] as? String ?? "", - attributes: map["attributes"] as? [String] ?? [], - lengths: map["lengths"] as? [Int] ?? [Int](), + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + attributes: map["attributes"] as! [String], + lengths: map["lengths"] as! [Int], orders: map["orders"] as? [String], - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "" + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String ) } } diff --git a/Sources/AppwriteModels/IndexList.swift b/Sources/AppwriteModels/IndexList.swift index d81532a..2f3ae30 100644 --- a/Sources/AppwriteModels/IndexList.swift +++ b/Sources/AppwriteModels/IndexList.swift @@ -47,8 +47,8 @@ open class IndexList: Codable { public static func from(map: [String: Any] ) -> IndexList { return IndexList( - total: map["total"] as? Int ?? 0, - indexes: (map["indexes"] as? [[String: Any]] ?? []).map { Index.from(map: $0) } + total: map["total"] as! Int, + indexes: (map["indexes"] as! [[String: Any]]).map { Index.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Jwt.swift b/Sources/AppwriteModels/Jwt.swift index 65e28af..fd7fb49 100644 --- a/Sources/AppwriteModels/Jwt.swift +++ b/Sources/AppwriteModels/Jwt.swift @@ -38,7 +38,7 @@ open class Jwt: Codable { public static func from(map: [String: Any] ) -> Jwt { return Jwt( - jwt: map["jwt"] as? String ?? "" + jwt: map["jwt"] as! String ) } } diff --git a/Sources/AppwriteModels/Language.swift b/Sources/AppwriteModels/Language.swift index cb01df3..d1e1a15 100644 --- a/Sources/AppwriteModels/Language.swift +++ b/Sources/AppwriteModels/Language.swift @@ -56,9 +56,9 @@ open class Language: Codable { public static func from(map: [String: Any] ) -> Language { return Language( - name: map["name"] as? String ?? "", - code: map["code"] as? String ?? "", - nativeName: map["nativeName"] as? String ?? "" + name: map["name"] as! String, + code: map["code"] as! String, + nativeName: map["nativeName"] as! String ) } } diff --git a/Sources/AppwriteModels/LanguageList.swift b/Sources/AppwriteModels/LanguageList.swift index 46d99a2..13c6e4a 100644 --- a/Sources/AppwriteModels/LanguageList.swift +++ b/Sources/AppwriteModels/LanguageList.swift @@ -47,8 +47,8 @@ open class LanguageList: Codable { public static func from(map: [String: Any] ) -> LanguageList { return LanguageList( - total: map["total"] as? Int ?? 0, - languages: (map["languages"] as? [[String: Any]] ?? []).map { Language.from(map: $0) } + total: map["total"] as! Int, + languages: (map["languages"] as! [[String: Any]]).map { Language.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Locale.swift b/Sources/AppwriteModels/Locale.swift index 406c6b4..4d034f4 100644 --- a/Sources/AppwriteModels/Locale.swift +++ b/Sources/AppwriteModels/Locale.swift @@ -92,13 +92,13 @@ open class Locale: Codable { public static func from(map: [String: Any] ) -> Locale { return Locale( - ip: map["ip"] as? String ?? "", - countryCode: map["countryCode"] as? String ?? "", - country: map["country"] as? String ?? "", - continentCode: map["continentCode"] as? String ?? "", - continent: map["continent"] as? String ?? "", - eu: map["eu"] as? Bool ?? false, - currency: map["currency"] as? String ?? "" + ip: map["ip"] as! String, + countryCode: map["countryCode"] as! String, + country: map["country"] as! String, + continentCode: map["continentCode"] as! String, + continent: map["continent"] as! String, + eu: map["eu"] as! Bool, + currency: map["currency"] as! String ) } } diff --git a/Sources/AppwriteModels/LocaleCode.swift b/Sources/AppwriteModels/LocaleCode.swift index 0b645f6..d2678bb 100644 --- a/Sources/AppwriteModels/LocaleCode.swift +++ b/Sources/AppwriteModels/LocaleCode.swift @@ -47,8 +47,8 @@ open class LocaleCode: Codable { public static func from(map: [String: Any] ) -> LocaleCode { return LocaleCode( - code: map["code"] as? String ?? "", - name: map["name"] as? String ?? "" + code: map["code"] as! String, + name: map["name"] as! String ) } } diff --git a/Sources/AppwriteModels/LocaleCodeList.swift b/Sources/AppwriteModels/LocaleCodeList.swift index c91540f..5ef0653 100644 --- a/Sources/AppwriteModels/LocaleCodeList.swift +++ b/Sources/AppwriteModels/LocaleCodeList.swift @@ -47,8 +47,8 @@ open class LocaleCodeList: Codable { public static func from(map: [String: Any] ) -> LocaleCodeList { return LocaleCodeList( - total: map["total"] as? Int ?? 0, - localeCodes: (map["localeCodes"] as? [[String: Any]] ?? []).map { LocaleCode.from(map: $0) } + total: map["total"] as! Int, + localeCodes: (map["localeCodes"] as! [[String: Any]]).map { LocaleCode.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Log.swift b/Sources/AppwriteModels/Log.swift index b2b1216..16c27ef 100644 --- a/Sources/AppwriteModels/Log.swift +++ b/Sources/AppwriteModels/Log.swift @@ -218,27 +218,27 @@ open class Log: Codable { public static func from(map: [String: Any] ) -> Log { return Log( - event: map["event"] as? String ?? "", - userId: map["userId"] as? String ?? "", - userEmail: map["userEmail"] as? String ?? "", - userName: map["userName"] as? String ?? "", - mode: map["mode"] as? String ?? "", - ip: map["ip"] as? String ?? "", - time: map["time"] as? String ?? "", - osCode: map["osCode"] as? String ?? "", - osName: map["osName"] as? String ?? "", - osVersion: map["osVersion"] as? String ?? "", - clientType: map["clientType"] as? String ?? "", - clientCode: map["clientCode"] as? String ?? "", - clientName: map["clientName"] as? String ?? "", - clientVersion: map["clientVersion"] as? String ?? "", - clientEngine: map["clientEngine"] as? String ?? "", - clientEngineVersion: map["clientEngineVersion"] as? String ?? "", - deviceName: map["deviceName"] as? String ?? "", - deviceBrand: map["deviceBrand"] as? String ?? "", - deviceModel: map["deviceModel"] as? String ?? "", - countryCode: map["countryCode"] as? String ?? "", - countryName: map["countryName"] as? String ?? "" + event: map["event"] as! String, + userId: map["userId"] as! String, + userEmail: map["userEmail"] as! String, + userName: map["userName"] as! String, + mode: map["mode"] as! String, + ip: map["ip"] as! String, + time: map["time"] as! String, + osCode: map["osCode"] as! String, + osName: map["osName"] as! String, + osVersion: map["osVersion"] as! String, + clientType: map["clientType"] as! String, + clientCode: map["clientCode"] as! String, + clientName: map["clientName"] as! String, + clientVersion: map["clientVersion"] as! String, + clientEngine: map["clientEngine"] as! String, + clientEngineVersion: map["clientEngineVersion"] as! String, + deviceName: map["deviceName"] as! String, + deviceBrand: map["deviceBrand"] as! String, + deviceModel: map["deviceModel"] as! String, + countryCode: map["countryCode"] as! String, + countryName: map["countryName"] as! String ) } } diff --git a/Sources/AppwriteModels/LogList.swift b/Sources/AppwriteModels/LogList.swift index 8e40eb5..7ff2d07 100644 --- a/Sources/AppwriteModels/LogList.swift +++ b/Sources/AppwriteModels/LogList.swift @@ -47,8 +47,8 @@ open class LogList: Codable { public static func from(map: [String: Any] ) -> LogList { return LogList( - total: map["total"] as? Int ?? 0, - logs: (map["logs"] as? [[String: Any]] ?? []).map { Log.from(map: $0) } + total: map["total"] as! Int, + logs: (map["logs"] as! [[String: Any]]).map { Log.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Membership.swift b/Sources/AppwriteModels/Membership.swift index 1886000..8d26766 100644 --- a/Sources/AppwriteModels/Membership.swift +++ b/Sources/AppwriteModels/Membership.swift @@ -146,19 +146,19 @@ open class Membership: Codable { public static func from(map: [String: Any] ) -> Membership { return Membership( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - userId: map["userId"] as? String ?? "", - userName: map["userName"] as? String ?? "", - userEmail: map["userEmail"] as? String ?? "", - teamId: map["teamId"] as? String ?? "", - teamName: map["teamName"] as? String ?? "", - invited: map["invited"] as? String ?? "", - joined: map["joined"] as? String ?? "", - confirm: map["confirm"] as? Bool ?? false, - mfa: map["mfa"] as? Bool ?? false, - roles: map["roles"] as? [String] ?? [] + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + userId: map["userId"] as! String, + userName: map["userName"] as! String, + userEmail: map["userEmail"] as! String, + teamId: map["teamId"] as! String, + teamName: map["teamName"] as! String, + invited: map["invited"] as! String, + joined: map["joined"] as! String, + confirm: map["confirm"] as! Bool, + mfa: map["mfa"] as! Bool, + roles: map["roles"] as! [String] ) } } diff --git a/Sources/AppwriteModels/MembershipList.swift b/Sources/AppwriteModels/MembershipList.swift index abaa881..a7b0cd6 100644 --- a/Sources/AppwriteModels/MembershipList.swift +++ b/Sources/AppwriteModels/MembershipList.swift @@ -47,8 +47,8 @@ open class MembershipList: Codable { public static func from(map: [String: Any] ) -> MembershipList { return MembershipList( - total: map["total"] as? Int ?? 0, - memberships: (map["memberships"] as? [[String: Any]] ?? []).map { Membership.from(map: $0) } + total: map["total"] as! Int, + memberships: (map["memberships"] as! [[String: Any]]).map { Membership.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Message.swift b/Sources/AppwriteModels/Message.swift index a19645e..442d7c8 100644 --- a/Sources/AppwriteModels/Message.swift +++ b/Sources/AppwriteModels/Message.swift @@ -146,19 +146,19 @@ open class Message: Codable { public static func from(map: [String: Any] ) -> Message { return Message( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - providerType: map["providerType"] as? String ?? "", - topics: map["topics"] as? [String] ?? [], - users: map["users"] as? [String] ?? [], - targets: map["targets"] as? [String] ?? [], + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + providerType: map["providerType"] as! String, + topics: map["topics"] as! [String], + users: map["users"] as! [String], + targets: map["targets"] as! [String], scheduledAt: map["scheduledAt"] as? String, deliveredAt: map["deliveredAt"] as? String, deliveryErrors: map["deliveryErrors"] as? [String], - deliveredTotal: map["deliveredTotal"] as? Int ?? 0, - data: map["data"] as? [String: AnyCodable] ?? [String: AnyCodable](), - status: map["status"] as? String ?? "" + deliveredTotal: map["deliveredTotal"] as! Int, + data: map["data"] as! [String: AnyCodable], + status: map["status"] as! String ) } } diff --git a/Sources/AppwriteModels/MessageList.swift b/Sources/AppwriteModels/MessageList.swift index d64e7bb..f62fcaa 100644 --- a/Sources/AppwriteModels/MessageList.swift +++ b/Sources/AppwriteModels/MessageList.swift @@ -47,8 +47,8 @@ open class MessageList: Codable { public static func from(map: [String: Any] ) -> MessageList { return MessageList( - total: map["total"] as? Int ?? 0, - messages: (map["messages"] as? [[String: Any]] ?? []).map { Message.from(map: $0) } + total: map["total"] as! Int, + messages: (map["messages"] as! [[String: Any]]).map { Message.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/MfaChallenge.swift b/Sources/AppwriteModels/MfaChallenge.swift index 7550cce..c6b77a5 100644 --- a/Sources/AppwriteModels/MfaChallenge.swift +++ b/Sources/AppwriteModels/MfaChallenge.swift @@ -65,10 +65,10 @@ open class MfaChallenge: Codable { public static func from(map: [String: Any] ) -> MfaChallenge { return MfaChallenge( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - userId: map["userId"] as? String ?? "", - expire: map["expire"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + userId: map["userId"] as! String, + expire: map["expire"] as! String ) } } diff --git a/Sources/AppwriteModels/MfaFactors.swift b/Sources/AppwriteModels/MfaFactors.swift index 9fb46b5..4291fab 100644 --- a/Sources/AppwriteModels/MfaFactors.swift +++ b/Sources/AppwriteModels/MfaFactors.swift @@ -65,10 +65,10 @@ open class MfaFactors: Codable { public static func from(map: [String: Any] ) -> MfaFactors { return MfaFactors( - totp: map["totp"] as? Bool ?? false, - phone: map["phone"] as? Bool ?? false, - email: map["email"] as? Bool ?? false, - recoveryCode: map["recoveryCode"] as? Bool ?? false + totp: map["totp"] as! Bool, + phone: map["phone"] as! Bool, + email: map["email"] as! Bool, + recoveryCode: map["recoveryCode"] as! Bool ) } } diff --git a/Sources/AppwriteModels/MfaRecoveryCodes.swift b/Sources/AppwriteModels/MfaRecoveryCodes.swift index ac67444..bd2968f 100644 --- a/Sources/AppwriteModels/MfaRecoveryCodes.swift +++ b/Sources/AppwriteModels/MfaRecoveryCodes.swift @@ -38,7 +38,7 @@ open class MfaRecoveryCodes: Codable { public static func from(map: [String: Any] ) -> MfaRecoveryCodes { return MfaRecoveryCodes( - recoveryCodes: map["recoveryCodes"] as? [String] ?? [] + recoveryCodes: map["recoveryCodes"] as! [String] ) } } diff --git a/Sources/AppwriteModels/MfaType.swift b/Sources/AppwriteModels/MfaType.swift index fdcd119..8646385 100644 --- a/Sources/AppwriteModels/MfaType.swift +++ b/Sources/AppwriteModels/MfaType.swift @@ -47,8 +47,8 @@ open class MfaType: Codable { public static func from(map: [String: Any] ) -> MfaType { return MfaType( - secret: map["secret"] as? String ?? "", - uri: map["uri"] as? String ?? "" + secret: map["secret"] as! String, + uri: map["uri"] as! String ) } } diff --git a/Sources/AppwriteModels/Phone.swift b/Sources/AppwriteModels/Phone.swift index 2510956..fc90d49 100644 --- a/Sources/AppwriteModels/Phone.swift +++ b/Sources/AppwriteModels/Phone.swift @@ -56,9 +56,9 @@ open class Phone: Codable { public static func from(map: [String: Any] ) -> Phone { return Phone( - code: map["code"] as? String ?? "", - countryCode: map["countryCode"] as? String ?? "", - countryName: map["countryName"] as? String ?? "" + code: map["code"] as! String, + countryCode: map["countryCode"] as! String, + countryName: map["countryName"] as! String ) } } diff --git a/Sources/AppwriteModels/PhoneList.swift b/Sources/AppwriteModels/PhoneList.swift index adf5287..6f3bee3 100644 --- a/Sources/AppwriteModels/PhoneList.swift +++ b/Sources/AppwriteModels/PhoneList.swift @@ -47,8 +47,8 @@ open class PhoneList: Codable { public static func from(map: [String: Any] ) -> PhoneList { return PhoneList( - total: map["total"] as? Int ?? 0, - phones: (map["phones"] as? [[String: Any]] ?? []).map { Phone.from(map: $0) } + total: map["total"] as! Int, + phones: (map["phones"] as! [[String: Any]]).map { Phone.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Preferences.swift b/Sources/AppwriteModels/Preferences.swift index 707297d..41f94e6 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: map["data"] != nil ? try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map["data"]!, options: [])) : try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) ) } } diff --git a/Sources/AppwriteModels/Provider.swift b/Sources/AppwriteModels/Provider.swift index 4d9accc..50e50d2 100644 --- a/Sources/AppwriteModels/Provider.swift +++ b/Sources/AppwriteModels/Provider.swift @@ -110,14 +110,14 @@ open class Provider: Codable { public static func from(map: [String: Any] ) -> Provider { return Provider( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - name: map["name"] as? String ?? "", - provider: map["provider"] as? String ?? "", - enabled: map["enabled"] as? Bool ?? false, - type: map["type"] as? String ?? "", - credentials: map["credentials"] as? [String: AnyCodable] ?? [String: AnyCodable](), + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + name: map["name"] as! String, + provider: map["provider"] as! String, + enabled: map["enabled"] as! Bool, + type: map["type"] as! String, + credentials: map["credentials"] as! [String: AnyCodable], options: map["options"] as? [String: AnyCodable] ) } diff --git a/Sources/AppwriteModels/ProviderList.swift b/Sources/AppwriteModels/ProviderList.swift index 5853910..76fd4eb 100644 --- a/Sources/AppwriteModels/ProviderList.swift +++ b/Sources/AppwriteModels/ProviderList.swift @@ -47,8 +47,8 @@ open class ProviderList: Codable { public static func from(map: [String: Any] ) -> ProviderList { return ProviderList( - total: map["total"] as? Int ?? 0, - providers: (map["providers"] as? [[String: Any]] ?? []).map { Provider.from(map: $0) } + total: map["total"] as! Int, + providers: (map["providers"] as! [[String: Any]]).map { Provider.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/ResourceToken.swift b/Sources/AppwriteModels/ResourceToken.swift index 7826f69..a3badb6 100644 --- a/Sources/AppwriteModels/ResourceToken.swift +++ b/Sources/AppwriteModels/ResourceToken.swift @@ -92,13 +92,13 @@ open class ResourceToken: Codable { public static func from(map: [String: Any] ) -> ResourceToken { return ResourceToken( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - resourceId: map["resourceId"] as? String ?? "", - resourceType: map["resourceType"] as? String ?? "", - expire: map["expire"] as? String ?? "", - secret: map["secret"] as? String ?? "", - accessedAt: map["accessedAt"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + resourceId: map["resourceId"] as! String, + resourceType: map["resourceType"] as! String, + expire: map["expire"] as! String, + secret: map["secret"] as! String, + accessedAt: map["accessedAt"] as! String ) } } diff --git a/Sources/AppwriteModels/ResourceTokenList.swift b/Sources/AppwriteModels/ResourceTokenList.swift index e2dcbff..6d894b6 100644 --- a/Sources/AppwriteModels/ResourceTokenList.swift +++ b/Sources/AppwriteModels/ResourceTokenList.swift @@ -47,8 +47,8 @@ open class ResourceTokenList: Codable { public static func from(map: [String: Any] ) -> ResourceTokenList { return ResourceTokenList( - total: map["total"] as? Int ?? 0, - tokens: (map["tokens"] as? [[String: Any]] ?? []).map { ResourceToken.from(map: $0) } + total: map["total"] as! Int, + tokens: (map["tokens"] as! [[String: Any]]).map { ResourceToken.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Runtime.swift b/Sources/AppwriteModels/Runtime.swift index be07b7c..f8e6950 100644 --- a/Sources/AppwriteModels/Runtime.swift +++ b/Sources/AppwriteModels/Runtime.swift @@ -101,14 +101,14 @@ open class Runtime: Codable { public static func from(map: [String: Any] ) -> Runtime { return Runtime( - id: map["$id"] as? String ?? "", - key: map["key"] as? String ?? "", - name: map["name"] as? String ?? "", - version: map["version"] as? String ?? "", - base: map["base"] as? String ?? "", - image: map["image"] as? String ?? "", - logo: map["logo"] as? String ?? "", - supports: map["supports"] as? [String] ?? [] + id: map["$id"] as! String, + key: map["key"] as! String, + name: map["name"] as! String, + version: map["version"] as! String, + base: map["base"] as! String, + image: map["image"] as! String, + logo: map["logo"] as! String, + supports: map["supports"] as! [String] ) } } diff --git a/Sources/AppwriteModels/RuntimeList.swift b/Sources/AppwriteModels/RuntimeList.swift index a014115..ab99ed1 100644 --- a/Sources/AppwriteModels/RuntimeList.swift +++ b/Sources/AppwriteModels/RuntimeList.swift @@ -47,8 +47,8 @@ open class RuntimeList: Codable { public static func from(map: [String: Any] ) -> RuntimeList { return RuntimeList( - total: map["total"] as? Int ?? 0, - runtimes: (map["runtimes"] as? [[String: Any]] ?? []).map { Runtime.from(map: $0) } + total: map["total"] as! Int, + runtimes: (map["runtimes"] as! [[String: Any]]).map { Runtime.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Session.swift b/Sources/AppwriteModels/Session.swift index 1ee01a4..b5c25a6 100644 --- a/Sources/AppwriteModels/Session.swift +++ b/Sources/AppwriteModels/Session.swift @@ -290,35 +290,35 @@ open class Session: Codable { public static func from(map: [String: Any] ) -> Session { return Session( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - userId: map["userId"] as? String ?? "", - expire: map["expire"] as? String ?? "", - provider: map["provider"] as? String ?? "", - providerUid: map["providerUid"] as? String ?? "", - providerAccessToken: map["providerAccessToken"] as? String ?? "", - providerAccessTokenExpiry: map["providerAccessTokenExpiry"] as? String ?? "", - providerRefreshToken: map["providerRefreshToken"] as? String ?? "", - ip: map["ip"] as? String ?? "", - osCode: map["osCode"] as? String ?? "", - osName: map["osName"] as? String ?? "", - osVersion: map["osVersion"] as? String ?? "", - clientType: map["clientType"] as? String ?? "", - clientCode: map["clientCode"] as? String ?? "", - clientName: map["clientName"] as? String ?? "", - clientVersion: map["clientVersion"] as? String ?? "", - clientEngine: map["clientEngine"] as? String ?? "", - clientEngineVersion: map["clientEngineVersion"] as? String ?? "", - deviceName: map["deviceName"] as? String ?? "", - deviceBrand: map["deviceBrand"] as? String ?? "", - deviceModel: map["deviceModel"] as? String ?? "", - countryCode: map["countryCode"] as? String ?? "", - countryName: map["countryName"] as? String ?? "", - current: map["current"] as? Bool ?? false, - factors: map["factors"] as? [String] ?? [], - secret: map["secret"] as? String ?? "", - mfaUpdatedAt: map["mfaUpdatedAt"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + userId: map["userId"] as! String, + expire: map["expire"] as! String, + provider: map["provider"] as! String, + providerUid: map["providerUid"] as! String, + providerAccessToken: map["providerAccessToken"] as! String, + providerAccessTokenExpiry: map["providerAccessTokenExpiry"] as! String, + providerRefreshToken: map["providerRefreshToken"] as! String, + ip: map["ip"] as! String, + osCode: map["osCode"] as! String, + osName: map["osName"] as! String, + osVersion: map["osVersion"] as! String, + clientType: map["clientType"] as! String, + clientCode: map["clientCode"] as! String, + clientName: map["clientName"] as! String, + clientVersion: map["clientVersion"] as! String, + clientEngine: map["clientEngine"] as! String, + clientEngineVersion: map["clientEngineVersion"] as! String, + deviceName: map["deviceName"] as! String, + deviceBrand: map["deviceBrand"] as! String, + deviceModel: map["deviceModel"] as! String, + countryCode: map["countryCode"] as! String, + countryName: map["countryName"] as! String, + current: map["current"] as! Bool, + factors: map["factors"] as! [String], + secret: map["secret"] as! String, + mfaUpdatedAt: map["mfaUpdatedAt"] as! String ) } } diff --git a/Sources/AppwriteModels/SessionList.swift b/Sources/AppwriteModels/SessionList.swift index 2dd724b..13b6b3d 100644 --- a/Sources/AppwriteModels/SessionList.swift +++ b/Sources/AppwriteModels/SessionList.swift @@ -47,8 +47,8 @@ open class SessionList: Codable { public static func from(map: [String: Any] ) -> SessionList { return SessionList( - total: map["total"] as? Int ?? 0, - sessions: (map["sessions"] as? [[String: Any]] ?? []).map { Session.from(map: $0) } + total: map["total"] as! Int, + sessions: (map["sessions"] as! [[String: Any]]).map { Session.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Site.swift b/Sources/AppwriteModels/Site.swift index 249dc98..ef79e4a 100644 --- a/Sources/AppwriteModels/Site.swift +++ b/Sources/AppwriteModels/Site.swift @@ -290,35 +290,35 @@ open class Site: Codable { public static func from(map: [String: Any] ) -> Site { return Site( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - name: map["name"] as? String ?? "", - enabled: map["enabled"] as? Bool ?? false, - live: map["live"] as? Bool ?? false, - logging: map["logging"] as? Bool ?? false, - framework: map["framework"] as? String ?? "", - deploymentId: map["deploymentId"] as? String ?? "", - deploymentCreatedAt: map["deploymentCreatedAt"] as? String ?? "", - deploymentScreenshotLight: map["deploymentScreenshotLight"] as? String ?? "", - deploymentScreenshotDark: map["deploymentScreenshotDark"] as? String ?? "", - latestDeploymentId: map["latestDeploymentId"] as? String ?? "", - latestDeploymentCreatedAt: map["latestDeploymentCreatedAt"] as? String ?? "", - latestDeploymentStatus: map["latestDeploymentStatus"] as? String ?? "", - vars: (map["vars"] as? [[String: Any]] ?? []).map { Variable.from(map: $0) }, - timeout: map["timeout"] as? Int ?? 0, - installCommand: map["installCommand"] as? String ?? "", - buildCommand: map["buildCommand"] as? String ?? "", - outputDirectory: map["outputDirectory"] as? String ?? "", - installationId: map["installationId"] as? String ?? "", - providerRepositoryId: map["providerRepositoryId"] as? String ?? "", - providerBranch: map["providerBranch"] as? String ?? "", - providerRootDirectory: map["providerRootDirectory"] as? String ?? "", - providerSilentMode: map["providerSilentMode"] as? Bool ?? false, - specification: map["specification"] as? String ?? "", - buildRuntime: map["buildRuntime"] as? String ?? "", - adapter: map["adapter"] as? String ?? "", - fallbackFile: map["fallbackFile"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + name: map["name"] as! String, + enabled: map["enabled"] as! Bool, + live: map["live"] as! Bool, + logging: map["logging"] as! Bool, + framework: map["framework"] as! String, + deploymentId: map["deploymentId"] as! String, + deploymentCreatedAt: map["deploymentCreatedAt"] as! String, + deploymentScreenshotLight: map["deploymentScreenshotLight"] as! String, + deploymentScreenshotDark: map["deploymentScreenshotDark"] as! String, + latestDeploymentId: map["latestDeploymentId"] as! String, + latestDeploymentCreatedAt: map["latestDeploymentCreatedAt"] as! String, + latestDeploymentStatus: map["latestDeploymentStatus"] as! String, + vars: (map["vars"] as! [[String: Any]]).map { Variable.from(map: $0) }, + timeout: map["timeout"] as! Int, + installCommand: map["installCommand"] as! String, + buildCommand: map["buildCommand"] as! String, + outputDirectory: map["outputDirectory"] as! String, + installationId: map["installationId"] as! String, + providerRepositoryId: map["providerRepositoryId"] as! String, + providerBranch: map["providerBranch"] as! String, + providerRootDirectory: map["providerRootDirectory"] as! String, + providerSilentMode: map["providerSilentMode"] as! Bool, + specification: map["specification"] as! String, + buildRuntime: map["buildRuntime"] as! String, + adapter: map["adapter"] as! String, + fallbackFile: map["fallbackFile"] as! String ) } } diff --git a/Sources/AppwriteModels/SiteList.swift b/Sources/AppwriteModels/SiteList.swift index e1ecb9e..6c37fae 100644 --- a/Sources/AppwriteModels/SiteList.swift +++ b/Sources/AppwriteModels/SiteList.swift @@ -47,8 +47,8 @@ open class SiteList: Codable { public static func from(map: [String: Any] ) -> SiteList { return SiteList( - total: map["total"] as? Int ?? 0, - sites: (map["sites"] as? [[String: Any]] ?? []).map { Site.from(map: $0) } + total: map["total"] as! Int, + sites: (map["sites"] as! [[String: Any]]).map { Site.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Specification.swift b/Sources/AppwriteModels/Specification.swift index b128974..a84f617 100644 --- a/Sources/AppwriteModels/Specification.swift +++ b/Sources/AppwriteModels/Specification.swift @@ -65,10 +65,10 @@ open class Specification: Codable { public static func from(map: [String: Any] ) -> Specification { return Specification( - memory: map["memory"] as? Int ?? 0, - cpus: map["cpus"] as? Double ?? 0.0, - enabled: map["enabled"] as? Bool ?? false, - slug: map["slug"] as? String ?? "" + memory: map["memory"] as! Int, + cpus: map["cpus"] as! Double, + enabled: map["enabled"] as! Bool, + slug: map["slug"] as! String ) } } diff --git a/Sources/AppwriteModels/SpecificationList.swift b/Sources/AppwriteModels/SpecificationList.swift index f21bf7d..f2b9766 100644 --- a/Sources/AppwriteModels/SpecificationList.swift +++ b/Sources/AppwriteModels/SpecificationList.swift @@ -47,8 +47,8 @@ open class SpecificationList: Codable { public static func from(map: [String: Any] ) -> SpecificationList { return SpecificationList( - total: map["total"] as? Int ?? 0, - specifications: (map["specifications"] as? [[String: Any]] ?? []).map { Specification.from(map: $0) } + total: map["total"] as! Int, + specifications: (map["specifications"] as! [[String: Any]]).map { Specification.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Subscriber.swift b/Sources/AppwriteModels/Subscriber.swift index f0a399c..ad6fa5d 100644 --- a/Sources/AppwriteModels/Subscriber.swift +++ b/Sources/AppwriteModels/Subscriber.swift @@ -110,15 +110,15 @@ open class Subscriber: Codable { public static func from(map: [String: Any] ) -> Subscriber { return Subscriber( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - targetId: map["targetId"] as? String ?? "", - target: map["target"] != nil ? Target.from(map: map["target"] as! [String: Any]) : Target(), - userId: map["userId"] as? String ?? "", - userName: map["userName"] as? String ?? "", - topicId: map["topicId"] as? String ?? "", - providerType: map["providerType"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + targetId: map["targetId"] as! String, + target: Target.from(map: map["target"] as! [String: Any]), + userId: map["userId"] as! String, + userName: map["userName"] as! String, + topicId: map["topicId"] as! String, + providerType: map["providerType"] as! String ) } } diff --git a/Sources/AppwriteModels/SubscriberList.swift b/Sources/AppwriteModels/SubscriberList.swift index 486938f..2d63f07 100644 --- a/Sources/AppwriteModels/SubscriberList.swift +++ b/Sources/AppwriteModels/SubscriberList.swift @@ -47,8 +47,8 @@ open class SubscriberList: Codable { public static func from(map: [String: Any] ) -> SubscriberList { return SubscriberList( - total: map["total"] as? Int ?? 0, - subscribers: (map["subscribers"] as? [[String: Any]] ?? []).map { Subscriber.from(map: $0) } + total: map["total"] as! Int, + subscribers: (map["subscribers"] as! [[String: Any]]).map { Subscriber.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Target.swift b/Sources/AppwriteModels/Target.swift index 6e34abd..0581a61 100644 --- a/Sources/AppwriteModels/Target.swift +++ b/Sources/AppwriteModels/Target.swift @@ -110,15 +110,15 @@ open class Target: Codable { public static func from(map: [String: Any] ) -> Target { return Target( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - name: map["name"] as? String ?? "", - userId: map["userId"] as? String ?? "", + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + name: map["name"] as! String, + userId: map["userId"] as! String, providerId: map["providerId"] as? String, - providerType: map["providerType"] as? String ?? "", - identifier: map["identifier"] as? String ?? "", - expired: map["expired"] as? Bool ?? false + providerType: map["providerType"] as! String, + identifier: map["identifier"] as! String, + expired: map["expired"] as! Bool ) } } diff --git a/Sources/AppwriteModels/TargetList.swift b/Sources/AppwriteModels/TargetList.swift index f5fb597..6c9f247 100644 --- a/Sources/AppwriteModels/TargetList.swift +++ b/Sources/AppwriteModels/TargetList.swift @@ -47,8 +47,8 @@ open class TargetList: Codable { public static func from(map: [String: Any] ) -> TargetList { return TargetList( - total: map["total"] as? Int ?? 0, - targets: (map["targets"] as? [[String: Any]] ?? []).map { Target.from(map: $0) } + total: map["total"] as! Int, + targets: (map["targets"] as! [[String: Any]]).map { Target.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Team.swift b/Sources/AppwriteModels/Team.swift index 052debe..9ca7307 100644 --- a/Sources/AppwriteModels/Team.swift +++ b/Sources/AppwriteModels/Team.swift @@ -83,12 +83,12 @@ open class Team: Codable { public static func from(map: [String: Any] ) -> Team { return Team( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - name: map["name"] as? String ?? "", - total: map["total"] as? Int ?? 0, - prefs: map["prefs"] != nil ? Preferences.from(map: map["prefs"] as! [String: Any]) : Preferences() + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + name: map["name"] as! String, + total: map["total"] as! Int, + prefs: Preferences.from(map: map["prefs"] as! [String: Any]) ) } } diff --git a/Sources/AppwriteModels/TeamList.swift b/Sources/AppwriteModels/TeamList.swift index aaa02af..384d9f6 100644 --- a/Sources/AppwriteModels/TeamList.swift +++ b/Sources/AppwriteModels/TeamList.swift @@ -47,8 +47,8 @@ open class TeamList: Codable { public static func from(map: [String: Any] ) -> TeamList { return TeamList( - total: map["total"] as? Int ?? 0, - teams: (map["teams"] as? [[String: Any]] ?? []).map { Team.from(map: $0) } + total: map["total"] as! Int, + teams: (map["teams"] as! [[String: Any]]).map { Team.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Token.swift b/Sources/AppwriteModels/Token.swift index 1ded551..f832402 100644 --- a/Sources/AppwriteModels/Token.swift +++ b/Sources/AppwriteModels/Token.swift @@ -83,12 +83,12 @@ open class Token: Codable { public static func from(map: [String: Any] ) -> Token { return Token( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - userId: map["userId"] as? String ?? "", - secret: map["secret"] as? String ?? "", - expire: map["expire"] as? String ?? "", - phrase: map["phrase"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + userId: map["userId"] as! String, + secret: map["secret"] as! String, + expire: map["expire"] as! String, + phrase: map["phrase"] as! String ) } } diff --git a/Sources/AppwriteModels/Topic.swift b/Sources/AppwriteModels/Topic.swift index 6c926f7..4489abb 100644 --- a/Sources/AppwriteModels/Topic.swift +++ b/Sources/AppwriteModels/Topic.swift @@ -101,14 +101,14 @@ open class Topic: Codable { public static func from(map: [String: Any] ) -> Topic { return Topic( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - name: map["name"] as? String ?? "", - emailTotal: map["emailTotal"] as? Int ?? 0, - smsTotal: map["smsTotal"] as? Int ?? 0, - pushTotal: map["pushTotal"] as? Int ?? 0, - subscribe: map["subscribe"] as? [String] ?? [] + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + name: map["name"] as! String, + emailTotal: map["emailTotal"] as! Int, + smsTotal: map["smsTotal"] as! Int, + pushTotal: map["pushTotal"] as! Int, + subscribe: map["subscribe"] as! [String] ) } } diff --git a/Sources/AppwriteModels/TopicList.swift b/Sources/AppwriteModels/TopicList.swift index 58f264e..66eae2c 100644 --- a/Sources/AppwriteModels/TopicList.swift +++ b/Sources/AppwriteModels/TopicList.swift @@ -47,8 +47,8 @@ open class TopicList: Codable { public static func from(map: [String: Any] ) -> TopicList { return TopicList( - total: map["total"] as? Int ?? 0, - topics: (map["topics"] as? [[String: Any]] ?? []).map { Topic.from(map: $0) } + total: map["total"] as! Int, + topics: (map["topics"] as! [[String: Any]]).map { Topic.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/User.swift b/Sources/AppwriteModels/User.swift index a519c76..6e972d3 100644 --- a/Sources/AppwriteModels/User.swift +++ b/Sources/AppwriteModels/User.swift @@ -200,25 +200,25 @@ open class User: Codable { public static func from(map: [String: Any] ) -> User { return User( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - name: map["name"] as? String ?? "", + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + name: map["name"] as! String, password: map["password"] as? String, hash: map["hash"] as? String, hashOptions: map["hashOptions"] as? [String: AnyCodable], - registration: map["registration"] as? String ?? "", - status: map["status"] as? Bool ?? false, - labels: map["labels"] as? [String] ?? [], - passwordUpdate: map["passwordUpdate"] as? String ?? "", - email: map["email"] as? String ?? "", - phone: map["phone"] as? String ?? "", - emailVerification: map["emailVerification"] as? Bool ?? false, - phoneVerification: map["phoneVerification"] as? Bool ?? false, - mfa: map["mfa"] as? Bool ?? false, - prefs: map["prefs"] != nil ? Preferences.from(map: map["prefs"] as! [String: Any]) : Preferences(), - targets: (map["targets"] as? [[String: Any]] ?? []).map { Target.from(map: $0) }, - accessedAt: map["accessedAt"] as? String ?? "" + registration: map["registration"] as! String, + status: map["status"] as! Bool, + labels: map["labels"] as! [String], + passwordUpdate: map["passwordUpdate"] as! String, + email: map["email"] as! String, + phone: map["phone"] as! String, + emailVerification: map["emailVerification"] as! Bool, + phoneVerification: map["phoneVerification"] as! Bool, + mfa: map["mfa"] as! Bool, + prefs: Preferences.from(map: map["prefs"] as! [String: Any]), + targets: (map["targets"] as! [[String: Any]]).map { Target.from(map: $0) }, + accessedAt: map["accessedAt"] as! String ) } } diff --git a/Sources/AppwriteModels/UserList.swift b/Sources/AppwriteModels/UserList.swift index 55699c2..7bf7413 100644 --- a/Sources/AppwriteModels/UserList.swift +++ b/Sources/AppwriteModels/UserList.swift @@ -47,8 +47,8 @@ open class UserList: Codable { public static func from(map: [String: Any] ) -> UserList { return UserList( - total: map["total"] as? Int ?? 0, - users: (map["users"] as? [[String: Any]] ?? []).map { User.from(map: $0) } + total: map["total"] as! Int, + users: (map["users"] as! [[String: Any]]).map { User.from(map: $0) } ) } } diff --git a/Sources/AppwriteModels/Variable.swift b/Sources/AppwriteModels/Variable.swift index 7dc0690..662e7a3 100644 --- a/Sources/AppwriteModels/Variable.swift +++ b/Sources/AppwriteModels/Variable.swift @@ -101,14 +101,14 @@ open class Variable: Codable { public static func from(map: [String: Any] ) -> Variable { return Variable( - id: map["$id"] as? String ?? "", - createdAt: map["$createdAt"] as? String ?? "", - updatedAt: map["$updatedAt"] as? String ?? "", - key: map["key"] as? String ?? "", - value: map["value"] as? String ?? "", - secret: map["secret"] as? Bool ?? false, - resourceType: map["resourceType"] as? String ?? "", - resourceId: map["resourceId"] as? String ?? "" + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + key: map["key"] as! String, + value: map["value"] as! String, + secret: map["secret"] as! Bool, + resourceType: map["resourceType"] as! String, + resourceId: map["resourceId"] as! String ) } } diff --git a/Sources/AppwriteModels/VariableList.swift b/Sources/AppwriteModels/VariableList.swift index efc84cf..8345d0b 100644 --- a/Sources/AppwriteModels/VariableList.swift +++ b/Sources/AppwriteModels/VariableList.swift @@ -47,8 +47,8 @@ open class VariableList: Codable { public static func from(map: [String: Any] ) -> VariableList { return VariableList( - total: map["total"] as? Int ?? 0, - variables: (map["variables"] as? [[String: Any]] ?? []).map { Variable.from(map: $0) } + total: map["total"] as! Int, + variables: (map["variables"] as! [[String: Any]]).map { Variable.from(map: $0) } ) } } From f545e49a7c5901a6dc0faf98e288c3e271e080a5 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 4 Jun 2025 06:53:34 +0000 Subject: [PATCH 4/4] chore: regenerate sdk --- Sources/Appwrite/Services/Databases.swift | 76 +++++++++++++++++++++ Sources/AppwriteEnums/BuildRuntime.swift | 2 - Sources/AppwriteEnums/Runtime.swift | 2 - docs/examples/databases/create-documents.md | 14 ++++ 4 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 docs/examples/databases/create-documents.md diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index ffcccd8..aae760f 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -1655,6 +1655,82 @@ open class Databases: Service { ) } + /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// + /// Create new Documents. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + /// API or directly from your database console. + /// + /// @param String databaseId + /// @param String collectionId + /// @param [Any] documents + /// @throws Exception + /// @return array + /// + open func createDocuments( + databaseId: String, + collectionId: String, + documents: [Any], + nestedType: T.Type + ) async throws -> AppwriteModels.DocumentList { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + + let apiParams: [String: Any?] = [ + "documents": documents + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.DocumentList = { response in + return AppwriteModels.DocumentList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// **WARNING: Experimental Feature** - This endpoint is experimental and not + /// yet officially supported. It may be subject to breaking changes or removal + /// in future versions. + /// + /// Create new Documents. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + /// API or directly from your database console. + /// + /// @param String databaseId + /// @param String collectionId + /// @param [Any] documents + /// @throws Exception + /// @return array + /// + open func createDocuments( + databaseId: String, + collectionId: String, + documents: [Any] + ) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> { + return try await createDocuments( + databaseId: databaseId, + collectionId: collectionId, + documents: documents, + nestedType: [String: AnyCodable].self + ) + } + /// /// **WARNING: Experimental Feature** - This endpoint is experimental and not /// yet officially supported. It may be subject to breaking changes or removal diff --git a/Sources/AppwriteEnums/BuildRuntime.swift b/Sources/AppwriteEnums/BuildRuntime.swift index dc9b179..90ca969 100644 --- a/Sources/AppwriteEnums/BuildRuntime.swift +++ b/Sources/AppwriteEnums/BuildRuntime.swift @@ -38,7 +38,6 @@ public enum BuildRuntime: String, CustomStringConvertible { case dart31 = "dart-3.1" case dart33 = "dart-3.3" case dart35 = "dart-3.5" - case dart38 = "dart-3.8" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" case dotnet80 = "dotnet-8.0" @@ -65,7 +64,6 @@ public enum BuildRuntime: String, CustomStringConvertible { case flutter324 = "flutter-3.24" case flutter327 = "flutter-3.27" case flutter329 = "flutter-3.29" - case flutter332 = "flutter-3.32" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/Runtime.swift b/Sources/AppwriteEnums/Runtime.swift index a461f31..5a6cccf 100644 --- a/Sources/AppwriteEnums/Runtime.swift +++ b/Sources/AppwriteEnums/Runtime.swift @@ -38,7 +38,6 @@ public enum Runtime: String, CustomStringConvertible { case dart31 = "dart-3.1" case dart33 = "dart-3.3" case dart35 = "dart-3.5" - case dart38 = "dart-3.8" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" case dotnet80 = "dotnet-8.0" @@ -65,7 +64,6 @@ public enum Runtime: String, CustomStringConvertible { case flutter324 = "flutter-3.24" case flutter327 = "flutter-3.27" case flutter329 = "flutter-3.29" - case flutter332 = "flutter-3.32" public var description: String { return rawValue diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md new file mode 100644 index 0000000..39a58ab --- /dev/null +++ b/docs/examples/databases/create-documents.md @@ -0,0 +1,14 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey("") // Your secret API key + +let databases = Databases(client) + +let documentList = try await databases.createDocuments( + databaseId: "", + collectionId: "", + documents: [] +) +