diff --git a/README.md b/README.md index a6c1d21..7368b46 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.6.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.2-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) @@ -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: "9.0.0"), + .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "9.0.1"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 1255ec9..daae34d 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -23,7 +23,7 @@ open class Client { "x-sdk-name": "Apple", "x-sdk-platform": "client", "x-sdk-language": "apple", - "x-sdk-version": "9.0.0", + "x-sdk-version": "9.0.1", "x-appwrite-response-format": "1.6.0" ] @@ -170,14 +170,15 @@ open class Client { /// @return Client /// open func setEndpoint(_ endPoint: String) -> Client { - self.endPoint = endPoint - - if (self.endPointRealtime == nil && endPoint.starts(with: "http")) { - self.endPointRealtime = endPoint - .replacingOccurrences(of: "http://", with: "ws://") - .replacingOccurrences(of: "https://", with: "wss://") + if !endPoint.hasPrefix("http://") && !endPoint.hasPrefix("https://") { + fatalError("Invalid endpoint URL: \(endPoint)") } + self.endPoint = endPoint + self.endPointRealtime = endPoint + .replacingOccurrences(of: "http://", with: "ws://") + .replacingOccurrences(of: "https://", with: "wss://") + return self } @@ -189,8 +190,11 @@ open class Client { /// @return Client /// open func setEndpointRealtime(_ endPoint: String) -> Client { - self.endPointRealtime = endPoint + if !endPoint.hasPrefix("ws://") && !endPoint.hasPrefix("wss://") { + fatalError("Invalid realtime endpoint URL: \(endPoint)") + } + self.endPointRealtime = endPoint return self } diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 817e9f4..6903c6b 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -21,9 +21,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.User = { response in return AppwriteModels.User.from(map: response as! [String: Any]) @@ -217,9 +215,7 @@ open class Account: Service { "queries": queries ] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.IdentityList = { response in return AppwriteModels.IdentityList.from(map: response as! [String: Any]) @@ -310,9 +306,7 @@ open class Account: Service { "queries": queries ] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.LogList = { response in return AppwriteModels.LogList.from(map: response as! [String: Any]) @@ -585,9 +579,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.MfaFactors = { response in return AppwriteModels.MfaFactors.from(map: response as! [String: Any]) @@ -617,9 +609,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) @@ -886,9 +876,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.Preferences = { response in return AppwriteModels.Preferences.from(map: response as! [String: Any]) @@ -1074,9 +1062,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.SessionList = { response in return AppwriteModels.SessionList.from(map: response as! [String: Any]) @@ -1380,9 +1366,7 @@ open class Account: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.Session = { response in return AppwriteModels.Session.from(map: response as! [String: Any]) diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index d7946b5..907d8cf 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -32,9 +32,7 @@ open class Databases: Service { "queries": queries ] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.DocumentList = { response in return AppwriteModels.DocumentList.from(map: response as! [String: Any]) @@ -77,6 +75,7 @@ open class Databases: Service { /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. + /// /// /// @param String databaseId /// @param String collectionId @@ -126,6 +125,7 @@ open class Databases: Service { /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. + /// /// /// @param String databaseId /// @param String collectionId @@ -179,9 +179,7 @@ open class Databases: Service { "queries": queries ] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.Document = { response in return AppwriteModels.Document.from(map: response as! [String: Any]) diff --git a/Sources/Appwrite/Services/Functions.swift b/Sources/Appwrite/Services/Functions.swift index 185f887..5c8572e 100644 --- a/Sources/Appwrite/Services/Functions.swift +++ b/Sources/Appwrite/Services/Functions.swift @@ -31,9 +31,7 @@ open class Functions: Service { "search": search ] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.ExecutionList = { response in return AppwriteModels.ExecutionList.from(map: response as! [String: Any]) @@ -120,9 +118,7 @@ open class Functions: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.Execution = { response in return AppwriteModels.Execution.from(map: response as! [String: Any]) diff --git a/Sources/Appwrite/Services/Locale.swift b/Sources/Appwrite/Services/Locale.swift index a15f09a..b9d2682 100644 --- a/Sources/Appwrite/Services/Locale.swift +++ b/Sources/Appwrite/Services/Locale.swift @@ -25,9 +25,7 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.Locale = { response in return AppwriteModels.Locale.from(map: response as! [String: Any]) @@ -55,9 +53,7 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.LocaleCodeList = { response in return AppwriteModels.LocaleCodeList.from(map: response as! [String: Any]) @@ -85,9 +81,7 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.ContinentList = { response in return AppwriteModels.ContinentList.from(map: response as! [String: Any]) @@ -115,9 +109,7 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.CountryList = { response in return AppwriteModels.CountryList.from(map: response as! [String: Any]) @@ -145,9 +137,7 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.CountryList = { response in return AppwriteModels.CountryList.from(map: response as! [String: Any]) @@ -175,9 +165,7 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.PhoneList = { response in return AppwriteModels.PhoneList.from(map: response as! [String: Any]) @@ -206,9 +194,7 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.CurrencyList = { response in return AppwriteModels.CurrencyList.from(map: response as! [String: Any]) @@ -236,9 +222,7 @@ open class Locale: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.LanguageList = { response in return AppwriteModels.LanguageList.from(map: response as! [String: Any]) diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index 3ad9e7e..8cbbc04 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -31,9 +31,7 @@ open class Storage: Service { "search": search ] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.FileList = { response in return AppwriteModels.FileList.from(map: response as! [String: Any]) @@ -131,9 +129,7 @@ open class Storage: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.File = { response in return AppwriteModels.File.from(map: response as! [String: Any]) diff --git a/Sources/Appwrite/Services/Teams.swift b/Sources/Appwrite/Services/Teams.swift index b20c3bd..6b410ee 100644 --- a/Sources/Appwrite/Services/Teams.swift +++ b/Sources/Appwrite/Services/Teams.swift @@ -29,9 +29,7 @@ open class Teams: Service { "search": search ] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.TeamList = { response in return AppwriteModels.TeamList.from(map: response as! [String: Any]) @@ -148,9 +146,7 @@ open class Teams: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.Team = { response in return AppwriteModels.Team.from(map: response as! [String: Any]) @@ -288,9 +284,7 @@ open class Teams: Service { "search": search ] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.MembershipList = { response in return AppwriteModels.MembershipList.from(map: response as! [String: Any]) @@ -396,9 +390,7 @@ open class Teams: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.Membership = { response in return AppwriteModels.Membership.from(map: response as! [String: Any]) @@ -552,9 +544,7 @@ open class Teams: Service { let apiParams: [String: Any] = [:] - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] + let apiHeaders: [String: String] = [:] let converter: (Any) -> AppwriteModels.Preferences = { response in return AppwriteModels.Preferences.from(map: response as! [String: Any]) diff --git a/Sources/AppwriteEnums/CreditCard.swift b/Sources/AppwriteEnums/CreditCard.swift index 0922fbc..688c5a4 100644 --- a/Sources/AppwriteEnums/CreditCard.swift +++ b/Sources/AppwriteEnums/CreditCard.swift @@ -17,6 +17,7 @@ public enum CreditCard: String, CustomStringConvertible { case visa = "visa" case mIR = "mir" case maestro = "maestro" + case rupay = "rupay" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/OAuthProvider.swift b/Sources/AppwriteEnums/OAuthProvider.swift index e00ba46..4c4ec6e 100644 --- a/Sources/AppwriteEnums/OAuthProvider.swift +++ b/Sources/AppwriteEnums/OAuthProvider.swift @@ -15,6 +15,7 @@ public enum OAuthProvider: String, CustomStringConvertible { case dropbox = "dropbox" case etsy = "etsy" case facebook = "facebook" + case figma = "figma" case github = "github" case gitlab = "gitlab" case google = "google"