diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eea076..b622be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,16 @@ # Change Log +## 18.1.0 + +* Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`). +* Added: `Membership.userAccessedAt` field. +* Updated: Requests now send an explicit `accept` header matching each endpoint's response type. + ## 18.0.0 * Breaking: `avatars.getScreenshot` `theme` parameter now uses the `BrowserTheme` enum * Breaking: Removed generic type parameters from `presences` service methods -* Added: `BrowserTheme` enum +* Replaced: `BrowserTheme` enum * Updated: `Presence` model is now concrete and adds a `metadata` field ## 17.1.1 diff --git a/README.md b/README.md index e262c07..ba26403 100644 --- a/README.md +++ b/README.md @@ -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: "18.0.0"), + .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "18.1.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 17f521f..ac23a0e 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -27,7 +27,7 @@ open class Client { "x-sdk-name": "Apple", "x-sdk-platform": "client", "x-sdk-language": "apple", - "x-sdk-version": "18.0.0", + "x-sdk-version": "18.1.0", "x-appwrite-response-format": "1.9.5" ] @@ -108,7 +108,6 @@ open class Client { /// open func setProject(_ value: String) -> Client { config["project"] = value - _ = addHeader(key: "X-Appwrite-Project", value: value) return self } @@ -384,7 +383,8 @@ open class Client { let apiPath: String = "/ping" let apiHeaders: [String: String] = [ - "content-type": "application/json" + "content-type": "application/json", + "X-Appwrite-Project": config["project"] ?? "" ] return try await call( @@ -415,7 +415,7 @@ open class Client { let validParams = params.filter { $0.value != nil } let queryParameters = method == "GET" && !validParams.isEmpty - ? "?" + parametersToQueryString(params: validParams) + ? (path.contains("?") ? "&" : "?") + parametersToQueryString(params: validParams) : "" var request = HTTPClientRequest(url: endPoint + path + queryParameters) diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 0f07c6f..a8f386b 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -21,7 +21,10 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.User = { response in return AppwriteModels.User.from(map: response as! [String: Any]) @@ -83,7 +86,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -160,7 +165,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -223,7 +230,10 @@ open class Account: Service { "total": total ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.IdentityList = { response in return AppwriteModels.IdentityList.from(map: response as! [String: Any]) @@ -255,6 +265,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -287,7 +298,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Jwt = { response in @@ -324,7 +337,10 @@ open class Account: Service { "total": total ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.LogList = { response in return AppwriteModels.LogList.from(map: response as! [String: Any]) @@ -358,7 +374,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -412,7 +430,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.MfaType = { response in @@ -448,7 +468,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.MfaType = { response in @@ -489,7 +511,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -552,7 +576,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -608,6 +634,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -635,6 +662,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -666,7 +694,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.MfaChallenge = { response in @@ -702,7 +732,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.MfaChallenge = { response in @@ -744,7 +776,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Session = { response in @@ -785,7 +819,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Session = { response in @@ -814,7 +850,10 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.MfaFactors = { response in return AppwriteModels.MfaFactors.from(map: response as! [String: Any]) @@ -841,7 +880,10 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.MfaFactors = { response in return AppwriteModels.MfaFactors.from(map: response as! [String: Any]) @@ -872,7 +914,10 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.MfaRecoveryCodes = { response in return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) @@ -902,7 +947,10 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.MfaRecoveryCodes = { response in return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) @@ -935,7 +983,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.MfaRecoveryCodes = { response in @@ -968,7 +1018,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.MfaRecoveryCodes = { response in @@ -1001,7 +1053,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.MfaRecoveryCodes = { response in @@ -1033,7 +1087,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.MfaRecoveryCodes = { response in @@ -1068,7 +1124,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -1125,7 +1183,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -1189,7 +1249,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -1242,7 +1304,10 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Preferences = { response in return AppwriteModels.Preferences.from(map: response as! [String: Any]) @@ -1291,7 +1356,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -1354,7 +1421,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -1403,7 +1472,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -1432,7 +1503,10 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.SessionList = { response in return AppwriteModels.SessionList.from(map: response as! [String: Any]) @@ -1461,6 +1535,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -1490,7 +1565,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Session = { response in @@ -1532,7 +1609,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Session = { response in @@ -1572,7 +1651,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Session = { response in @@ -1672,7 +1753,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Session = { response in @@ -1711,7 +1794,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Session = { response in @@ -1744,7 +1829,10 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Session = { response in return AppwriteModels.Session.from(map: response as! [String: Any]) @@ -1778,7 +1866,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Session = { response in @@ -1815,6 +1905,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -1841,7 +1932,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.User = { response in @@ -1900,7 +1993,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Target = { response in @@ -1941,7 +2036,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Target = { response in @@ -1976,6 +2073,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -2023,7 +2121,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -2079,7 +2179,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -2183,7 +2285,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -2231,7 +2335,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -2280,7 +2386,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -2320,7 +2428,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -2361,7 +2471,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -2397,7 +2509,9 @@ open class Account: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in @@ -2437,7 +2551,9 @@ open class Account: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Token = { response in diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index 2ab5617..a0a369a 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -25,7 +25,10 @@ open class Databases: Service { "queries": queries ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.TransactionList = { response in return AppwriteModels.TransactionList.from(map: response as! [String: Any]) @@ -58,7 +61,9 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Transaction = { response in @@ -90,7 +95,10 @@ open class Databases: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Transaction = { response in return AppwriteModels.Transaction.from(map: response as! [String: Any]) @@ -129,7 +137,9 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Transaction = { response in @@ -162,6 +172,7 @@ open class Databases: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -193,7 +204,9 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Transaction = { response in @@ -244,7 +257,10 @@ open class Databases: Service { "ttl": ttl ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.DocumentList = { response in return AppwriteModels.DocumentList.from(map: response as! [String: Any]) @@ -331,7 +347,9 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Document = { response in @@ -415,7 +433,10 @@ open class Databases: Service { "transactionId": transactionId ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Document = { response in return AppwriteModels.Document.from(map: response as! [String: Any]) @@ -499,7 +520,9 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Document = { response in @@ -587,7 +610,9 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Document = { response in @@ -665,6 +690,7 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -713,7 +739,9 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Document = { response in @@ -803,7 +831,9 @@ open class Databases: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Document = { response in diff --git a/Sources/Appwrite/Services/Functions.swift b/Sources/Appwrite/Services/Functions.swift index 7a63a48..b7f0ecf 100644 --- a/Sources/Appwrite/Services/Functions.swift +++ b/Sources/Appwrite/Services/Functions.swift @@ -32,7 +32,10 @@ open class Functions: Service { "total": total ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.ExecutionList = { response in return AppwriteModels.ExecutionList.from(map: response as! [String: Any]) @@ -86,7 +89,9 @@ open class Functions: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Execution = { response in @@ -121,7 +126,10 @@ open class Functions: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Execution = { response in return AppwriteModels.Execution.from(map: response as! [String: Any]) diff --git a/Sources/Appwrite/Services/Graphql.swift b/Sources/Appwrite/Services/Graphql.swift index 3bc2cda..34b49f8 100644 --- a/Sources/Appwrite/Services/Graphql.swift +++ b/Sources/Appwrite/Services/Graphql.swift @@ -26,8 +26,10 @@ open class Graphql: Service { ] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "x-sdk-graphql": "true", - "content-type": "application/json" + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> Any = { response in @@ -61,8 +63,10 @@ open class Graphql: Service { ] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "x-sdk-graphql": "true", - "content-type": "application/json" + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> Any = { response in diff --git a/Sources/Appwrite/Services/Locale.swift b/Sources/Appwrite/Services/Locale.swift index 5b70743..86cc129 100644 --- a/Sources/Appwrite/Services/Locale.swift +++ b/Sources/Appwrite/Services/Locale.swift @@ -25,7 +25,10 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Locale = { response in return AppwriteModels.Locale.from(map: response as! [String: Any]) @@ -53,7 +56,10 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.LocaleCodeList = { response in return AppwriteModels.LocaleCodeList.from(map: response as! [String: Any]) @@ -81,7 +87,10 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.ContinentList = { response in return AppwriteModels.ContinentList.from(map: response as! [String: Any]) @@ -109,7 +118,10 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.CountryList = { response in return AppwriteModels.CountryList.from(map: response as! [String: Any]) @@ -137,7 +149,10 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.CountryList = { response in return AppwriteModels.CountryList.from(map: response as! [String: Any]) @@ -165,7 +180,10 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.PhoneList = { response in return AppwriteModels.PhoneList.from(map: response as! [String: Any]) @@ -194,7 +212,10 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.CurrencyList = { response in return AppwriteModels.CurrencyList.from(map: response as! [String: Any]) @@ -222,7 +243,10 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.LanguageList = { response in return AppwriteModels.LanguageList.from(map: response as! [String: Any]) diff --git a/Sources/Appwrite/Services/Messaging.swift b/Sources/Appwrite/Services/Messaging.swift index c25be74..79ba04e 100644 --- a/Sources/Appwrite/Services/Messaging.swift +++ b/Sources/Appwrite/Services/Messaging.swift @@ -32,7 +32,9 @@ open class Messaging: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Subscriber = { response in @@ -68,6 +70,7 @@ open class Messaging: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] diff --git a/Sources/Appwrite/Services/Presences.swift b/Sources/Appwrite/Services/Presences.swift index 715e963..16f7047 100644 --- a/Sources/Appwrite/Services/Presences.swift +++ b/Sources/Appwrite/Services/Presences.swift @@ -32,7 +32,10 @@ open class Presences: Service { "ttl": ttl ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.PresenceList = { response in return AppwriteModels.PresenceList.from(map: response as! [String: Any]) @@ -65,7 +68,10 @@ open class Presences: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Presence = { response in return AppwriteModels.Presence.from(map: response as! [String: Any]) @@ -111,7 +117,9 @@ open class Presences: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Presence = { response in @@ -162,7 +170,9 @@ open class Presences: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Presence = { response in @@ -196,6 +206,7 @@ open class Presences: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index be1ffd5..4c84a35 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -35,7 +35,10 @@ open class Storage: Service { "total": total ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.FileList = { response in return AppwriteModels.FileList.from(map: response as! [String: Any]) @@ -95,7 +98,9 @@ open class Storage: Service { ] var apiHeaders: [String: String] = [ - "content-type": "multipart/form-data" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "multipart/form-data", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.File = { response in @@ -135,7 +140,10 @@ open class Storage: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.File = { response in return AppwriteModels.File.from(map: response as! [String: Any]) @@ -178,7 +186,9 @@ open class Storage: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.File = { response in @@ -215,6 +225,7 @@ open class Storage: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] diff --git a/Sources/Appwrite/Services/TablesDB.swift b/Sources/Appwrite/Services/TablesDB.swift index c812ccb..a057333 100644 --- a/Sources/Appwrite/Services/TablesDB.swift +++ b/Sources/Appwrite/Services/TablesDB.swift @@ -25,7 +25,10 @@ open class TablesDB: Service { "queries": queries ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.TransactionList = { response in return AppwriteModels.TransactionList.from(map: response as! [String: Any]) @@ -58,7 +61,9 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Transaction = { response in @@ -90,7 +95,10 @@ open class TablesDB: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Transaction = { response in return AppwriteModels.Transaction.from(map: response as! [String: Any]) @@ -129,7 +137,9 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Transaction = { response in @@ -162,6 +172,7 @@ open class TablesDB: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -193,7 +204,9 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Transaction = { response in @@ -243,7 +256,10 @@ open class TablesDB: Service { "ttl": ttl ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.RowList = { response in return AppwriteModels.RowList.from(map: response as! [String: Any]) @@ -328,7 +344,9 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Row = { response in @@ -410,7 +428,10 @@ open class TablesDB: Service { "transactionId": transactionId ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Row = { response in return AppwriteModels.Row.from(map: response as! [String: Any]) @@ -492,7 +513,9 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Row = { response in @@ -578,7 +601,9 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Row = { response in @@ -654,6 +679,7 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -701,7 +727,9 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Row = { response in @@ -789,7 +817,9 @@ open class TablesDB: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Row = { response in diff --git a/Sources/Appwrite/Services/Teams.swift b/Sources/Appwrite/Services/Teams.swift index b40b9b7..506d4ad 100644 --- a/Sources/Appwrite/Services/Teams.swift +++ b/Sources/Appwrite/Services/Teams.swift @@ -33,7 +33,10 @@ open class Teams: Service { "total": total ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.TeamList = { response in return AppwriteModels.TeamList.from(map: response as! [String: Any]) @@ -99,7 +102,9 @@ open class Teams: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Team = { response in @@ -157,7 +162,10 @@ open class Teams: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Team = { response in return AppwriteModels.Team.from(map: response as! [String: Any]) @@ -211,7 +219,9 @@ open class Teams: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Team = { response in @@ -265,6 +275,7 @@ open class Teams: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -303,7 +314,10 @@ open class Teams: Service { "total": total ] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.MembershipList = { response in return AppwriteModels.MembershipList.from(map: response as! [String: Any]) @@ -374,7 +388,9 @@ open class Teams: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Membership = { response in @@ -411,7 +427,10 @@ open class Teams: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Membership = { response in return AppwriteModels.Membership.from(map: response as! [String: Any]) @@ -453,7 +472,9 @@ open class Teams: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Membership = { response in @@ -491,6 +512,7 @@ open class Teams: Service { let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", "content-type": "application/json" ] @@ -534,7 +556,9 @@ open class Teams: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Membership = { response in @@ -569,7 +593,10 @@ open class Teams: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [:] + let apiHeaders: [String: String] = [ + "X-Appwrite-Project": client.config["project"] ?? "", + "accept": "application/json" + ] let converter: (Any) throws -> AppwriteModels.Preferences = { response in return AppwriteModels.Preferences.from(map: response as! [String: Any]) @@ -627,7 +654,9 @@ open class Teams: Service { ] let apiHeaders: [String: String] = [ - "content-type": "application/json" + "X-Appwrite-Project": client.config["project"] ?? "", + "content-type": "application/json", + "accept": "application/json" ] let converter: (Any) throws -> AppwriteModels.Preferences = { response in diff --git a/Sources/AppwriteModels/Membership.swift b/Sources/AppwriteModels/Membership.swift index 277601c..79228ee 100644 --- a/Sources/AppwriteModels/Membership.swift +++ b/Sources/AppwriteModels/Membership.swift @@ -18,6 +18,7 @@ open class Membership: Codable { case joined = "joined" case confirm = "confirm" case mfa = "mfa" + case userAccessedAt = "userAccessedAt" case roles = "roles" } @@ -47,6 +48,8 @@ open class Membership: Codable { public let confirm: Bool /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. public let mfa: Bool + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + public let userAccessedAt: String /// User list of roles public let roles: [String] @@ -64,6 +67,7 @@ open class Membership: Codable { joined: String, confirm: Bool, mfa: Bool, + userAccessedAt: String, roles: [String] ) { self.id = id @@ -79,6 +83,7 @@ open class Membership: Codable { self.joined = joined self.confirm = confirm self.mfa = mfa + self.userAccessedAt = userAccessedAt self.roles = roles } @@ -98,6 +103,7 @@ open class Membership: Codable { self.joined = try container.decode(String.self, forKey: .joined) self.confirm = try container.decode(Bool.self, forKey: .confirm) self.mfa = try container.decode(Bool.self, forKey: .mfa) + self.userAccessedAt = try container.decode(String.self, forKey: .userAccessedAt) self.roles = try container.decode([String].self, forKey: .roles) } @@ -117,6 +123,7 @@ open class Membership: Codable { try container.encode(joined, forKey: .joined) try container.encode(confirm, forKey: .confirm) try container.encode(mfa, forKey: .mfa) + try container.encode(userAccessedAt, forKey: .userAccessedAt) try container.encode(roles, forKey: .roles) } @@ -135,6 +142,7 @@ open class Membership: Codable { "joined": joined as Any, "confirm": confirm as Any, "mfa": mfa as Any, + "userAccessedAt": userAccessedAt as Any, "roles": roles as Any ] } @@ -154,6 +162,7 @@ open class Membership: Codable { joined: map["joined"] as! String, confirm: map["confirm"] as! Bool, mfa: map["mfa"] as! Bool, + userAccessedAt: map["userAccessedAt"] as! String, roles: map["roles"] as! [String] ) } diff --git a/Sources/AppwriteModels/User.swift b/Sources/AppwriteModels/User.swift index ad9de15..a3ae446 100644 --- a/Sources/AppwriteModels/User.swift +++ b/Sources/AppwriteModels/User.swift @@ -19,6 +19,11 @@ open class User: Codable { case email = "email" case phone = "phone" case emailVerification = "emailVerification" + case emailCanonical = "emailCanonical" + case emailIsFree = "emailIsFree" + case emailIsDisposable = "emailIsDisposable" + case emailIsCorporate = "emailIsCorporate" + case emailIsCanonical = "emailIsCanonical" case phoneVerification = "phoneVerification" case mfa = "mfa" case prefs = "prefs" @@ -56,6 +61,16 @@ open class User: Codable { public let phone: String /// Email verification status. public let emailVerification: Bool + /// Canonical form of the user email address. + public let emailCanonical: String? + /// Whether the user email is from a free email provider. + public let emailIsFree: Bool? + /// Whether the user email is from a disposable email provider. + public let emailIsDisposable: Bool? + /// Whether the user email is from a corporate domain. + public let emailIsCorporate: Bool? + /// Whether the user email is in its canonical form. + public let emailIsCanonical: Bool? /// Phone verification status. public let phoneVerification: Bool /// Multi factor authentication status. @@ -86,6 +101,11 @@ open class User: Codable { email: String, phone: String, emailVerification: Bool, + emailCanonical: String?, + emailIsFree: Bool?, + emailIsDisposable: Bool?, + emailIsCorporate: Bool?, + emailIsCanonical: Bool?, phoneVerification: Bool, mfa: Bool, prefs: Preferences, @@ -108,6 +128,11 @@ open class User: Codable { self.email = email self.phone = phone self.emailVerification = emailVerification + self.emailCanonical = emailCanonical + self.emailIsFree = emailIsFree + self.emailIsDisposable = emailIsDisposable + self.emailIsCorporate = emailIsCorporate + self.emailIsCanonical = emailIsCanonical self.phoneVerification = phoneVerification self.mfa = mfa self.prefs = prefs @@ -134,6 +159,11 @@ open class User: Codable { self.email = try container.decode(String.self, forKey: .email) self.phone = try container.decode(String.self, forKey: .phone) self.emailVerification = try container.decode(Bool.self, forKey: .emailVerification) + self.emailCanonical = try container.decodeIfPresent(String.self, forKey: .emailCanonical) + self.emailIsFree = try container.decodeIfPresent(Bool.self, forKey: .emailIsFree) + self.emailIsDisposable = try container.decodeIfPresent(Bool.self, forKey: .emailIsDisposable) + self.emailIsCorporate = try container.decodeIfPresent(Bool.self, forKey: .emailIsCorporate) + self.emailIsCanonical = try container.decodeIfPresent(Bool.self, forKey: .emailIsCanonical) self.phoneVerification = try container.decode(Bool.self, forKey: .phoneVerification) self.mfa = try container.decode(Bool.self, forKey: .mfa) self.prefs = try container.decode(Preferences.self, forKey: .prefs) @@ -160,6 +190,11 @@ open class User: Codable { try container.encode(email, forKey: .email) try container.encode(phone, forKey: .phone) try container.encode(emailVerification, forKey: .emailVerification) + try container.encodeIfPresent(emailCanonical, forKey: .emailCanonical) + try container.encodeIfPresent(emailIsFree, forKey: .emailIsFree) + try container.encodeIfPresent(emailIsDisposable, forKey: .emailIsDisposable) + try container.encodeIfPresent(emailIsCorporate, forKey: .emailIsCorporate) + try container.encodeIfPresent(emailIsCanonical, forKey: .emailIsCanonical) try container.encode(phoneVerification, forKey: .phoneVerification) try container.encode(mfa, forKey: .mfa) try container.encode(prefs, forKey: .prefs) @@ -185,6 +220,11 @@ open class User: Codable { "email": email as Any, "phone": phone as Any, "emailVerification": emailVerification as Any, + "emailCanonical": emailCanonical as Any, + "emailIsFree": emailIsFree as Any, + "emailIsDisposable": emailIsDisposable as Any, + "emailIsCorporate": emailIsCorporate as Any, + "emailIsCanonical": emailIsCanonical as Any, "phoneVerification": phoneVerification as Any, "mfa": mfa as Any, "prefs": prefs.toMap() as Any, @@ -211,6 +251,11 @@ open class User: Codable { email: map["email"] as! String, phone: map["phone"] as! String, emailVerification: map["emailVerification"] as! Bool, + emailCanonical: map["emailCanonical"] as? String, + emailIsFree: map["emailIsFree"] as? Bool, + emailIsDisposable: map["emailIsDisposable"] as? Bool, + emailIsCorporate: map["emailIsCorporate"] as? Bool, + emailIsCanonical: map["emailIsCanonical"] as? Bool, phoneVerification: map["phoneVerification"] as! Bool, mfa: map["mfa"] as! Bool, prefs: Preferences.from(map: map["prefs"] as! [String: Any]), diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index fe287d7..dbbddb7 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -9,7 +9,7 @@ let account = Account(client) let user = try await account.updatePassword( password: "", - oldPassword: "password" // optional + oldPassword: "" // optional ) ```