diff --git a/README.md b/README.md index 160afa8..e2cdc33 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: "7.0.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "8.0.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 1b39b35..22ed536 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": "7.0.0", + "x-sdk-version": "8.0.0", "x-appwrite-response-format": "1.6.0" ] @@ -337,20 +337,24 @@ open class Client { var message = "" var data = try await response.body.collect(upTo: Int.max) var type = "" + var responseString = "" do { let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any] message = dict?["message"] as? String ?? response.status.reasonPhrase type = dict?["type"] as? String ?? "" + responseString = String(decoding: data.readableBytesView, as: UTF8.self) } catch { message = data.readString(length: data.readableBytes)! + responseString = message } throw AppwriteError( message: message, code: Int(response.status.code), - type: type + type: type, + response: responseString ) } @@ -434,20 +438,24 @@ open class Client { default: var message = "" var type = "" + var responseString = "" do { let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any] message = dict?["message"] as? String ?? response.status.reasonPhrase type = dict?["type"] as? String ?? "" + responseString = String(decoding: data.readableBytesView, as: UTF8.self) } catch { message = data.readString(length: data.readableBytes)! + responseString = message } throw AppwriteError( message: message, code: Int(response.status.code), - type: type + type: type, + response: responseString ) } } diff --git a/Sources/Appwrite/Models/AppwriteError.swift b/Sources/Appwrite/Models/AppwriteError.swift index a0e0963..4c79512 100644 --- a/Sources/Appwrite/Models/AppwriteError.swift +++ b/Sources/Appwrite/Models/AppwriteError.swift @@ -5,11 +5,13 @@ open class AppwriteError : Swift.Error, Decodable { public let message: String public let code: Int? public let type: String? + public let response: String - init(message: String, code: Int? = nil, type: String? = nil) { + init(message: String, code: Int? = nil, type: String? = nil, response: String = "") { self.message = message self.code = code self.type = type + self.response = response } } diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index cce7e89..3a05228 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Account service allows you to authenticate and manage a user account. open class Account: Service { - /// - /// Get account /// /// Get the currently logged in user. /// @@ -40,8 +38,6 @@ open class Account: Service { ) } - /// - /// Get account /// /// Get the currently logged in user. /// @@ -55,8 +51,6 @@ open class Account: Service { ) } - /// - /// Create account /// /// Use this endpoint to allow a new user to register a new account in your /// project. After the user registration completes successfully, you can use @@ -106,8 +100,6 @@ open class Account: Service { ) } - /// - /// Create account /// /// Use this endpoint to allow a new user to register a new account in your /// project. After the user registration completes successfully, you can use @@ -139,8 +131,6 @@ open class Account: Service { ) } - /// - /// Update email /// /// Update currently logged in user account email address. After changing user /// address, the user confirmation status will get reset. A new confirmation @@ -185,8 +175,6 @@ open class Account: Service { ) } - /// - /// Update email /// /// Update currently logged in user account email address. After changing user /// address, the user confirmation status will get reset. A new confirmation @@ -213,8 +201,6 @@ open class Account: Service { ) } - /// - /// List identities /// /// Get the list of identities for the currently logged in user. /// @@ -248,8 +234,6 @@ open class Account: Service { ) } - /// - /// Delete identity /// /// Delete an identity by its unique ID. /// @@ -276,8 +260,6 @@ open class Account: Service { params: apiParams ) } - /// - /// Create JWT /// /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT /// to authenticate on behalf of the current user when working with the @@ -311,8 +293,6 @@ open class Account: Service { ) } - /// - /// List logs /// /// Get the list of latest security activity logs for the currently logged in /// user. Each log returns user IP address, location and date and time of log. @@ -347,8 +327,6 @@ open class Account: Service { ) } - /// - /// Update MFA /// /// Enable or disable MFA on an account. /// @@ -383,8 +361,6 @@ open class Account: Service { ) } - /// - /// Update MFA /// /// Enable or disable MFA on an account. /// @@ -401,8 +377,6 @@ open class Account: Service { ) } - /// - /// Create authenticator /// /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify @@ -438,8 +412,6 @@ open class Account: Service { ) } - /// - /// Verify authenticator /// /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -479,8 +451,6 @@ open class Account: Service { ) } - /// - /// Verify authenticator /// /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -502,8 +472,6 @@ open class Account: Service { ) } - /// - /// Delete authenticator /// /// Delete an authenticator for a user by ID. /// @@ -530,8 +498,6 @@ open class Account: Service { params: apiParams ) } - /// - /// Create MFA challenge /// /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) @@ -567,8 +533,6 @@ open class Account: Service { ) } - /// - /// Create MFA challenge (confirmation) /// /// Complete the MFA challenge by providing the one-time password. Finish the /// process of MFA verification by providing the one-time password. To begin @@ -609,8 +573,6 @@ open class Account: Service { ) } - /// - /// List factors /// /// List the factors available on the account to be used as a MFA challange. /// @@ -640,8 +602,6 @@ open class Account: Service { ) } - /// - /// Get MFA recovery codes /// /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using @@ -674,8 +634,6 @@ open class Account: Service { ) } - /// - /// Create MFA recovery codes /// /// Generate recovery codes as backup for MFA flow. It's recommended to /// generate and show then immediately after user successfully adds their @@ -709,8 +667,6 @@ open class Account: Service { ) } - /// - /// Regenerate MFA recovery codes /// /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using @@ -743,8 +699,6 @@ open class Account: Service { ) } - /// - /// Update name /// /// Update currently logged in user account name. /// @@ -779,8 +733,6 @@ open class Account: Service { ) } - /// - /// Update name /// /// Update currently logged in user account name. /// @@ -797,8 +749,6 @@ open class Account: Service { ) } - /// - /// Update password /// /// Update currently logged in user password. For validation, user is required /// to pass in the new password, and the old password. For users created with @@ -838,8 +788,6 @@ open class Account: Service { ) } - /// - /// Update password /// /// Update currently logged in user password. For validation, user is required /// to pass in the new password, and the old password. For users created with @@ -861,8 +809,6 @@ open class Account: Service { ) } - /// - /// Update phone /// /// Update the currently logged in user's phone number. After updating the /// phone number, the phone verification status will be reset. A confirmation @@ -904,8 +850,6 @@ open class Account: Service { ) } - /// - /// Update phone /// /// Update the currently logged in user's phone number. After updating the /// phone number, the phone verification status will be reset. A confirmation @@ -929,8 +873,6 @@ open class Account: Service { ) } - /// - /// Get account preferences /// /// Get the preferences as a key-value object for the currently logged in user. /// @@ -961,8 +903,6 @@ open class Account: Service { ) } - /// - /// Get account preferences /// /// Get the preferences as a key-value object for the currently logged in user. /// @@ -976,8 +916,6 @@ open class Account: Service { ) } - /// - /// Update preferences /// /// Update currently logged in user account preferences. The object you pass is /// stored as is, and replaces any previous value. The maximum allowed prefs @@ -1014,8 +952,6 @@ open class Account: Service { ) } - /// - /// Update preferences /// /// Update currently logged in user account preferences. The object you pass is /// stored as is, and replaces any previous value. The maximum allowed prefs @@ -1034,8 +970,6 @@ open class Account: Service { ) } - /// - /// Create password recovery /// /// Sends the user an email with a temporary secret key for password reset. /// When the user clicks the confirmation link he is redirected back to your @@ -1079,8 +1013,6 @@ open class Account: Service { ) } - /// - /// Create password recovery (confirmation) /// /// Use this endpoint to complete the user account password reset. Both the /// **userId** and **secret** arguments will be passed as query parameters to @@ -1129,8 +1061,6 @@ open class Account: Service { ) } - /// - /// List sessions /// /// Get the list of active sessions across different devices for the currently /// logged in user. @@ -1161,8 +1091,6 @@ open class Account: Service { ) } - /// - /// Delete sessions /// /// Delete all sessions from the user account and remove any sessions cookies /// from the end client. @@ -1187,8 +1115,6 @@ open class Account: Service { params: apiParams ) } - /// - /// Create anonymous session /// /// Use this endpoint to allow a new user to register an anonymous account in /// your project. This route will also create a new session for the user. To @@ -1224,8 +1150,6 @@ open class Account: Service { ) } - /// - /// Create email password session /// /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. @@ -1267,8 +1191,6 @@ open class Account: Service { ) } - /// - /// Update magic URL session /// /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication @@ -1307,8 +1229,6 @@ open class Account: Service { ) } - /// - /// Update phone session /// /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication @@ -1347,8 +1267,6 @@ open class Account: Service { ) } - /// - /// Create session /// /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication @@ -1387,8 +1305,6 @@ open class Account: Service { ) } - /// - /// Get session /// /// Use this endpoint to get a logged in user's session using a Session ID. /// Inputting 'current' will return the current session being used. @@ -1422,8 +1338,6 @@ open class Account: Service { ) } - /// - /// Update session /// /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an @@ -1458,8 +1372,6 @@ open class Account: Service { ) } - /// - /// Delete session /// /// Logout the user. Use 'current' as the session ID to logout on this device, /// use a session ID to logout on another device. If you're looking to logout @@ -1490,8 +1402,6 @@ open class Account: Service { params: apiParams ) } - /// - /// Update status /// /// Block the currently logged in user account. Behind the scene, the user /// record is not deleted but permanently blocked from any access. To @@ -1524,8 +1434,6 @@ open class Account: Service { ) } - /// - /// Update status /// /// Block the currently logged in user account. Behind the scene, the user /// record is not deleted but permanently blocked from any access. To @@ -1541,8 +1449,6 @@ open class Account: Service { ) } - /// - /// Create email token (OTP) /// /// Sends the user an email with a secret key for creating a session. If the /// provided user ID has not be registered, a new user will be created. Use the @@ -1591,8 +1497,6 @@ open class Account: Service { ) } - /// - /// Create magic URL token /// /// Sends the user an email with a secret key for creating a session. If the /// provided user ID has not been registered, a new user will be created. When @@ -1648,8 +1552,6 @@ open class Account: Service { ) } - /// - /// Create OAuth2 token /// /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console @@ -1701,8 +1603,6 @@ open class Account: Service { ) } - /// - /// Create phone token /// /// Sends the user an SMS with a secret key for creating a session. If the /// provided user ID has not be registered, a new user will be created. Use the @@ -1748,8 +1648,6 @@ open class Account: Service { ) } - /// - /// Create email verification /// /// Use this endpoint to send a verification message to your user email address /// to confirm they are the valid owners of that address. Both the **userId** @@ -1797,8 +1695,6 @@ open class Account: Service { ) } - /// - /// Create email verification (confirmation) /// /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL @@ -1838,8 +1734,6 @@ open class Account: Service { ) } - /// - /// Create phone verification /// /// Use this endpoint to send a verification SMS to the currently logged in /// user. This endpoint is meant for use after updating a user's phone number @@ -1876,8 +1770,6 @@ open class Account: Service { ) } - /// - /// Update phone verification (confirmation) /// /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to diff --git a/Sources/Appwrite/Services/Avatars.swift b/Sources/Appwrite/Services/Avatars.swift index 8699edf..04eb51a 100644 --- a/Sources/Appwrite/Services/Avatars.swift +++ b/Sources/Appwrite/Services/Avatars.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars. open class Avatars: Service { - /// - /// Get browser icon /// /// You can use this endpoint to show different browser icons to your users. /// The code argument receives the browser code as it appears in your user [GET @@ -57,8 +55,6 @@ open class Avatars: Service { ) } - /// - /// Get credit card icon /// /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the @@ -105,8 +101,6 @@ open class Avatars: Service { ) } - /// - /// Get favicon /// /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. @@ -139,8 +133,6 @@ open class Avatars: Service { ) } - /// - /// Get country flag /// /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, @@ -188,8 +180,6 @@ open class Avatars: Service { ) } - /// - /// Get image from URL /// /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display @@ -235,8 +225,6 @@ open class Avatars: Service { ) } - /// - /// Get user initials /// /// Use this endpoint to show your user initials avatar icon on your website or /// app. By default, this route will try to print your logged-in user name or @@ -290,8 +278,6 @@ open class Avatars: Service { ) } - /// - /// Get QR code /// /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index 7e196e7..41899d1 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Databases service allows you to create structured collections of documents, query and filter lists of documents open class Databases: Service { - /// - /// List databases /// /// Get a list of all databases from the current Appwrite project. You can use /// the search parameter to filter your results. @@ -47,8 +45,6 @@ open class Databases: Service { ) } - /// - /// Create database /// /// Create a new Database. /// @@ -89,8 +85,6 @@ open class Databases: Service { ) } - /// - /// Get database /// /// Get a database by its unique ID. This endpoint response returns a JSON /// object with the database metadata. @@ -124,8 +118,6 @@ open class Databases: Service { ) } - /// - /// Update database /// /// Update a database by its unique ID. /// @@ -165,8 +157,6 @@ open class Databases: Service { ) } - /// - /// Delete database /// /// Delete a database by its unique ID. Only API keys with with databases.write /// scope can delete a database. @@ -194,8 +184,6 @@ open class Databases: Service { params: apiParams ) } - /// - /// List collections /// /// Get a list of all collections that belong to the provided databaseId. You /// can use the search parameter to filter your results. @@ -236,8 +224,6 @@ open class Databases: Service { ) } - /// - /// Create collection /// /// Create a new Collection. Before using this route, you should create a new /// database resource using either a [server @@ -289,8 +275,6 @@ open class Databases: Service { ) } - /// - /// Get collection /// /// Get a collection by its unique ID. This endpoint response returns a JSON /// object with the collection metadata. @@ -327,8 +311,6 @@ open class Databases: Service { ) } - /// - /// Update collection /// /// Update a collection by its unique ID. /// @@ -377,8 +359,6 @@ open class Databases: Service { ) } - /// - /// Delete collection /// /// Delete a collection by its unique ID. Only users with write permissions /// have access to delete this resource. @@ -409,8 +389,6 @@ open class Databases: Service { params: apiParams ) } - /// - /// List attributes /// /// List attributes in the collection. /// @@ -450,8 +428,6 @@ open class Databases: Service { ) } - /// - /// Create boolean attribute /// /// Create a boolean attribute. /// @@ -501,8 +477,6 @@ open class Databases: Service { ) } - /// - /// Update boolean attribute /// /// Update a boolean attribute. Changing the `default` value will not update /// already existing documents. @@ -552,8 +526,6 @@ open class Databases: Service { ) } - /// - /// Create datetime attribute /// /// Create a date time attribute according to the ISO 8601 standard. /// @@ -602,8 +574,6 @@ open class Databases: Service { ) } - /// - /// Update dateTime attribute /// /// Update a date time attribute. Changing the `default` value will not update /// already existing documents. @@ -653,8 +623,6 @@ open class Databases: Service { ) } - /// - /// Create email attribute /// /// Create an email attribute. /// @@ -704,8 +672,6 @@ open class Databases: Service { ) } - /// - /// Update email attribute /// /// Update an email attribute. Changing the `default` value will not update /// already existing documents. @@ -756,8 +722,6 @@ open class Databases: Service { ) } - /// - /// Create enum attribute /// /// Create an enumeration attribute. The `elements` param acts as a white-list /// of accepted values for this attribute. @@ -811,8 +775,6 @@ open class Databases: Service { ) } - /// - /// Update enum attribute /// /// Update an enum attribute. Changing the `default` value will not update /// already existing documents. @@ -866,8 +828,6 @@ open class Databases: Service { ) } - /// - /// Create float attribute /// /// Create a float attribute. Optionally, minimum and maximum values can be /// provided. @@ -924,8 +884,6 @@ open class Databases: Service { ) } - /// - /// Update float attribute /// /// Update a float attribute. Changing the `default` value will not update /// already existing documents. @@ -982,8 +940,6 @@ open class Databases: Service { ) } - /// - /// Create integer attribute /// /// Create an integer attribute. Optionally, minimum and maximum values can be /// provided. @@ -1040,8 +996,6 @@ open class Databases: Service { ) } - /// - /// Update integer attribute /// /// Update an integer attribute. Changing the `default` value will not update /// already existing documents. @@ -1098,8 +1052,6 @@ open class Databases: Service { ) } - /// - /// Create IP address attribute /// /// Create IP address attribute. /// @@ -1149,8 +1101,6 @@ open class Databases: Service { ) } - /// - /// Update IP address attribute /// /// Update an ip attribute. Changing the `default` value will not update /// already existing documents. @@ -1201,8 +1151,6 @@ open class Databases: Service { ) } - /// - /// Create relationship attribute /// /// Create relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -1259,8 +1207,6 @@ open class Databases: Service { ) } - /// - /// Create string attribute /// /// Create a string attribute. /// @@ -1316,8 +1262,6 @@ open class Databases: Service { ) } - /// - /// Update string attribute /// /// Update a string attribute. Changing the `default` value will not update /// already existing documents. @@ -1371,8 +1315,6 @@ open class Databases: Service { ) } - /// - /// Create URL attribute /// /// Create a URL attribute. /// @@ -1422,8 +1364,6 @@ open class Databases: Service { ) } - /// - /// Update URL attribute /// /// Update an url attribute. Changing the `default` value will not update /// already existing documents. @@ -1474,8 +1414,6 @@ open class Databases: Service { ) } - /// - /// Get attribute /// /// Get attribute by ID. /// @@ -1508,8 +1446,6 @@ open class Databases: Service { params: apiParams ) } - /// - /// Delete attribute /// /// Deletes an attribute. /// @@ -1542,8 +1478,6 @@ open class Databases: Service { params: apiParams ) } - /// - /// Update relationship attribute /// /// Update relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -1591,8 +1525,6 @@ open class Databases: Service { ) } - /// - /// List documents /// /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. @@ -1634,8 +1566,6 @@ open class Databases: Service { ) } - /// - /// List documents /// /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. @@ -1659,8 +1589,6 @@ open class Databases: Service { ) } - /// - /// Create document /// /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server @@ -1710,8 +1638,6 @@ open class Databases: Service { ) } - /// - /// Create document /// /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server @@ -1743,8 +1669,6 @@ open class Databases: Service { ) } - /// - /// Get document /// /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. @@ -1789,8 +1713,6 @@ open class Databases: Service { ) } - /// - /// Get document /// /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. @@ -1817,8 +1739,6 @@ open class Databases: Service { ) } - /// - /// Update document /// /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. @@ -1866,8 +1786,6 @@ open class Databases: Service { ) } - /// - /// Update document /// /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. @@ -1897,8 +1815,6 @@ open class Databases: Service { ) } - /// - /// Delete document /// /// Delete a document by its unique ID. /// @@ -1931,8 +1847,6 @@ open class Databases: Service { params: apiParams ) } - /// - /// List indexes /// /// List indexes in the collection. /// @@ -1972,8 +1886,6 @@ open class Databases: Service { ) } - /// - /// Create index /// /// Creates an index on the attributes listed. Your index should include all /// the attributes you will query in a single request. @@ -2024,8 +1936,6 @@ open class Databases: Service { ) } - /// - /// Get index /// /// Get index by ID. /// @@ -2064,8 +1974,6 @@ open class Databases: Service { ) } - /// - /// Delete index /// /// Delete an index. /// diff --git a/Sources/Appwrite/Services/Functions.swift b/Sources/Appwrite/Services/Functions.swift index 28d5963..c56935e 100644 --- a/Sources/Appwrite/Services/Functions.swift +++ b/Sources/Appwrite/Services/Functions.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Functions Service allows you view, create and manage your Cloud Functions. open class Functions: Service { - /// - /// List functions /// /// Get a list of all the project's functions. You can use the query params to /// filter your results. @@ -47,8 +45,6 @@ open class Functions: Service { ) } - /// - /// Create function /// /// Create a new function. You can pass a list of /// [permissions](https://appwrite.io/docs/permissions) to allow different @@ -148,8 +144,6 @@ open class Functions: Service { ) } - /// - /// List runtimes /// /// Get a list of all runtimes that are currently active on your instance. /// @@ -179,8 +173,6 @@ open class Functions: Service { ) } - /// - /// List available function runtime specifications /// /// List allowed function specifications for this instance. /// @@ -211,8 +203,6 @@ open class Functions: Service { ) } - /// - /// Get function /// /// Get a function by its unique ID. /// @@ -245,8 +235,6 @@ open class Functions: Service { ) } - /// - /// Update function /// /// Update function by its unique ID. /// @@ -331,8 +319,6 @@ open class Functions: Service { ) } - /// - /// Delete function /// /// Delete a function by its unique ID. /// @@ -359,8 +345,6 @@ open class Functions: Service { params: apiParams ) } - /// - /// List deployments /// /// Get a list of all the project's code deployments. You can use the query /// params to filter your results. @@ -401,8 +385,6 @@ open class Functions: Service { ) } - /// - /// Create deployment /// /// Create a new function code deployment. Use this endpoint to upload a new /// version of your code function. To execute your newly uploaded code, you'll @@ -462,8 +444,6 @@ open class Functions: Service { ) } - /// - /// Get deployment /// /// Get a code deployment by its unique ID. /// @@ -499,8 +479,6 @@ open class Functions: Service { ) } - /// - /// Update deployment /// /// Update the function code deployment ID using the unique function ID. Use /// this endpoint to switch the code deployment that should be executed by the @@ -538,8 +516,6 @@ open class Functions: Service { ) } - /// - /// Delete deployment /// /// Delete a code deployment by its unique ID. /// @@ -569,8 +545,6 @@ open class Functions: Service { params: apiParams ) } - /// - /// Rebuild deployment /// /// Create a new build for an existing function deployment. This endpoint /// allows you to rebuild a deployment with the updated function configuration, @@ -608,8 +582,6 @@ open class Functions: Service { params: apiParams ) } - /// - /// Cancel deployment /// /// Cancel an ongoing function deployment build. If the build is already in /// progress, it will be stopped and marked as canceled. If the build hasn't @@ -649,8 +621,6 @@ open class Functions: Service { ) } - /// - /// Download deployment /// /// Get a Deployment's contents by its unique ID. This endpoint supports range /// requests for partial or streaming file download. @@ -681,8 +651,6 @@ open class Functions: Service { ) } - /// - /// List executions /// /// Get a list of all the current user function execution logs. You can use the /// query params to filter your results. @@ -723,8 +691,6 @@ open class Functions: Service { ) } - /// - /// Create execution /// /// Trigger a function execution. The returned object will return you the /// current execution status. You can ping the `Get Execution` endpoint to get @@ -779,8 +745,6 @@ open class Functions: Service { ) } - /// - /// Get execution /// /// Get a function execution log by its unique ID. /// @@ -816,8 +780,6 @@ open class Functions: Service { ) } - /// - /// Delete execution /// /// Delete a function execution by its unique ID. /// @@ -848,8 +810,6 @@ open class Functions: Service { params: apiParams ) } - /// - /// List variables /// /// Get a list of all variables of a specific function. /// @@ -882,8 +842,6 @@ open class Functions: Service { ) } - /// - /// Create variable /// /// Create a new function environment variable. These variables can be accessed /// in the function at runtime as environment variables. @@ -924,8 +882,6 @@ open class Functions: Service { ) } - /// - /// Get variable /// /// Get a variable by its unique ID. /// @@ -961,8 +917,6 @@ open class Functions: Service { ) } - /// - /// Update variable /// /// Update variable by its unique ID. /// @@ -1005,8 +959,6 @@ open class Functions: Service { ) } - /// - /// Delete variable /// /// Delete a variable by its unique ID. /// diff --git a/Sources/Appwrite/Services/Graphql.swift b/Sources/Appwrite/Services/Graphql.swift index cc019c9..68c326f 100644 --- a/Sources/Appwrite/Services/Graphql.swift +++ b/Sources/Appwrite/Services/Graphql.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The GraphQL API allows you to query and mutate your Appwrite server using GraphQL. open class Graphql: Service { - /// - /// GraphQL endpoint /// /// Execute a GraphQL mutation. /// @@ -44,8 +42,6 @@ open class Graphql: Service { ) } - /// - /// GraphQL endpoint /// /// Execute a GraphQL mutation. /// diff --git a/Sources/Appwrite/Services/Health.swift b/Sources/Appwrite/Services/Health.swift index 07c73b8..6957a34 100644 --- a/Sources/Appwrite/Services/Health.swift +++ b/Sources/Appwrite/Services/Health.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Health service allows you to both validate and monitor your Appwrite server's health. open class Health: Service { - /// - /// Get HTTP /// /// Check the Appwrite HTTP server is up and responsive. /// @@ -39,8 +37,6 @@ open class Health: Service { ) } - /// - /// Get antivirus /// /// Check the Appwrite Antivirus server is up and connection is successful. /// @@ -70,8 +66,6 @@ open class Health: Service { ) } - /// - /// Get cache /// /// Check the Appwrite in-memory cache servers are up and connection is /// successful. @@ -102,8 +96,6 @@ open class Health: Service { ) } - /// - /// Get the SSL certificate for a domain /// /// Get the SSL certificate for a domain /// @@ -137,8 +129,6 @@ open class Health: Service { ) } - /// - /// Get DB /// /// Check the Appwrite database servers are up and connection is successful. /// @@ -168,8 +158,6 @@ open class Health: Service { ) } - /// - /// Get pubsub /// /// Check the Appwrite pub-sub servers are up and connection is successful. /// @@ -199,8 +187,6 @@ open class Health: Service { ) } - /// - /// Get queue /// /// Check the Appwrite queue messaging servers are up and connection is /// successful. @@ -231,8 +217,6 @@ open class Health: Service { ) } - /// - /// Get builds queue /// /// Get the number of builds that are waiting to be processed in the Appwrite /// internal queue server. @@ -267,8 +251,6 @@ open class Health: Service { ) } - /// - /// Get certificates queue /// /// Get the number of certificates that are waiting to be issued against /// [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue @@ -304,8 +286,6 @@ open class Health: Service { ) } - /// - /// Get databases queue /// /// Get the number of database changes that are waiting to be processed in the /// Appwrite internal queue server. @@ -343,8 +323,6 @@ open class Health: Service { ) } - /// - /// Get deletes queue /// /// Get the number of background destructive changes that are waiting to be /// processed in the Appwrite internal queue server. @@ -379,8 +357,6 @@ open class Health: Service { ) } - /// - /// Get number of failed queue jobs /// /// Returns the amount of failed jobs in a given queue. /// @@ -418,8 +394,6 @@ open class Health: Service { ) } - /// - /// Get functions queue /// /// Get the number of function executions that are waiting to be processed in /// the Appwrite internal queue server. @@ -454,8 +428,6 @@ open class Health: Service { ) } - /// - /// Get logs queue /// /// Get the number of logs that are waiting to be processed in the Appwrite /// internal queue server. @@ -490,8 +462,6 @@ open class Health: Service { ) } - /// - /// Get mails queue /// /// Get the number of mails that are waiting to be processed in the Appwrite /// internal queue server. @@ -526,8 +496,6 @@ open class Health: Service { ) } - /// - /// Get messaging queue /// /// Get the number of messages that are waiting to be processed in the Appwrite /// internal queue server. @@ -562,8 +530,6 @@ open class Health: Service { ) } - /// - /// Get migrations queue /// /// Get the number of migrations that are waiting to be processed in the /// Appwrite internal queue server. @@ -598,8 +564,6 @@ open class Health: Service { ) } - /// - /// Get usage queue /// /// Get the number of metrics that are waiting to be processed in the Appwrite /// internal queue server. @@ -634,8 +598,6 @@ open class Health: Service { ) } - /// - /// Get usage dump queue /// /// Get the number of projects containing metrics that are waiting to be /// processed in the Appwrite internal queue server. @@ -670,8 +632,6 @@ open class Health: Service { ) } - /// - /// Get webhooks queue /// /// Get the number of webhooks that are waiting to be processed in the Appwrite /// internal queue server. @@ -706,8 +666,6 @@ open class Health: Service { ) } - /// - /// Get storage /// /// Check the Appwrite storage device is up and connection is successful. /// @@ -737,8 +695,6 @@ open class Health: Service { ) } - /// - /// Get local storage /// /// Check the Appwrite local storage device is up and connection is successful. /// @@ -768,8 +724,6 @@ open class Health: Service { ) } - /// - /// Get time /// /// Check the Appwrite server time is synced with Google remote NTP server. We /// use this technology to smoothly handle leap seconds with no disruptive diff --git a/Sources/Appwrite/Services/Locale.swift b/Sources/Appwrite/Services/Locale.swift index 170e11a..a15f09a 100644 --- a/Sources/Appwrite/Services/Locale.swift +++ b/Sources/Appwrite/Services/Locale.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Locale service allows you to customize your app based on your users' location. open class Locale: Service { - /// - /// Get user locale /// /// Get the current user location based on IP. Returns an object with user /// country code, country name, continent name, continent code, ip address and @@ -44,8 +42,6 @@ open class Locale: Service { ) } - /// - /// List locale codes /// /// List of all locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). @@ -76,8 +72,6 @@ open class Locale: Service { ) } - /// - /// List continents /// /// List of all continents. You can use the locale header to get the data in a /// supported language. @@ -108,8 +102,6 @@ open class Locale: Service { ) } - /// - /// List countries /// /// List of all countries. You can use the locale header to get the data in a /// supported language. @@ -140,8 +132,6 @@ open class Locale: Service { ) } - /// - /// List EU countries /// /// List of all countries that are currently members of the EU. You can use the /// locale header to get the data in a supported language. @@ -172,8 +162,6 @@ open class Locale: Service { ) } - /// - /// List countries phone codes /// /// List of all countries phone codes. You can use the locale header to get the /// data in a supported language. @@ -204,8 +192,6 @@ open class Locale: Service { ) } - /// - /// List currencies /// /// List of all currencies, including currency symbol, name, plural, and /// decimal digits for all major and minor currencies. You can use the locale @@ -237,8 +223,6 @@ open class Locale: Service { ) } - /// - /// List languages /// /// List of all languages classified by ISO 639-1 including 2-letter code, name /// in English, and name in the respective language. diff --git a/Sources/Appwrite/Services/Messaging.swift b/Sources/Appwrite/Services/Messaging.swift index 636fbe1..b43f9a0 100644 --- a/Sources/Appwrite/Services/Messaging.swift +++ b/Sources/Appwrite/Services/Messaging.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Messaging service allows you to send messages to any provider type (SMTP, push notification, SMS, etc.). open class Messaging: Service { - /// - /// List messages /// /// Get a list of all messages from the current Appwrite project. /// @@ -46,8 +44,6 @@ open class Messaging: Service { ) } - /// - /// Create email /// /// Create a new email message. /// @@ -115,9 +111,9 @@ open class Messaging: Service { } /// - /// Update email - /// - /// Update an email message by its unique ID. + /// Update an email message by its unique ID. This endpoint only works on + /// messages that are in draft status. Messages that are already processing, + /// sent, or failed cannot be updated. /// /// /// @param String messageId @@ -183,8 +179,6 @@ open class Messaging: Service { ) } - /// - /// Create push notification /// /// Create a new push notification. /// @@ -273,9 +267,9 @@ open class Messaging: Service { } /// - /// Update push notification - /// - /// Update a push notification by its unique ID. + /// Update a push notification by its unique ID. This endpoint only works on + /// messages that are in draft status. Messages that are already processing, + /// sent, or failed cannot be updated. /// /// /// @param String messageId @@ -362,8 +356,6 @@ open class Messaging: Service { ) } - /// - /// Create SMS /// /// Create a new SMS message. /// @@ -416,9 +408,9 @@ open class Messaging: Service { } /// - /// Update SMS - /// - /// Update an SMS message by its unique ID. + /// Update an SMS message by its unique ID. This endpoint only works on + /// messages that are in draft status. Messages that are already processing, + /// sent, or failed cannot be updated. /// /// /// @param String messageId @@ -469,8 +461,6 @@ open class Messaging: Service { ) } - /// - /// Get message /// /// Get a message by its unique ID. /// @@ -504,8 +494,6 @@ open class Messaging: Service { ) } - /// - /// Delete message /// /// Delete a message. If the message is not a draft or scheduled, but has been /// sent, this will not recall the message. @@ -533,8 +521,6 @@ open class Messaging: Service { params: apiParams ) } - /// - /// List message logs /// /// Get the message activity logs listed by its unique ID. /// @@ -571,8 +557,6 @@ open class Messaging: Service { ) } - /// - /// List message targets /// /// Get a list of the targets associated with a message. /// @@ -609,8 +593,6 @@ open class Messaging: Service { ) } - /// - /// List providers /// /// Get a list of all providers from the current Appwrite project. /// @@ -647,8 +629,6 @@ open class Messaging: Service { ) } - /// - /// Create APNS provider /// /// Create a new Apple Push Notification service provider. /// @@ -703,8 +683,6 @@ open class Messaging: Service { ) } - /// - /// Update APNS provider /// /// Update a Apple Push Notification service provider by its unique ID. /// @@ -759,8 +737,6 @@ open class Messaging: Service { ) } - /// - /// Create FCM provider /// /// Create a new Firebase Cloud Messaging provider. /// @@ -803,8 +779,6 @@ open class Messaging: Service { ) } - /// - /// Update FCM provider /// /// Update a Firebase Cloud Messaging provider by its unique ID. /// @@ -847,8 +821,6 @@ open class Messaging: Service { ) } - /// - /// Create Mailgun provider /// /// Create a new Mailgun provider. /// @@ -909,8 +881,6 @@ open class Messaging: Service { ) } - /// - /// Update Mailgun provider /// /// Update a Mailgun provider by its unique ID. /// @@ -971,8 +941,6 @@ open class Messaging: Service { ) } - /// - /// Create Msg91 provider /// /// Create a new MSG91 provider. /// @@ -1021,8 +989,6 @@ open class Messaging: Service { ) } - /// - /// Update Msg91 provider /// /// Update a MSG91 provider by its unique ID. /// @@ -1071,8 +1037,6 @@ open class Messaging: Service { ) } - /// - /// Create Sendgrid provider /// /// Create a new Sendgrid provider. /// @@ -1127,8 +1091,6 @@ open class Messaging: Service { ) } - /// - /// Update Sendgrid provider /// /// Update a Sendgrid provider by its unique ID. /// @@ -1183,8 +1145,6 @@ open class Messaging: Service { ) } - /// - /// Create SMTP provider /// /// Create a new SMTP provider. /// @@ -1257,8 +1217,6 @@ open class Messaging: Service { ) } - /// - /// Update SMTP provider /// /// Update a SMTP provider by its unique ID. /// @@ -1331,8 +1289,6 @@ open class Messaging: Service { ) } - /// - /// Create Telesign provider /// /// Create a new Telesign provider. /// @@ -1381,8 +1337,6 @@ open class Messaging: Service { ) } - /// - /// Update Telesign provider /// /// Update a Telesign provider by its unique ID. /// @@ -1431,8 +1385,6 @@ open class Messaging: Service { ) } - /// - /// Create Textmagic provider /// /// Create a new Textmagic provider. /// @@ -1481,8 +1433,6 @@ open class Messaging: Service { ) } - /// - /// Update Textmagic provider /// /// Update a Textmagic provider by its unique ID. /// @@ -1531,8 +1481,6 @@ open class Messaging: Service { ) } - /// - /// Create Twilio provider /// /// Create a new Twilio provider. /// @@ -1581,8 +1529,6 @@ open class Messaging: Service { ) } - /// - /// Update Twilio provider /// /// Update a Twilio provider by its unique ID. /// @@ -1631,8 +1577,6 @@ open class Messaging: Service { ) } - /// - /// Create Vonage provider /// /// Create a new Vonage provider. /// @@ -1681,8 +1625,6 @@ open class Messaging: Service { ) } - /// - /// Update Vonage provider /// /// Update a Vonage provider by its unique ID. /// @@ -1731,8 +1673,6 @@ open class Messaging: Service { ) } - /// - /// Get provider /// /// Get a provider by its unique ID. /// @@ -1766,8 +1706,6 @@ open class Messaging: Service { ) } - /// - /// Delete provider /// /// Delete a provider by its unique ID. /// @@ -1794,8 +1732,6 @@ open class Messaging: Service { params: apiParams ) } - /// - /// List provider logs /// /// Get the provider activity logs listed by its unique ID. /// @@ -1832,8 +1768,6 @@ open class Messaging: Service { ) } - /// - /// List subscriber logs /// /// Get the subscriber activity logs listed by its unique ID. /// @@ -1870,8 +1804,6 @@ open class Messaging: Service { ) } - /// - /// List topics /// /// Get a list of all topics from the current Appwrite project. /// @@ -1908,8 +1840,6 @@ open class Messaging: Service { ) } - /// - /// Create topic /// /// Create a new topic. /// @@ -1949,8 +1879,6 @@ open class Messaging: Service { ) } - /// - /// Get topic /// /// Get a topic by its unique ID. /// @@ -1984,8 +1912,6 @@ open class Messaging: Service { ) } - /// - /// Update topic /// /// Update a topic by its unique ID. /// @@ -2026,8 +1952,6 @@ open class Messaging: Service { ) } - /// - /// Delete topic /// /// Delete a topic by its unique ID. /// @@ -2054,8 +1978,6 @@ open class Messaging: Service { params: apiParams ) } - /// - /// List topic logs /// /// Get the topic activity logs listed by its unique ID. /// @@ -2092,8 +2014,6 @@ open class Messaging: Service { ) } - /// - /// List subscribers /// /// Get a list of all subscribers from the current Appwrite project. /// @@ -2133,8 +2053,6 @@ open class Messaging: Service { ) } - /// - /// Create subscriber /// /// Create a new subscriber. /// @@ -2174,8 +2092,6 @@ open class Messaging: Service { ) } - /// - /// Get subscriber /// /// Get a subscriber by its unique ID. /// @@ -2212,8 +2128,6 @@ open class Messaging: Service { ) } - /// - /// Delete subscriber /// /// Delete a subscriber by its unique ID. /// diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index c3454aa..206b0e1 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Storage service allows you to manage your project files. open class Storage: Service { - /// - /// List buckets /// /// Get a list of all the storage buckets. You can use the query params to /// filter your results. @@ -47,8 +45,6 @@ open class Storage: Service { ) } - /// - /// Create bucket /// /// Create a new storage bucket. /// @@ -109,8 +105,6 @@ open class Storage: Service { ) } - /// - /// Get bucket /// /// Get a storage bucket by its unique ID. This endpoint response returns a /// JSON object with the storage bucket metadata. @@ -144,8 +138,6 @@ open class Storage: Service { ) } - /// - /// Update bucket /// /// Update a storage bucket by its unique ID. /// @@ -206,8 +198,6 @@ open class Storage: Service { ) } - /// - /// Delete bucket /// /// Delete a storage bucket by its unique ID. /// @@ -234,8 +224,6 @@ open class Storage: Service { params: apiParams ) } - /// - /// List files /// /// Get a list of all the user files. You can use the query params to filter /// your results. @@ -276,8 +264,6 @@ open class Storage: Service { ) } - /// - /// Create file /// /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server @@ -342,8 +328,6 @@ open class Storage: Service { ) } - /// - /// Get file /// /// Get a file by its unique ID. This endpoint response returns a JSON object /// with the file metadata. @@ -380,8 +364,6 @@ open class Storage: Service { ) } - /// - /// Update file /// /// Update a file by its unique ID. Only users with write permissions have /// access to update this resource. @@ -425,8 +407,6 @@ open class Storage: Service { ) } - /// - /// Delete file /// /// Delete a file by its unique ID. Only users with write permissions have /// access to delete this resource. @@ -457,8 +437,6 @@ open class Storage: Service { params: apiParams ) } - /// - /// Get file for download /// /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start @@ -490,8 +468,6 @@ open class Storage: Service { ) } - /// - /// Get file preview /// /// Get a file preview image. Currently, this method supports preview for image /// files (jpg, png, and gif), other supported formats, like pdf, docs, slides, @@ -561,8 +537,6 @@ open class Storage: Service { ) } - /// - /// Get file for view /// /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' diff --git a/Sources/Appwrite/Services/Teams.swift b/Sources/Appwrite/Services/Teams.swift index a4d3123..b20c3bd 100644 --- a/Sources/Appwrite/Services/Teams.swift +++ b/Sources/Appwrite/Services/Teams.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources open class Teams: Service { - /// - /// List teams /// /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. @@ -48,8 +46,6 @@ open class Teams: Service { ) } - /// - /// List teams /// /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. @@ -70,8 +66,6 @@ open class Teams: Service { ) } - /// - /// Create team /// /// Create a new team. The user who creates the team will automatically be /// assigned as the owner of the team. Only the users with the owner role can @@ -114,8 +108,6 @@ open class Teams: Service { ) } - /// - /// Create team /// /// Create a new team. The user who creates the team will automatically be /// assigned as the owner of the team. Only the users with the owner role can @@ -140,8 +132,6 @@ open class Teams: Service { ) } - /// - /// Get team /// /// Get a team by its ID. All team members have read access for this resource. /// @@ -175,8 +165,6 @@ open class Teams: Service { ) } - /// - /// Get team /// /// Get a team by its ID. All team members have read access for this resource. /// @@ -193,8 +181,6 @@ open class Teams: Service { ) } - /// - /// Update name /// /// Update the team's name by its unique ID. /// @@ -232,8 +218,6 @@ open class Teams: Service { ) } - /// - /// Update name /// /// Update the team's name by its unique ID. /// @@ -253,8 +237,6 @@ open class Teams: Service { ) } - /// - /// Delete team /// /// Delete a team using its ID. Only team members with the owner role can /// delete the team. @@ -282,8 +264,6 @@ open class Teams: Service { params: apiParams ) } - /// - /// List team memberships /// /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from @@ -325,8 +305,6 @@ open class Teams: Service { ) } - /// - /// Create team membership /// /// Invite a new member to join your team. Provide an ID for existing users, or /// invite unregistered users using an email or phone number. If initiated from @@ -398,8 +376,6 @@ open class Teams: Service { ) } - /// - /// Get team membership /// /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by @@ -437,8 +413,6 @@ open class Teams: Service { ) } - /// - /// Update membership /// /// Modify the roles of a team member. Only team members with the owner role /// have access to this endpoint. Learn more about [roles and @@ -481,8 +455,6 @@ open class Teams: Service { ) } - /// - /// Delete team membership /// /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to @@ -514,8 +486,6 @@ open class Teams: Service { params: apiParams ) } - /// - /// Update team membership status /// /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received @@ -564,8 +534,6 @@ open class Teams: Service { ) } - /// - /// Get team preferences /// /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user @@ -601,8 +569,6 @@ open class Teams: Service { ) } - /// - /// Get team preferences /// /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user @@ -621,8 +587,6 @@ open class Teams: Service { ) } - /// - /// Update preferences /// /// Update the team's preferences by its unique ID. The object you pass is /// stored as is and replaces any previous value. The maximum allowed prefs @@ -662,8 +626,6 @@ open class Teams: Service { ) } - /// - /// Update preferences /// /// Update the team's preferences by its unique ID. The object you pass is /// stored as is and replaces any previous value. The maximum allowed prefs diff --git a/Sources/Appwrite/Services/Users.swift b/Sources/Appwrite/Services/Users.swift index 3b78b8a..787f346 100644 --- a/Sources/Appwrite/Services/Users.swift +++ b/Sources/Appwrite/Services/Users.swift @@ -8,8 +8,6 @@ import AppwriteModels /// The Users service allows you to manage your project users. open class Users: Service { - /// - /// List users /// /// Get a list of all the project's users. You can use the query params to /// filter your results. @@ -48,8 +46,6 @@ open class Users: Service { ) } - /// - /// List users /// /// Get a list of all the project's users. You can use the query params to /// filter your results. @@ -70,8 +66,6 @@ open class Users: Service { ) } - /// - /// Create user /// /// Create a new user. /// @@ -118,8 +112,6 @@ open class Users: Service { ) } - /// - /// Create user /// /// Create a new user. /// @@ -148,8 +140,6 @@ open class Users: Service { ) } - /// - /// Create user with Argon2 password /// /// Create a new user. Password provided must be hashed with the /// [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST @@ -196,8 +186,6 @@ open class Users: Service { ) } - /// - /// Create user with Argon2 password /// /// Create a new user. Password provided must be hashed with the /// [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST @@ -226,8 +214,6 @@ open class Users: Service { ) } - /// - /// Create user with bcrypt password /// /// Create a new user. Password provided must be hashed with the /// [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST @@ -274,8 +260,6 @@ open class Users: Service { ) } - /// - /// Create user with bcrypt password /// /// Create a new user. Password provided must be hashed with the /// [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST @@ -304,8 +288,6 @@ open class Users: Service { ) } - /// - /// List identities /// /// Get identities for all users. /// @@ -342,8 +324,6 @@ open class Users: Service { ) } - /// - /// Delete identity /// /// Delete an identity by its unique ID. /// @@ -370,8 +350,6 @@ open class Users: Service { params: apiParams ) } - /// - /// Create user with MD5 password /// /// Create a new user. Password provided must be hashed with the /// [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST @@ -418,8 +396,6 @@ open class Users: Service { ) } - /// - /// Create user with MD5 password /// /// Create a new user. Password provided must be hashed with the /// [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST @@ -448,8 +424,6 @@ open class Users: Service { ) } - /// - /// Create user with PHPass password /// /// Create a new user. Password provided must be hashed with the /// [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST @@ -496,8 +470,6 @@ open class Users: Service { ) } - /// - /// Create user with PHPass password /// /// Create a new user. Password provided must be hashed with the /// [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST @@ -526,8 +498,6 @@ open class Users: Service { ) } - /// - /// Create user with Scrypt password /// /// Create a new user. Password provided must be hashed with the /// [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST @@ -589,8 +559,6 @@ open class Users: Service { ) } - /// - /// Create user with Scrypt password /// /// Create a new user. Password provided must be hashed with the /// [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST @@ -634,8 +602,6 @@ open class Users: Service { ) } - /// - /// Create user with Scrypt modified password /// /// Create a new user. Password provided must be hashed with the [Scrypt /// Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) @@ -692,8 +658,6 @@ open class Users: Service { ) } - /// - /// Create user with Scrypt modified password /// /// Create a new user. Password provided must be hashed with the [Scrypt /// Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) @@ -732,8 +696,6 @@ open class Users: Service { ) } - /// - /// Create user with SHA password /// /// Create a new user. Password provided must be hashed with the /// [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use @@ -783,8 +745,6 @@ open class Users: Service { ) } - /// - /// Create user with SHA password /// /// Create a new user. Password provided must be hashed with the /// [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use @@ -816,8 +776,6 @@ open class Users: Service { ) } - /// - /// Get user /// /// Get a user by its unique ID. /// @@ -851,8 +809,6 @@ open class Users: Service { ) } - /// - /// Get user /// /// Get a user by its unique ID. /// @@ -869,8 +825,6 @@ open class Users: Service { ) } - /// - /// Delete user /// /// Delete a user by its unique ID, thereby releasing it's ID. Since ID is /// released and can be reused, all user-related resources like documents or @@ -902,8 +856,6 @@ open class Users: Service { params: apiParams ) } - /// - /// Update email /// /// Update the user email by its unique ID. /// @@ -941,8 +893,6 @@ open class Users: Service { ) } - /// - /// Update email /// /// Update the user email by its unique ID. /// @@ -962,8 +912,6 @@ open class Users: Service { ) } - /// - /// Create user JWT /// /// Use this endpoint to create a JSON Web Token for user by its unique ID. You /// can use the resulting JWT to authenticate on behalf of the user. The JWT @@ -1005,8 +953,6 @@ open class Users: Service { ) } - /// - /// Update user labels /// /// Update the user labels by its unique ID. /// @@ -1049,8 +995,6 @@ open class Users: Service { ) } - /// - /// Update user labels /// /// Update the user labels by its unique ID. /// @@ -1075,8 +1019,6 @@ open class Users: Service { ) } - /// - /// List user logs /// /// Get the user activity logs list by its unique ID. /// @@ -1113,8 +1055,6 @@ open class Users: Service { ) } - /// - /// List user memberships /// /// Get the user membership list by its unique ID. /// @@ -1147,8 +1087,6 @@ open class Users: Service { ) } - /// - /// Update MFA /// /// Enable or disable MFA on a user account. /// @@ -1186,8 +1124,6 @@ open class Users: Service { ) } - /// - /// Update MFA /// /// Enable or disable MFA on a user account. /// @@ -1207,8 +1143,6 @@ open class Users: Service { ) } - /// - /// Delete authenticator /// /// Delete an authenticator app. /// @@ -1238,8 +1172,6 @@ open class Users: Service { params: apiParams ) } - /// - /// List factors /// /// List the factors available on the account to be used as a MFA challange. /// @@ -1272,8 +1204,6 @@ open class Users: Service { ) } - /// - /// Get MFA recovery codes /// /// Get recovery codes that can be used as backup for MFA flow by User ID. /// Before getting codes, they must be generated using @@ -1309,8 +1239,6 @@ open class Users: Service { ) } - /// - /// Regenerate MFA recovery codes /// /// Regenerate recovery codes that can be used as backup for MFA flow by User /// ID. Before regenerating codes, they must be first generated using @@ -1346,8 +1274,6 @@ open class Users: Service { ) } - /// - /// Create MFA recovery codes /// /// Generate recovery codes used as backup for MFA flow for User ID. Recovery /// codes can be used as a MFA verification type in @@ -1383,8 +1309,6 @@ open class Users: Service { ) } - /// - /// Update name /// /// Update the user name by its unique ID. /// @@ -1422,8 +1346,6 @@ open class Users: Service { ) } - /// - /// Update name /// /// Update the user name by its unique ID. /// @@ -1443,8 +1365,6 @@ open class Users: Service { ) } - /// - /// Update password /// /// Update the user password by its unique ID. /// @@ -1482,8 +1402,6 @@ open class Users: Service { ) } - /// - /// Update password /// /// Update the user password by its unique ID. /// @@ -1503,8 +1421,6 @@ open class Users: Service { ) } - /// - /// Update phone /// /// Update the user phone by its unique ID. /// @@ -1542,8 +1458,6 @@ open class Users: Service { ) } - /// - /// Update phone /// /// Update the user phone by its unique ID. /// @@ -1563,8 +1477,6 @@ open class Users: Service { ) } - /// - /// Get user preferences /// /// Get the user preferences by its unique ID. /// @@ -1598,8 +1510,6 @@ open class Users: Service { ) } - /// - /// Get user preferences /// /// Get the user preferences by its unique ID. /// @@ -1616,8 +1526,6 @@ open class Users: Service { ) } - /// - /// Update user preferences /// /// Update the user preferences by its unique ID. The object you pass is stored /// as is, and replaces any previous value. The maximum allowed prefs size is @@ -1657,8 +1565,6 @@ open class Users: Service { ) } - /// - /// Update user preferences /// /// Update the user preferences by its unique ID. The object you pass is stored /// as is, and replaces any previous value. The maximum allowed prefs size is @@ -1680,8 +1586,6 @@ open class Users: Service { ) } - /// - /// List user sessions /// /// Get the user sessions list by its unique ID. /// @@ -1714,8 +1618,6 @@ open class Users: Service { ) } - /// - /// Create session /// /// Creates a session for a user. Returns an immediately usable session object. /// @@ -1753,8 +1655,6 @@ open class Users: Service { ) } - /// - /// Delete user sessions /// /// Delete all user's sessions by using the user's unique ID. /// @@ -1781,8 +1681,6 @@ open class Users: Service { params: apiParams ) } - /// - /// Delete user session /// /// Delete a user sessions by its unique ID. /// @@ -1812,8 +1710,6 @@ open class Users: Service { params: apiParams ) } - /// - /// Update user status /// /// Update the user status by its unique ID. Use this endpoint as an /// alternative to deleting a user if you want to keep user's ID reserved. @@ -1852,8 +1748,6 @@ open class Users: Service { ) } - /// - /// Update user status /// /// Update the user status by its unique ID. Use this endpoint as an /// alternative to deleting a user if you want to keep user's ID reserved. @@ -1874,8 +1768,6 @@ open class Users: Service { ) } - /// - /// List user targets /// /// List the messaging targets that are associated with a user. /// @@ -1912,8 +1804,6 @@ open class Users: Service { ) } - /// - /// Create user target /// /// Create a messaging target. /// @@ -1962,8 +1852,6 @@ open class Users: Service { ) } - /// - /// Get user target /// /// Get a user's push notification target by ID. /// @@ -1999,8 +1887,6 @@ open class Users: Service { ) } - /// - /// Update user target /// /// Update a messaging target. /// @@ -2046,8 +1932,6 @@ open class Users: Service { ) } - /// - /// Delete user target /// /// Delete a messaging target. /// @@ -2077,8 +1961,6 @@ open class Users: Service { params: apiParams ) } - /// - /// Create token /// /// Returns a token with a secret key for creating a session. Use the user ID /// and secret and submit a request to the [PUT @@ -2122,8 +2004,6 @@ open class Users: Service { ) } - /// - /// Update email verification /// /// Update the user email verification status by its unique ID. /// @@ -2161,8 +2041,6 @@ open class Users: Service { ) } - /// - /// Update email verification /// /// Update the user email verification status by its unique ID. /// @@ -2182,8 +2060,6 @@ open class Users: Service { ) } - /// - /// Update phone verification /// /// Update the user phone verification status by its unique ID. /// @@ -2221,8 +2097,6 @@ open class Users: Service { ) } - /// - /// Update phone verification /// /// Update the user phone verification status by its unique ID. /// diff --git a/Sources/AppwriteModels/AlgoArgon2.swift b/Sources/AppwriteModels/AlgoArgon2.swift index c93c034..fd88955 100644 --- a/Sources/AppwriteModels/AlgoArgon2.swift +++ b/Sources/AppwriteModels/AlgoArgon2.swift @@ -2,7 +2,14 @@ import Foundation import JSONCodable /// AlgoArgon2 -public class AlgoArgon2 { +open class AlgoArgon2: Codable { + + enum CodingKeys: String, CodingKey { + case type = "type" + case memoryCost = "memoryCost" + case timeCost = "timeCost" + case threads = "threads" + } /// Algo type. public let type: String @@ -29,6 +36,24 @@ public class AlgoArgon2 { self.threads = threads } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.type = try container.decode(String.self, forKey: .type) + self.memoryCost = try container.decode(Int.self, forKey: .memoryCost) + self.timeCost = try container.decode(Int.self, forKey: .timeCost) + self.threads = try container.decode(Int.self, forKey: .threads) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(type, forKey: .type) + try container.encode(memoryCost, forKey: .memoryCost) + try container.encode(timeCost, forKey: .timeCost) + try container.encode(threads, forKey: .threads) + } + public func toMap() -> [String: Any] { return [ "type": type as Any, diff --git a/Sources/AppwriteModels/AlgoBcrypt.swift b/Sources/AppwriteModels/AlgoBcrypt.swift index 8d59f2d..b34095d 100644 --- a/Sources/AppwriteModels/AlgoBcrypt.swift +++ b/Sources/AppwriteModels/AlgoBcrypt.swift @@ -2,7 +2,11 @@ import Foundation import JSONCodable /// AlgoBcrypt -public class AlgoBcrypt { +open class AlgoBcrypt: Codable { + + enum CodingKeys: String, CodingKey { + case type = "type" + } /// Algo type. public let type: String @@ -14,6 +18,18 @@ public class AlgoBcrypt { self.type = type } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.type = try container.decode(String.self, forKey: .type) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(type, forKey: .type) + } + public func toMap() -> [String: Any] { return [ "type": type as Any diff --git a/Sources/AppwriteModels/AlgoMd5.swift b/Sources/AppwriteModels/AlgoMd5.swift index 050fe5c..72fbb8d 100644 --- a/Sources/AppwriteModels/AlgoMd5.swift +++ b/Sources/AppwriteModels/AlgoMd5.swift @@ -2,7 +2,11 @@ import Foundation import JSONCodable /// AlgoMD5 -public class AlgoMd5 { +open class AlgoMd5: Codable { + + enum CodingKeys: String, CodingKey { + case type = "type" + } /// Algo type. public let type: String @@ -14,6 +18,18 @@ public class AlgoMd5 { self.type = type } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.type = try container.decode(String.self, forKey: .type) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(type, forKey: .type) + } + public func toMap() -> [String: Any] { return [ "type": type as Any diff --git a/Sources/AppwriteModels/AlgoPhpass.swift b/Sources/AppwriteModels/AlgoPhpass.swift index 493463d..7bd0c99 100644 --- a/Sources/AppwriteModels/AlgoPhpass.swift +++ b/Sources/AppwriteModels/AlgoPhpass.swift @@ -2,7 +2,11 @@ import Foundation import JSONCodable /// AlgoPHPass -public class AlgoPhpass { +open class AlgoPhpass: Codable { + + enum CodingKeys: String, CodingKey { + case type = "type" + } /// Algo type. public let type: String @@ -14,6 +18,18 @@ public class AlgoPhpass { self.type = type } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.type = try container.decode(String.self, forKey: .type) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(type, forKey: .type) + } + public func toMap() -> [String: Any] { return [ "type": type as Any diff --git a/Sources/AppwriteModels/AlgoScrypt.swift b/Sources/AppwriteModels/AlgoScrypt.swift index 73254f2..03ce541 100644 --- a/Sources/AppwriteModels/AlgoScrypt.swift +++ b/Sources/AppwriteModels/AlgoScrypt.swift @@ -2,7 +2,15 @@ import Foundation import JSONCodable /// AlgoScrypt -public class AlgoScrypt { +open class AlgoScrypt: Codable { + + enum CodingKeys: String, CodingKey { + case type = "type" + case costCpu = "costCpu" + case costMemory = "costMemory" + case costParallel = "costParallel" + case length = "length" + } /// Algo type. public let type: String @@ -34,6 +42,26 @@ public class AlgoScrypt { self.length = length } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.type = try container.decode(String.self, forKey: .type) + self.costCpu = try container.decode(Int.self, forKey: .costCpu) + self.costMemory = try container.decode(Int.self, forKey: .costMemory) + self.costParallel = try container.decode(Int.self, forKey: .costParallel) + self.length = try container.decode(Int.self, forKey: .length) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(type, forKey: .type) + try container.encode(costCpu, forKey: .costCpu) + try container.encode(costMemory, forKey: .costMemory) + try container.encode(costParallel, forKey: .costParallel) + try container.encode(length, forKey: .length) + } + public func toMap() -> [String: Any] { return [ "type": type as Any, diff --git a/Sources/AppwriteModels/AlgoScryptModified.swift b/Sources/AppwriteModels/AlgoScryptModified.swift index bc1fde5..0b2fa4e 100644 --- a/Sources/AppwriteModels/AlgoScryptModified.swift +++ b/Sources/AppwriteModels/AlgoScryptModified.swift @@ -2,7 +2,14 @@ import Foundation import JSONCodable /// AlgoScryptModified -public class AlgoScryptModified { +open class AlgoScryptModified: Codable { + + enum CodingKeys: String, CodingKey { + case type = "type" + case salt = "salt" + case saltSeparator = "saltSeparator" + case signerKey = "signerKey" + } /// Algo type. public let type: String @@ -29,6 +36,24 @@ public class AlgoScryptModified { self.signerKey = signerKey } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.type = try container.decode(String.self, forKey: .type) + self.salt = try container.decode(String.self, forKey: .salt) + self.saltSeparator = try container.decode(String.self, forKey: .saltSeparator) + self.signerKey = try container.decode(String.self, forKey: .signerKey) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(type, forKey: .type) + try container.encode(salt, forKey: .salt) + try container.encode(saltSeparator, forKey: .saltSeparator) + try container.encode(signerKey, forKey: .signerKey) + } + public func toMap() -> [String: Any] { return [ "type": type as Any, diff --git a/Sources/AppwriteModels/AlgoSha.swift b/Sources/AppwriteModels/AlgoSha.swift index c0a0532..ffc0e05 100644 --- a/Sources/AppwriteModels/AlgoSha.swift +++ b/Sources/AppwriteModels/AlgoSha.swift @@ -2,7 +2,11 @@ import Foundation import JSONCodable /// AlgoSHA -public class AlgoSha { +open class AlgoSha: Codable { + + enum CodingKeys: String, CodingKey { + case type = "type" + } /// Algo type. public let type: String @@ -14,6 +18,18 @@ public class AlgoSha { self.type = type } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.type = try container.decode(String.self, forKey: .type) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(type, forKey: .type) + } + public func toMap() -> [String: Any] { return [ "type": type as Any diff --git a/Sources/AppwriteModels/AttributeBoolean.swift b/Sources/AppwriteModels/AttributeBoolean.swift index f8373c4..31522c2 100644 --- a/Sources/AppwriteModels/AttributeBoolean.swift +++ b/Sources/AppwriteModels/AttributeBoolean.swift @@ -2,7 +2,19 @@ import Foundation import JSONCodable /// AttributeBoolean -public class AttributeBoolean { +open class AttributeBoolean: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -54,6 +66,34 @@ public class AttributeBoolean { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.`default` = try container.decodeIfPresent(Bool.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeDatetime.swift b/Sources/AppwriteModels/AttributeDatetime.swift index 260e978..ac80231 100644 --- a/Sources/AppwriteModels/AttributeDatetime.swift +++ b/Sources/AppwriteModels/AttributeDatetime.swift @@ -2,7 +2,20 @@ import Foundation import JSONCodable /// AttributeDatetime -public class AttributeDatetime { +open class AttributeDatetime: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case format = "format" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -59,6 +72,36 @@ public class AttributeDatetime { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeEmail.swift b/Sources/AppwriteModels/AttributeEmail.swift index 9223060..8e57b2c 100644 --- a/Sources/AppwriteModels/AttributeEmail.swift +++ b/Sources/AppwriteModels/AttributeEmail.swift @@ -2,7 +2,20 @@ import Foundation import JSONCodable /// AttributeEmail -public class AttributeEmail { +open class AttributeEmail: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case format = "format" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -59,6 +72,36 @@ public class AttributeEmail { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeEnum.swift b/Sources/AppwriteModels/AttributeEnum.swift index 8694823..e232869 100644 --- a/Sources/AppwriteModels/AttributeEnum.swift +++ b/Sources/AppwriteModels/AttributeEnum.swift @@ -2,7 +2,21 @@ import Foundation import JSONCodable /// AttributeEnum -public class AttributeEnum { +open class AttributeEnum: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case elements = "elements" + case format = "format" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -64,6 +78,38 @@ public class AttributeEnum { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.elements = try container.decode([String].self, forKey: .elements) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(elements, forKey: .elements) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeFloat.swift b/Sources/AppwriteModels/AttributeFloat.swift index 72d2353..676f317 100644 --- a/Sources/AppwriteModels/AttributeFloat.swift +++ b/Sources/AppwriteModels/AttributeFloat.swift @@ -2,7 +2,21 @@ import Foundation import JSONCodable /// AttributeFloat -public class AttributeFloat { +open class AttributeFloat: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case min = "min" + case max = "max" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -64,6 +78,38 @@ public class AttributeFloat { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.min = try container.decodeIfPresent(Double.self, forKey: .min) + self.max = try container.decodeIfPresent(Double.self, forKey: .max) + self.`default` = try container.decodeIfPresent(Double.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(min, forKey: .min) + try container.encodeIfPresent(max, forKey: .max) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeInteger.swift b/Sources/AppwriteModels/AttributeInteger.swift index eaca8ac..06d3a69 100644 --- a/Sources/AppwriteModels/AttributeInteger.swift +++ b/Sources/AppwriteModels/AttributeInteger.swift @@ -2,7 +2,21 @@ import Foundation import JSONCodable /// AttributeInteger -public class AttributeInteger { +open class AttributeInteger: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case min = "min" + case max = "max" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -64,6 +78,38 @@ public class AttributeInteger { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.min = try container.decodeIfPresent(Int.self, forKey: .min) + self.max = try container.decodeIfPresent(Int.self, forKey: .max) + self.`default` = try container.decodeIfPresent(Int.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(min, forKey: .min) + try container.encodeIfPresent(max, forKey: .max) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeIp.swift b/Sources/AppwriteModels/AttributeIp.swift index 39bd657..7904155 100644 --- a/Sources/AppwriteModels/AttributeIp.swift +++ b/Sources/AppwriteModels/AttributeIp.swift @@ -2,7 +2,20 @@ import Foundation import JSONCodable /// AttributeIP -public class AttributeIp { +open class AttributeIp: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case format = "format" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -59,6 +72,36 @@ public class AttributeIp { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeList.swift b/Sources/AppwriteModels/AttributeList.swift index a4a070f..2116477 100644 --- a/Sources/AppwriteModels/AttributeList.swift +++ b/Sources/AppwriteModels/AttributeList.swift @@ -2,23 +2,42 @@ import Foundation import JSONCodable /// Attributes List -public class AttributeList { +open class AttributeList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case attributes = "attributes" + } /// Total number of attributes in the given collection. public let total: Int /// List of attributes. - public let attributes: [Any] + public let attributes: [AnyCodable] init( total: Int, - attributes: [Any] + attributes: [AnyCodable] ) { self.total = total self.attributes = attributes } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.attributes = try container.decode([AnyCodable].self, forKey: .attributes) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(attributes, forKey: .attributes) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, @@ -29,7 +48,7 @@ public class AttributeList { public static func from(map: [String: Any] ) -> AttributeList { return AttributeList( total: map["total"] as! Int, - attributes: map["attributes"] as! [Any] + attributes: map["attributes"] as! [AnyCodable] ) } } diff --git a/Sources/AppwriteModels/AttributeRelationship.swift b/Sources/AppwriteModels/AttributeRelationship.swift index 8d8c8d0..a1f8cd7 100644 --- a/Sources/AppwriteModels/AttributeRelationship.swift +++ b/Sources/AppwriteModels/AttributeRelationship.swift @@ -2,7 +2,24 @@ import Foundation import JSONCodable /// AttributeRelationship -public class AttributeRelationship { +open class AttributeRelationship: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case relatedCollection = "relatedCollection" + case relationType = "relationType" + case twoWay = "twoWay" + case twoWayKey = "twoWayKey" + case onDelete = "onDelete" + case side = "side" + } /// Attribute Key. public let key: String @@ -79,6 +96,44 @@ public class AttributeRelationship { self.side = side } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.relatedCollection = try container.decode(String.self, forKey: .relatedCollection) + self.relationType = try container.decode(String.self, forKey: .relationType) + self.twoWay = try container.decode(Bool.self, forKey: .twoWay) + self.twoWayKey = try container.decode(String.self, forKey: .twoWayKey) + self.onDelete = try container.decode(String.self, forKey: .onDelete) + self.side = try container.decode(String.self, forKey: .side) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(relatedCollection, forKey: .relatedCollection) + try container.encode(relationType, forKey: .relationType) + try container.encode(twoWay, forKey: .twoWay) + try container.encode(twoWayKey, forKey: .twoWayKey) + try container.encode(onDelete, forKey: .onDelete) + try container.encode(side, forKey: .side) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeString.swift b/Sources/AppwriteModels/AttributeString.swift index d609b0a..5aeead7 100644 --- a/Sources/AppwriteModels/AttributeString.swift +++ b/Sources/AppwriteModels/AttributeString.swift @@ -2,7 +2,20 @@ import Foundation import JSONCodable /// AttributeString -public class AttributeString { +open class AttributeString: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case size = "size" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -59,6 +72,36 @@ public class AttributeString { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + 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`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(size, forKey: .size) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/AttributeUrl.swift b/Sources/AppwriteModels/AttributeUrl.swift index 952d990..cfbeac5 100644 --- a/Sources/AppwriteModels/AttributeUrl.swift +++ b/Sources/AppwriteModels/AttributeUrl.swift @@ -2,7 +2,20 @@ import Foundation import JSONCodable /// AttributeURL -public class AttributeUrl { +open class AttributeUrl: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case format = "format" + case `default` = "default" + } /// Attribute Key. public let key: String @@ -59,6 +72,36 @@ public class AttributeUrl { self.`default` = `default` } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/Bucket.swift b/Sources/AppwriteModels/Bucket.swift index d10f6a8..be437f5 100644 --- a/Sources/AppwriteModels/Bucket.swift +++ b/Sources/AppwriteModels/Bucket.swift @@ -2,7 +2,22 @@ import Foundation import JSONCodable /// Bucket -public class Bucket { +open class Bucket: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case fileSecurity = "fileSecurity" + case name = "name" + case enabled = "enabled" + case maximumFileSize = "maximumFileSize" + case allowedFileExtensions = "allowedFileExtensions" + case compression = "compression" + case encryption = "encryption" + case antivirus = "antivirus" + } /// Bucket ID. public let id: String @@ -69,6 +84,40 @@ public class Bucket { self.antivirus = antivirus } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.permissions = try container.decode([String].self, forKey: .permissions) + self.fileSecurity = try container.decode(Bool.self, forKey: .fileSecurity) + self.name = try container.decode(String.self, forKey: .name) + self.enabled = try container.decode(Bool.self, forKey: .enabled) + self.maximumFileSize = try container.decode(Int.self, forKey: .maximumFileSize) + self.allowedFileExtensions = try container.decode([String].self, forKey: .allowedFileExtensions) + self.compression = try container.decode(String.self, forKey: .compression) + self.encryption = try container.decode(Bool.self, forKey: .encryption) + self.antivirus = try container.decode(Bool.self, forKey: .antivirus) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(permissions, forKey: .permissions) + try container.encode(fileSecurity, forKey: .fileSecurity) + try container.encode(name, forKey: .name) + try container.encode(enabled, forKey: .enabled) + try container.encode(maximumFileSize, forKey: .maximumFileSize) + try container.encode(allowedFileExtensions, forKey: .allowedFileExtensions) + try container.encode(compression, forKey: .compression) + try container.encode(encryption, forKey: .encryption) + try container.encode(antivirus, forKey: .antivirus) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/BucketList.swift b/Sources/AppwriteModels/BucketList.swift index 2937fa6..8fca4e4 100644 --- a/Sources/AppwriteModels/BucketList.swift +++ b/Sources/AppwriteModels/BucketList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Buckets List -public class BucketList { +open class BucketList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case buckets = "buckets" + } /// Total number of buckets documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class BucketList { self.buckets = buckets } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.buckets = try container.decode([Bucket].self, forKey: .buckets) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(buckets, forKey: .buckets) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Build.swift b/Sources/AppwriteModels/Build.swift index 1de9b05..454ba67 100644 --- a/Sources/AppwriteModels/Build.swift +++ b/Sources/AppwriteModels/Build.swift @@ -2,7 +2,19 @@ import Foundation import JSONCodable /// Build -public class Build { +open class Build: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case deploymentId = "deploymentId" + case status = "status" + case stdout = "stdout" + case stderr = "stderr" + case startTime = "startTime" + case endTime = "endTime" + case duration = "duration" + case size = "size" + } /// Build ID. public let id: String @@ -54,6 +66,34 @@ public class Build { self.size = size } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.deploymentId = try container.decode(String.self, forKey: .deploymentId) + self.status = try container.decode(String.self, forKey: .status) + self.stdout = try container.decode(String.self, forKey: .stdout) + self.stderr = try container.decode(String.self, forKey: .stderr) + self.startTime = try container.decode(String.self, forKey: .startTime) + self.endTime = try container.decode(String.self, forKey: .endTime) + self.duration = try container.decode(Int.self, forKey: .duration) + self.size = try container.decode(Int.self, forKey: .size) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(deploymentId, forKey: .deploymentId) + try container.encode(status, forKey: .status) + try container.encode(stdout, forKey: .stdout) + try container.encode(stderr, forKey: .stderr) + try container.encode(startTime, forKey: .startTime) + try container.encode(endTime, forKey: .endTime) + try container.encode(duration, forKey: .duration) + try container.encode(size, forKey: .size) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/Collection.swift b/Sources/AppwriteModels/Collection.swift index 7b609ad..548af2f 100644 --- a/Sources/AppwriteModels/Collection.swift +++ b/Sources/AppwriteModels/Collection.swift @@ -2,7 +2,20 @@ import Foundation import JSONCodable /// Collection -public class Collection { +open class Collection: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case databaseId = "databaseId" + case name = "name" + case enabled = "enabled" + case documentSecurity = "documentSecurity" + case attributes = "attributes" + case indexes = "indexes" + } /// Collection ID. public let id: String @@ -29,7 +42,7 @@ public class Collection { public let documentSecurity: Bool /// Collection attributes. - public let attributes: [Any] + public let attributes: [AnyCodable] /// Collection indexes. public let indexes: [Index] @@ -44,7 +57,7 @@ public class Collection { name: String, enabled: Bool, documentSecurity: Bool, - attributes: [Any], + attributes: [AnyCodable], indexes: [Index] ) { self.id = id @@ -59,6 +72,36 @@ public class Collection { self.indexes = indexes } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.permissions = try container.decode([String].self, forKey: .permissions) + self.databaseId = try container.decode(String.self, forKey: .databaseId) + self.name = try container.decode(String.self, forKey: .name) + self.enabled = try container.decode(Bool.self, forKey: .enabled) + self.documentSecurity = try container.decode(Bool.self, forKey: .documentSecurity) + self.attributes = try container.decode([AnyCodable].self, forKey: .attributes) + self.indexes = try container.decode([Index].self, forKey: .indexes) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(permissions, forKey: .permissions) + try container.encode(databaseId, forKey: .databaseId) + try container.encode(name, forKey: .name) + try container.encode(enabled, forKey: .enabled) + try container.encode(documentSecurity, forKey: .documentSecurity) + try container.encode(attributes, forKey: .attributes) + try container.encode(indexes, forKey: .indexes) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, @@ -84,7 +127,7 @@ public class Collection { name: map["name"] as! String, enabled: map["enabled"] as! Bool, documentSecurity: map["documentSecurity"] as! Bool, - attributes: map["attributes"] as! [Any], + attributes: map["attributes"] as! [AnyCodable], indexes: (map["indexes"] as! [[String: Any]]).map { Index.from(map: $0) } ) } diff --git a/Sources/AppwriteModels/CollectionList.swift b/Sources/AppwriteModels/CollectionList.swift index 295cfa0..f5f383f 100644 --- a/Sources/AppwriteModels/CollectionList.swift +++ b/Sources/AppwriteModels/CollectionList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Collections List -public class CollectionList { +open class CollectionList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case collections = "collections" + } /// Total number of collections documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class CollectionList { self.collections = collections } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.collections = try container.decode([Collection].self, forKey: .collections) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(collections, forKey: .collections) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Continent.swift b/Sources/AppwriteModels/Continent.swift index f181353..b8994d9 100644 --- a/Sources/AppwriteModels/Continent.swift +++ b/Sources/AppwriteModels/Continent.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Continent -public class Continent { +open class Continent: Codable { + + enum CodingKeys: String, CodingKey { + case name = "name" + case code = "code" + } /// Continent name. public let name: String @@ -19,6 +24,20 @@ public class Continent { self.code = code } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.code = try container.decode(String.self, forKey: .code) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(name, forKey: .name) + try container.encode(code, forKey: .code) + } + public func toMap() -> [String: Any] { return [ "name": name as Any, diff --git a/Sources/AppwriteModels/ContinentList.swift b/Sources/AppwriteModels/ContinentList.swift index 3cd7620..fa9a90f 100644 --- a/Sources/AppwriteModels/ContinentList.swift +++ b/Sources/AppwriteModels/ContinentList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Continents List -public class ContinentList { +open class ContinentList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case continents = "continents" + } /// Total number of continents documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class ContinentList { self.continents = continents } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.continents = try container.decode([Continent].self, forKey: .continents) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(continents, forKey: .continents) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Country.swift b/Sources/AppwriteModels/Country.swift index 3ce533b..c24f7e9 100644 --- a/Sources/AppwriteModels/Country.swift +++ b/Sources/AppwriteModels/Country.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Country -public class Country { +open class Country: Codable { + + enum CodingKeys: String, CodingKey { + case name = "name" + case code = "code" + } /// Country name. public let name: String @@ -19,6 +24,20 @@ public class Country { self.code = code } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.code = try container.decode(String.self, forKey: .code) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(name, forKey: .name) + try container.encode(code, forKey: .code) + } + public func toMap() -> [String: Any] { return [ "name": name as Any, diff --git a/Sources/AppwriteModels/CountryList.swift b/Sources/AppwriteModels/CountryList.swift index 8d120bd..865cc19 100644 --- a/Sources/AppwriteModels/CountryList.swift +++ b/Sources/AppwriteModels/CountryList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Countries List -public class CountryList { +open class CountryList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case countries = "countries" + } /// Total number of countries documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class CountryList { self.countries = countries } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.countries = try container.decode([Country].self, forKey: .countries) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(countries, forKey: .countries) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Currency.swift b/Sources/AppwriteModels/Currency.swift index d93ce0c..320337b 100644 --- a/Sources/AppwriteModels/Currency.swift +++ b/Sources/AppwriteModels/Currency.swift @@ -2,7 +2,17 @@ import Foundation import JSONCodable /// Currency -public class Currency { +open class Currency: Codable { + + enum CodingKeys: String, CodingKey { + case symbol = "symbol" + case name = "name" + case symbolNative = "symbolNative" + case decimalDigits = "decimalDigits" + case rounding = "rounding" + case code = "code" + case namePlural = "namePlural" + } /// Currency symbol. public let symbol: String @@ -44,6 +54,30 @@ public class Currency { self.namePlural = namePlural } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.symbol = try container.decode(String.self, forKey: .symbol) + self.name = try container.decode(String.self, forKey: .name) + self.symbolNative = try container.decode(String.self, forKey: .symbolNative) + self.decimalDigits = try container.decode(Int.self, forKey: .decimalDigits) + self.rounding = try container.decode(Double.self, forKey: .rounding) + self.code = try container.decode(String.self, forKey: .code) + self.namePlural = try container.decode(String.self, forKey: .namePlural) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(symbol, forKey: .symbol) + try container.encode(name, forKey: .name) + try container.encode(symbolNative, forKey: .symbolNative) + try container.encode(decimalDigits, forKey: .decimalDigits) + try container.encode(rounding, forKey: .rounding) + try container.encode(code, forKey: .code) + try container.encode(namePlural, forKey: .namePlural) + } + public func toMap() -> [String: Any] { return [ "symbol": symbol as Any, diff --git a/Sources/AppwriteModels/CurrencyList.swift b/Sources/AppwriteModels/CurrencyList.swift index a2e9f00..1e0dff9 100644 --- a/Sources/AppwriteModels/CurrencyList.swift +++ b/Sources/AppwriteModels/CurrencyList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Currencies List -public class CurrencyList { +open class CurrencyList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case currencies = "currencies" + } /// Total number of currencies documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class CurrencyList { self.currencies = currencies } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.currencies = try container.decode([Currency].self, forKey: .currencies) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(currencies, forKey: .currencies) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Database.swift b/Sources/AppwriteModels/Database.swift index fd97fe8..c35c0b3 100644 --- a/Sources/AppwriteModels/Database.swift +++ b/Sources/AppwriteModels/Database.swift @@ -2,7 +2,15 @@ import Foundation import JSONCodable /// Database -public class Database { +open class Database: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case name = "name" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case enabled = "enabled" + } /// Database ID. public let id: String @@ -34,6 +42,26 @@ public class Database { self.enabled = enabled } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.name = try container.decode(String.self, forKey: .name) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.enabled = try container.decode(Bool.self, forKey: .enabled) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(name, forKey: .name) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(enabled, forKey: .enabled) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/DatabaseList.swift b/Sources/AppwriteModels/DatabaseList.swift index 4932ee4..588cbaa 100644 --- a/Sources/AppwriteModels/DatabaseList.swift +++ b/Sources/AppwriteModels/DatabaseList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Databases List -public class DatabaseList { +open class DatabaseList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case databases = "databases" + } /// Total number of databases documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class DatabaseList { self.databases = databases } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.databases = try container.decode([Database].self, forKey: .databases) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(databases, forKey: .databases) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Deployment.swift b/Sources/AppwriteModels/Deployment.swift index 3c7f9d9..5af8a63 100644 --- a/Sources/AppwriteModels/Deployment.swift +++ b/Sources/AppwriteModels/Deployment.swift @@ -2,7 +2,34 @@ import Foundation import JSONCodable /// Deployment -public class Deployment { +open class Deployment: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case type = "type" + case resourceId = "resourceId" + case resourceType = "resourceType" + case entrypoint = "entrypoint" + case size = "size" + case buildSize = "buildSize" + case buildId = "buildId" + case activate = "activate" + case status = "status" + case buildLogs = "buildLogs" + case buildTime = "buildTime" + case providerRepositoryName = "providerRepositoryName" + case providerRepositoryOwner = "providerRepositoryOwner" + case providerRepositoryUrl = "providerRepositoryUrl" + case providerBranch = "providerBranch" + case providerCommitHash = "providerCommitHash" + case providerCommitAuthorUrl = "providerCommitAuthorUrl" + case providerCommitAuthor = "providerCommitAuthor" + case providerCommitMessage = "providerCommitMessage" + case providerCommitUrl = "providerCommitUrl" + case providerBranchUrl = "providerBranchUrl" + } /// Deployment ID. public let id: String @@ -129,6 +156,64 @@ public class Deployment { self.providerBranchUrl = providerBranchUrl } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.type = try container.decode(String.self, forKey: .type) + self.resourceId = try container.decode(String.self, forKey: .resourceId) + self.resourceType = try container.decode(String.self, forKey: .resourceType) + self.entrypoint = try container.decode(String.self, forKey: .entrypoint) + self.size = try container.decode(Int.self, forKey: .size) + self.buildSize = try container.decode(Int.self, forKey: .buildSize) + self.buildId = try container.decode(String.self, forKey: .buildId) + self.activate = try container.decode(Bool.self, forKey: .activate) + self.status = try container.decode(String.self, forKey: .status) + self.buildLogs = try container.decode(String.self, forKey: .buildLogs) + self.buildTime = try container.decode(Int.self, forKey: .buildTime) + self.providerRepositoryName = try container.decode(String.self, forKey: .providerRepositoryName) + self.providerRepositoryOwner = try container.decode(String.self, forKey: .providerRepositoryOwner) + self.providerRepositoryUrl = try container.decode(String.self, forKey: .providerRepositoryUrl) + self.providerBranch = try container.decode(String.self, forKey: .providerBranch) + self.providerCommitHash = try container.decode(String.self, forKey: .providerCommitHash) + self.providerCommitAuthorUrl = try container.decode(String.self, forKey: .providerCommitAuthorUrl) + self.providerCommitAuthor = try container.decode(String.self, forKey: .providerCommitAuthor) + self.providerCommitMessage = try container.decode(String.self, forKey: .providerCommitMessage) + self.providerCommitUrl = try container.decode(String.self, forKey: .providerCommitUrl) + self.providerBranchUrl = try container.decode(String.self, forKey: .providerBranchUrl) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(type, forKey: .type) + try container.encode(resourceId, forKey: .resourceId) + try container.encode(resourceType, forKey: .resourceType) + try container.encode(entrypoint, forKey: .entrypoint) + try container.encode(size, forKey: .size) + try container.encode(buildSize, forKey: .buildSize) + try container.encode(buildId, forKey: .buildId) + try container.encode(activate, forKey: .activate) + try container.encode(status, forKey: .status) + try container.encode(buildLogs, forKey: .buildLogs) + try container.encode(buildTime, forKey: .buildTime) + try container.encode(providerRepositoryName, forKey: .providerRepositoryName) + try container.encode(providerRepositoryOwner, forKey: .providerRepositoryOwner) + try container.encode(providerRepositoryUrl, forKey: .providerRepositoryUrl) + try container.encode(providerBranch, forKey: .providerBranch) + try container.encode(providerCommitHash, forKey: .providerCommitHash) + try container.encode(providerCommitAuthorUrl, forKey: .providerCommitAuthorUrl) + try container.encode(providerCommitAuthor, forKey: .providerCommitAuthor) + try container.encode(providerCommitMessage, forKey: .providerCommitMessage) + try container.encode(providerCommitUrl, forKey: .providerCommitUrl) + try container.encode(providerBranchUrl, forKey: .providerBranchUrl) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/DeploymentList.swift b/Sources/AppwriteModels/DeploymentList.swift index aaa874d..e218064 100644 --- a/Sources/AppwriteModels/DeploymentList.swift +++ b/Sources/AppwriteModels/DeploymentList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Deployments List -public class DeploymentList { +open class DeploymentList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case deployments = "deployments" + } /// Total number of deployments documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class DeploymentList { self.deployments = deployments } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.deployments = try container.decode([Deployment].self, forKey: .deployments) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(deployments, forKey: .deployments) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Document.swift b/Sources/AppwriteModels/Document.swift index c0c49c6..a1c0326 100644 --- a/Sources/AppwriteModels/Document.swift +++ b/Sources/AppwriteModels/Document.swift @@ -2,7 +2,17 @@ import Foundation import JSONCodable /// Document -public class Document { +open class Document: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case collectionId = "$collectionId" + case databaseId = "$databaseId" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case data + } /// Document ID. public let id: String @@ -43,6 +53,30 @@ public class Document { self.data = data } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.collectionId = try container.decode(String.self, forKey: .collectionId) + self.databaseId = try container.decode(String.self, forKey: .databaseId) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.permissions = try container.decode([String].self, forKey: .permissions) + self.data = try container.decode(T.self, forKey: .data) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(collectionId, forKey: .collectionId) + try container.encode(databaseId, forKey: .databaseId) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(permissions, forKey: .permissions) + try container.encode(data, forKey: .data) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/DocumentList.swift b/Sources/AppwriteModels/DocumentList.swift index 4a573fe..a129182 100644 --- a/Sources/AppwriteModels/DocumentList.swift +++ b/Sources/AppwriteModels/DocumentList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Documents List -public class DocumentList { +open class DocumentList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case documents = "documents" + } /// Total number of documents documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class DocumentList { self.documents = documents } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.documents = try container.decode([Document].self, forKey: .documents) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(documents, forKey: .documents) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index d589342..f9a86e7 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -2,7 +2,27 @@ import Foundation import JSONCodable /// Execution -public class Execution { +open class Execution: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case functionId = "functionId" + case trigger = "trigger" + case status = "status" + case requestMethod = "requestMethod" + case requestPath = "requestPath" + case requestHeaders = "requestHeaders" + case responseStatusCode = "responseStatusCode" + case responseBody = "responseBody" + case responseHeaders = "responseHeaders" + case logs = "logs" + case errors = "errors" + case duration = "duration" + case scheduledAt = "scheduledAt" + } /// Execution ID. public let id: String @@ -94,6 +114,50 @@ public class Execution { self.scheduledAt = scheduledAt } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.permissions = try container.decode([String].self, forKey: .permissions) + self.functionId = try container.decode(String.self, forKey: .functionId) + self.trigger = try container.decode(String.self, forKey: .trigger) + self.status = try container.decode(String.self, forKey: .status) + self.requestMethod = try container.decode(String.self, forKey: .requestMethod) + self.requestPath = try container.decode(String.self, forKey: .requestPath) + self.requestHeaders = try container.decode([Headers].self, forKey: .requestHeaders) + self.responseStatusCode = try container.decode(Int.self, forKey: .responseStatusCode) + self.responseBody = try container.decode(String.self, forKey: .responseBody) + self.responseHeaders = try container.decode([Headers].self, forKey: .responseHeaders) + self.logs = try container.decode(String.self, forKey: .logs) + self.errors = try container.decode(String.self, forKey: .errors) + self.duration = try container.decode(Double.self, forKey: .duration) + self.scheduledAt = try container.decodeIfPresent(String.self, forKey: .scheduledAt) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(permissions, forKey: .permissions) + try container.encode(functionId, forKey: .functionId) + try container.encode(trigger, forKey: .trigger) + try container.encode(status, forKey: .status) + try container.encode(requestMethod, forKey: .requestMethod) + try container.encode(requestPath, forKey: .requestPath) + try container.encode(requestHeaders, forKey: .requestHeaders) + try container.encode(responseStatusCode, forKey: .responseStatusCode) + try container.encode(responseBody, forKey: .responseBody) + try container.encode(responseHeaders, forKey: .responseHeaders) + try container.encode(logs, forKey: .logs) + try container.encode(errors, forKey: .errors) + try container.encode(duration, forKey: .duration) + try container.encodeIfPresent(scheduledAt, forKey: .scheduledAt) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/ExecutionList.swift b/Sources/AppwriteModels/ExecutionList.swift index 8a502d9..72d43a6 100644 --- a/Sources/AppwriteModels/ExecutionList.swift +++ b/Sources/AppwriteModels/ExecutionList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Executions List -public class ExecutionList { +open class ExecutionList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case executions = "executions" + } /// Total number of executions documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class ExecutionList { self.executions = executions } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.executions = try container.decode([Execution].self, forKey: .executions) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(executions, forKey: .executions) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/File.swift b/Sources/AppwriteModels/File.swift index db896ab..713c7ca 100644 --- a/Sources/AppwriteModels/File.swift +++ b/Sources/AppwriteModels/File.swift @@ -2,7 +2,21 @@ import Foundation import JSONCodable /// File -public class File { +open class File: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case bucketId = "bucketId" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case name = "name" + case signature = "signature" + case mimeType = "mimeType" + case sizeOriginal = "sizeOriginal" + case chunksTotal = "chunksTotal" + case chunksUploaded = "chunksUploaded" + } /// File ID. public let id: String @@ -64,6 +78,38 @@ public class File { self.chunksUploaded = chunksUploaded } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.bucketId = try container.decode(String.self, forKey: .bucketId) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.permissions = try container.decode([String].self, forKey: .permissions) + self.name = try container.decode(String.self, forKey: .name) + self.signature = try container.decode(String.self, forKey: .signature) + self.mimeType = try container.decode(String.self, forKey: .mimeType) + self.sizeOriginal = try container.decode(Int.self, forKey: .sizeOriginal) + self.chunksTotal = try container.decode(Int.self, forKey: .chunksTotal) + self.chunksUploaded = try container.decode(Int.self, forKey: .chunksUploaded) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(bucketId, forKey: .bucketId) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(permissions, forKey: .permissions) + try container.encode(name, forKey: .name) + try container.encode(signature, forKey: .signature) + try container.encode(mimeType, forKey: .mimeType) + try container.encode(sizeOriginal, forKey: .sizeOriginal) + try container.encode(chunksTotal, forKey: .chunksTotal) + try container.encode(chunksUploaded, forKey: .chunksUploaded) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/FileList.swift b/Sources/AppwriteModels/FileList.swift index 0d6ad88..bec7b76 100644 --- a/Sources/AppwriteModels/FileList.swift +++ b/Sources/AppwriteModels/FileList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Files List -public class FileList { +open class FileList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case files = "files" + } /// Total number of files documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class FileList { self.files = files } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.files = try container.decode([File].self, forKey: .files) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(files, forKey: .files) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Function.swift b/Sources/AppwriteModels/Function.swift index c91ce93..3199ece 100644 --- a/Sources/AppwriteModels/Function.swift +++ b/Sources/AppwriteModels/Function.swift @@ -2,7 +2,34 @@ import Foundation import JSONCodable /// Function -public class Function { +open class Function: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case execute = "execute" + case name = "name" + case enabled = "enabled" + case live = "live" + case logging = "logging" + case runtime = "runtime" + case deployment = "deployment" + case scopes = "scopes" + case vars = "vars" + case events = "events" + case schedule = "schedule" + case timeout = "timeout" + case entrypoint = "entrypoint" + case commands = "commands" + case version = "version" + case installationId = "installationId" + case providerRepositoryId = "providerRepositoryId" + case providerBranch = "providerBranch" + case providerRootDirectory = "providerRootDirectory" + case providerSilentMode = "providerSilentMode" + case specification = "specification" + } /// Function ID. public let id: String @@ -129,6 +156,64 @@ public class Function { self.specification = specification } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.execute = try container.decode([String].self, forKey: .execute) + self.name = try container.decode(String.self, forKey: .name) + self.enabled = try container.decode(Bool.self, forKey: .enabled) + self.live = try container.decode(Bool.self, forKey: .live) + self.logging = try container.decode(Bool.self, forKey: .logging) + self.runtime = try container.decode(String.self, forKey: .runtime) + self.deployment = try container.decode(String.self, forKey: .deployment) + self.scopes = try container.decode([String].self, forKey: .scopes) + self.vars = try container.decode([Variable].self, forKey: .vars) + self.events = try container.decode([String].self, forKey: .events) + self.schedule = try container.decode(String.self, forKey: .schedule) + self.timeout = try container.decode(Int.self, forKey: .timeout) + self.entrypoint = try container.decode(String.self, forKey: .entrypoint) + self.commands = try container.decode(String.self, forKey: .commands) + self.version = try container.decode(String.self, forKey: .version) + self.installationId = try container.decode(String.self, forKey: .installationId) + self.providerRepositoryId = try container.decode(String.self, forKey: .providerRepositoryId) + self.providerBranch = try container.decode(String.self, forKey: .providerBranch) + self.providerRootDirectory = try container.decode(String.self, forKey: .providerRootDirectory) + self.providerSilentMode = try container.decode(Bool.self, forKey: .providerSilentMode) + self.specification = try container.decode(String.self, forKey: .specification) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(execute, forKey: .execute) + try container.encode(name, forKey: .name) + try container.encode(enabled, forKey: .enabled) + try container.encode(live, forKey: .live) + try container.encode(logging, forKey: .logging) + try container.encode(runtime, forKey: .runtime) + try container.encode(deployment, forKey: .deployment) + try container.encode(scopes, forKey: .scopes) + try container.encode(vars, forKey: .vars) + try container.encode(events, forKey: .events) + try container.encode(schedule, forKey: .schedule) + try container.encode(timeout, forKey: .timeout) + try container.encode(entrypoint, forKey: .entrypoint) + try container.encode(commands, forKey: .commands) + try container.encode(version, forKey: .version) + try container.encode(installationId, forKey: .installationId) + try container.encode(providerRepositoryId, forKey: .providerRepositoryId) + try container.encode(providerBranch, forKey: .providerBranch) + try container.encode(providerRootDirectory, forKey: .providerRootDirectory) + try container.encode(providerSilentMode, forKey: .providerSilentMode) + try container.encode(specification, forKey: .specification) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/FunctionList.swift b/Sources/AppwriteModels/FunctionList.swift index b36bfc6..c00badb 100644 --- a/Sources/AppwriteModels/FunctionList.swift +++ b/Sources/AppwriteModels/FunctionList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Functions List -public class FunctionList { +open class FunctionList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case functions = "functions" + } /// Total number of functions documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class FunctionList { self.functions = functions } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.functions = try container.decode([Function].self, forKey: .functions) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(functions, forKey: .functions) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Headers.swift b/Sources/AppwriteModels/Headers.swift index 6f554ac..ae468e5 100644 --- a/Sources/AppwriteModels/Headers.swift +++ b/Sources/AppwriteModels/Headers.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Headers -public class Headers { +open class Headers: Codable { + + enum CodingKeys: String, CodingKey { + case name = "name" + case value = "value" + } /// Header name. public let name: String @@ -19,6 +24,20 @@ public class Headers { self.value = value } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.value = try container.decode(String.self, forKey: .value) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(name, forKey: .name) + try container.encode(value, forKey: .value) + } + public func toMap() -> [String: Any] { return [ "name": name as Any, diff --git a/Sources/AppwriteModels/HealthAntivirus.swift b/Sources/AppwriteModels/HealthAntivirus.swift index 17636de..a68bb36 100644 --- a/Sources/AppwriteModels/HealthAntivirus.swift +++ b/Sources/AppwriteModels/HealthAntivirus.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Health Antivirus -public class HealthAntivirus { +open class HealthAntivirus: Codable { + + enum CodingKeys: String, CodingKey { + case version = "version" + case status = "status" + } /// Antivirus version. public let version: String @@ -19,6 +24,20 @@ public class HealthAntivirus { self.status = status } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.version = try container.decode(String.self, forKey: .version) + self.status = try container.decode(String.self, forKey: .status) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(version, forKey: .version) + try container.encode(status, forKey: .status) + } + public func toMap() -> [String: Any] { return [ "version": version as Any, diff --git a/Sources/AppwriteModels/HealthCertificate.swift b/Sources/AppwriteModels/HealthCertificate.swift index 9d7b938..1ef3837 100644 --- a/Sources/AppwriteModels/HealthCertificate.swift +++ b/Sources/AppwriteModels/HealthCertificate.swift @@ -2,7 +2,16 @@ import Foundation import JSONCodable /// Health Certificate -public class HealthCertificate { +open class HealthCertificate: Codable { + + enum CodingKeys: String, CodingKey { + case name = "name" + case subjectSN = "subjectSN" + case issuerOrganisation = "issuerOrganisation" + case validFrom = "validFrom" + case validTo = "validTo" + case signatureTypeSN = "signatureTypeSN" + } /// Certificate name public let name: String @@ -39,6 +48,28 @@ public class HealthCertificate { self.signatureTypeSN = signatureTypeSN } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.subjectSN = try container.decode(String.self, forKey: .subjectSN) + self.issuerOrganisation = try container.decode(String.self, forKey: .issuerOrganisation) + self.validFrom = try container.decode(String.self, forKey: .validFrom) + self.validTo = try container.decode(String.self, forKey: .validTo) + self.signatureTypeSN = try container.decode(String.self, forKey: .signatureTypeSN) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(name, forKey: .name) + try container.encode(subjectSN, forKey: .subjectSN) + try container.encode(issuerOrganisation, forKey: .issuerOrganisation) + try container.encode(validFrom, forKey: .validFrom) + try container.encode(validTo, forKey: .validTo) + try container.encode(signatureTypeSN, forKey: .signatureTypeSN) + } + public func toMap() -> [String: Any] { return [ "name": name as Any, diff --git a/Sources/AppwriteModels/HealthQueue.swift b/Sources/AppwriteModels/HealthQueue.swift index 43a7906..856a6d9 100644 --- a/Sources/AppwriteModels/HealthQueue.swift +++ b/Sources/AppwriteModels/HealthQueue.swift @@ -2,7 +2,11 @@ import Foundation import JSONCodable /// Health Queue -public class HealthQueue { +open class HealthQueue: Codable { + + enum CodingKeys: String, CodingKey { + case size = "size" + } /// Amount of actions in the queue. public let size: Int @@ -14,6 +18,18 @@ public class HealthQueue { self.size = size } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.size = try container.decode(Int.self, forKey: .size) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(size, forKey: .size) + } + public func toMap() -> [String: Any] { return [ "size": size as Any diff --git a/Sources/AppwriteModels/HealthStatus.swift b/Sources/AppwriteModels/HealthStatus.swift index f7fb7e6..8818778 100644 --- a/Sources/AppwriteModels/HealthStatus.swift +++ b/Sources/AppwriteModels/HealthStatus.swift @@ -2,7 +2,13 @@ import Foundation import JSONCodable /// Health Status -public class HealthStatus { +open class HealthStatus: Codable { + + enum CodingKeys: String, CodingKey { + case name = "name" + case ping = "ping" + case status = "status" + } /// Name of the service. public let name: String @@ -24,6 +30,22 @@ public class HealthStatus { self.status = status } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.ping = try container.decode(Int.self, forKey: .ping) + self.status = try container.decode(String.self, forKey: .status) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(name, forKey: .name) + try container.encode(ping, forKey: .ping) + try container.encode(status, forKey: .status) + } + public func toMap() -> [String: Any] { return [ "name": name as Any, diff --git a/Sources/AppwriteModels/HealthTime.swift b/Sources/AppwriteModels/HealthTime.swift index 2f4cf72..aab020b 100644 --- a/Sources/AppwriteModels/HealthTime.swift +++ b/Sources/AppwriteModels/HealthTime.swift @@ -2,7 +2,13 @@ import Foundation import JSONCodable /// Health Time -public class HealthTime { +open class HealthTime: Codable { + + enum CodingKeys: String, CodingKey { + case remoteTime = "remoteTime" + case localTime = "localTime" + case diff = "diff" + } /// Current unix timestamp on trustful remote server. public let remoteTime: Int @@ -24,6 +30,22 @@ public class HealthTime { self.diff = diff } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.remoteTime = try container.decode(Int.self, forKey: .remoteTime) + self.localTime = try container.decode(Int.self, forKey: .localTime) + self.diff = try container.decode(Int.self, forKey: .diff) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(remoteTime, forKey: .remoteTime) + try container.encode(localTime, forKey: .localTime) + try container.encode(diff, forKey: .diff) + } + public func toMap() -> [String: Any] { return [ "remoteTime": remoteTime as Any, diff --git a/Sources/AppwriteModels/Identity.swift b/Sources/AppwriteModels/Identity.swift index fb54237..f93035d 100644 --- a/Sources/AppwriteModels/Identity.swift +++ b/Sources/AppwriteModels/Identity.swift @@ -2,7 +2,20 @@ import Foundation import JSONCodable /// Identity -public class Identity { +open class Identity: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case userId = "userId" + case provider = "provider" + case providerUid = "providerUid" + case providerEmail = "providerEmail" + case providerAccessToken = "providerAccessToken" + case providerAccessTokenExpiry = "providerAccessTokenExpiry" + case providerRefreshToken = "providerRefreshToken" + } /// Identity ID. public let id: String @@ -59,6 +72,36 @@ public class Identity { self.providerRefreshToken = providerRefreshToken } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.userId = try container.decode(String.self, forKey: .userId) + self.provider = try container.decode(String.self, forKey: .provider) + self.providerUid = try container.decode(String.self, forKey: .providerUid) + self.providerEmail = try container.decode(String.self, forKey: .providerEmail) + self.providerAccessToken = try container.decode(String.self, forKey: .providerAccessToken) + self.providerAccessTokenExpiry = try container.decode(String.self, forKey: .providerAccessTokenExpiry) + self.providerRefreshToken = try container.decode(String.self, forKey: .providerRefreshToken) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(userId, forKey: .userId) + try container.encode(provider, forKey: .provider) + try container.encode(providerUid, forKey: .providerUid) + try container.encode(providerEmail, forKey: .providerEmail) + try container.encode(providerAccessToken, forKey: .providerAccessToken) + try container.encode(providerAccessTokenExpiry, forKey: .providerAccessTokenExpiry) + try container.encode(providerRefreshToken, forKey: .providerRefreshToken) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/IdentityList.swift b/Sources/AppwriteModels/IdentityList.swift index b068f4c..6065fad 100644 --- a/Sources/AppwriteModels/IdentityList.swift +++ b/Sources/AppwriteModels/IdentityList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Identities List -public class IdentityList { +open class IdentityList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case identities = "identities" + } /// Total number of identities documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class IdentityList { self.identities = identities } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.identities = try container.decode([Identity].self, forKey: .identities) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(identities, forKey: .identities) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Index.swift b/Sources/AppwriteModels/Index.swift index 019ec28..6b7d9d5 100644 --- a/Sources/AppwriteModels/Index.swift +++ b/Sources/AppwriteModels/Index.swift @@ -2,7 +2,18 @@ import Foundation import JSONCodable /// Index -public class Index { +open class Index: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case attributes = "attributes" + case orders = "orders" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + } /// Index Key. public let key: String @@ -49,6 +60,32 @@ public class Index { self.updatedAt = updatedAt } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.attributes = try container.decode([String].self, forKey: .attributes) + self.orders = try container.decodeIfPresent([String].self, forKey: .orders) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(attributes, forKey: .attributes) + try container.encodeIfPresent(orders, forKey: .orders) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + } + public func toMap() -> [String: Any] { return [ "key": key as Any, diff --git a/Sources/AppwriteModels/IndexList.swift b/Sources/AppwriteModels/IndexList.swift index 6ca5ae9..2f3ae30 100644 --- a/Sources/AppwriteModels/IndexList.swift +++ b/Sources/AppwriteModels/IndexList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Indexes List -public class IndexList { +open class IndexList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case indexes = "indexes" + } /// Total number of indexes documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class IndexList { self.indexes = indexes } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.indexes = try container.decode([Index].self, forKey: .indexes) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(indexes, forKey: .indexes) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Jwt.swift b/Sources/AppwriteModels/Jwt.swift index 5778435..fd7fb49 100644 --- a/Sources/AppwriteModels/Jwt.swift +++ b/Sources/AppwriteModels/Jwt.swift @@ -2,7 +2,11 @@ import Foundation import JSONCodable /// JWT -public class Jwt { +open class Jwt: Codable { + + enum CodingKeys: String, CodingKey { + case jwt = "jwt" + } /// JWT encoded string. public let jwt: String @@ -14,6 +18,18 @@ public class Jwt { self.jwt = jwt } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.jwt = try container.decode(String.self, forKey: .jwt) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(jwt, forKey: .jwt) + } + public func toMap() -> [String: Any] { return [ "jwt": jwt as Any diff --git a/Sources/AppwriteModels/Language.swift b/Sources/AppwriteModels/Language.swift index f385d5a..d1e1a15 100644 --- a/Sources/AppwriteModels/Language.swift +++ b/Sources/AppwriteModels/Language.swift @@ -2,7 +2,13 @@ import Foundation import JSONCodable /// Language -public class Language { +open class Language: Codable { + + enum CodingKeys: String, CodingKey { + case name = "name" + case code = "code" + case nativeName = "nativeName" + } /// Language name. public let name: String @@ -24,6 +30,22 @@ public class Language { self.nativeName = nativeName } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.code = try container.decode(String.self, forKey: .code) + self.nativeName = try container.decode(String.self, forKey: .nativeName) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(name, forKey: .name) + try container.encode(code, forKey: .code) + try container.encode(nativeName, forKey: .nativeName) + } + public func toMap() -> [String: Any] { return [ "name": name as Any, diff --git a/Sources/AppwriteModels/LanguageList.swift b/Sources/AppwriteModels/LanguageList.swift index b4515e3..13c6e4a 100644 --- a/Sources/AppwriteModels/LanguageList.swift +++ b/Sources/AppwriteModels/LanguageList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Languages List -public class LanguageList { +open class LanguageList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case languages = "languages" + } /// Total number of languages documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class LanguageList { self.languages = languages } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.languages = try container.decode([Language].self, forKey: .languages) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(languages, forKey: .languages) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Locale.swift b/Sources/AppwriteModels/Locale.swift index 7445776..4d034f4 100644 --- a/Sources/AppwriteModels/Locale.swift +++ b/Sources/AppwriteModels/Locale.swift @@ -2,7 +2,17 @@ import Foundation import JSONCodable /// Locale -public class Locale { +open class Locale: Codable { + + enum CodingKeys: String, CodingKey { + case ip = "ip" + case countryCode = "countryCode" + case country = "country" + case continentCode = "continentCode" + case continent = "continent" + case eu = "eu" + case currency = "currency" + } /// User IP address. public let ip: String @@ -44,6 +54,30 @@ public class Locale { self.currency = currency } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.ip = try container.decode(String.self, forKey: .ip) + self.countryCode = try container.decode(String.self, forKey: .countryCode) + self.country = try container.decode(String.self, forKey: .country) + self.continentCode = try container.decode(String.self, forKey: .continentCode) + self.continent = try container.decode(String.self, forKey: .continent) + self.eu = try container.decode(Bool.self, forKey: .eu) + self.currency = try container.decode(String.self, forKey: .currency) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(ip, forKey: .ip) + try container.encode(countryCode, forKey: .countryCode) + try container.encode(country, forKey: .country) + try container.encode(continentCode, forKey: .continentCode) + try container.encode(continent, forKey: .continent) + try container.encode(eu, forKey: .eu) + try container.encode(currency, forKey: .currency) + } + public func toMap() -> [String: Any] { return [ "ip": ip as Any, diff --git a/Sources/AppwriteModels/LocaleCode.swift b/Sources/AppwriteModels/LocaleCode.swift index 8e561c7..d2678bb 100644 --- a/Sources/AppwriteModels/LocaleCode.swift +++ b/Sources/AppwriteModels/LocaleCode.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// LocaleCode -public class LocaleCode { +open class LocaleCode: Codable { + + enum CodingKeys: String, CodingKey { + case code = "code" + case name = "name" + } /// Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) public let code: String @@ -19,6 +24,20 @@ public class LocaleCode { self.name = name } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.code = try container.decode(String.self, forKey: .code) + self.name = try container.decode(String.self, forKey: .name) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(code, forKey: .code) + try container.encode(name, forKey: .name) + } + public func toMap() -> [String: Any] { return [ "code": code as Any, diff --git a/Sources/AppwriteModels/LocaleCodeList.swift b/Sources/AppwriteModels/LocaleCodeList.swift index 895ef7d..5ef0653 100644 --- a/Sources/AppwriteModels/LocaleCodeList.swift +++ b/Sources/AppwriteModels/LocaleCodeList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Locale codes list -public class LocaleCodeList { +open class LocaleCodeList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case localeCodes = "localeCodes" + } /// Total number of localeCodes documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class LocaleCodeList { self.localeCodes = localeCodes } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.localeCodes = try container.decode([LocaleCode].self, forKey: .localeCodes) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(localeCodes, forKey: .localeCodes) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Log.swift b/Sources/AppwriteModels/Log.swift index df5464d..16c27ef 100644 --- a/Sources/AppwriteModels/Log.swift +++ b/Sources/AppwriteModels/Log.swift @@ -2,7 +2,31 @@ import Foundation import JSONCodable /// Log -public class Log { +open class Log: Codable { + + enum CodingKeys: String, CodingKey { + case event = "event" + case userId = "userId" + case userEmail = "userEmail" + case userName = "userName" + case mode = "mode" + case ip = "ip" + case time = "time" + case osCode = "osCode" + case osName = "osName" + case osVersion = "osVersion" + case clientType = "clientType" + case clientCode = "clientCode" + case clientName = "clientName" + case clientVersion = "clientVersion" + case clientEngine = "clientEngine" + case clientEngineVersion = "clientEngineVersion" + case deviceName = "deviceName" + case deviceBrand = "deviceBrand" + case deviceModel = "deviceModel" + case countryCode = "countryCode" + case countryName = "countryName" + } /// Event name. public let event: String @@ -114,6 +138,58 @@ public class Log { self.countryName = countryName } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.event = try container.decode(String.self, forKey: .event) + self.userId = try container.decode(String.self, forKey: .userId) + self.userEmail = try container.decode(String.self, forKey: .userEmail) + self.userName = try container.decode(String.self, forKey: .userName) + self.mode = try container.decode(String.self, forKey: .mode) + self.ip = try container.decode(String.self, forKey: .ip) + self.time = try container.decode(String.self, forKey: .time) + self.osCode = try container.decode(String.self, forKey: .osCode) + self.osName = try container.decode(String.self, forKey: .osName) + self.osVersion = try container.decode(String.self, forKey: .osVersion) + self.clientType = try container.decode(String.self, forKey: .clientType) + self.clientCode = try container.decode(String.self, forKey: .clientCode) + self.clientName = try container.decode(String.self, forKey: .clientName) + self.clientVersion = try container.decode(String.self, forKey: .clientVersion) + self.clientEngine = try container.decode(String.self, forKey: .clientEngine) + self.clientEngineVersion = try container.decode(String.self, forKey: .clientEngineVersion) + self.deviceName = try container.decode(String.self, forKey: .deviceName) + self.deviceBrand = try container.decode(String.self, forKey: .deviceBrand) + self.deviceModel = try container.decode(String.self, forKey: .deviceModel) + self.countryCode = try container.decode(String.self, forKey: .countryCode) + self.countryName = try container.decode(String.self, forKey: .countryName) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(event, forKey: .event) + try container.encode(userId, forKey: .userId) + try container.encode(userEmail, forKey: .userEmail) + try container.encode(userName, forKey: .userName) + try container.encode(mode, forKey: .mode) + try container.encode(ip, forKey: .ip) + try container.encode(time, forKey: .time) + try container.encode(osCode, forKey: .osCode) + try container.encode(osName, forKey: .osName) + try container.encode(osVersion, forKey: .osVersion) + try container.encode(clientType, forKey: .clientType) + try container.encode(clientCode, forKey: .clientCode) + try container.encode(clientName, forKey: .clientName) + try container.encode(clientVersion, forKey: .clientVersion) + try container.encode(clientEngine, forKey: .clientEngine) + try container.encode(clientEngineVersion, forKey: .clientEngineVersion) + try container.encode(deviceName, forKey: .deviceName) + try container.encode(deviceBrand, forKey: .deviceBrand) + try container.encode(deviceModel, forKey: .deviceModel) + try container.encode(countryCode, forKey: .countryCode) + try container.encode(countryName, forKey: .countryName) + } + public func toMap() -> [String: Any] { return [ "event": event as Any, diff --git a/Sources/AppwriteModels/LogList.swift b/Sources/AppwriteModels/LogList.swift index 2f99674..7ff2d07 100644 --- a/Sources/AppwriteModels/LogList.swift +++ b/Sources/AppwriteModels/LogList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Logs List -public class LogList { +open class LogList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case logs = "logs" + } /// Total number of logs documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class LogList { self.logs = logs } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.logs = try container.decode([Log].self, forKey: .logs) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(logs, forKey: .logs) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Membership.swift b/Sources/AppwriteModels/Membership.swift index 805cb47..8d26766 100644 --- a/Sources/AppwriteModels/Membership.swift +++ b/Sources/AppwriteModels/Membership.swift @@ -2,7 +2,23 @@ import Foundation import JSONCodable /// Membership -public class Membership { +open class Membership: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case userId = "userId" + case userName = "userName" + case userEmail = "userEmail" + case teamId = "teamId" + case teamName = "teamName" + case invited = "invited" + case joined = "joined" + case confirm = "confirm" + case mfa = "mfa" + case roles = "roles" + } /// Membership ID. public let id: String @@ -74,6 +90,42 @@ public class Membership { self.roles = roles } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.userId = try container.decode(String.self, forKey: .userId) + self.userName = try container.decode(String.self, forKey: .userName) + self.userEmail = try container.decode(String.self, forKey: .userEmail) + self.teamId = try container.decode(String.self, forKey: .teamId) + self.teamName = try container.decode(String.self, forKey: .teamName) + self.invited = try container.decode(String.self, forKey: .invited) + self.joined = try container.decode(String.self, forKey: .joined) + self.confirm = try container.decode(Bool.self, forKey: .confirm) + self.mfa = try container.decode(Bool.self, forKey: .mfa) + self.roles = try container.decode([String].self, forKey: .roles) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(userId, forKey: .userId) + try container.encode(userName, forKey: .userName) + try container.encode(userEmail, forKey: .userEmail) + try container.encode(teamId, forKey: .teamId) + try container.encode(teamName, forKey: .teamName) + try container.encode(invited, forKey: .invited) + try container.encode(joined, forKey: .joined) + try container.encode(confirm, forKey: .confirm) + try container.encode(mfa, forKey: .mfa) + try container.encode(roles, forKey: .roles) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/MembershipList.swift b/Sources/AppwriteModels/MembershipList.swift index f27cc99..a7b0cd6 100644 --- a/Sources/AppwriteModels/MembershipList.swift +++ b/Sources/AppwriteModels/MembershipList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Memberships List -public class MembershipList { +open class MembershipList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case memberships = "memberships" + } /// Total number of memberships documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class MembershipList { self.memberships = memberships } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.memberships = try container.decode([Membership].self, forKey: .memberships) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(memberships, forKey: .memberships) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Message.swift b/Sources/AppwriteModels/Message.swift index 1bbe9f9..442d7c8 100644 --- a/Sources/AppwriteModels/Message.swift +++ b/Sources/AppwriteModels/Message.swift @@ -2,7 +2,23 @@ import Foundation import JSONCodable /// Message -public class Message { +open class Message: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case providerType = "providerType" + case topics = "topics" + case users = "users" + case targets = "targets" + case scheduledAt = "scheduledAt" + case deliveredAt = "deliveredAt" + case deliveryErrors = "deliveryErrors" + case deliveredTotal = "deliveredTotal" + case data = "data" + case status = "status" + } /// Message ID. public let id: String @@ -38,7 +54,7 @@ public class Message { public let deliveredTotal: Int /// Data of the message. - public let data: Any + public let data: [String: AnyCodable] /// Status of delivery. public let status: String @@ -56,7 +72,7 @@ public class Message { deliveredAt: String?, deliveryErrors: [String]?, deliveredTotal: Int, - data: Any, + data: [String: AnyCodable], status: String ) { self.id = id @@ -74,6 +90,42 @@ public class Message { self.status = status } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.providerType = try container.decode(String.self, forKey: .providerType) + self.topics = try container.decode([String].self, forKey: .topics) + self.users = try container.decode([String].self, forKey: .users) + self.targets = try container.decode([String].self, forKey: .targets) + self.scheduledAt = try container.decodeIfPresent(String.self, forKey: .scheduledAt) + self.deliveredAt = try container.decodeIfPresent(String.self, forKey: .deliveredAt) + self.deliveryErrors = try container.decodeIfPresent([String].self, forKey: .deliveryErrors) + self.deliveredTotal = try container.decode(Int.self, forKey: .deliveredTotal) + self.data = try container.decode([String: AnyCodable].self, forKey: .data) + self.status = try container.decode(String.self, forKey: .status) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(providerType, forKey: .providerType) + try container.encode(topics, forKey: .topics) + try container.encode(users, forKey: .users) + try container.encode(targets, forKey: .targets) + try container.encodeIfPresent(scheduledAt, forKey: .scheduledAt) + try container.encodeIfPresent(deliveredAt, forKey: .deliveredAt) + try container.encodeIfPresent(deliveryErrors, forKey: .deliveryErrors) + try container.encode(deliveredTotal, forKey: .deliveredTotal) + try container.encode(data, forKey: .data) + try container.encode(status, forKey: .status) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, @@ -105,7 +157,7 @@ public class Message { deliveredAt: map["deliveredAt"] as? String, deliveryErrors: map["deliveryErrors"] as? [String], deliveredTotal: map["deliveredTotal"] as! Int, - data: map["data"] as! Any, + data: map["data"] as! [String: AnyCodable], status: map["status"] as! String ) } diff --git a/Sources/AppwriteModels/MessageList.swift b/Sources/AppwriteModels/MessageList.swift index c64f376..f62fcaa 100644 --- a/Sources/AppwriteModels/MessageList.swift +++ b/Sources/AppwriteModels/MessageList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Message list -public class MessageList { +open class MessageList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case messages = "messages" + } /// Total number of messages documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class MessageList { self.messages = messages } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.messages = try container.decode([Message].self, forKey: .messages) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(messages, forKey: .messages) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/MfaChallenge.swift b/Sources/AppwriteModels/MfaChallenge.swift index 5a1e874..c6b77a5 100644 --- a/Sources/AppwriteModels/MfaChallenge.swift +++ b/Sources/AppwriteModels/MfaChallenge.swift @@ -2,7 +2,14 @@ import Foundation import JSONCodable /// MFA Challenge -public class MfaChallenge { +open class MfaChallenge: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case userId = "userId" + case expire = "expire" + } /// Token ID. public let id: String @@ -29,6 +36,24 @@ public class MfaChallenge { self.expire = expire } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.userId = try container.decode(String.self, forKey: .userId) + self.expire = try container.decode(String.self, forKey: .expire) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(userId, forKey: .userId) + try container.encode(expire, forKey: .expire) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/MfaFactors.swift b/Sources/AppwriteModels/MfaFactors.swift index 716c055..4291fab 100644 --- a/Sources/AppwriteModels/MfaFactors.swift +++ b/Sources/AppwriteModels/MfaFactors.swift @@ -2,7 +2,14 @@ import Foundation import JSONCodable /// MFAFactors -public class MfaFactors { +open class MfaFactors: Codable { + + enum CodingKeys: String, CodingKey { + case totp = "totp" + case phone = "phone" + case email = "email" + case recoveryCode = "recoveryCode" + } /// Can TOTP be used for MFA challenge for this account. public let totp: Bool @@ -29,6 +36,24 @@ public class MfaFactors { self.recoveryCode = recoveryCode } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.totp = try container.decode(Bool.self, forKey: .totp) + self.phone = try container.decode(Bool.self, forKey: .phone) + self.email = try container.decode(Bool.self, forKey: .email) + self.recoveryCode = try container.decode(Bool.self, forKey: .recoveryCode) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(totp, forKey: .totp) + try container.encode(phone, forKey: .phone) + try container.encode(email, forKey: .email) + try container.encode(recoveryCode, forKey: .recoveryCode) + } + public func toMap() -> [String: Any] { return [ "totp": totp as Any, diff --git a/Sources/AppwriteModels/MfaRecoveryCodes.swift b/Sources/AppwriteModels/MfaRecoveryCodes.swift index 314e11c..bd2968f 100644 --- a/Sources/AppwriteModels/MfaRecoveryCodes.swift +++ b/Sources/AppwriteModels/MfaRecoveryCodes.swift @@ -2,7 +2,11 @@ import Foundation import JSONCodable /// MFA Recovery Codes -public class MfaRecoveryCodes { +open class MfaRecoveryCodes: Codable { + + enum CodingKeys: String, CodingKey { + case recoveryCodes = "recoveryCodes" + } /// Recovery codes. public let recoveryCodes: [String] @@ -14,6 +18,18 @@ public class MfaRecoveryCodes { self.recoveryCodes = recoveryCodes } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.recoveryCodes = try container.decode([String].self, forKey: .recoveryCodes) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(recoveryCodes, forKey: .recoveryCodes) + } + public func toMap() -> [String: Any] { return [ "recoveryCodes": recoveryCodes as Any diff --git a/Sources/AppwriteModels/MfaType.swift b/Sources/AppwriteModels/MfaType.swift index 503134f..8646385 100644 --- a/Sources/AppwriteModels/MfaType.swift +++ b/Sources/AppwriteModels/MfaType.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// MFAType -public class MfaType { +open class MfaType: Codable { + + enum CodingKeys: String, CodingKey { + case secret = "secret" + case uri = "uri" + } /// Secret token used for TOTP factor. public let secret: String @@ -19,6 +24,20 @@ public class MfaType { self.uri = uri } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.secret = try container.decode(String.self, forKey: .secret) + self.uri = try container.decode(String.self, forKey: .uri) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(secret, forKey: .secret) + try container.encode(uri, forKey: .uri) + } + public func toMap() -> [String: Any] { return [ "secret": secret as Any, diff --git a/Sources/AppwriteModels/Phone.swift b/Sources/AppwriteModels/Phone.swift index 2e113b4..fc90d49 100644 --- a/Sources/AppwriteModels/Phone.swift +++ b/Sources/AppwriteModels/Phone.swift @@ -2,7 +2,13 @@ import Foundation import JSONCodable /// Phone -public class Phone { +open class Phone: Codable { + + enum CodingKeys: String, CodingKey { + case code = "code" + case countryCode = "countryCode" + case countryName = "countryName" + } /// Phone code. public let code: String @@ -24,6 +30,22 @@ public class Phone { self.countryName = countryName } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.code = try container.decode(String.self, forKey: .code) + self.countryCode = try container.decode(String.self, forKey: .countryCode) + self.countryName = try container.decode(String.self, forKey: .countryName) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(code, forKey: .code) + try container.encode(countryCode, forKey: .countryCode) + try container.encode(countryName, forKey: .countryName) + } + public func toMap() -> [String: Any] { return [ "code": code as Any, diff --git a/Sources/AppwriteModels/PhoneList.swift b/Sources/AppwriteModels/PhoneList.swift index 38a5a6f..6f3bee3 100644 --- a/Sources/AppwriteModels/PhoneList.swift +++ b/Sources/AppwriteModels/PhoneList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Phones List -public class PhoneList { +open class PhoneList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case phones = "phones" + } /// Total number of phones documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class PhoneList { self.phones = phones } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.phones = try container.decode([Phone].self, forKey: .phones) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(phones, forKey: .phones) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Preferences.swift b/Sources/AppwriteModels/Preferences.swift index 9904ccc..41f94e6 100644 --- a/Sources/AppwriteModels/Preferences.swift +++ b/Sources/AppwriteModels/Preferences.swift @@ -2,7 +2,11 @@ import Foundation import JSONCodable /// Preferences -public class Preferences { +open class Preferences: Codable { + + enum CodingKeys: String, CodingKey { + case data + } /// Additional properties public let data: T @@ -13,6 +17,18 @@ public class Preferences { self.data = data } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.data = try container.decode(T.self, forKey: .data) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(data, forKey: .data) + } + public func toMap() -> [String: Any] { return [ "data": try! JSONEncoder().encode(data) diff --git a/Sources/AppwriteModels/Provider.swift b/Sources/AppwriteModels/Provider.swift index 4a0e46c..50e50d2 100644 --- a/Sources/AppwriteModels/Provider.swift +++ b/Sources/AppwriteModels/Provider.swift @@ -2,7 +2,19 @@ import Foundation import JSONCodable /// Provider -public class Provider { +open class Provider: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case name = "name" + case provider = "provider" + case enabled = "enabled" + case type = "type" + case credentials = "credentials" + case options = "options" + } /// Provider ID. public let id: String @@ -26,10 +38,10 @@ public class Provider { public let type: String /// Provider credentials. - public let credentials: Any + public let credentials: [String: AnyCodable] /// Provider options. - public let options: Any? + public let options: [String: AnyCodable]? init( @@ -40,8 +52,8 @@ public class Provider { provider: String, enabled: Bool, type: String, - credentials: Any, - options: Any? + credentials: [String: AnyCodable], + options: [String: AnyCodable]? ) { self.id = id self.createdAt = createdAt @@ -54,6 +66,34 @@ public class Provider { self.options = options } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.name = try container.decode(String.self, forKey: .name) + self.provider = try container.decode(String.self, forKey: .provider) + self.enabled = try container.decode(Bool.self, forKey: .enabled) + self.type = try container.decode(String.self, forKey: .type) + self.credentials = try container.decode([String: AnyCodable].self, forKey: .credentials) + self.options = try container.decodeIfPresent([String: AnyCodable].self, forKey: .options) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(name, forKey: .name) + try container.encode(provider, forKey: .provider) + try container.encode(enabled, forKey: .enabled) + try container.encode(type, forKey: .type) + try container.encode(credentials, forKey: .credentials) + try container.encodeIfPresent(options, forKey: .options) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, @@ -77,8 +117,8 @@ public class Provider { provider: map["provider"] as! String, enabled: map["enabled"] as! Bool, type: map["type"] as! String, - credentials: map["credentials"] as! Any, - options: map["options"] as? Any + 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 16e2293..76fd4eb 100644 --- a/Sources/AppwriteModels/ProviderList.swift +++ b/Sources/AppwriteModels/ProviderList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Provider list -public class ProviderList { +open class ProviderList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case providers = "providers" + } /// Total number of providers documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class ProviderList { self.providers = providers } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.providers = try container.decode([Provider].self, forKey: .providers) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(providers, forKey: .providers) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Runtime.swift b/Sources/AppwriteModels/Runtime.swift index 01ea4c4..f8e6950 100644 --- a/Sources/AppwriteModels/Runtime.swift +++ b/Sources/AppwriteModels/Runtime.swift @@ -2,7 +2,18 @@ import Foundation import JSONCodable /// Runtime -public class Runtime { +open class Runtime: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case key = "key" + case name = "name" + case version = "version" + case base = "base" + case image = "image" + case logo = "logo" + case supports = "supports" + } /// Runtime ID. public let id: String @@ -49,6 +60,32 @@ public class Runtime { self.supports = supports } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.key = try container.decode(String.self, forKey: .key) + self.name = try container.decode(String.self, forKey: .name) + self.version = try container.decode(String.self, forKey: .version) + self.base = try container.decode(String.self, forKey: .base) + self.image = try container.decode(String.self, forKey: .image) + self.logo = try container.decode(String.self, forKey: .logo) + self.supports = try container.decode([String].self, forKey: .supports) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(key, forKey: .key) + try container.encode(name, forKey: .name) + try container.encode(version, forKey: .version) + try container.encode(base, forKey: .base) + try container.encode(image, forKey: .image) + try container.encode(logo, forKey: .logo) + try container.encode(supports, forKey: .supports) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/RuntimeList.swift b/Sources/AppwriteModels/RuntimeList.swift index 4cd4153..ab99ed1 100644 --- a/Sources/AppwriteModels/RuntimeList.swift +++ b/Sources/AppwriteModels/RuntimeList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Runtimes List -public class RuntimeList { +open class RuntimeList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case runtimes = "runtimes" + } /// Total number of runtimes documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class RuntimeList { self.runtimes = runtimes } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.runtimes = try container.decode([Runtime].self, forKey: .runtimes) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(runtimes, forKey: .runtimes) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Session.swift b/Sources/AppwriteModels/Session.swift index 86f4a7c..b5c25a6 100644 --- a/Sources/AppwriteModels/Session.swift +++ b/Sources/AppwriteModels/Session.swift @@ -2,7 +2,39 @@ import Foundation import JSONCodable /// Session -public class Session { +open class Session: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case userId = "userId" + case expire = "expire" + case provider = "provider" + case providerUid = "providerUid" + case providerAccessToken = "providerAccessToken" + case providerAccessTokenExpiry = "providerAccessTokenExpiry" + case providerRefreshToken = "providerRefreshToken" + case ip = "ip" + case osCode = "osCode" + case osName = "osName" + case osVersion = "osVersion" + case clientType = "clientType" + case clientCode = "clientCode" + case clientName = "clientName" + case clientVersion = "clientVersion" + case clientEngine = "clientEngine" + case clientEngineVersion = "clientEngineVersion" + case deviceName = "deviceName" + case deviceBrand = "deviceBrand" + case deviceModel = "deviceModel" + case countryCode = "countryCode" + case countryName = "countryName" + case current = "current" + case factors = "factors" + case secret = "secret" + case mfaUpdatedAt = "mfaUpdatedAt" + } /// Session ID. public let id: String @@ -154,6 +186,74 @@ public class Session { self.mfaUpdatedAt = mfaUpdatedAt } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.userId = try container.decode(String.self, forKey: .userId) + self.expire = try container.decode(String.self, forKey: .expire) + self.provider = try container.decode(String.self, forKey: .provider) + self.providerUid = try container.decode(String.self, forKey: .providerUid) + self.providerAccessToken = try container.decode(String.self, forKey: .providerAccessToken) + self.providerAccessTokenExpiry = try container.decode(String.self, forKey: .providerAccessTokenExpiry) + self.providerRefreshToken = try container.decode(String.self, forKey: .providerRefreshToken) + self.ip = try container.decode(String.self, forKey: .ip) + self.osCode = try container.decode(String.self, forKey: .osCode) + self.osName = try container.decode(String.self, forKey: .osName) + self.osVersion = try container.decode(String.self, forKey: .osVersion) + self.clientType = try container.decode(String.self, forKey: .clientType) + self.clientCode = try container.decode(String.self, forKey: .clientCode) + self.clientName = try container.decode(String.self, forKey: .clientName) + self.clientVersion = try container.decode(String.self, forKey: .clientVersion) + self.clientEngine = try container.decode(String.self, forKey: .clientEngine) + self.clientEngineVersion = try container.decode(String.self, forKey: .clientEngineVersion) + self.deviceName = try container.decode(String.self, forKey: .deviceName) + self.deviceBrand = try container.decode(String.self, forKey: .deviceBrand) + self.deviceModel = try container.decode(String.self, forKey: .deviceModel) + self.countryCode = try container.decode(String.self, forKey: .countryCode) + self.countryName = try container.decode(String.self, forKey: .countryName) + self.current = try container.decode(Bool.self, forKey: .current) + self.factors = try container.decode([String].self, forKey: .factors) + self.secret = try container.decode(String.self, forKey: .secret) + self.mfaUpdatedAt = try container.decode(String.self, forKey: .mfaUpdatedAt) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(userId, forKey: .userId) + try container.encode(expire, forKey: .expire) + try container.encode(provider, forKey: .provider) + try container.encode(providerUid, forKey: .providerUid) + try container.encode(providerAccessToken, forKey: .providerAccessToken) + try container.encode(providerAccessTokenExpiry, forKey: .providerAccessTokenExpiry) + try container.encode(providerRefreshToken, forKey: .providerRefreshToken) + try container.encode(ip, forKey: .ip) + try container.encode(osCode, forKey: .osCode) + try container.encode(osName, forKey: .osName) + try container.encode(osVersion, forKey: .osVersion) + try container.encode(clientType, forKey: .clientType) + try container.encode(clientCode, forKey: .clientCode) + try container.encode(clientName, forKey: .clientName) + try container.encode(clientVersion, forKey: .clientVersion) + try container.encode(clientEngine, forKey: .clientEngine) + try container.encode(clientEngineVersion, forKey: .clientEngineVersion) + try container.encode(deviceName, forKey: .deviceName) + try container.encode(deviceBrand, forKey: .deviceBrand) + try container.encode(deviceModel, forKey: .deviceModel) + try container.encode(countryCode, forKey: .countryCode) + try container.encode(countryName, forKey: .countryName) + try container.encode(current, forKey: .current) + try container.encode(factors, forKey: .factors) + try container.encode(secret, forKey: .secret) + try container.encode(mfaUpdatedAt, forKey: .mfaUpdatedAt) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/SessionList.swift b/Sources/AppwriteModels/SessionList.swift index 409f72a..13b6b3d 100644 --- a/Sources/AppwriteModels/SessionList.swift +++ b/Sources/AppwriteModels/SessionList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Sessions List -public class SessionList { +open class SessionList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case sessions = "sessions" + } /// Total number of sessions documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class SessionList { self.sessions = sessions } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.sessions = try container.decode([Session].self, forKey: .sessions) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(sessions, forKey: .sessions) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Specification.swift b/Sources/AppwriteModels/Specification.swift index fd9e49b..a84f617 100644 --- a/Sources/AppwriteModels/Specification.swift +++ b/Sources/AppwriteModels/Specification.swift @@ -2,7 +2,14 @@ import Foundation import JSONCodable /// Specification -public class Specification { +open class Specification: Codable { + + enum CodingKeys: String, CodingKey { + case memory = "memory" + case cpus = "cpus" + case enabled = "enabled" + case slug = "slug" + } /// Memory size in MB. public let memory: Int @@ -29,6 +36,24 @@ public class Specification { self.slug = slug } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.memory = try container.decode(Int.self, forKey: .memory) + self.cpus = try container.decode(Double.self, forKey: .cpus) + self.enabled = try container.decode(Bool.self, forKey: .enabled) + self.slug = try container.decode(String.self, forKey: .slug) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(memory, forKey: .memory) + try container.encode(cpus, forKey: .cpus) + try container.encode(enabled, forKey: .enabled) + try container.encode(slug, forKey: .slug) + } + public func toMap() -> [String: Any] { return [ "memory": memory as Any, diff --git a/Sources/AppwriteModels/SpecificationList.swift b/Sources/AppwriteModels/SpecificationList.swift index fbe93ca..f2b9766 100644 --- a/Sources/AppwriteModels/SpecificationList.swift +++ b/Sources/AppwriteModels/SpecificationList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Specifications List -public class SpecificationList { +open class SpecificationList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case specifications = "specifications" + } /// Total number of specifications documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class SpecificationList { self.specifications = specifications } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.specifications = try container.decode([Specification].self, forKey: .specifications) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(specifications, forKey: .specifications) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Subscriber.swift b/Sources/AppwriteModels/Subscriber.swift index 5ab202d..ad6fa5d 100644 --- a/Sources/AppwriteModels/Subscriber.swift +++ b/Sources/AppwriteModels/Subscriber.swift @@ -2,7 +2,19 @@ import Foundation import JSONCodable /// Subscriber -public class Subscriber { +open class Subscriber: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case targetId = "targetId" + case target = "target" + case userId = "userId" + case userName = "userName" + case topicId = "topicId" + case providerType = "providerType" + } /// Subscriber ID. public let id: String @@ -54,6 +66,34 @@ public class Subscriber { self.providerType = providerType } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.targetId = try container.decode(String.self, forKey: .targetId) + self.target = try container.decode(Target.self, forKey: .target) + self.userId = try container.decode(String.self, forKey: .userId) + self.userName = try container.decode(String.self, forKey: .userName) + self.topicId = try container.decode(String.self, forKey: .topicId) + self.providerType = try container.decode(String.self, forKey: .providerType) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(targetId, forKey: .targetId) + try container.encode(target, forKey: .target) + try container.encode(userId, forKey: .userId) + try container.encode(userName, forKey: .userName) + try container.encode(topicId, forKey: .topicId) + try container.encode(providerType, forKey: .providerType) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/SubscriberList.swift b/Sources/AppwriteModels/SubscriberList.swift index 5d38226..2d63f07 100644 --- a/Sources/AppwriteModels/SubscriberList.swift +++ b/Sources/AppwriteModels/SubscriberList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Subscriber list -public class SubscriberList { +open class SubscriberList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case subscribers = "subscribers" + } /// Total number of subscribers documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class SubscriberList { self.subscribers = subscribers } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.subscribers = try container.decode([Subscriber].self, forKey: .subscribers) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(subscribers, forKey: .subscribers) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Target.swift b/Sources/AppwriteModels/Target.swift index 2e81790..0581a61 100644 --- a/Sources/AppwriteModels/Target.swift +++ b/Sources/AppwriteModels/Target.swift @@ -2,7 +2,19 @@ import Foundation import JSONCodable /// Target -public class Target { +open class Target: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case name = "name" + case userId = "userId" + case providerId = "providerId" + case providerType = "providerType" + case identifier = "identifier" + case expired = "expired" + } /// Target ID. public let id: String @@ -54,6 +66,34 @@ public class Target { self.expired = expired } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.name = try container.decode(String.self, forKey: .name) + self.userId = try container.decode(String.self, forKey: .userId) + self.providerId = try container.decodeIfPresent(String.self, forKey: .providerId) + self.providerType = try container.decode(String.self, forKey: .providerType) + self.identifier = try container.decode(String.self, forKey: .identifier) + self.expired = try container.decode(Bool.self, forKey: .expired) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(name, forKey: .name) + try container.encode(userId, forKey: .userId) + try container.encodeIfPresent(providerId, forKey: .providerId) + try container.encode(providerType, forKey: .providerType) + try container.encode(identifier, forKey: .identifier) + try container.encode(expired, forKey: .expired) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/TargetList.swift b/Sources/AppwriteModels/TargetList.swift index dadd887..6c9f247 100644 --- a/Sources/AppwriteModels/TargetList.swift +++ b/Sources/AppwriteModels/TargetList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Target list -public class TargetList { +open class TargetList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case targets = "targets" + } /// Total number of targets documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class TargetList { self.targets = targets } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.targets = try container.decode([Target].self, forKey: .targets) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(targets, forKey: .targets) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Team.swift b/Sources/AppwriteModels/Team.swift index a44c305..9ca7307 100644 --- a/Sources/AppwriteModels/Team.swift +++ b/Sources/AppwriteModels/Team.swift @@ -2,7 +2,16 @@ import Foundation import JSONCodable /// Team -public class Team { +open class Team: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case name = "name" + case total = "total" + case prefs = "prefs" + } /// Team ID. public let id: String @@ -39,6 +48,28 @@ public class Team { self.prefs = prefs } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.name = try container.decode(String.self, forKey: .name) + self.total = try container.decode(Int.self, forKey: .total) + self.prefs = try container.decode(Preferences.self, forKey: .prefs) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(name, forKey: .name) + try container.encode(total, forKey: .total) + try container.encode(prefs, forKey: .prefs) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/TeamList.swift b/Sources/AppwriteModels/TeamList.swift index ec7e0bd..384d9f6 100644 --- a/Sources/AppwriteModels/TeamList.swift +++ b/Sources/AppwriteModels/TeamList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Teams List -public class TeamList { +open class TeamList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case teams = "teams" + } /// Total number of teams documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class TeamList { self.teams = teams } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.teams = try container.decode([Team].self, forKey: .teams) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(teams, forKey: .teams) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Token.swift b/Sources/AppwriteModels/Token.swift index 31d4b4a..f832402 100644 --- a/Sources/AppwriteModels/Token.swift +++ b/Sources/AppwriteModels/Token.swift @@ -2,7 +2,16 @@ import Foundation import JSONCodable /// Token -public class Token { +open class Token: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case userId = "userId" + case secret = "secret" + case expire = "expire" + case phrase = "phrase" + } /// Token ID. public let id: String @@ -39,6 +48,28 @@ public class Token { self.phrase = phrase } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.userId = try container.decode(String.self, forKey: .userId) + self.secret = try container.decode(String.self, forKey: .secret) + self.expire = try container.decode(String.self, forKey: .expire) + self.phrase = try container.decode(String.self, forKey: .phrase) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(userId, forKey: .userId) + try container.encode(secret, forKey: .secret) + try container.encode(expire, forKey: .expire) + try container.encode(phrase, forKey: .phrase) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/Topic.swift b/Sources/AppwriteModels/Topic.swift index bc89a07..4489abb 100644 --- a/Sources/AppwriteModels/Topic.swift +++ b/Sources/AppwriteModels/Topic.swift @@ -2,7 +2,18 @@ import Foundation import JSONCodable /// Topic -public class Topic { +open class Topic: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case name = "name" + case emailTotal = "emailTotal" + case smsTotal = "smsTotal" + case pushTotal = "pushTotal" + case subscribe = "subscribe" + } /// Topic ID. public let id: String @@ -49,6 +60,32 @@ public class Topic { self.subscribe = subscribe } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.name = try container.decode(String.self, forKey: .name) + self.emailTotal = try container.decode(Int.self, forKey: .emailTotal) + self.smsTotal = try container.decode(Int.self, forKey: .smsTotal) + self.pushTotal = try container.decode(Int.self, forKey: .pushTotal) + self.subscribe = try container.decode([String].self, forKey: .subscribe) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(name, forKey: .name) + try container.encode(emailTotal, forKey: .emailTotal) + try container.encode(smsTotal, forKey: .smsTotal) + try container.encode(pushTotal, forKey: .pushTotal) + try container.encode(subscribe, forKey: .subscribe) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/TopicList.swift b/Sources/AppwriteModels/TopicList.swift index b7d35a0..66eae2c 100644 --- a/Sources/AppwriteModels/TopicList.swift +++ b/Sources/AppwriteModels/TopicList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Topic list -public class TopicList { +open class TopicList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case topics = "topics" + } /// Total number of topics documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class TopicList { self.topics = topics } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.topics = try container.decode([Topic].self, forKey: .topics) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(topics, forKey: .topics) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/User.swift b/Sources/AppwriteModels/User.swift index 0229dc5..6e972d3 100644 --- a/Sources/AppwriteModels/User.swift +++ b/Sources/AppwriteModels/User.swift @@ -2,7 +2,29 @@ import Foundation import JSONCodable /// User -public class User { +open class User: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case name = "name" + case password = "password" + case hash = "hash" + case hashOptions = "hashOptions" + case registration = "registration" + case status = "status" + case labels = "labels" + case passwordUpdate = "passwordUpdate" + case email = "email" + case phone = "phone" + case emailVerification = "emailVerification" + case phoneVerification = "phoneVerification" + case mfa = "mfa" + case prefs = "prefs" + case targets = "targets" + case accessedAt = "accessedAt" + } /// User ID. public let id: String @@ -23,7 +45,7 @@ public class User { public let hash: String? /// Password hashing algorithm configuration. - public let hashOptions: Any? + public let hashOptions: [String: AnyCodable]? /// User registration date in ISO 8601 format. public let registration: String @@ -69,7 +91,7 @@ public class User { name: String, password: String?, hash: String?, - hashOptions: Any?, + hashOptions: [String: AnyCodable]?, registration: String, status: Bool, labels: [String], @@ -104,6 +126,54 @@ public class User { self.accessedAt = accessedAt } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.name = try container.decode(String.self, forKey: .name) + self.password = try container.decodeIfPresent(String.self, forKey: .password) + self.hash = try container.decodeIfPresent(String.self, forKey: .hash) + self.hashOptions = try container.decodeIfPresent([String: AnyCodable].self, forKey: .hashOptions) + self.registration = try container.decode(String.self, forKey: .registration) + self.status = try container.decode(Bool.self, forKey: .status) + self.labels = try container.decode([String].self, forKey: .labels) + self.passwordUpdate = try container.decode(String.self, forKey: .passwordUpdate) + self.email = try container.decode(String.self, forKey: .email) + self.phone = try container.decode(String.self, forKey: .phone) + self.emailVerification = try container.decode(Bool.self, forKey: .emailVerification) + self.phoneVerification = try container.decode(Bool.self, forKey: .phoneVerification) + self.mfa = try container.decode(Bool.self, forKey: .mfa) + self.prefs = try container.decode(Preferences.self, forKey: .prefs) + self.targets = try container.decode([Target].self, forKey: .targets) + self.accessedAt = try container.decode(String.self, forKey: .accessedAt) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(name, forKey: .name) + try container.encodeIfPresent(password, forKey: .password) + try container.encodeIfPresent(hash, forKey: .hash) + try container.encodeIfPresent(hashOptions, forKey: .hashOptions) + try container.encode(registration, forKey: .registration) + try container.encode(status, forKey: .status) + try container.encode(labels, forKey: .labels) + try container.encode(passwordUpdate, forKey: .passwordUpdate) + try container.encode(email, forKey: .email) + try container.encode(phone, forKey: .phone) + try container.encode(emailVerification, forKey: .emailVerification) + try container.encode(phoneVerification, forKey: .phoneVerification) + try container.encode(mfa, forKey: .mfa) + try container.encode(prefs, forKey: .prefs) + try container.encode(targets, forKey: .targets) + try container.encode(accessedAt, forKey: .accessedAt) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, @@ -136,7 +206,7 @@ public class User { name: map["name"] as! String, password: map["password"] as? String, hash: map["hash"] as? String, - hashOptions: map["hashOptions"] as? Any, + hashOptions: map["hashOptions"] as? [String: AnyCodable], registration: map["registration"] as! String, status: map["status"] as! Bool, labels: map["labels"] as! [String], diff --git a/Sources/AppwriteModels/UserList.swift b/Sources/AppwriteModels/UserList.swift index 44eebb2..7bf7413 100644 --- a/Sources/AppwriteModels/UserList.swift +++ b/Sources/AppwriteModels/UserList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Users List -public class UserList { +open class UserList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case users = "users" + } /// Total number of users documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class UserList { self.users = users } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.users = try container.decode([User].self, forKey: .users) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(users, forKey: .users) + } + public func toMap() -> [String: Any] { return [ "total": total as Any, diff --git a/Sources/AppwriteModels/Variable.swift b/Sources/AppwriteModels/Variable.swift index 63934d1..1e35992 100644 --- a/Sources/AppwriteModels/Variable.swift +++ b/Sources/AppwriteModels/Variable.swift @@ -2,7 +2,17 @@ import Foundation import JSONCodable /// Variable -public class Variable { +open class Variable: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case key = "key" + case value = "value" + case resourceType = "resourceType" + case resourceId = "resourceId" + } /// Variable ID. public let id: String @@ -44,6 +54,30 @@ public class Variable { self.resourceId = resourceId } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.key = try container.decode(String.self, forKey: .key) + self.value = try container.decode(String.self, forKey: .value) + self.resourceType = try container.decode(String.self, forKey: .resourceType) + self.resourceId = try container.decode(String.self, forKey: .resourceId) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(key, forKey: .key) + try container.encode(value, forKey: .value) + try container.encode(resourceType, forKey: .resourceType) + try container.encode(resourceId, forKey: .resourceId) + } + public func toMap() -> [String: Any] { return [ "$id": id as Any, diff --git a/Sources/AppwriteModels/VariableList.swift b/Sources/AppwriteModels/VariableList.swift index 86c6ddc..8345d0b 100644 --- a/Sources/AppwriteModels/VariableList.swift +++ b/Sources/AppwriteModels/VariableList.swift @@ -2,7 +2,12 @@ import Foundation import JSONCodable /// Variables List -public class VariableList { +open class VariableList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case variables = "variables" + } /// Total number of variables documents that matched your query. public let total: Int @@ -19,6 +24,20 @@ public class VariableList { self.variables = variables } + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.total = try container.decode(Int.self, forKey: .total) + self.variables = try container.decode([Variable].self, forKey: .variables) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(variables, forKey: .variables) + } + public func toMap() -> [String: Any] { return [ "total": total as Any,