From f3f964544fe77f00c2a491fb34a5cc291994e501 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 20 Aug 2025 03:09:32 +1200 Subject: [PATCH 1/6] Add 1.8.x support --- README.md | 6 +- Sources/Appwrite/Client.swift | 4 +- Sources/Appwrite/Query.swift | 84 ++++ Sources/Appwrite/Services/Account.swift | 2 + Sources/Appwrite/Services/Databases.swift | 183 +------- Sources/Appwrite/Services/TablesDb.swift | 421 ++++++++++++++++++ Sources/AppwriteModels/ContinentList.swift | 2 +- Sources/AppwriteModels/CountryList.swift | 2 +- Sources/AppwriteModels/CurrencyList.swift | 2 +- Sources/AppwriteModels/DocumentList.swift | 2 +- Sources/AppwriteModels/ExecutionList.swift | 2 +- Sources/AppwriteModels/FileList.swift | 2 +- Sources/AppwriteModels/IdentityList.swift | 2 +- Sources/AppwriteModels/LanguageList.swift | 2 +- Sources/AppwriteModels/LocaleCodeList.swift | 2 +- Sources/AppwriteModels/LogList.swift | 2 +- Sources/AppwriteModels/MembershipList.swift | 2 +- Sources/AppwriteModels/PhoneList.swift | 2 +- Sources/AppwriteModels/Row.swift | 113 +++++ Sources/AppwriteModels/RowList.swift | 54 +++ Sources/AppwriteModels/SessionList.swift | 2 +- Sources/AppwriteModels/TeamList.swift | 2 +- .../databases/decrement-document-attribute.md | 17 - .../databases/increment-document-attribute.md | 17 - docs/examples/functions/create-execution.md | 2 +- docs/examples/tablesdb/create-row.md | 16 + docs/examples/tablesdb/delete-row.md | 14 + docs/examples/tablesdb/get-row.md | 15 + docs/examples/tablesdb/list-rows.md | 14 + docs/examples/tablesdb/update-row.md | 16 + docs/examples/tablesdb/upsert-row.md | 16 + 31 files changed, 796 insertions(+), 226 deletions(-) create mode 100644 Sources/Appwrite/Services/TablesDb.swift create mode 100644 Sources/AppwriteModels/Row.swift create mode 100644 Sources/AppwriteModels/RowList.swift delete mode 100644 docs/examples/databases/decrement-document-attribute.md delete mode 100644 docs/examples/databases/increment-document-attribute.md create mode 100644 docs/examples/tablesdb/create-row.md create mode 100644 docs/examples/tablesdb/delete-row.md create mode 100644 docs/examples/tablesdb/get-row.md create mode 100644 docs/examples/tablesdb/list-rows.md create mode 100644 docs/examples/tablesdb/update-row.md create mode 100644 docs/examples/tablesdb/upsert-row.md diff --git a/README.md b/README.md index c7da177..0d94889 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ ![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-apple.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-apple.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Apple SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies: ```swift dependencies: [ - .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "10.2.0"), + .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "11.0.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index bcd9028..910f79a 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -23,8 +23,8 @@ open class Client { "x-sdk-name": "Apple", "x-sdk-platform": "client", "x-sdk-language": "apple", - "x-sdk-version": "10.2.0", - "x-appwrite-response-format": "1.7.0" + "x-sdk-version": "11.0.0", + "x-appwrite-response-format": "1.8.0" ] internal var config: [String: String] = [:] diff --git a/Sources/Appwrite/Query.swift b/Sources/Appwrite/Query.swift index 20c499e..1956cdd 100644 --- a/Sources/Appwrite/Query.swift +++ b/Sources/Appwrite/Query.swift @@ -284,6 +284,90 @@ public struct Query : Codable, CustomStringConvertible { ).description } + public static func notContains(_ attribute: String, value: Any) -> String { + return Query( + method: "notContains", + attribute: attribute, + values: Query.parseValue(value) + ).description + } + + public static func notSearch(_ attribute: String, value: String) -> String { + return Query( + method: "notSearch", + attribute: attribute, + values: [value] + ).description + } + + public static func notBetween(_ attribute: String, start: Int, end: Int) -> String { + return Query( + method: "notBetween", + attribute: attribute, + values: [start, end] + ).description + } + + public static func notBetween(_ attribute: String, start: Double, end: Double) -> String { + return Query( + method: "notBetween", + attribute: attribute, + values: [start, end] + ).description + } + + public static func notBetween(_ attribute: String, start: String, end: String) -> String { + return Query( + method: "notBetween", + attribute: attribute, + values: [start, end] + ).description + } + + public static func notStartsWith(_ attribute: String, value: String) -> String { + return Query( + method: "notStartsWith", + attribute: attribute, + values: [value] + ).description + } + + public static func notEndsWith(_ attribute: String, value: String) -> String { + return Query( + method: "notEndsWith", + attribute: attribute, + values: [value] + ).description + } + + public static func createdBefore(_ value: String) -> String { + return Query( + method: "createdBefore", + values: [value] + ).description + } + + public static func createdAfter(_ value: String) -> String { + return Query( + method: "createdAfter", + values: [value] + ).description + } + + public static func updatedBefore(_ value: String) -> String { + return Query( + method: "updatedBefore", + values: [value] + ).description + } + + public static func updatedAfter(_ value: String) -> String { + return Query( + method: "updatedAfter", + values: [value] + ).description + } + public static func or(_ queries: [String]) -> String { let decoder = JSONDecoder() let decodedQueries = queries.compactMap { queryStr -> Query? in diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 59f06a8..d6726f0 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -1214,6 +1214,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// + @available(*, deprecated, message: "This API has been deprecated.") open func updateMagicURLSession( userId: String, secret: String @@ -1313,6 +1314,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// + @available(*, deprecated, message: "This API has been deprecated.") open func updatePhoneSession( userId: String, secret: String diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index 599c7b7..dc84978 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -19,6 +19,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -59,6 +60,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -87,6 +89,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -137,6 +140,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -166,6 +170,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -209,6 +214,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -225,10 +231,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -243,6 +245,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, @@ -279,10 +282,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -297,6 +296,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, @@ -327,6 +327,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -375,6 +376,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -402,6 +404,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRow` instead.") open func deleteDocument( databaseId: String, collectionId: String, @@ -425,169 +428,5 @@ open class Databases: Service { params: apiParams ) } - /// - /// Decrement a specific attribute of a document by a given value. - /// - /// - Parameters: - /// - databaseId: String - /// - collectionId: String - /// - documentId: String - /// - attribute: String - /// - value: Double (optional) - /// - min: Double (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Document - /// - open func decrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = nil, - min: Double? = nil, - nestedType: T.Type - ) async throws -> AppwriteModels.Document { - let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" - .replacingOccurrences(of: "{databaseId}", with: databaseId) - .replacingOccurrences(of: "{collectionId}", with: collectionId) - .replacingOccurrences(of: "{documentId}", with: documentId) - .replacingOccurrences(of: "{attribute}", with: attribute) - - let apiParams: [String: Any?] = [ - "value": value, - "min": min - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.Document = { response in - return AppwriteModels.Document.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "PATCH", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Decrement a specific attribute of a document by a given value. - /// - /// - Parameters: - /// - databaseId: String - /// - collectionId: String - /// - documentId: String - /// - attribute: String - /// - value: Double (optional) - /// - min: Double (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Document - /// - open func decrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = nil, - min: Double? = nil - ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { - return try await decrementDocumentAttribute( - databaseId: databaseId, - collectionId: collectionId, - documentId: documentId, - attribute: attribute, - value: value, - min: min, - nestedType: [String: AnyCodable].self - ) - } - - /// - /// Increment a specific attribute of a document by a given value. - /// - /// - Parameters: - /// - databaseId: String - /// - collectionId: String - /// - documentId: String - /// - attribute: String - /// - value: Double (optional) - /// - max: Double (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Document - /// - open func incrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = nil, - max: Double? = nil, - nestedType: T.Type - ) async throws -> AppwriteModels.Document { - let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" - .replacingOccurrences(of: "{databaseId}", with: databaseId) - .replacingOccurrences(of: "{collectionId}", with: collectionId) - .replacingOccurrences(of: "{documentId}", with: documentId) - .replacingOccurrences(of: "{attribute}", with: attribute) - - let apiParams: [String: Any?] = [ - "value": value, - "max": max - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.Document = { response in - return AppwriteModels.Document.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "PATCH", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Increment a specific attribute of a document by a given value. - /// - /// - Parameters: - /// - databaseId: String - /// - collectionId: String - /// - documentId: String - /// - attribute: String - /// - value: Double (optional) - /// - max: Double (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Document - /// - open func incrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = nil, - max: Double? = nil - ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { - return try await incrementDocumentAttribute( - databaseId: databaseId, - collectionId: collectionId, - documentId: documentId, - attribute: attribute, - value: value, - max: max, - nestedType: [String: AnyCodable].self - ) - } - } \ No newline at end of file diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift new file mode 100644 index 0000000..e15b520 --- /dev/null +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -0,0 +1,421 @@ +import AsyncHTTPClient +import Foundation +import NIO +import JSONCodable +import AppwriteEnums +import AppwriteModels + +/// +open class TablesDb: Service { + + /// + /// Get a list of all the user's rows in a given table. You can use the query + /// params to filter your results. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func listRows( + databaseId: String, + tableId: String, + queries: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.RowList { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.RowList = { response in + return AppwriteModels.RowList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a list of all the user's rows in a given table. You can use the query + /// params to filter your results. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func listRows( + databaseId: String, + tableId: String, + queries: [String]? = nil + ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { + return try await listRows( + databaseId: databaseId, + tableId: tableId, + queries: queries, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Create a new Row. Before using this route, you should create a new table + /// resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "rowId": rowId, + "data": data, + "permissions": permissions + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a new Row. Before using this route, you should create a new table + /// resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: [String]? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await createRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + data: data, + permissions: permissions, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Get a row by its unique ID. This endpoint response returns a JSON object + /// with the row data. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a row by its unique ID. This endpoint response returns a JSON object + /// with the row data. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: [String]? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await getRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + queries: queries, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Create or update a Row. Before using this route, you should create a new + /// table resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func upsertRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = nil, + permissions: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + + let apiParams: [String: Any?] = [ + "data": data, + "permissions": permissions + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create or update a Row. Before using this route, you should create a new + /// table resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func upsertRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = nil, + permissions: [String]? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await upsertRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + data: data, + permissions: permissions, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Update a row by its unique ID. Using the patch method you can pass only + /// specific fields that will get updated. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = nil, + permissions: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + + let apiParams: [String: Any?] = [ + "data": data, + "permissions": permissions + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a row by its unique ID. Using the patch method you can pass only + /// specific fields that will get updated. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = nil, + permissions: [String]? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await updateRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + data: data, + permissions: permissions, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Delete a row by its unique ID. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteRow( + databaseId: String, + tableId: String, + rowId: String + ) async throws -> Any { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + return try await client.call( + method: "DELETE", + path: apiPath, + headers: apiHeaders, + params: apiParams ) + } + + +} \ No newline at end of file diff --git a/Sources/AppwriteModels/ContinentList.swift b/Sources/AppwriteModels/ContinentList.swift index fa9a90f..7ebd966 100644 --- a/Sources/AppwriteModels/ContinentList.swift +++ b/Sources/AppwriteModels/ContinentList.swift @@ -9,7 +9,7 @@ open class ContinentList: Codable { case continents = "continents" } - /// Total number of continents documents that matched your query. + /// Total number of continents rows that matched your query. public let total: Int /// List of continents. diff --git a/Sources/AppwriteModels/CountryList.swift b/Sources/AppwriteModels/CountryList.swift index 865cc19..61389ba 100644 --- a/Sources/AppwriteModels/CountryList.swift +++ b/Sources/AppwriteModels/CountryList.swift @@ -9,7 +9,7 @@ open class CountryList: Codable { case countries = "countries" } - /// Total number of countries documents that matched your query. + /// Total number of countries rows that matched your query. public let total: Int /// List of countries. diff --git a/Sources/AppwriteModels/CurrencyList.swift b/Sources/AppwriteModels/CurrencyList.swift index 1e0dff9..12962a6 100644 --- a/Sources/AppwriteModels/CurrencyList.swift +++ b/Sources/AppwriteModels/CurrencyList.swift @@ -9,7 +9,7 @@ open class CurrencyList: Codable { case currencies = "currencies" } - /// Total number of currencies documents that matched your query. + /// Total number of currencies rows that matched your query. public let total: Int /// List of currencies. diff --git a/Sources/AppwriteModels/DocumentList.swift b/Sources/AppwriteModels/DocumentList.swift index a129182..abed99a 100644 --- a/Sources/AppwriteModels/DocumentList.swift +++ b/Sources/AppwriteModels/DocumentList.swift @@ -9,7 +9,7 @@ open class DocumentList: Codable { case documents = "documents" } - /// Total number of documents documents that matched your query. + /// Total number of documents rows that matched your query. public let total: Int /// List of documents. diff --git a/Sources/AppwriteModels/ExecutionList.swift b/Sources/AppwriteModels/ExecutionList.swift index 72d43a6..da9ea78 100644 --- a/Sources/AppwriteModels/ExecutionList.swift +++ b/Sources/AppwriteModels/ExecutionList.swift @@ -9,7 +9,7 @@ open class ExecutionList: Codable { case executions = "executions" } - /// Total number of executions documents that matched your query. + /// Total number of executions rows that matched your query. public let total: Int /// List of executions. diff --git a/Sources/AppwriteModels/FileList.swift b/Sources/AppwriteModels/FileList.swift index bec7b76..bd4e332 100644 --- a/Sources/AppwriteModels/FileList.swift +++ b/Sources/AppwriteModels/FileList.swift @@ -9,7 +9,7 @@ open class FileList: Codable { case files = "files" } - /// Total number of files documents that matched your query. + /// Total number of files rows that matched your query. public let total: Int /// List of files. diff --git a/Sources/AppwriteModels/IdentityList.swift b/Sources/AppwriteModels/IdentityList.swift index 6065fad..958284c 100644 --- a/Sources/AppwriteModels/IdentityList.swift +++ b/Sources/AppwriteModels/IdentityList.swift @@ -9,7 +9,7 @@ open class IdentityList: Codable { case identities = "identities" } - /// Total number of identities documents that matched your query. + /// Total number of identities rows that matched your query. public let total: Int /// List of identities. diff --git a/Sources/AppwriteModels/LanguageList.swift b/Sources/AppwriteModels/LanguageList.swift index 13c6e4a..0edfa80 100644 --- a/Sources/AppwriteModels/LanguageList.swift +++ b/Sources/AppwriteModels/LanguageList.swift @@ -9,7 +9,7 @@ open class LanguageList: Codable { case languages = "languages" } - /// Total number of languages documents that matched your query. + /// Total number of languages rows that matched your query. public let total: Int /// List of languages. diff --git a/Sources/AppwriteModels/LocaleCodeList.swift b/Sources/AppwriteModels/LocaleCodeList.swift index 5ef0653..0d22818 100644 --- a/Sources/AppwriteModels/LocaleCodeList.swift +++ b/Sources/AppwriteModels/LocaleCodeList.swift @@ -9,7 +9,7 @@ open class LocaleCodeList: Codable { case localeCodes = "localeCodes" } - /// Total number of localeCodes documents that matched your query. + /// Total number of localeCodes rows that matched your query. public let total: Int /// List of localeCodes. diff --git a/Sources/AppwriteModels/LogList.swift b/Sources/AppwriteModels/LogList.swift index 7ff2d07..c9207b8 100644 --- a/Sources/AppwriteModels/LogList.swift +++ b/Sources/AppwriteModels/LogList.swift @@ -9,7 +9,7 @@ open class LogList: Codable { case logs = "logs" } - /// Total number of logs documents that matched your query. + /// Total number of logs rows that matched your query. public let total: Int /// List of logs. diff --git a/Sources/AppwriteModels/MembershipList.swift b/Sources/AppwriteModels/MembershipList.swift index a7b0cd6..9290f69 100644 --- a/Sources/AppwriteModels/MembershipList.swift +++ b/Sources/AppwriteModels/MembershipList.swift @@ -9,7 +9,7 @@ open class MembershipList: Codable { case memberships = "memberships" } - /// Total number of memberships documents that matched your query. + /// Total number of memberships rows that matched your query. public let total: Int /// List of memberships. diff --git a/Sources/AppwriteModels/PhoneList.swift b/Sources/AppwriteModels/PhoneList.swift index 6f3bee3..63371a6 100644 --- a/Sources/AppwriteModels/PhoneList.swift +++ b/Sources/AppwriteModels/PhoneList.swift @@ -9,7 +9,7 @@ open class PhoneList: Codable { case phones = "phones" } - /// Total number of phones documents that matched your query. + /// Total number of phones rows that matched your query. public let total: Int /// List of phones. diff --git a/Sources/AppwriteModels/Row.swift b/Sources/AppwriteModels/Row.swift new file mode 100644 index 0000000..6e94a9e --- /dev/null +++ b/Sources/AppwriteModels/Row.swift @@ -0,0 +1,113 @@ +import Foundation +import JSONCodable + +/// Row +open class Row: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case sequence = "$sequence" + case tableId = "$tableId" + case databaseId = "$databaseId" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case data + } + + /// Row ID. + public let id: String + + /// Row automatically incrementing ID. + public let sequence: Int + + /// Table ID. + public let tableId: String + + /// Database ID. + public let databaseId: String + + /// Row creation date in ISO 8601 format. + public let createdAt: String + + /// Row update date in ISO 8601 format. + public let updatedAt: String + + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + public let permissions: [String] + + /// Additional properties + public let data: T + + init( + id: String, + sequence: Int, + tableId: String, + databaseId: String, + createdAt: String, + updatedAt: String, + permissions: [String], + data: T + ) { + self.id = id + self.sequence = sequence + self.tableId = tableId + self.databaseId = databaseId + self.createdAt = createdAt + self.updatedAt = updatedAt + self.permissions = permissions + 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.sequence = try container.decode(Int.self, forKey: .sequence) + self.tableId = try container.decode(String.self, forKey: .tableId) + 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(sequence, forKey: .sequence) + try container.encode(tableId, forKey: .tableId) + 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, + "$sequence": sequence as Any, + "$tableId": tableId as Any, + "$databaseId": databaseId as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "$permissions": permissions as Any, + "data": try! JSONEncoder().encode(data) + ] + } + + public static func from(map: [String: Any] ) -> Row { + return Row( + id: map["$id"] as! String, + sequence: map["$sequence"] as! Int, + tableId: map["$tableId"] as! String, + databaseId: map["$databaseId"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + ) + } +} diff --git a/Sources/AppwriteModels/RowList.swift b/Sources/AppwriteModels/RowList.swift new file mode 100644 index 0000000..8eb7d80 --- /dev/null +++ b/Sources/AppwriteModels/RowList.swift @@ -0,0 +1,54 @@ +import Foundation +import JSONCodable + +/// Rows List +open class RowList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case rows = "rows" + } + + /// Total number of rows rows that matched your query. + public let total: Int + + /// List of rows. + public let rows: [Row] + + + init( + total: Int, + rows: [Row] + ) { + self.total = total + self.rows = rows + } + + 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.rows = try container.decode([Row].self, forKey: .rows) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(rows, forKey: .rows) + } + + public func toMap() -> [String: Any] { + return [ + "total": total as Any, + "rows": rows.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> RowList { + return RowList( + total: map["total"] as! Int, + rows: (map["rows"] as! [[String: Any]]).map { Row.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/SessionList.swift b/Sources/AppwriteModels/SessionList.swift index 13b6b3d..5a227e5 100644 --- a/Sources/AppwriteModels/SessionList.swift +++ b/Sources/AppwriteModels/SessionList.swift @@ -9,7 +9,7 @@ open class SessionList: Codable { case sessions = "sessions" } - /// Total number of sessions documents that matched your query. + /// Total number of sessions rows that matched your query. public let total: Int /// List of sessions. diff --git a/Sources/AppwriteModels/TeamList.swift b/Sources/AppwriteModels/TeamList.swift index 384d9f6..988a1ec 100644 --- a/Sources/AppwriteModels/TeamList.swift +++ b/Sources/AppwriteModels/TeamList.swift @@ -9,7 +9,7 @@ open class TeamList: Codable { case teams = "teams" } - /// Total number of teams documents that matched your query. + /// Total number of teams rows that matched your query. public let total: Int /// List of teams. diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md deleted file mode 100644 index 8ef2637..0000000 --- a/docs/examples/databases/decrement-document-attribute.md +++ /dev/null @@ -1,17 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let databases = Databases(client) - -let document = try await databases.decrementDocumentAttribute( - databaseId: "", - collectionId: "", - documentId: "", - attribute: "", - value: 0, // optional - min: 0 // optional -) - diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md deleted file mode 100644 index f64b2cd..0000000 --- a/docs/examples/databases/increment-document-attribute.md +++ /dev/null @@ -1,17 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let databases = Databases(client) - -let document = try await databases.incrementDocumentAttribute( - databaseId: "", - collectionId: "", - documentId: "", - attribute: "", - value: 0, // optional - max: 0 // optional -) - diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 7470e9e..b7311df 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -14,6 +14,6 @@ let execution = try await functions.createExecution( path: "", // optional method: .gET, // optional headers: [:], // optional - scheduledAt: "" // optional + scheduledAt: "" // optional ) diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md new file mode 100644 index 0000000..56442a0 --- /dev/null +++ b/docs/examples/tablesdb/create-row.md @@ -0,0 +1,16 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let tablesDb = TablesDb(client) + +let row = try await tablesDb.createRow( + databaseId: "", + tableId: "", + rowId: "", + data: [:], + permissions: ["read("any")"] // optional +) + diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md new file mode 100644 index 0000000..11c1587 --- /dev/null +++ b/docs/examples/tablesdb/delete-row.md @@ -0,0 +1,14 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let tablesDb = TablesDb(client) + +let result = try await tablesDb.deleteRow( + databaseId: "", + tableId: "", + rowId: "" +) + diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md new file mode 100644 index 0000000..6f89799 --- /dev/null +++ b/docs/examples/tablesdb/get-row.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let tablesDb = TablesDb(client) + +let row = try await tablesDb.getRow( + databaseId: "", + tableId: "", + rowId: "", + queries: [] // optional +) + diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md new file mode 100644 index 0000000..b94bdae --- /dev/null +++ b/docs/examples/tablesdb/list-rows.md @@ -0,0 +1,14 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let tablesDb = TablesDb(client) + +let rowList = try await tablesDb.listRows( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md new file mode 100644 index 0000000..275ed59 --- /dev/null +++ b/docs/examples/tablesdb/update-row.md @@ -0,0 +1,16 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let tablesDb = TablesDb(client) + +let row = try await tablesDb.updateRow( + databaseId: "", + tableId: "", + rowId: "", + data: [:], // optional + permissions: ["read("any")"] // optional +) + diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md new file mode 100644 index 0000000..0398919 --- /dev/null +++ b/docs/examples/tablesdb/upsert-row.md @@ -0,0 +1,16 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let tablesDb = TablesDb(client) + +let row = try await tablesDb.upsertRow( + databaseId: "", + tableId: "", + rowId: "", + data: [:], // optional + permissions: ["read("any")"] // optional +) + From a63464c35765bf3b09a73d235e8e43220066fb32 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 20 Aug 2025 19:17:30 +1200 Subject: [PATCH 2/6] Add 1.8.x support --- Sources/Appwrite/Services/Databases.swift | 168 ++++++++++++++++++ Sources/Appwrite/Services/TablesDb.swift | 164 +++++++++++++++++ .../databases/decrement-document-attribute.md | 17 ++ .../databases/increment-document-attribute.md | 17 ++ .../examples/tablesdb/decrement-row-column.md | 17 ++ .../examples/tablesdb/increment-row-column.md | 17 ++ 6 files changed, 400 insertions(+) create mode 100644 docs/examples/databases/decrement-document-attribute.md create mode 100644 docs/examples/databases/increment-document-attribute.md create mode 100644 docs/examples/tablesdb/decrement-row-column.md create mode 100644 docs/examples/tablesdb/increment-row-column.md diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index dc84978..86893dc 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -428,5 +428,173 @@ open class Databases: Service { params: apiParams ) } + /// + /// Decrement a specific attribute of a document by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - attribute: String + /// - value: Double (optional) + /// - min: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.") + open func decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = nil, + min: Double? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Document { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + .replacingOccurrences(of: "{documentId}", with: documentId) + .replacingOccurrences(of: "{attribute}", with: attribute) + + let apiParams: [String: Any?] = [ + "value": value, + "min": min + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Document = { response in + return AppwriteModels.Document.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Decrement a specific attribute of a document by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - attribute: String + /// - value: Double (optional) + /// - min: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.") + open func decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = nil, + min: Double? = nil + ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { + return try await decrementDocumentAttribute( + databaseId: databaseId, + collectionId: collectionId, + documentId: documentId, + attribute: attribute, + value: value, + min: min, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Increment a specific attribute of a document by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - attribute: String + /// - value: Double (optional) + /// - max: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.") + open func incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = nil, + max: Double? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Document { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + .replacingOccurrences(of: "{documentId}", with: documentId) + .replacingOccurrences(of: "{attribute}", with: attribute) + + let apiParams: [String: Any?] = [ + "value": value, + "max": max + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Document = { response in + return AppwriteModels.Document.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Increment a specific attribute of a document by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - attribute: String + /// - value: Double (optional) + /// - max: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.") + open func incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = nil, + max: Double? = nil + ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { + return try await incrementDocumentAttribute( + databaseId: databaseId, + collectionId: collectionId, + documentId: documentId, + attribute: attribute, + value: value, + max: max, + nestedType: [String: AnyCodable].self + ) + } + } \ No newline at end of file diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift index e15b520..f2e4b8c 100644 --- a/Sources/Appwrite/Services/TablesDb.swift +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -417,5 +417,169 @@ open class TablesDb: Service { params: apiParams ) } + /// + /// Decrement a specific column of a row by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - column: String + /// - value: Double (optional) + /// - min: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func decrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = nil, + min: Double? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + .replacingOccurrences(of: "{column}", with: column) + + let apiParams: [String: Any?] = [ + "value": value, + "min": min + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Decrement a specific column of a row by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - column: String + /// - value: Double (optional) + /// - min: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func decrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = nil, + min: Double? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await decrementRowColumn( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + column: column, + value: value, + min: min, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Increment a specific column of a row by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - column: String + /// - value: Double (optional) + /// - max: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func incrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = nil, + max: Double? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + .replacingOccurrences(of: "{column}", with: column) + + let apiParams: [String: Any?] = [ + "value": value, + "max": max + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Increment a specific column of a row by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - column: String + /// - value: Double (optional) + /// - max: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func incrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = nil, + max: Double? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await incrementRowColumn( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + column: column, + value: value, + max: max, + nestedType: [String: AnyCodable].self + ) + } + } \ No newline at end of file diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..8ef2637 --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let databases = Databases(client) + +let document = try await databases.decrementDocumentAttribute( + databaseId: "", + collectionId: "", + documentId: "", + attribute: "", + value: 0, // optional + min: 0 // optional +) + diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..f64b2cd --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let databases = Databases(client) + +let document = try await databases.incrementDocumentAttribute( + databaseId: "", + collectionId: "", + documentId: "", + attribute: "", + value: 0, // optional + max: 0 // optional +) + diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md new file mode 100644 index 0000000..0e619ce --- /dev/null +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let tablesDb = TablesDb(client) + +let row = try await tablesDb.decrementRowColumn( + databaseId: "", + tableId: "", + rowId: "", + column: "", + value: 0, // optional + min: 0 // optional +) + diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md new file mode 100644 index 0000000..ac4b671 --- /dev/null +++ b/docs/examples/tablesdb/increment-row-column.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let tablesDb = TablesDb(client) + +let row = try await tablesDb.incrementRowColumn( + databaseId: "", + tableId: "", + rowId: "", + column: "", + value: 0, // optional + max: 0 // optional +) + From 15d7aa7a4e759b586f04a7d5b5da5f67e00987f1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 21 Aug 2025 22:15:37 +1200 Subject: [PATCH 3/6] Fix casing --- Sources/Appwrite/Services/Account.swift | 334 ++++++++++++++++++ Sources/Appwrite/Services/Databases.swift | 30 +- Sources/Appwrite/Services/TablesDb.swift | 10 +- Sources/AppwriteModels/ContinentList.swift | 2 +- Sources/AppwriteModels/CountryList.swift | 2 +- Sources/AppwriteModels/CurrencyList.swift | 2 +- Sources/AppwriteModels/DocumentList.swift | 2 +- Sources/AppwriteModels/ExecutionList.swift | 2 +- Sources/AppwriteModels/FileList.swift | 2 +- Sources/AppwriteModels/IdentityList.swift | 2 +- Sources/AppwriteModels/LanguageList.swift | 2 +- Sources/AppwriteModels/LocaleCodeList.swift | 2 +- Sources/AppwriteModels/LogList.swift | 2 +- Sources/AppwriteModels/MembershipList.swift | 2 +- Sources/AppwriteModels/PhoneList.swift | 2 +- Sources/AppwriteModels/RowList.swift | 2 +- Sources/AppwriteModels/SessionList.swift | 2 +- Sources/AppwriteModels/TeamList.swift | 2 +- .../account/create-m-f-a-authenticator.md | 13 + .../account/create-m-f-a-challenge.md | 13 + .../account/create-m-f-a-recovery-codes.md | 10 + .../account/delete-m-f-a-authenticator.md | 13 + .../account/get-m-f-a-recovery-codes.md | 10 + docs/examples/account/list-m-f-a-factors.md | 10 + .../account/update-m-f-a-authenticator.md | 14 + .../account/update-m-f-a-challenge.md | 13 + .../account/update-m-f-a-recovery-codes.md | 10 + docs/examples/tablesdb/create-row.md | 4 +- .../examples/tablesdb/decrement-row-column.md | 4 +- docs/examples/tablesdb/delete-row.md | 4 +- docs/examples/tablesdb/get-row.md | 4 +- .../examples/tablesdb/increment-row-column.md | 4 +- docs/examples/tablesdb/list-rows.md | 4 +- docs/examples/tablesdb/update-row.md | 4 +- docs/examples/tablesdb/upsert-row.md | 4 +- 35 files changed, 491 insertions(+), 51 deletions(-) create mode 100644 docs/examples/account/create-m-f-a-authenticator.md create mode 100644 docs/examples/account/create-m-f-a-challenge.md create mode 100644 docs/examples/account/create-m-f-a-recovery-codes.md create mode 100644 docs/examples/account/delete-m-f-a-authenticator.md create mode 100644 docs/examples/account/get-m-f-a-recovery-codes.md create mode 100644 docs/examples/account/list-m-f-a-factors.md create mode 100644 docs/examples/account/update-m-f-a-authenticator.md create mode 100644 docs/examples/account/update-m-f-a-challenge.md create mode 100644 docs/examples/account/update-m-f-a-recovery-codes.md diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index d6726f0..2c582da 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -391,6 +391,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaType /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFAAuthenticator` instead.") open func createMfaAuthenticator( type: AppwriteEnums.AuthenticatorType ) async throws -> AppwriteModels.MfaType { @@ -416,6 +417,42 @@ open class Account: Service { ) } + /// + /// Add an authenticator app to be used as an MFA factor. Verify the + /// authenticator using the [verify + /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) + /// method. + /// + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaType + /// + open func createMFAAuthenticator( + type: AppwriteEnums.AuthenticatorType + ) async throws -> AppwriteModels.MfaType { + let apiPath: String = "/account/mfa/authenticators/{type}" + .replacingOccurrences(of: "{type}", with: type.rawValue) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaType = { response in + return AppwriteModels.MfaType.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -427,6 +464,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.") open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, otp: String, @@ -467,6 +505,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.") open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, otp: String @@ -478,6 +517,68 @@ open class Account: Service { ) } + /// + /// Verify an authenticator app after adding it using the [add + /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) + /// method. + /// + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User + /// + open func updateMFAAuthenticator( + type: AppwriteEnums.AuthenticatorType, + otp: String, + nestedType: T.Type + ) async throws -> AppwriteModels.User { + let apiPath: String = "/account/mfa/authenticators/{type}" + .replacingOccurrences(of: "{type}", with: type.rawValue) + + let apiParams: [String: Any?] = [ + "otp": otp + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.User = { response in + return AppwriteModels.User.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Verify an authenticator app after adding it using the [add + /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) + /// method. + /// + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User + /// + open func updateMFAAuthenticator( + type: AppwriteEnums.AuthenticatorType, + otp: String + ) async throws -> AppwriteModels.User<[String: AnyCodable]> { + return try await updateMFAAuthenticator( + type: type, + otp: otp, + nestedType: [String: AnyCodable].self + ) + } + /// /// Delete an authenticator for a user by ID. /// @@ -486,6 +587,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `DeleteMFAAuthenticator` instead.") open func deleteMfaAuthenticator( type: AppwriteEnums.AuthenticatorType ) async throws -> Any { @@ -505,6 +607,33 @@ open class Account: Service { params: apiParams ) } + /// + /// Delete an authenticator for a user by ID. + /// + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteMFAAuthenticator( + type: AppwriteEnums.AuthenticatorType + ) async throws -> Any { + let apiPath: String = "/account/mfa/authenticators/{type}" + .replacingOccurrences(of: "{type}", with: type.rawValue) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + return try await client.call( + method: "DELETE", + path: apiPath, + headers: apiHeaders, + params: apiParams ) + } + /// /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) @@ -515,6 +644,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaChallenge /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFAChallenge` instead.") open func createMfaChallenge( factor: AppwriteEnums.AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { @@ -541,6 +671,42 @@ open class Account: Service { ) } + /// + /// Begin the process of MFA verification after sign-in. Finish the flow with + /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) + /// method. + /// + /// - Parameters: + /// - factor: AppwriteEnums.AuthenticationFactor + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaChallenge + /// + open func createMFAChallenge( + factor: AppwriteEnums.AuthenticationFactor + ) async throws -> AppwriteModels.MfaChallenge { + let apiPath: String = "/account/mfa/challenge" + + let apiParams: [String: Any?] = [ + "factor": factor + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaChallenge = { response in + return AppwriteModels.MfaChallenge.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Complete the MFA challenge by providing the one-time password. Finish the /// process of MFA verification by providing the one-time password. To begin @@ -554,6 +720,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAChallenge` instead.") open func updateMfaChallenge( challengeId: String, otp: String @@ -582,12 +749,54 @@ open class Account: Service { ) } + /// + /// Complete the MFA challenge by providing the one-time password. Finish the + /// process of MFA verification by providing the one-time password. To begin + /// the flow, use + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method. + /// + /// - Parameters: + /// - challengeId: String + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session + /// + open func updateMFAChallenge( + challengeId: String, + otp: String + ) async throws -> AppwriteModels.Session { + let apiPath: String = "/account/mfa/challenge" + + let apiParams: [String: Any?] = [ + "challengeId": challengeId, + "otp": otp + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Session = { response in + return AppwriteModels.Session.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// List the factors available on the account to be used as a MFA challange. /// /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaFactors /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `ListMFAFactors` instead.") open func listMfaFactors( ) async throws -> AppwriteModels.MfaFactors { let apiPath: String = "/account/mfa/factors" @@ -609,6 +818,33 @@ open class Account: Service { ) } + /// + /// List the factors available on the account to be used as a MFA challange. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaFactors + /// + open func listMFAFactors( + ) async throws -> AppwriteModels.MfaFactors { + let apiPath: String = "/account/mfa/factors" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.MfaFactors = { response in + return AppwriteModels.MfaFactors.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using @@ -618,6 +854,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `GetMFARecoveryCodes` instead.") open func getMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -639,6 +876,36 @@ open class Account: Service { ) } + /// + /// Get recovery codes that can be used as backup for MFA flow. Before getting + /// codes, they must be generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. An OTP challenge is required to read recovery codes. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func getMFARecoveryCodes( + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/account/mfa/recovery-codes" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Generate recovery codes as backup for MFA flow. It's recommended to /// generate and show then immediately after user successfully adds their @@ -649,6 +916,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFARecoveryCodes` instead.") open func createMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -672,6 +940,39 @@ open class Account: Service { ) } + /// + /// Generate recovery codes as backup for MFA flow. It's recommended to + /// generate and show then immediately after user successfully adds their + /// authehticator. Recovery codes can be used as a MFA verification type in + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func createMFARecoveryCodes( + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/account/mfa/recovery-codes" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using @@ -681,6 +982,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFARecoveryCodes` instead.") open func updateMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -704,6 +1006,38 @@ open class Account: Service { ) } + /// + /// Regenerate recovery codes that can be used as backup for MFA flow. Before + /// regenerating codes, they must be first generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. An OTP challenge is required to regenreate recovery codes. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func updateMFARecoveryCodes( + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/account/mfa/recovery-codes" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Update currently logged in user account name. /// diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index 86893dc..e8c8f1e 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -19,7 +19,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -60,7 +60,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -89,7 +89,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -140,7 +140,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -170,7 +170,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -214,7 +214,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -245,7 +245,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, @@ -296,7 +296,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, @@ -327,7 +327,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -376,7 +376,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -404,7 +404,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.") open func deleteDocument( databaseId: String, collectionId: String, @@ -441,7 +441,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -492,7 +492,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -525,7 +525,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -576,7 +576,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift index f2e4b8c..cbc2abb 100644 --- a/Sources/Appwrite/Services/TablesDb.swift +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -6,7 +6,7 @@ import AppwriteEnums import AppwriteModels /// -open class TablesDb: Service { +open class TablesDB: Service { /// /// Get a list of all the user's rows in a given table. You can use the query @@ -75,7 +75,7 @@ open class TablesDb: Service { /// /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -125,7 +125,7 @@ open class TablesDb: Service { /// /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -227,7 +227,7 @@ open class TablesDb: Service { /// /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -277,7 +277,7 @@ open class TablesDb: Service { /// /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: diff --git a/Sources/AppwriteModels/ContinentList.swift b/Sources/AppwriteModels/ContinentList.swift index 7ebd966..0e697e7 100644 --- a/Sources/AppwriteModels/ContinentList.swift +++ b/Sources/AppwriteModels/ContinentList.swift @@ -9,7 +9,7 @@ open class ContinentList: Codable { case continents = "continents" } - /// Total number of continents rows that matched your query. + /// Total number of continents that matched your query. public let total: Int /// List of continents. diff --git a/Sources/AppwriteModels/CountryList.swift b/Sources/AppwriteModels/CountryList.swift index 61389ba..15a8d89 100644 --- a/Sources/AppwriteModels/CountryList.swift +++ b/Sources/AppwriteModels/CountryList.swift @@ -9,7 +9,7 @@ open class CountryList: Codable { case countries = "countries" } - /// Total number of countries rows that matched your query. + /// Total number of countries that matched your query. public let total: Int /// List of countries. diff --git a/Sources/AppwriteModels/CurrencyList.swift b/Sources/AppwriteModels/CurrencyList.swift index 12962a6..81d1c26 100644 --- a/Sources/AppwriteModels/CurrencyList.swift +++ b/Sources/AppwriteModels/CurrencyList.swift @@ -9,7 +9,7 @@ open class CurrencyList: Codable { case currencies = "currencies" } - /// Total number of currencies rows that matched your query. + /// Total number of currencies that matched your query. public let total: Int /// List of currencies. diff --git a/Sources/AppwriteModels/DocumentList.swift b/Sources/AppwriteModels/DocumentList.swift index abed99a..77f2679 100644 --- a/Sources/AppwriteModels/DocumentList.swift +++ b/Sources/AppwriteModels/DocumentList.swift @@ -9,7 +9,7 @@ open class DocumentList: Codable { case documents = "documents" } - /// Total number of documents rows that matched your query. + /// Total number of documents that matched your query. public let total: Int /// List of documents. diff --git a/Sources/AppwriteModels/ExecutionList.swift b/Sources/AppwriteModels/ExecutionList.swift index da9ea78..c903b34 100644 --- a/Sources/AppwriteModels/ExecutionList.swift +++ b/Sources/AppwriteModels/ExecutionList.swift @@ -9,7 +9,7 @@ open class ExecutionList: Codable { case executions = "executions" } - /// Total number of executions rows that matched your query. + /// Total number of executions that matched your query. public let total: Int /// List of executions. diff --git a/Sources/AppwriteModels/FileList.swift b/Sources/AppwriteModels/FileList.swift index bd4e332..19d52a0 100644 --- a/Sources/AppwriteModels/FileList.swift +++ b/Sources/AppwriteModels/FileList.swift @@ -9,7 +9,7 @@ open class FileList: Codable { case files = "files" } - /// Total number of files rows that matched your query. + /// Total number of files that matched your query. public let total: Int /// List of files. diff --git a/Sources/AppwriteModels/IdentityList.swift b/Sources/AppwriteModels/IdentityList.swift index 958284c..abcc362 100644 --- a/Sources/AppwriteModels/IdentityList.swift +++ b/Sources/AppwriteModels/IdentityList.swift @@ -9,7 +9,7 @@ open class IdentityList: Codable { case identities = "identities" } - /// Total number of identities rows that matched your query. + /// Total number of identities that matched your query. public let total: Int /// List of identities. diff --git a/Sources/AppwriteModels/LanguageList.swift b/Sources/AppwriteModels/LanguageList.swift index 0edfa80..2b1f03c 100644 --- a/Sources/AppwriteModels/LanguageList.swift +++ b/Sources/AppwriteModels/LanguageList.swift @@ -9,7 +9,7 @@ open class LanguageList: Codable { case languages = "languages" } - /// Total number of languages rows that matched your query. + /// Total number of languages that matched your query. public let total: Int /// List of languages. diff --git a/Sources/AppwriteModels/LocaleCodeList.swift b/Sources/AppwriteModels/LocaleCodeList.swift index 0d22818..f1d1678 100644 --- a/Sources/AppwriteModels/LocaleCodeList.swift +++ b/Sources/AppwriteModels/LocaleCodeList.swift @@ -9,7 +9,7 @@ open class LocaleCodeList: Codable { case localeCodes = "localeCodes" } - /// Total number of localeCodes rows that matched your query. + /// Total number of localeCodes that matched your query. public let total: Int /// List of localeCodes. diff --git a/Sources/AppwriteModels/LogList.swift b/Sources/AppwriteModels/LogList.swift index c9207b8..ba76a8a 100644 --- a/Sources/AppwriteModels/LogList.swift +++ b/Sources/AppwriteModels/LogList.swift @@ -9,7 +9,7 @@ open class LogList: Codable { case logs = "logs" } - /// Total number of logs rows that matched your query. + /// Total number of logs that matched your query. public let total: Int /// List of logs. diff --git a/Sources/AppwriteModels/MembershipList.swift b/Sources/AppwriteModels/MembershipList.swift index 9290f69..7d6ffd1 100644 --- a/Sources/AppwriteModels/MembershipList.swift +++ b/Sources/AppwriteModels/MembershipList.swift @@ -9,7 +9,7 @@ open class MembershipList: Codable { case memberships = "memberships" } - /// Total number of memberships rows that matched your query. + /// Total number of memberships that matched your query. public let total: Int /// List of memberships. diff --git a/Sources/AppwriteModels/PhoneList.swift b/Sources/AppwriteModels/PhoneList.swift index 63371a6..f09d239 100644 --- a/Sources/AppwriteModels/PhoneList.swift +++ b/Sources/AppwriteModels/PhoneList.swift @@ -9,7 +9,7 @@ open class PhoneList: Codable { case phones = "phones" } - /// Total number of phones rows that matched your query. + /// Total number of phones that matched your query. public let total: Int /// List of phones. diff --git a/Sources/AppwriteModels/RowList.swift b/Sources/AppwriteModels/RowList.swift index 8eb7d80..c14c83b 100644 --- a/Sources/AppwriteModels/RowList.swift +++ b/Sources/AppwriteModels/RowList.swift @@ -9,7 +9,7 @@ open class RowList: Codable { case rows = "rows" } - /// Total number of rows rows that matched your query. + /// Total number of rows that matched your query. public let total: Int /// List of rows. diff --git a/Sources/AppwriteModels/SessionList.swift b/Sources/AppwriteModels/SessionList.swift index 5a227e5..c9c8394 100644 --- a/Sources/AppwriteModels/SessionList.swift +++ b/Sources/AppwriteModels/SessionList.swift @@ -9,7 +9,7 @@ open class SessionList: Codable { case sessions = "sessions" } - /// Total number of sessions rows that matched your query. + /// Total number of sessions that matched your query. public let total: Int /// List of sessions. diff --git a/Sources/AppwriteModels/TeamList.swift b/Sources/AppwriteModels/TeamList.swift index 988a1ec..2b789d9 100644 --- a/Sources/AppwriteModels/TeamList.swift +++ b/Sources/AppwriteModels/TeamList.swift @@ -9,7 +9,7 @@ open class TeamList: Codable { case teams = "teams" } - /// Total number of teams rows that matched your query. + /// Total number of teams that matched your query. public let total: Int /// List of teams. diff --git a/docs/examples/account/create-m-f-a-authenticator.md b/docs/examples/account/create-m-f-a-authenticator.md new file mode 100644 index 0000000..cfe0082 --- /dev/null +++ b/docs/examples/account/create-m-f-a-authenticator.md @@ -0,0 +1,13 @@ +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let mfaType = try await account.createMFAAuthenticator( + type: .totp +) + diff --git a/docs/examples/account/create-m-f-a-challenge.md b/docs/examples/account/create-m-f-a-challenge.md new file mode 100644 index 0000000..27f1bc1 --- /dev/null +++ b/docs/examples/account/create-m-f-a-challenge.md @@ -0,0 +1,13 @@ +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let mfaChallenge = try await account.createMFAChallenge( + factor: .email +) + diff --git a/docs/examples/account/create-m-f-a-recovery-codes.md b/docs/examples/account/create-m-f-a-recovery-codes.md new file mode 100644 index 0000000..2674a40 --- /dev/null +++ b/docs/examples/account/create-m-f-a-recovery-codes.md @@ -0,0 +1,10 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let mfaRecoveryCodes = try await account.createMFARecoveryCodes() + diff --git a/docs/examples/account/delete-m-f-a-authenticator.md b/docs/examples/account/delete-m-f-a-authenticator.md new file mode 100644 index 0000000..adfa363 --- /dev/null +++ b/docs/examples/account/delete-m-f-a-authenticator.md @@ -0,0 +1,13 @@ +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let result = try await account.deleteMFAAuthenticator( + type: .totp +) + diff --git a/docs/examples/account/get-m-f-a-recovery-codes.md b/docs/examples/account/get-m-f-a-recovery-codes.md new file mode 100644 index 0000000..efee499 --- /dev/null +++ b/docs/examples/account/get-m-f-a-recovery-codes.md @@ -0,0 +1,10 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let mfaRecoveryCodes = try await account.getMFARecoveryCodes() + diff --git a/docs/examples/account/list-m-f-a-factors.md b/docs/examples/account/list-m-f-a-factors.md new file mode 100644 index 0000000..d81e77e --- /dev/null +++ b/docs/examples/account/list-m-f-a-factors.md @@ -0,0 +1,10 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let mfaFactors = try await account.listMFAFactors() + diff --git a/docs/examples/account/update-m-f-a-authenticator.md b/docs/examples/account/update-m-f-a-authenticator.md new file mode 100644 index 0000000..5245be2 --- /dev/null +++ b/docs/examples/account/update-m-f-a-authenticator.md @@ -0,0 +1,14 @@ +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let user = try await account.updateMFAAuthenticator( + type: .totp, + otp: "" +) + diff --git a/docs/examples/account/update-m-f-a-challenge.md b/docs/examples/account/update-m-f-a-challenge.md new file mode 100644 index 0000000..473393e --- /dev/null +++ b/docs/examples/account/update-m-f-a-challenge.md @@ -0,0 +1,13 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let session = try await account.updateMFAChallenge( + challengeId: "", + otp: "" +) + diff --git a/docs/examples/account/update-m-f-a-recovery-codes.md b/docs/examples/account/update-m-f-a-recovery-codes.md new file mode 100644 index 0000000..fbd6847 --- /dev/null +++ b/docs/examples/account/update-m-f-a-recovery-codes.md @@ -0,0 +1,10 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let mfaRecoveryCodes = try await account.updateMFARecoveryCodes() + diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 56442a0..0972892 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -4,9 +4,9 @@ let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.createRow( +let row = try await tablesDB.createRow( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index 0e619ce..ab8ac5b 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -4,9 +4,9 @@ let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.decrementRowColumn( +let row = try await tablesDB.decrementRowColumn( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md index 11c1587..b527aca 100644 --- a/docs/examples/tablesdb/delete-row.md +++ b/docs/examples/tablesdb/delete-row.md @@ -4,9 +4,9 @@ let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let result = try await tablesDb.deleteRow( +let result = try await tablesDB.deleteRow( databaseId: "", tableId: "", rowId: "" diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index 6f89799..bc2e2c6 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -4,9 +4,9 @@ let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.getRow( +let row = try await tablesDB.getRow( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index ac4b671..550d668 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -4,9 +4,9 @@ let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.incrementRowColumn( +let row = try await tablesDB.incrementRowColumn( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index b94bdae..94853c2 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -4,9 +4,9 @@ let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let rowList = try await tablesDb.listRows( +let rowList = try await tablesDB.listRows( databaseId: "", tableId: "", queries: [] // optional diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 275ed59..87a8f27 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -4,9 +4,9 @@ let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.updateRow( +let row = try await tablesDB.updateRow( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 0398919..ed95da7 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -4,9 +4,9 @@ let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.upsertRow( +let row = try await tablesDB.upsertRow( databaseId: "", tableId: "", rowId: "", From 6f79cb1cbfd65205d78b1805d857415ae4073918 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 23 Aug 2025 20:08:49 +1200 Subject: [PATCH 4/6] Add 1.8.x support --- Sources/Appwrite/Services/Account.swift | 8 ++++++-- Sources/AppwriteModels/Execution.swift | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 2c582da..1cb7cfe 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -1977,8 +1977,11 @@ open class Account: Service { /// /// 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 - /// returned user ID and secret and submit a request to the [POST + /// email address has never been used, a **new account is created** using the + /// provided `userId`. Otherwise, if the email address is already attached to + /// an account, the **user ID is ignored**. Then, the user will receive an + /// email with the one-time password. Use the returned user ID and secret and + /// submit a request to the [POST /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. @@ -1986,6 +1989,7 @@ open class Account: Service { /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). + /// /// /// - Parameters: /// - userId: String diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 6e81532..d216290 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -10,6 +10,7 @@ open class Execution: Codable { case updatedAt = "$updatedAt" case permissions = "$permissions" case functionId = "functionId" + case deploymentId = "deploymentId" case trigger = "trigger" case status = "status" case requestMethod = "requestMethod" @@ -39,6 +40,9 @@ open class Execution: Codable { /// Function ID. public let functionId: String + /// Function's deployment ID used to create the execution. + public let deploymentId: String + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. public let trigger: String @@ -82,6 +86,7 @@ open class Execution: Codable { updatedAt: String, permissions: [String], functionId: String, + deploymentId: String, trigger: String, status: String, requestMethod: String, @@ -100,6 +105,7 @@ open class Execution: Codable { self.updatedAt = updatedAt self.permissions = permissions self.functionId = functionId + self.deploymentId = deploymentId self.trigger = trigger self.status = status self.requestMethod = requestMethod @@ -122,6 +128,7 @@ open class Execution: Codable { 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.deploymentId = try container.decode(String.self, forKey: .deploymentId) self.trigger = try container.decode(String.self, forKey: .trigger) self.status = try container.decode(String.self, forKey: .status) self.requestMethod = try container.decode(String.self, forKey: .requestMethod) @@ -144,6 +151,7 @@ open class Execution: Codable { try container.encode(updatedAt, forKey: .updatedAt) try container.encode(permissions, forKey: .permissions) try container.encode(functionId, forKey: .functionId) + try container.encode(deploymentId, forKey: .deploymentId) try container.encode(trigger, forKey: .trigger) try container.encode(status, forKey: .status) try container.encode(requestMethod, forKey: .requestMethod) @@ -165,6 +173,7 @@ open class Execution: Codable { "$updatedAt": updatedAt as Any, "$permissions": permissions as Any, "functionId": functionId as Any, + "deploymentId": deploymentId as Any, "trigger": trigger as Any, "status": status as Any, "requestMethod": requestMethod as Any, @@ -187,6 +196,7 @@ open class Execution: Codable { updatedAt: map["$updatedAt"] as! String, permissions: map["$permissions"] as! [String], functionId: map["functionId"] as! String, + deploymentId: map["deploymentId"] as! String, trigger: map["trigger"] as! String, status: map["status"] as! String, requestMethod: map["requestMethod"] as! String, From e92bdd6b3f7d987bdfececee2714d02b51ba82b3 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 23 Aug 2025 22:14:37 +1200 Subject: [PATCH 5/6] Add 1.8.x support --- Sources/Appwrite/Services/Account.swift | 20 ++++++++++---------- Sources/AppwriteModels/Execution.swift | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 1cb7cfe..4234e7a 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -391,7 +391,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaType /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.") open func createMfaAuthenticator( type: AppwriteEnums.AuthenticatorType ) async throws -> AppwriteModels.MfaType { @@ -464,7 +464,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.") open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, otp: String, @@ -505,7 +505,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.") open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, otp: String @@ -587,7 +587,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `DeleteMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.") open func deleteMfaAuthenticator( type: AppwriteEnums.AuthenticatorType ) async throws -> Any { @@ -644,7 +644,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaChallenge /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFAChallenge` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.") open func createMfaChallenge( factor: AppwriteEnums.AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { @@ -720,7 +720,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAChallenge` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.") open func updateMfaChallenge( challengeId: String, otp: String @@ -796,7 +796,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaFactors /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `ListMFAFactors` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.") open func listMfaFactors( ) async throws -> AppwriteModels.MfaFactors { let apiPath: String = "/account/mfa/factors" @@ -854,7 +854,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `GetMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.") open func getMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -916,7 +916,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.") open func createMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -982,7 +982,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.") open func updateMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index d216290..baaf71e 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -31,7 +31,7 @@ open class Execution: Codable { /// Execution creation date in ISO 8601 format. public let createdAt: String - /// Execution upate date in ISO 8601 format. + /// Execution update date in ISO 8601 format. public let updatedAt: String /// Execution roles. From 11952bfb66b110b74d0ea78622cd0b2ee4abad93 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 26 Aug 2025 04:22:32 +1200 Subject: [PATCH 6/6] Fix docs --- .../account/{create-j-w-t.md => create-jwt.md} | 0 .../examples/account/create-m-f-a-authenticator.md | 13 ------------- docs/examples/account/create-m-f-a-challenge.md | 13 ------------- .../account/create-m-f-a-recovery-codes.md | 10 ---------- ...ic-u-r-l-token.md => create-magic-url-token.md} | 0 docs/examples/account/create-mfa-authenticator.md | 2 +- docs/examples/account/create-mfa-challenge.md | 2 +- docs/examples/account/create-mfa-recovery-codes.md | 2 +- ...-auth2session.md => create-o-auth-2-session.md} | 0 ...te-o-auth2token.md => create-o-auth-2-token.md} | 0 .../examples/account/delete-m-f-a-authenticator.md | 13 ------------- docs/examples/account/delete-mfa-authenticator.md | 2 +- docs/examples/account/get-m-f-a-recovery-codes.md | 10 ---------- docs/examples/account/get-mfa-recovery-codes.md | 2 +- docs/examples/account/list-m-f-a-factors.md | 10 ---------- docs/examples/account/list-mfa-factors.md | 2 +- .../examples/account/update-m-f-a-authenticator.md | 14 -------------- docs/examples/account/update-m-f-a-challenge.md | 13 ------------- .../account/update-m-f-a-recovery-codes.md | 10 ---------- ...-r-l-session.md => update-magic-url-session.md} | 0 docs/examples/account/update-mfa-authenticator.md | 2 +- docs/examples/account/update-mfa-challenge.md | 2 +- docs/examples/account/update-mfa-recovery-codes.md | 2 +- .../account/{update-m-f-a.md => update-mfa.md} | 0 docs/examples/avatars/{get-q-r.md => get-qr.md} | 0 ...{list-countries-e-u.md => list-countries-eu.md} | 0 26 files changed, 9 insertions(+), 115 deletions(-) rename docs/examples/account/{create-j-w-t.md => create-jwt.md} (100%) delete mode 100644 docs/examples/account/create-m-f-a-authenticator.md delete mode 100644 docs/examples/account/create-m-f-a-challenge.md delete mode 100644 docs/examples/account/create-m-f-a-recovery-codes.md rename docs/examples/account/{create-magic-u-r-l-token.md => create-magic-url-token.md} (100%) rename docs/examples/account/{create-o-auth2session.md => create-o-auth-2-session.md} (100%) rename docs/examples/account/{create-o-auth2token.md => create-o-auth-2-token.md} (100%) delete mode 100644 docs/examples/account/delete-m-f-a-authenticator.md delete mode 100644 docs/examples/account/get-m-f-a-recovery-codes.md delete mode 100644 docs/examples/account/list-m-f-a-factors.md delete mode 100644 docs/examples/account/update-m-f-a-authenticator.md delete mode 100644 docs/examples/account/update-m-f-a-challenge.md delete mode 100644 docs/examples/account/update-m-f-a-recovery-codes.md rename docs/examples/account/{update-magic-u-r-l-session.md => update-magic-url-session.md} (100%) rename docs/examples/account/{update-m-f-a.md => update-mfa.md} (100%) rename docs/examples/avatars/{get-q-r.md => get-qr.md} (100%) rename docs/examples/locale/{list-countries-e-u.md => list-countries-eu.md} (100%) diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-jwt.md similarity index 100% rename from docs/examples/account/create-j-w-t.md rename to docs/examples/account/create-jwt.md diff --git a/docs/examples/account/create-m-f-a-authenticator.md b/docs/examples/account/create-m-f-a-authenticator.md deleted file mode 100644 index cfe0082..0000000 --- a/docs/examples/account/create-m-f-a-authenticator.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite -import AppwriteEnums - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let mfaType = try await account.createMFAAuthenticator( - type: .totp -) - diff --git a/docs/examples/account/create-m-f-a-challenge.md b/docs/examples/account/create-m-f-a-challenge.md deleted file mode 100644 index 27f1bc1..0000000 --- a/docs/examples/account/create-m-f-a-challenge.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite -import AppwriteEnums - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let mfaChallenge = try await account.createMFAChallenge( - factor: .email -) - diff --git a/docs/examples/account/create-m-f-a-recovery-codes.md b/docs/examples/account/create-m-f-a-recovery-codes.md deleted file mode 100644 index 2674a40..0000000 --- a/docs/examples/account/create-m-f-a-recovery-codes.md +++ /dev/null @@ -1,10 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let mfaRecoveryCodes = try await account.createMFARecoveryCodes() - diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-url-token.md similarity index 100% rename from docs/examples/account/create-magic-u-r-l-token.md rename to docs/examples/account/create-magic-url-token.md diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index 56799e3..cfe0082 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -7,7 +7,7 @@ let client = Client() let account = Account(client) -let mfaType = try await account.createMfaAuthenticator( +let mfaType = try await account.createMFAAuthenticator( type: .totp ) diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 0b5d385..27f1bc1 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -7,7 +7,7 @@ let client = Client() let account = Account(client) -let mfaChallenge = try await account.createMfaChallenge( +let mfaChallenge = try await account.createMFAChallenge( factor: .email ) diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index c0ccb39..2674a40 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -6,5 +6,5 @@ let client = Client() let account = Account(client) -let mfaRecoveryCodes = try await account.createMfaRecoveryCodes() +let mfaRecoveryCodes = try await account.createMFARecoveryCodes() diff --git a/docs/examples/account/create-o-auth2session.md b/docs/examples/account/create-o-auth-2-session.md similarity index 100% rename from docs/examples/account/create-o-auth2session.md rename to docs/examples/account/create-o-auth-2-session.md diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth-2-token.md similarity index 100% rename from docs/examples/account/create-o-auth2token.md rename to docs/examples/account/create-o-auth-2-token.md diff --git a/docs/examples/account/delete-m-f-a-authenticator.md b/docs/examples/account/delete-m-f-a-authenticator.md deleted file mode 100644 index adfa363..0000000 --- a/docs/examples/account/delete-m-f-a-authenticator.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite -import AppwriteEnums - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let result = try await account.deleteMFAAuthenticator( - type: .totp -) - diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 16cbbe3..adfa363 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -7,7 +7,7 @@ let client = Client() let account = Account(client) -let result = try await account.deleteMfaAuthenticator( +let result = try await account.deleteMFAAuthenticator( type: .totp ) diff --git a/docs/examples/account/get-m-f-a-recovery-codes.md b/docs/examples/account/get-m-f-a-recovery-codes.md deleted file mode 100644 index efee499..0000000 --- a/docs/examples/account/get-m-f-a-recovery-codes.md +++ /dev/null @@ -1,10 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let mfaRecoveryCodes = try await account.getMFARecoveryCodes() - diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index 2f5d623..efee499 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -6,5 +6,5 @@ let client = Client() let account = Account(client) -let mfaRecoveryCodes = try await account.getMfaRecoveryCodes() +let mfaRecoveryCodes = try await account.getMFARecoveryCodes() diff --git a/docs/examples/account/list-m-f-a-factors.md b/docs/examples/account/list-m-f-a-factors.md deleted file mode 100644 index d81e77e..0000000 --- a/docs/examples/account/list-m-f-a-factors.md +++ /dev/null @@ -1,10 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let mfaFactors = try await account.listMFAFactors() - diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index f6d7a6f..d81e77e 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -6,5 +6,5 @@ let client = Client() let account = Account(client) -let mfaFactors = try await account.listMfaFactors() +let mfaFactors = try await account.listMFAFactors() diff --git a/docs/examples/account/update-m-f-a-authenticator.md b/docs/examples/account/update-m-f-a-authenticator.md deleted file mode 100644 index 5245be2..0000000 --- a/docs/examples/account/update-m-f-a-authenticator.md +++ /dev/null @@ -1,14 +0,0 @@ -import Appwrite -import AppwriteEnums - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let user = try await account.updateMFAAuthenticator( - type: .totp, - otp: "" -) - diff --git a/docs/examples/account/update-m-f-a-challenge.md b/docs/examples/account/update-m-f-a-challenge.md deleted file mode 100644 index 473393e..0000000 --- a/docs/examples/account/update-m-f-a-challenge.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let session = try await account.updateMFAChallenge( - challengeId: "", - otp: "" -) - diff --git a/docs/examples/account/update-m-f-a-recovery-codes.md b/docs/examples/account/update-m-f-a-recovery-codes.md deleted file mode 100644 index fbd6847..0000000 --- a/docs/examples/account/update-m-f-a-recovery-codes.md +++ /dev/null @@ -1,10 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let mfaRecoveryCodes = try await account.updateMFARecoveryCodes() - diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-url-session.md similarity index 100% rename from docs/examples/account/update-magic-u-r-l-session.md rename to docs/examples/account/update-magic-url-session.md diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index 6a42fb9..5245be2 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -7,7 +7,7 @@ let client = Client() let account = Account(client) -let user = try await account.updateMfaAuthenticator( +let user = try await account.updateMFAAuthenticator( type: .totp, otp: "" ) diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index db9753b..473393e 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -6,7 +6,7 @@ let client = Client() let account = Account(client) -let session = try await account.updateMfaChallenge( +let session = try await account.updateMFAChallenge( challengeId: "", otp: "" ) diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index c3b8d41..fbd6847 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -6,5 +6,5 @@ let client = Client() let account = Account(client) -let mfaRecoveryCodes = try await account.updateMfaRecoveryCodes() +let mfaRecoveryCodes = try await account.updateMFARecoveryCodes() diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-mfa.md similarity index 100% rename from docs/examples/account/update-m-f-a.md rename to docs/examples/account/update-mfa.md diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-qr.md similarity index 100% rename from docs/examples/avatars/get-q-r.md rename to docs/examples/avatars/get-qr.md diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-eu.md similarity index 100% rename from docs/examples/locale/list-countries-e-u.md rename to docs/examples/locale/list-countries-eu.md