From fcff5fb3abcf5009068e84800e4c1ab2ef8ee46d Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 13 Feb 2026 08:02:29 +0000 Subject: [PATCH 1/4] updated spec --- README.md | 2 +- Sources/Appwrite/Channel.swift | 57 +- Sources/Appwrite/Services/Account.swift | 605 ++++++++++++++++++ Sources/Appwrite/Services/Organizations.swift | 188 ++++++ Sources/AppwriteEnums/OAuthProvider.swift | 2 + Sources/AppwriteEnums/Scopes.swift | 11 + Sources/AppwriteModels/BillingAddress.swift | 106 +++ .../AppwriteModels/BillingAddressList.swift | 52 ++ .../AppwriteModels/DowngradeFeedback.swift | 124 ++++ .../EstimationDeleteOrganization.swift | 43 ++ Sources/AppwriteModels/Invoice.swift | 232 +++++++ Sources/AppwriteModels/Key.swift | 115 ++++ Sources/AppwriteModels/KeyList.swift | 52 ++ Sources/AppwriteModels/PaymentMethod.swift | 214 +++++++ .../AppwriteModels/PaymentMethodList.swift | 52 ++ Sources/AppwriteModels/UsageResources.swift | 88 +++ .../account/create-billing-address.md | 19 + docs/examples/account/create-key.md | 17 + .../examples/account/create-payment-method.md | 12 + .../account/delete-billing-address.md | 14 + docs/examples/account/delete-key.md | 14 + .../examples/account/delete-payment-method.md | 14 + docs/examples/account/get-billing-address.md | 14 + docs/examples/account/get-key.md | 14 + docs/examples/account/get-payment-method.md | 14 + .../account/list-billing-addresses.md | 14 + docs/examples/account/list-keys.md | 14 + docs/examples/account/list-payment-methods.md | 14 + .../account/update-billing-address.md | 20 + docs/examples/account/update-key.md | 18 + .../update-payment-method-mandate-options.md | 14 + .../account/update-payment-method-provider.md | 17 + .../examples/account/update-payment-method.md | 17 + .../create-downgrade-feedback.md | 18 + docs/examples/organizations/delete.md | 14 + .../estimation-delete-organization.md | 14 + .../organizations/get-billing-address.md | 15 + .../organizations/get-payment-method.md | 15 + 38 files changed, 2241 insertions(+), 38 deletions(-) create mode 100644 Sources/Appwrite/Services/Organizations.swift create mode 100644 Sources/AppwriteEnums/Scopes.swift create mode 100644 Sources/AppwriteModels/BillingAddress.swift create mode 100644 Sources/AppwriteModels/BillingAddressList.swift create mode 100644 Sources/AppwriteModels/DowngradeFeedback.swift create mode 100644 Sources/AppwriteModels/EstimationDeleteOrganization.swift create mode 100644 Sources/AppwriteModels/Invoice.swift create mode 100644 Sources/AppwriteModels/Key.swift create mode 100644 Sources/AppwriteModels/KeyList.swift create mode 100644 Sources/AppwriteModels/PaymentMethod.swift create mode 100644 Sources/AppwriteModels/PaymentMethodList.swift create mode 100644 Sources/AppwriteModels/UsageResources.swift create mode 100644 docs/examples/account/create-billing-address.md create mode 100644 docs/examples/account/create-key.md create mode 100644 docs/examples/account/create-payment-method.md create mode 100644 docs/examples/account/delete-billing-address.md create mode 100644 docs/examples/account/delete-key.md create mode 100644 docs/examples/account/delete-payment-method.md create mode 100644 docs/examples/account/get-billing-address.md create mode 100644 docs/examples/account/get-key.md create mode 100644 docs/examples/account/get-payment-method.md create mode 100644 docs/examples/account/list-billing-addresses.md create mode 100644 docs/examples/account/list-keys.md create mode 100644 docs/examples/account/list-payment-methods.md create mode 100644 docs/examples/account/update-billing-address.md create mode 100644 docs/examples/account/update-key.md create mode 100644 docs/examples/account/update-payment-method-mandate-options.md create mode 100644 docs/examples/account/update-payment-method-provider.md create mode 100644 docs/examples/account/update-payment-method.md create mode 100644 docs/examples/organizations/create-downgrade-feedback.md create mode 100644 docs/examples/organizations/delete.md create mode 100644 docs/examples/organizations/estimation-delete-organization.md create mode 100644 docs/examples/organizations/get-billing-address.md create mode 100644 docs/examples/organizations/get-payment-method.md diff --git a/README.md b/README.md index b8e782e..8c9e493 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![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.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).** +**This SDK is compatible with Appwrite server version latest. 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 abstracts and simplifies 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) diff --git a/Sources/Appwrite/Channel.swift b/Sources/Appwrite/Channel.swift index 49f02c2..3328ffe 100644 --- a/Sources/Appwrite/Channel.swift +++ b/Sources/Appwrite/Channel.swift @@ -30,9 +30,13 @@ public class RealtimeChannel { self.segments = segments } - /// Internal helper to transition to next state with segment and ID - internal func next(_ segment: String, _ id: String = "*") -> RealtimeChannel { - return RealtimeChannel(segments + [segment, normalize(id)]) + /// Internal helper to transition to next state with segment and optional ID + internal func next(_ segment: String, _ id: String? = nil) -> RealtimeChannel { + if let id = id { + return RealtimeChannel(segments + [segment, normalize(id)]) + } + + return RealtimeChannel(segments + [segment]) } /// Internal helper for terminal actions (no ID segment) @@ -67,6 +71,10 @@ public enum Channel { return RealtimeChannel<_Func>(["functions", normalize(id)]) } + public static func execution(_ id: String = "*") -> RealtimeChannel<_Execution> { + return RealtimeChannel<_Execution>(["executions", normalize(id)]) + } + public static func team(_ id: String = "*") -> RealtimeChannel<_Team> { return RealtimeChannel<_Team>(["teams", normalize(id)]) } @@ -75,9 +83,8 @@ public enum Channel { return RealtimeChannel<_Membership>(["memberships", normalize(id)]) } - public static func account(_ userId: String = "") -> String { - let id = normalize(userId) - return id == "*" ? "account" : "account.\(id)" + public static func account() -> String { + return "account" } // Global events @@ -93,14 +100,14 @@ public enum Channel { /// Only available on RealtimeChannel<_Database> extension RealtimeChannel where T == _Database { - public func collection(_ id: String = "*") -> RealtimeChannel<_Collection> { - return self.next("collections", id) + public func collection(_ id: String? = nil) -> RealtimeChannel<_Collection> { + return self.next("collections", id ?? "*") } } /// Only available on RealtimeChannel<_Collection> extension RealtimeChannel where T == _Collection { - public func document(_ id: String = "*") -> RealtimeChannel<_Document> { + public func document(_ id: String? = nil) -> RealtimeChannel<_Document> { return self.next("documents", id) } } @@ -109,14 +116,14 @@ extension RealtimeChannel where T == _Collection { /// Only available on RealtimeChannel<_TablesDB> extension RealtimeChannel where T == _TablesDB { - public func table(_ id: String = "*") -> RealtimeChannel<_Table> { - return self.next("tables", id) + public func table(_ id: String? = nil) -> RealtimeChannel<_Table> { + return self.next("tables", id ?? "*") } } /// Only available on RealtimeChannel<_Table> extension RealtimeChannel where T == _Table { - public func row(_ id: String = "*") -> RealtimeChannel<_Row> { + public func row(_ id: String? = nil) -> RealtimeChannel<_Row> { return self.next("rows", id) } } @@ -125,20 +132,11 @@ extension RealtimeChannel where T == _Table { /// Only available on RealtimeChannel<_Bucket> extension RealtimeChannel where T == _Bucket { - public func file(_ id: String = "*") -> RealtimeChannel<_File> { + public func file(_ id: String? = nil) -> RealtimeChannel<_File> { return self.next("files", id) } } -// MARK: - FUNCTION ROUTE - -/// Only available on RealtimeChannel<_Func> -extension RealtimeChannel where T == _Func { - public func execution(_ id: String = "*") -> RealtimeChannel<_Execution> { - return self.next("executions", id) - } -} - // MARK: - TERMINAL ACTIONS // Restricted to actionable types (_Document, _Row, _File, _Execution, _Team, _Membership) @@ -187,21 +185,6 @@ extension RealtimeChannel where T == _File { } } -/// Only available on RealtimeChannel<_Execution> -extension RealtimeChannel where T == _Execution { - public func create() -> RealtimeChannel<_Resolved> { - return self.resolve("create") - } - - public func update() -> RealtimeChannel<_Resolved> { - return self.resolve("update") - } - - public func delete() -> RealtimeChannel<_Resolved> { - return self.resolve("delete") - } -} - /// Only available on RealtimeChannel<_Team> extension RealtimeChannel where T == _Team { public func create() -> RealtimeChannel<_Resolved> { diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index a05909f..d52f7ac 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -131,6 +131,197 @@ open class Account: Service { ) } + /// + /// List all billing addresses for a user. + /// + /// - Parameters: + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.BillingAddressList + /// + open func listBillingAddresses( + queries: [String]? = nil + ) async throws -> AppwriteModels.BillingAddressList { + let apiPath: String = "/account/billing-addresses" + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.BillingAddressList = { response in + return AppwriteModels.BillingAddressList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Add a new billing address to a user's account. + /// + /// - Parameters: + /// - country: String + /// - city: String + /// - streetAddress: String + /// - addressLine2: String (optional) + /// - state: String (optional) + /// - postalCode: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.BillingAddress + /// + open func createBillingAddress( + country: String, + city: String, + streetAddress: String, + addressLine2: String? = nil, + state: String? = nil, + postalCode: String? = nil + ) async throws -> AppwriteModels.BillingAddress { + let apiPath: String = "/account/billing-addresses" + + let apiParams: [String: Any?] = [ + "country": country, + "city": city, + "streetAddress": streetAddress, + "addressLine2": addressLine2, + "state": state, + "postalCode": postalCode + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.BillingAddress = { response in + return AppwriteModels.BillingAddress.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a specific billing address for a user using it's ID. + /// + /// - Parameters: + /// - billingAddressId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.BillingAddress + /// + open func getBillingAddress( + billingAddressId: String + ) async throws -> AppwriteModels.BillingAddress { + let apiPath: String = "/account/billing-addresses/{billingAddressId}" + .replacingOccurrences(of: "{billingAddressId}", with: billingAddressId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.BillingAddress = { response in + return AppwriteModels.BillingAddress.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a specific billing address using it's ID. + /// + /// - Parameters: + /// - billingAddressId: String + /// - country: String + /// - city: String + /// - streetAddress: String + /// - addressLine2: String (optional) + /// - state: String (optional) + /// - postalCode: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.BillingAddress + /// + open func updateBillingAddress( + billingAddressId: String, + country: String, + city: String, + streetAddress: String, + addressLine2: String? = nil, + state: String? = nil, + postalCode: String? = nil + ) async throws -> AppwriteModels.BillingAddress { + let apiPath: String = "/account/billing-addresses/{billingAddressId}" + .replacingOccurrences(of: "{billingAddressId}", with: billingAddressId) + + let apiParams: [String: Any?] = [ + "country": country, + "city": city, + "streetAddress": streetAddress, + "addressLine2": addressLine2, + "state": state, + "postalCode": postalCode + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.BillingAddress = { response in + return AppwriteModels.BillingAddress.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Delete a specific billing address using it's ID. + /// + /// - Parameters: + /// - billingAddressId: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteBillingAddress( + billingAddressId: String + ) async throws -> Any { + let apiPath: String = "/account/billing-addresses/{billingAddressId}" + .replacingOccurrences(of: "{billingAddressId}", with: billingAddressId) + + 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 ) + } + /// /// Update currently logged in user account email address. After changing user /// address, the user confirmation status will get reset. A new confirmation @@ -303,6 +494,182 @@ open class Account: Service { ) } + /// + /// Get a list of all API keys from the current account. + /// + /// - Parameters: + /// - total: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.KeyList + /// + open func listKeys( + total: Bool? = nil + ) async throws -> AppwriteModels.KeyList { + let apiPath: String = "/account/keys" + + let apiParams: [String: Any?] = [ + "total": total + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.KeyList = { response in + return AppwriteModels.KeyList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a new account API key. + /// + /// - Parameters: + /// - name: String + /// - scopes: [AppwriteEnums.Scopes] + /// - expire: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Key + /// + open func createKey( + name: String, + scopes: [AppwriteEnums.Scopes], + expire: String? = nil + ) async throws -> AppwriteModels.Key { + let apiPath: String = "/account/keys" + + let apiParams: [String: Any?] = [ + "name": name, + "scopes": scopes, + "expire": expire + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Key = { response in + return AppwriteModels.Key.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a key by its unique ID. This endpoint returns details about a specific + /// API key in your account including it's scopes. + /// + /// - Parameters: + /// - keyId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Key + /// + open func getKey( + keyId: String + ) async throws -> AppwriteModels.Key { + let apiPath: String = "/account/keys/{keyId}" + .replacingOccurrences(of: "{keyId}", with: keyId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.Key = { response in + return AppwriteModels.Key.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a key by its unique ID. Use this endpoint to update the name, + /// scopes, or expiration time of an API key. + /// + /// - Parameters: + /// - keyId: String + /// - name: String + /// - scopes: [AppwriteEnums.Scopes] + /// - expire: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Key + /// + open func updateKey( + keyId: String, + name: String, + scopes: [AppwriteEnums.Scopes], + expire: String? = nil + ) async throws -> AppwriteModels.Key { + let apiPath: String = "/account/keys/{keyId}" + .replacingOccurrences(of: "{keyId}", with: keyId) + + let apiParams: [String: Any?] = [ + "name": name, + "scopes": scopes, + "expire": expire + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Key = { response in + return AppwriteModels.Key.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Delete a key by its unique ID. Once deleted, the key can no longer be used + /// to authenticate API calls. + /// + /// - Parameters: + /// - keyId: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteKey( + keyId: String + ) async throws -> Any { + let apiPath: String = "/account/keys/{keyId}" + .replacingOccurrences(of: "{keyId}", with: keyId) + + 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 ) + } + /// /// Get the list of latest security activity logs for the currently logged in /// user. Each log returns user IP address, location and date and time of log. @@ -1163,6 +1530,244 @@ open class Account: Service { ) } + /// + /// List payment methods for this account. + /// + /// - Parameters: + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.PaymentMethodList + /// + open func listPaymentMethods( + queries: [String]? = nil + ) async throws -> AppwriteModels.PaymentMethodList { + let apiPath: String = "/account/payment-methods" + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.PaymentMethodList = { response in + return AppwriteModels.PaymentMethodList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a new payment method for the current user account. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.PaymentMethod + /// + open func createPaymentMethod( + ) async throws -> AppwriteModels.PaymentMethod { + let apiPath: String = "/account/payment-methods" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.PaymentMethod = { response in + return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a specific payment method for the user. + /// + /// - Parameters: + /// - paymentMethodId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.PaymentMethod + /// + open func getPaymentMethod( + paymentMethodId: String + ) async throws -> AppwriteModels.PaymentMethod { + let apiPath: String = "/account/payment-methods/{paymentMethodId}" + .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.PaymentMethod = { response in + return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a new payment method for the current user account. + /// + /// - Parameters: + /// - paymentMethodId: String + /// - expiryMonth: Int + /// - expiryYear: Int + /// - state: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.PaymentMethod + /// + open func updatePaymentMethod( + paymentMethodId: String, + expiryMonth: Int, + expiryYear: Int, + state: String? = nil + ) async throws -> AppwriteModels.PaymentMethod { + let apiPath: String = "/account/payment-methods/{paymentMethodId}" + .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) + + let apiParams: [String: Any?] = [ + "expiryMonth": expiryMonth, + "expiryYear": expiryYear, + "state": state + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.PaymentMethod = { response in + return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Delete a specific payment method from a user's account. + /// + /// - Parameters: + /// - paymentMethodId: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deletePaymentMethod( + paymentMethodId: String + ) async throws -> Any { + let apiPath: String = "/account/payment-methods/{paymentMethodId}" + .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) + + 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 ) + } + + /// + /// Update payment method provider. + /// + /// - Parameters: + /// - paymentMethodId: String + /// - providerMethodId: String + /// - name: String + /// - state: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.PaymentMethod + /// + open func updatePaymentMethodProvider( + paymentMethodId: String, + providerMethodId: String, + name: String, + state: String? = nil + ) async throws -> AppwriteModels.PaymentMethod { + let apiPath: String = "/account/payment-methods/{paymentMethodId}/provider" + .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) + + let apiParams: [String: Any?] = [ + "providerMethodId": providerMethodId, + "name": name, + "state": state + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.PaymentMethod = { response in + return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update payment method mandate options. + /// + /// - Parameters: + /// - paymentMethodId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.PaymentMethod + /// + open func updatePaymentMethodMandateOptions( + paymentMethodId: String + ) async throws -> AppwriteModels.PaymentMethod { + let apiPath: String = "/account/payment-methods/{paymentMethodId}/setup" + .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.PaymentMethod = { response in + return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Update the currently logged in user's phone number. After updating the /// phone number, the phone verification status will be reset. A confirmation diff --git a/Sources/Appwrite/Services/Organizations.swift b/Sources/Appwrite/Services/Organizations.swift new file mode 100644 index 0000000..cb95d8a --- /dev/null +++ b/Sources/Appwrite/Services/Organizations.swift @@ -0,0 +1,188 @@ +import AsyncHTTPClient +import Foundation +import NIO +import JSONCodable +import AppwriteEnums +import AppwriteModels + +/// +open class Organizations: Service { + + /// + /// Delete an organization. + /// + /// - Parameters: + /// - organizationId: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func delete( + organizationId: String + ) async throws -> Any { + let apiPath: String = "/organizations/{organizationId}" + .replacingOccurrences(of: "{organizationId}", with: organizationId) + + 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 ) + } + + /// + /// Get a billing address using it's ID. + /// + /// - Parameters: + /// - organizationId: String + /// - billingAddressId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.BillingAddress + /// + open func getBillingAddress( + organizationId: String, + billingAddressId: String + ) async throws -> AppwriteModels.BillingAddress { + let apiPath: String = "/organizations/{organizationId}/billing-addresses/{billingAddressId}" + .replacingOccurrences(of: "{organizationId}", with: organizationId) + .replacingOccurrences(of: "{billingAddressId}", with: billingAddressId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.BillingAddress = { response in + return AppwriteModels.BillingAddress.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get estimation for deleting an organization. + /// + /// - Parameters: + /// - organizationId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.EstimationDeleteOrganization + /// + open func estimationDeleteOrganization( + organizationId: String + ) async throws -> AppwriteModels.EstimationDeleteOrganization { + let apiPath: String = "/organizations/{organizationId}/estimations/delete-organization" + .replacingOccurrences(of: "{organizationId}", with: organizationId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.EstimationDeleteOrganization = { response in + return AppwriteModels.EstimationDeleteOrganization.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Submit feedback about downgrading from a paid plan to a lower tier. This + /// helps the team understand user experience and improve the platform. + /// + /// + /// - Parameters: + /// - organizationId: String + /// - reason: String + /// - message: String + /// - fromPlanId: String + /// - toPlanId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DowngradeFeedback + /// + open func createDowngradeFeedback( + organizationId: String, + reason: String, + message: String, + fromPlanId: String, + toPlanId: String + ) async throws -> AppwriteModels.DowngradeFeedback { + let apiPath: String = "/organizations/{organizationId}/feedbacks/downgrade" + .replacingOccurrences(of: "{organizationId}", with: organizationId) + + let apiParams: [String: Any?] = [ + "reason": reason, + "message": message, + "fromPlanId": fromPlanId, + "toPlanId": toPlanId + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.DowngradeFeedback = { response in + return AppwriteModels.DowngradeFeedback.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get an organization's payment method using it's payment method ID. + /// + /// - Parameters: + /// - organizationId: String + /// - paymentMethodId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.PaymentMethod + /// + open func getPaymentMethod( + organizationId: String, + paymentMethodId: String + ) async throws -> AppwriteModels.PaymentMethod { + let apiPath: String = "/organizations/{organizationId}/payment-methods/{paymentMethodId}" + .replacingOccurrences(of: "{organizationId}", with: organizationId) + .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.PaymentMethod = { response in + return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + +} \ No newline at end of file diff --git a/Sources/AppwriteEnums/OAuthProvider.swift b/Sources/AppwriteEnums/OAuthProvider.swift index fb715a4..88effa3 100644 --- a/Sources/AppwriteEnums/OAuthProvider.swift +++ b/Sources/AppwriteEnums/OAuthProvider.swift @@ -40,6 +40,8 @@ public enum OAuthProvider: String, CustomStringConvertible { case yandex = "yandex" case zoho = "zoho" case zoom = "zoom" + case githubImagine = "githubImagine" + case googleImagine = "googleImagine" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/Scopes.swift b/Sources/AppwriteEnums/Scopes.swift new file mode 100644 index 0000000..127d59f --- /dev/null +++ b/Sources/AppwriteEnums/Scopes.swift @@ -0,0 +1,11 @@ +import Foundation + +public enum Scopes: String, CustomStringConvertible { + case account = "account" + case teamsRead = "teams.read" + case teamsWrite = "teams.write" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteModels/BillingAddress.swift b/Sources/AppwriteModels/BillingAddress.swift new file mode 100644 index 0000000..3f5b924 --- /dev/null +++ b/Sources/AppwriteModels/BillingAddress.swift @@ -0,0 +1,106 @@ +import Foundation +import JSONCodable + +/// BillingAddress +open class BillingAddress: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case userId = "userId" + case streetAddress = "streetAddress" + case addressLine2 = "addressLine2" + case country = "country" + case city = "city" + case state = "state" + case postalCode = "postalCode" + } + + /// Region ID + public let id: String + /// User ID + public let userId: String + /// Street address + public let streetAddress: String + /// Address line 2 + public let addressLine2: String + /// Address country + public let country: String + /// city + public let city: String + /// state + public let state: String + /// postal code + public let postalCode: String + + init( + id: String, + userId: String, + streetAddress: String, + addressLine2: String, + country: String, + city: String, + state: String, + postalCode: String + ) { + self.id = id + self.userId = userId + self.streetAddress = streetAddress + self.addressLine2 = addressLine2 + self.country = country + self.city = city + self.state = state + self.postalCode = postalCode + } + + 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.userId = try container.decode(String.self, forKey: .userId) + self.streetAddress = try container.decode(String.self, forKey: .streetAddress) + self.addressLine2 = try container.decode(String.self, forKey: .addressLine2) + self.country = try container.decode(String.self, forKey: .country) + self.city = try container.decode(String.self, forKey: .city) + self.state = try container.decode(String.self, forKey: .state) + self.postalCode = try container.decode(String.self, forKey: .postalCode) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(userId, forKey: .userId) + try container.encode(streetAddress, forKey: .streetAddress) + try container.encode(addressLine2, forKey: .addressLine2) + try container.encode(country, forKey: .country) + try container.encode(city, forKey: .city) + try container.encode(state, forKey: .state) + try container.encode(postalCode, forKey: .postalCode) + } + + public func toMap() -> [String: Any] { + return [ + "$id": id as Any, + "userId": userId as Any, + "streetAddress": streetAddress as Any, + "addressLine2": addressLine2 as Any, + "country": country as Any, + "city": city as Any, + "state": state as Any, + "postalCode": postalCode as Any + ] + } + + public static func from(map: [String: Any] ) -> BillingAddress { + return BillingAddress( + id: map["$id"] as! String, + userId: map["userId"] as! String, + streetAddress: map["streetAddress"] as! String, + addressLine2: map["addressLine2"] as! String, + country: map["country"] as! String, + city: map["city"] as! String, + state: map["state"] as! String, + postalCode: map["postalCode"] as! String + ) + } +} diff --git a/Sources/AppwriteModels/BillingAddressList.swift b/Sources/AppwriteModels/BillingAddressList.swift new file mode 100644 index 0000000..fd9dda9 --- /dev/null +++ b/Sources/AppwriteModels/BillingAddressList.swift @@ -0,0 +1,52 @@ +import Foundation +import JSONCodable + +/// Billing address list +open class BillingAddressList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case billingAddresses = "billingAddresses" + } + + /// Total number of billingAddresses that matched your query. + public let total: Int + /// List of billingAddresses. + public let billingAddresses: [BillingAddress] + + init( + total: Int, + billingAddresses: [BillingAddress] + ) { + self.total = total + self.billingAddresses = billingAddresses + } + + 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.billingAddresses = try container.decode([BillingAddress].self, forKey: .billingAddresses) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(billingAddresses, forKey: .billingAddresses) + } + + public func toMap() -> [String: Any] { + return [ + "total": total as Any, + "billingAddresses": billingAddresses.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> BillingAddressList { + return BillingAddressList( + total: map["total"] as! Int, + billingAddresses: (map["billingAddresses"] as! [[String: Any]]).map { BillingAddress.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/DowngradeFeedback.swift b/Sources/AppwriteModels/DowngradeFeedback.swift new file mode 100644 index 0000000..2bf7372 --- /dev/null +++ b/Sources/AppwriteModels/DowngradeFeedback.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// Downgrade Feedback +open class DowngradeFeedback: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case title = "title" + case message = "message" + case fromPlanId = "fromPlanId" + case toPlanId = "toPlanId" + case teamId = "teamId" + case userId = "userId" + case version = "version" + } + + /// Feedback ID. + public let id: String + /// Feedback creation date in ISO 8601 format. + public let createdAt: String + /// Feedback update date in ISO 8601 format. + public let updatedAt: String + /// Feedback reason + public let title: String + /// Feedback message + public let message: String + /// Plan ID downgrading from + public let fromPlanId: String + /// Plan ID downgrading to + public let toPlanId: String + /// Organization ID + public let teamId: String + /// User ID who submitted feedback + public let userId: String + /// Console version + public let version: String + + init( + id: String, + createdAt: String, + updatedAt: String, + title: String, + message: String, + fromPlanId: String, + toPlanId: String, + teamId: String, + userId: String, + version: String + ) { + self.id = id + self.createdAt = createdAt + self.updatedAt = updatedAt + self.title = title + self.message = message + self.fromPlanId = fromPlanId + self.toPlanId = toPlanId + self.teamId = teamId + self.userId = userId + self.version = version + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.title = try container.decode(String.self, forKey: .title) + self.message = try container.decode(String.self, forKey: .message) + self.fromPlanId = try container.decode(String.self, forKey: .fromPlanId) + self.toPlanId = try container.decode(String.self, forKey: .toPlanId) + self.teamId = try container.decode(String.self, forKey: .teamId) + self.userId = try container.decode(String.self, forKey: .userId) + self.version = try container.decode(String.self, forKey: .version) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(title, forKey: .title) + try container.encode(message, forKey: .message) + try container.encode(fromPlanId, forKey: .fromPlanId) + try container.encode(toPlanId, forKey: .toPlanId) + try container.encode(teamId, forKey: .teamId) + try container.encode(userId, forKey: .userId) + try container.encode(version, forKey: .version) + } + + public func toMap() -> [String: Any] { + return [ + "$id": id as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "title": title as Any, + "message": message as Any, + "fromPlanId": fromPlanId as Any, + "toPlanId": toPlanId as Any, + "teamId": teamId as Any, + "userId": userId as Any, + "version": version as Any + ] + } + + public static func from(map: [String: Any] ) -> DowngradeFeedback { + return DowngradeFeedback( + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + title: map["title"] as! String, + message: map["message"] as! String, + fromPlanId: map["fromPlanId"] as! String, + toPlanId: map["toPlanId"] as! String, + teamId: map["teamId"] as! String, + userId: map["userId"] as! String, + version: map["version"] as! String + ) + } +} diff --git a/Sources/AppwriteModels/EstimationDeleteOrganization.swift b/Sources/AppwriteModels/EstimationDeleteOrganization.swift new file mode 100644 index 0000000..0620a3e --- /dev/null +++ b/Sources/AppwriteModels/EstimationDeleteOrganization.swift @@ -0,0 +1,43 @@ +import Foundation +import JSONCodable + +/// EstimationDeleteOrganization +open class EstimationDeleteOrganization: Codable { + + enum CodingKeys: String, CodingKey { + case unpaidInvoices = "unpaidInvoices" + } + + /// List of unpaid invoices + public let unpaidInvoices: [Invoice] + + init( + unpaidInvoices: [Invoice] + ) { + self.unpaidInvoices = unpaidInvoices + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.unpaidInvoices = try container.decode([Invoice].self, forKey: .unpaidInvoices) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(unpaidInvoices, forKey: .unpaidInvoices) + } + + public func toMap() -> [String: Any] { + return [ + "unpaidInvoices": unpaidInvoices.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> EstimationDeleteOrganization { + return EstimationDeleteOrganization( + unpaidInvoices: (map["unpaidInvoices"] as! [[String: Any]]).map { Invoice.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/Invoice.swift b/Sources/AppwriteModels/Invoice.swift new file mode 100644 index 0000000..87106de --- /dev/null +++ b/Sources/AppwriteModels/Invoice.swift @@ -0,0 +1,232 @@ +import Foundation +import JSONCodable + +/// Invoice +open class Invoice: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case teamId = "teamId" + case aggregationId = "aggregationId" + case plan = "plan" + case usage = "usage" + case amount = "amount" + case tax = "tax" + case taxAmount = "taxAmount" + case vat = "vat" + case vatAmount = "vatAmount" + case grossAmount = "grossAmount" + case creditsUsed = "creditsUsed" + case currency = "currency" + case clientSecret = "clientSecret" + case status = "status" + case lastError = "lastError" + case dueAt = "dueAt" + case from = "from" + case to = "to" + } + + /// Invoice ID. + public let id: String + /// Invoice creation time in ISO 8601 format. + public let createdAt: String + /// Invoice update date in ISO 8601 format. + public let updatedAt: String + /// Invoice permissions. [Learn more about permissions](/docs/permissions). + public let permissions: [String] + /// Project ID + public let teamId: String + /// Aggregation ID + public let aggregationId: String + /// Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`. + public let plan: String + /// Usage breakdown per resource + public let usage: [UsageResources] + /// Invoice Amount + public let amount: Double + /// Tax percentage + public let tax: Double + /// Tax amount + public let taxAmount: Double + /// VAT percentage + public let vat: Double + /// VAT amount + public let vatAmount: Double + /// Gross amount after vat, tax, and discounts applied. + public let grossAmount: Double + /// Credits used. + public let creditsUsed: Double + /// Currency the invoice is in + public let currency: String + /// Client secret for processing failed payments in front-end + public let clientSecret: String + /// Invoice status + public let status: String + /// Last payment error associated with the invoice + public let lastError: String + /// Invoice due date. + public let dueAt: String + /// Beginning date of the invoice + public let from: String + /// End date of the invoice + public let to: String + + init( + id: String, + createdAt: String, + updatedAt: String, + permissions: [String], + teamId: String, + aggregationId: String, + plan: String, + usage: [UsageResources], + amount: Double, + tax: Double, + taxAmount: Double, + vat: Double, + vatAmount: Double, + grossAmount: Double, + creditsUsed: Double, + currency: String, + clientSecret: String, + status: String, + lastError: String, + dueAt: String, + from: String, + to: String + ) { + self.id = id + self.createdAt = createdAt + self.updatedAt = updatedAt + self.permissions = permissions + self.teamId = teamId + self.aggregationId = aggregationId + self.plan = plan + self.usage = usage + self.amount = amount + self.tax = tax + self.taxAmount = taxAmount + self.vat = vat + self.vatAmount = vatAmount + self.grossAmount = grossAmount + self.creditsUsed = creditsUsed + self.currency = currency + self.clientSecret = clientSecret + self.status = status + self.lastError = lastError + self.dueAt = dueAt + self.from = from + self.to = to + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.permissions = try container.decode([String].self, forKey: .permissions) + self.teamId = try container.decode(String.self, forKey: .teamId) + self.aggregationId = try container.decode(String.self, forKey: .aggregationId) + self.plan = try container.decode(String.self, forKey: .plan) + self.usage = try container.decode([UsageResources].self, forKey: .usage) + self.amount = try container.decode(Double.self, forKey: .amount) + self.tax = try container.decode(Double.self, forKey: .tax) + self.taxAmount = try container.decode(Double.self, forKey: .taxAmount) + self.vat = try container.decode(Double.self, forKey: .vat) + self.vatAmount = try container.decode(Double.self, forKey: .vatAmount) + self.grossAmount = try container.decode(Double.self, forKey: .grossAmount) + self.creditsUsed = try container.decode(Double.self, forKey: .creditsUsed) + self.currency = try container.decode(String.self, forKey: .currency) + self.clientSecret = try container.decode(String.self, forKey: .clientSecret) + self.status = try container.decode(String.self, forKey: .status) + self.lastError = try container.decode(String.self, forKey: .lastError) + self.dueAt = try container.decode(String.self, forKey: .dueAt) + self.from = try container.decode(String.self, forKey: .from) + self.to = try container.decode(String.self, forKey: .to) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(permissions, forKey: .permissions) + try container.encode(teamId, forKey: .teamId) + try container.encode(aggregationId, forKey: .aggregationId) + try container.encode(plan, forKey: .plan) + try container.encode(usage, forKey: .usage) + try container.encode(amount, forKey: .amount) + try container.encode(tax, forKey: .tax) + try container.encode(taxAmount, forKey: .taxAmount) + try container.encode(vat, forKey: .vat) + try container.encode(vatAmount, forKey: .vatAmount) + try container.encode(grossAmount, forKey: .grossAmount) + try container.encode(creditsUsed, forKey: .creditsUsed) + try container.encode(currency, forKey: .currency) + try container.encode(clientSecret, forKey: .clientSecret) + try container.encode(status, forKey: .status) + try container.encode(lastError, forKey: .lastError) + try container.encode(dueAt, forKey: .dueAt) + try container.encode(from, forKey: .from) + try container.encode(to, forKey: .to) + } + + public func toMap() -> [String: Any] { + return [ + "$id": id as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "$permissions": permissions as Any, + "teamId": teamId as Any, + "aggregationId": aggregationId as Any, + "plan": plan as Any, + "usage": usage.map { $0.toMap() } as Any, + "amount": amount as Any, + "tax": tax as Any, + "taxAmount": taxAmount as Any, + "vat": vat as Any, + "vatAmount": vatAmount as Any, + "grossAmount": grossAmount as Any, + "creditsUsed": creditsUsed as Any, + "currency": currency as Any, + "clientSecret": clientSecret as Any, + "status": status as Any, + "lastError": lastError as Any, + "dueAt": dueAt as Any, + "from": from as Any, + "to": to as Any + ] + } + + public static func from(map: [String: Any] ) -> Invoice { + return Invoice( + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + teamId: map["teamId"] as! String, + aggregationId: map["aggregationId"] as! String, + plan: map["plan"] as! String, + usage: (map["usage"] as! [[String: Any]]).map { UsageResources.from(map: $0) }, + amount: map["amount"] as! Double, + tax: map["tax"] as! Double, + taxAmount: map["taxAmount"] as! Double, + vat: map["vat"] as! Double, + vatAmount: map["vatAmount"] as! Double, + grossAmount: map["grossAmount"] as! Double, + creditsUsed: map["creditsUsed"] as! Double, + currency: map["currency"] as! String, + clientSecret: map["clientSecret"] as! String, + status: map["status"] as! String, + lastError: map["lastError"] as! String, + dueAt: map["dueAt"] as! String, + from: map["from"] as! String, + to: map["to"] as! String + ) + } +} diff --git a/Sources/AppwriteModels/Key.swift b/Sources/AppwriteModels/Key.swift new file mode 100644 index 0000000..9376ede --- /dev/null +++ b/Sources/AppwriteModels/Key.swift @@ -0,0 +1,115 @@ +import Foundation +import JSONCodable + +/// Key +open class Key: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case name = "name" + case expire = "expire" + case scopes = "scopes" + case secret = "secret" + case accessedAt = "accessedAt" + case sdks = "sdks" + } + + /// Key ID. + public let id: String + /// Key creation date in ISO 8601 format. + public let createdAt: String + /// Key update date in ISO 8601 format. + public let updatedAt: String + /// Key name. + public let name: String + /// Key expiration date in ISO 8601 format. + public let expire: String + /// Allowed permission scopes. + public let scopes: [String] + /// Secret key. + public let secret: String + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + public let accessedAt: String + /// List of SDK user agents that used this key. + public let sdks: [String] + + init( + id: String, + createdAt: String, + updatedAt: String, + name: String, + expire: String, + scopes: [String], + secret: String, + accessedAt: String, + sdks: [String] + ) { + self.id = id + self.createdAt = createdAt + self.updatedAt = updatedAt + self.name = name + self.expire = expire + self.scopes = scopes + self.secret = secret + self.accessedAt = accessedAt + self.sdks = sdks + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.name = try container.decode(String.self, forKey: .name) + self.expire = try container.decode(String.self, forKey: .expire) + self.scopes = try container.decode([String].self, forKey: .scopes) + self.secret = try container.decode(String.self, forKey: .secret) + self.accessedAt = try container.decode(String.self, forKey: .accessedAt) + self.sdks = try container.decode([String].self, forKey: .sdks) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(name, forKey: .name) + try container.encode(expire, forKey: .expire) + try container.encode(scopes, forKey: .scopes) + try container.encode(secret, forKey: .secret) + try container.encode(accessedAt, forKey: .accessedAt) + try container.encode(sdks, forKey: .sdks) + } + + public func toMap() -> [String: Any] { + return [ + "$id": id as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "name": name as Any, + "expire": expire as Any, + "scopes": scopes as Any, + "secret": secret as Any, + "accessedAt": accessedAt as Any, + "sdks": sdks as Any + ] + } + + public static func from(map: [String: Any] ) -> Key { + return Key( + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + name: map["name"] as! String, + expire: map["expire"] as! String, + scopes: map["scopes"] as! [String], + secret: map["secret"] as! String, + accessedAt: map["accessedAt"] as! String, + sdks: map["sdks"] as! [String] + ) + } +} diff --git a/Sources/AppwriteModels/KeyList.swift b/Sources/AppwriteModels/KeyList.swift new file mode 100644 index 0000000..17ee326 --- /dev/null +++ b/Sources/AppwriteModels/KeyList.swift @@ -0,0 +1,52 @@ +import Foundation +import JSONCodable + +/// API Keys List +open class KeyList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case keys = "keys" + } + + /// Total number of keys that matched your query. + public let total: Int + /// List of keys. + public let keys: [Key] + + init( + total: Int, + keys: [Key] + ) { + self.total = total + self.keys = keys + } + + 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.keys = try container.decode([Key].self, forKey: .keys) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(keys, forKey: .keys) + } + + public func toMap() -> [String: Any] { + return [ + "total": total as Any, + "keys": keys.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> KeyList { + return KeyList( + total: map["total"] as! Int, + keys: (map["keys"] as! [[String: Any]]).map { Key.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/PaymentMethod.swift b/Sources/AppwriteModels/PaymentMethod.swift new file mode 100644 index 0000000..280b97e --- /dev/null +++ b/Sources/AppwriteModels/PaymentMethod.swift @@ -0,0 +1,214 @@ +import Foundation +import JSONCodable + +/// paymentMethod +open class PaymentMethod: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case providerMethodId = "providerMethodId" + case clientSecret = "clientSecret" + case providerUserId = "providerUserId" + case userId = "userId" + case expiryMonth = "expiryMonth" + case expiryYear = "expiryYear" + case last4 = "last4" + case brand = "brand" + case name = "name" + case mandateId = "mandateId" + case country = "country" + case state = "state" + case lastError = "lastError" + case `default` = "default" + case expired = "expired" + case failed = "failed" + } + + /// Payment Method ID. + public let id: String + /// Payment method creation time in ISO 8601 format. + public let createdAt: String + /// Payment method update date in ISO 8601 format. + public let updatedAt: String + /// Payment method permissions. [Learn more about permissions](/docs/permissions). + public let permissions: [String] + /// Payment method ID from the payment provider + public let providerMethodId: String + /// Client secret hash for payment setup + public let clientSecret: String + /// User ID from the payment provider. + public let providerUserId: String + /// ID of the Team. + public let userId: String + /// Expiry month of the payment method. + public let expiryMonth: Int + /// Expiry year of the payment method. + public let expiryYear: Int + /// Last 4 digit of the payment method + public let last4: String + /// Payment method brand + public let brand: String + /// Name of the owner + public let name: String + /// Mandate ID of the payment method + public let mandateId: String + /// Country of the payment method + public let country: String + /// State of the payment method + public let state: String + /// Last payment error associated with the payment method. + public let lastError: String + /// True when it's the default payment method. + public let `default`: Bool + /// True when payment method has expired. + public let expired: Bool + /// True when payment method has failed to process multiple times. + public let failed: Bool + + init( + id: String, + createdAt: String, + updatedAt: String, + permissions: [String], + providerMethodId: String, + clientSecret: String, + providerUserId: String, + userId: String, + expiryMonth: Int, + expiryYear: Int, + last4: String, + brand: String, + name: String, + mandateId: String, + country: String, + state: String, + lastError: String, + `default`: Bool, + expired: Bool, + failed: Bool + ) { + self.id = id + self.createdAt = createdAt + self.updatedAt = updatedAt + self.permissions = permissions + self.providerMethodId = providerMethodId + self.clientSecret = clientSecret + self.providerUserId = providerUserId + self.userId = userId + self.expiryMonth = expiryMonth + self.expiryYear = expiryYear + self.last4 = last4 + self.brand = brand + self.name = name + self.mandateId = mandateId + self.country = country + self.state = state + self.lastError = lastError + self.`default` = `default` + self.expired = expired + self.failed = failed + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.id = try container.decode(String.self, forKey: .id) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.permissions = try container.decode([String].self, forKey: .permissions) + self.providerMethodId = try container.decode(String.self, forKey: .providerMethodId) + self.clientSecret = try container.decode(String.self, forKey: .clientSecret) + self.providerUserId = try container.decode(String.self, forKey: .providerUserId) + self.userId = try container.decode(String.self, forKey: .userId) + self.expiryMonth = try container.decode(Int.self, forKey: .expiryMonth) + self.expiryYear = try container.decode(Int.self, forKey: .expiryYear) + self.last4 = try container.decode(String.self, forKey: .last4) + self.brand = try container.decode(String.self, forKey: .brand) + self.name = try container.decode(String.self, forKey: .name) + self.mandateId = try container.decode(String.self, forKey: .mandateId) + self.country = try container.decode(String.self, forKey: .country) + self.state = try container.decode(String.self, forKey: .state) + self.lastError = try container.decode(String.self, forKey: .lastError) + self.`default` = try container.decode(Bool.self, forKey: .`default`) + self.expired = try container.decode(Bool.self, forKey: .expired) + self.failed = try container.decode(Bool.self, forKey: .failed) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(permissions, forKey: .permissions) + try container.encode(providerMethodId, forKey: .providerMethodId) + try container.encode(clientSecret, forKey: .clientSecret) + try container.encode(providerUserId, forKey: .providerUserId) + try container.encode(userId, forKey: .userId) + try container.encode(expiryMonth, forKey: .expiryMonth) + try container.encode(expiryYear, forKey: .expiryYear) + try container.encode(last4, forKey: .last4) + try container.encode(brand, forKey: .brand) + try container.encode(name, forKey: .name) + try container.encode(mandateId, forKey: .mandateId) + try container.encode(country, forKey: .country) + try container.encode(state, forKey: .state) + try container.encode(lastError, forKey: .lastError) + try container.encode(`default`, forKey: .`default`) + try container.encode(expired, forKey: .expired) + try container.encode(failed, forKey: .failed) + } + + public func toMap() -> [String: Any] { + return [ + "$id": id as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "$permissions": permissions as Any, + "providerMethodId": providerMethodId as Any, + "clientSecret": clientSecret as Any, + "providerUserId": providerUserId as Any, + "userId": userId as Any, + "expiryMonth": expiryMonth as Any, + "expiryYear": expiryYear as Any, + "last4": last4 as Any, + "brand": brand as Any, + "name": name as Any, + "mandateId": mandateId as Any, + "country": country as Any, + "state": state as Any, + "lastError": lastError as Any, + "default": `default` as Any, + "expired": expired as Any, + "failed": failed as Any + ] + } + + public static func from(map: [String: Any] ) -> PaymentMethod { + return PaymentMethod( + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + providerMethodId: map["providerMethodId"] as! String, + clientSecret: map["clientSecret"] as! String, + providerUserId: map["providerUserId"] as! String, + userId: map["userId"] as! String, + expiryMonth: map["expiryMonth"] as! Int, + expiryYear: map["expiryYear"] as! Int, + last4: map["last4"] as! String, + brand: map["brand"] as! String, + name: map["name"] as! String, + mandateId: map["mandateId"] as! String, + country: map["country"] as! String, + state: map["state"] as! String, + lastError: map["lastError"] as! String, + default: map["default"] as! Bool, + expired: map["expired"] as! Bool, + failed: map["failed"] as! Bool + ) + } +} diff --git a/Sources/AppwriteModels/PaymentMethodList.swift b/Sources/AppwriteModels/PaymentMethodList.swift new file mode 100644 index 0000000..617f9b4 --- /dev/null +++ b/Sources/AppwriteModels/PaymentMethodList.swift @@ -0,0 +1,52 @@ +import Foundation +import JSONCodable + +/// Payment methods list +open class PaymentMethodList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case paymentMethods = "paymentMethods" + } + + /// Total number of paymentMethods that matched your query. + public let total: Int + /// List of paymentMethods. + public let paymentMethods: [PaymentMethod] + + init( + total: Int, + paymentMethods: [PaymentMethod] + ) { + self.total = total + self.paymentMethods = paymentMethods + } + + 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.paymentMethods = try container.decode([PaymentMethod].self, forKey: .paymentMethods) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(paymentMethods, forKey: .paymentMethods) + } + + public func toMap() -> [String: Any] { + return [ + "total": total as Any, + "paymentMethods": paymentMethods.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> PaymentMethodList { + return PaymentMethodList( + total: map["total"] as! Int, + paymentMethods: (map["paymentMethods"] as! [[String: Any]]).map { PaymentMethod.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/UsageResources.swift b/Sources/AppwriteModels/UsageResources.swift new file mode 100644 index 0000000..5673af3 --- /dev/null +++ b/Sources/AppwriteModels/UsageResources.swift @@ -0,0 +1,88 @@ +import Foundation +import JSONCodable + +/// UsageResource +open class UsageResources: Codable { + + enum CodingKeys: String, CodingKey { + case name = "name" + case value = "value" + case amount = "amount" + case rate = "rate" + case desc = "desc" + case resourceId = "resourceId" + } + + /// Invoice name + public let name: String + /// Invoice value + public let value: Int + /// Invoice amount + public let amount: Double + /// Invoice rate + public let rate: Double + /// Invoice description + public let desc: String + /// Resource ID + public let resourceId: String + + init( + name: String, + value: Int, + amount: Double, + rate: Double, + desc: String, + resourceId: String + ) { + self.name = name + self.value = value + self.amount = amount + self.rate = rate + self.desc = desc + self.resourceId = resourceId + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + self.value = try container.decode(Int.self, forKey: .value) + self.amount = try container.decode(Double.self, forKey: .amount) + self.rate = try container.decode(Double.self, forKey: .rate) + self.desc = try container.decode(String.self, forKey: .desc) + self.resourceId = try container.decode(String.self, forKey: .resourceId) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(name, forKey: .name) + try container.encode(value, forKey: .value) + try container.encode(amount, forKey: .amount) + try container.encode(rate, forKey: .rate) + try container.encode(desc, forKey: .desc) + try container.encode(resourceId, forKey: .resourceId) + } + + public func toMap() -> [String: Any] { + return [ + "name": name as Any, + "value": value as Any, + "amount": amount as Any, + "rate": rate as Any, + "desc": desc as Any, + "resourceId": resourceId as Any + ] + } + + public static func from(map: [String: Any] ) -> UsageResources { + return UsageResources( + name: map["name"] as! String, + value: map["value"] as! Int, + amount: map["amount"] as! Double, + rate: map["rate"] as! Double, + desc: map["desc"] as! String, + resourceId: map["resourceId"] as! String + ) + } +} diff --git a/docs/examples/account/create-billing-address.md b/docs/examples/account/create-billing-address.md new file mode 100644 index 0000000..123629b --- /dev/null +++ b/docs/examples/account/create-billing-address.md @@ -0,0 +1,19 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let billingAddress = try await account.createBillingAddress( + country: "", + city: "", + streetAddress: "", + addressLine2: "", // optional + state: "", // optional + postalCode: "" // optional +) + +``` diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md new file mode 100644 index 0000000..d520953 --- /dev/null +++ b/docs/examples/account/create-key.md @@ -0,0 +1,17 @@ +```swift +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 key = try await account.createKey( + name: "", + scopes: [.account], + expire: "" // optional +) + +``` diff --git a/docs/examples/account/create-payment-method.md b/docs/examples/account/create-payment-method.md new file mode 100644 index 0000000..166010e --- /dev/null +++ b/docs/examples/account/create-payment-method.md @@ -0,0 +1,12 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let paymentMethod = try await account.createPaymentMethod() + +``` diff --git a/docs/examples/account/delete-billing-address.md b/docs/examples/account/delete-billing-address.md new file mode 100644 index 0000000..d663980 --- /dev/null +++ b/docs/examples/account/delete-billing-address.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +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.deleteBillingAddress( + billingAddressId: "" +) + +``` diff --git a/docs/examples/account/delete-key.md b/docs/examples/account/delete-key.md new file mode 100644 index 0000000..a20834b --- /dev/null +++ b/docs/examples/account/delete-key.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +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.deleteKey( + keyId: "" +) + +``` diff --git a/docs/examples/account/delete-payment-method.md b/docs/examples/account/delete-payment-method.md new file mode 100644 index 0000000..32af9c0 --- /dev/null +++ b/docs/examples/account/delete-payment-method.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +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.deletePaymentMethod( + paymentMethodId: "" +) + +``` diff --git a/docs/examples/account/get-billing-address.md b/docs/examples/account/get-billing-address.md new file mode 100644 index 0000000..52a1ea6 --- /dev/null +++ b/docs/examples/account/get-billing-address.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let billingAddress = try await account.getBillingAddress( + billingAddressId: "" +) + +``` diff --git a/docs/examples/account/get-key.md b/docs/examples/account/get-key.md new file mode 100644 index 0000000..3a5990b --- /dev/null +++ b/docs/examples/account/get-key.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let key = try await account.getKey( + keyId: "" +) + +``` diff --git a/docs/examples/account/get-payment-method.md b/docs/examples/account/get-payment-method.md new file mode 100644 index 0000000..9ecb0e5 --- /dev/null +++ b/docs/examples/account/get-payment-method.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let paymentMethod = try await account.getPaymentMethod( + paymentMethodId: "" +) + +``` diff --git a/docs/examples/account/list-billing-addresses.md b/docs/examples/account/list-billing-addresses.md new file mode 100644 index 0000000..9bfa316 --- /dev/null +++ b/docs/examples/account/list-billing-addresses.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let billingAddressList = try await account.listBillingAddresses( + queries: [] // optional +) + +``` diff --git a/docs/examples/account/list-keys.md b/docs/examples/account/list-keys.md new file mode 100644 index 0000000..cbf459c --- /dev/null +++ b/docs/examples/account/list-keys.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let keyList = try await account.listKeys( + total: false // optional +) + +``` diff --git a/docs/examples/account/list-payment-methods.md b/docs/examples/account/list-payment-methods.md new file mode 100644 index 0000000..63bd09a --- /dev/null +++ b/docs/examples/account/list-payment-methods.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let paymentMethodList = try await account.listPaymentMethods( + queries: [] // optional +) + +``` diff --git a/docs/examples/account/update-billing-address.md b/docs/examples/account/update-billing-address.md new file mode 100644 index 0000000..21a3fc3 --- /dev/null +++ b/docs/examples/account/update-billing-address.md @@ -0,0 +1,20 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let billingAddress = try await account.updateBillingAddress( + billingAddressId: "", + country: "", + city: "", + streetAddress: "", + addressLine2: "", // optional + state: "", // optional + postalCode: "" // optional +) + +``` diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md new file mode 100644 index 0000000..9444e1f --- /dev/null +++ b/docs/examples/account/update-key.md @@ -0,0 +1,18 @@ +```swift +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 key = try await account.updateKey( + keyId: "", + name: "", + scopes: [.account], + expire: "" // optional +) + +``` diff --git a/docs/examples/account/update-payment-method-mandate-options.md b/docs/examples/account/update-payment-method-mandate-options.md new file mode 100644 index 0000000..4c8ef8d --- /dev/null +++ b/docs/examples/account/update-payment-method-mandate-options.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let paymentMethod = try await account.updatePaymentMethodMandateOptions( + paymentMethodId: "" +) + +``` diff --git a/docs/examples/account/update-payment-method-provider.md b/docs/examples/account/update-payment-method-provider.md new file mode 100644 index 0000000..a7a5b34 --- /dev/null +++ b/docs/examples/account/update-payment-method-provider.md @@ -0,0 +1,17 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let paymentMethod = try await account.updatePaymentMethodProvider( + paymentMethodId: "", + providerMethodId: "", + name: "", + state: "" // optional +) + +``` diff --git a/docs/examples/account/update-payment-method.md b/docs/examples/account/update-payment-method.md new file mode 100644 index 0000000..bb53cc0 --- /dev/null +++ b/docs/examples/account/update-payment-method.md @@ -0,0 +1,17 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let paymentMethod = try await account.updatePaymentMethod( + paymentMethodId: "", + expiryMonth: 1, + expiryYear: 2026, + state: "" // optional +) + +``` diff --git a/docs/examples/organizations/create-downgrade-feedback.md b/docs/examples/organizations/create-downgrade-feedback.md new file mode 100644 index 0000000..69cb880 --- /dev/null +++ b/docs/examples/organizations/create-downgrade-feedback.md @@ -0,0 +1,18 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let organizations = Organizations(client) + +let downgradeFeedback = try await organizations.createDowngradeFeedback( + organizationId: "", + reason: "", + message: "", + fromPlanId: "", + toPlanId: "" +) + +``` diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md new file mode 100644 index 0000000..e0270c5 --- /dev/null +++ b/docs/examples/organizations/delete.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let organizations = Organizations(client) + +let result = try await organizations.delete( + organizationId: "" +) + +``` diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md new file mode 100644 index 0000000..5c22289 --- /dev/null +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -0,0 +1,14 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let organizations = Organizations(client) + +let estimationDeleteOrganization = try await organizations.estimationDeleteOrganization( + organizationId: "" +) + +``` diff --git a/docs/examples/organizations/get-billing-address.md b/docs/examples/organizations/get-billing-address.md new file mode 100644 index 0000000..800fb0f --- /dev/null +++ b/docs/examples/organizations/get-billing-address.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let organizations = Organizations(client) + +let billingAddress = try await organizations.getBillingAddress( + organizationId: "", + billingAddressId: "" +) + +``` diff --git a/docs/examples/organizations/get-payment-method.md b/docs/examples/organizations/get-payment-method.md new file mode 100644 index 0000000..86bf315 --- /dev/null +++ b/docs/examples/organizations/get-payment-method.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let organizations = Organizations(client) + +let paymentMethod = try await organizations.getPaymentMethod( + organizationId: "", + paymentMethodId: "" +) + +``` From 3dbf5be49bf6111346279854767928a2aeb4e87f Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 13 Feb 2026 08:39:12 +0000 Subject: [PATCH 2/4] updated --- Sources/Appwrite/Services/Account.swift | 191 -------------- Sources/Appwrite/Services/Organizations.swift | 188 -------------- Sources/AppwriteModels/BillingAddress.swift | 106 -------- .../AppwriteModels/BillingAddressList.swift | 52 ---- .../AppwriteModels/DowngradeFeedback.swift | 124 ---------- .../EstimationDeleteOrganization.swift | 43 ---- Sources/AppwriteModels/Invoice.swift | 232 ------------------ Sources/AppwriteModels/UsageResources.swift | 88 ------- .../account/create-billing-address.md | 19 -- .../account/delete-billing-address.md | 14 -- docs/examples/account/get-billing-address.md | 14 -- .../account/list-billing-addresses.md | 14 -- .../account/update-billing-address.md | 20 -- .../create-downgrade-feedback.md | 18 -- docs/examples/organizations/delete.md | 14 -- .../estimation-delete-organization.md | 14 -- .../organizations/get-billing-address.md | 15 -- .../organizations/get-payment-method.md | 15 -- 18 files changed, 1181 deletions(-) delete mode 100644 Sources/Appwrite/Services/Organizations.swift delete mode 100644 Sources/AppwriteModels/BillingAddress.swift delete mode 100644 Sources/AppwriteModels/BillingAddressList.swift delete mode 100644 Sources/AppwriteModels/DowngradeFeedback.swift delete mode 100644 Sources/AppwriteModels/EstimationDeleteOrganization.swift delete mode 100644 Sources/AppwriteModels/Invoice.swift delete mode 100644 Sources/AppwriteModels/UsageResources.swift delete mode 100644 docs/examples/account/create-billing-address.md delete mode 100644 docs/examples/account/delete-billing-address.md delete mode 100644 docs/examples/account/get-billing-address.md delete mode 100644 docs/examples/account/list-billing-addresses.md delete mode 100644 docs/examples/account/update-billing-address.md delete mode 100644 docs/examples/organizations/create-downgrade-feedback.md delete mode 100644 docs/examples/organizations/delete.md delete mode 100644 docs/examples/organizations/estimation-delete-organization.md delete mode 100644 docs/examples/organizations/get-billing-address.md delete mode 100644 docs/examples/organizations/get-payment-method.md diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index d52f7ac..7942f87 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -131,197 +131,6 @@ open class Account: Service { ) } - /// - /// List all billing addresses for a user. - /// - /// - Parameters: - /// - queries: [String] (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.BillingAddressList - /// - open func listBillingAddresses( - queries: [String]? = nil - ) async throws -> AppwriteModels.BillingAddressList { - let apiPath: String = "/account/billing-addresses" - - let apiParams: [String: Any?] = [ - "queries": queries - ] - - let apiHeaders: [String: String] = [:] - - let converter: (Any) -> AppwriteModels.BillingAddressList = { response in - return AppwriteModels.BillingAddressList.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "GET", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Add a new billing address to a user's account. - /// - /// - Parameters: - /// - country: String - /// - city: String - /// - streetAddress: String - /// - addressLine2: String (optional) - /// - state: String (optional) - /// - postalCode: String (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.BillingAddress - /// - open func createBillingAddress( - country: String, - city: String, - streetAddress: String, - addressLine2: String? = nil, - state: String? = nil, - postalCode: String? = nil - ) async throws -> AppwriteModels.BillingAddress { - let apiPath: String = "/account/billing-addresses" - - let apiParams: [String: Any?] = [ - "country": country, - "city": city, - "streetAddress": streetAddress, - "addressLine2": addressLine2, - "state": state, - "postalCode": postalCode - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.BillingAddress = { response in - return AppwriteModels.BillingAddress.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "POST", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Get a specific billing address for a user using it's ID. - /// - /// - Parameters: - /// - billingAddressId: String - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.BillingAddress - /// - open func getBillingAddress( - billingAddressId: String - ) async throws -> AppwriteModels.BillingAddress { - let apiPath: String = "/account/billing-addresses/{billingAddressId}" - .replacingOccurrences(of: "{billingAddressId}", with: billingAddressId) - - let apiParams: [String: Any] = [:] - - let apiHeaders: [String: String] = [:] - - let converter: (Any) -> AppwriteModels.BillingAddress = { response in - return AppwriteModels.BillingAddress.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "GET", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Update a specific billing address using it's ID. - /// - /// - Parameters: - /// - billingAddressId: String - /// - country: String - /// - city: String - /// - streetAddress: String - /// - addressLine2: String (optional) - /// - state: String (optional) - /// - postalCode: String (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.BillingAddress - /// - open func updateBillingAddress( - billingAddressId: String, - country: String, - city: String, - streetAddress: String, - addressLine2: String? = nil, - state: String? = nil, - postalCode: String? = nil - ) async throws -> AppwriteModels.BillingAddress { - let apiPath: String = "/account/billing-addresses/{billingAddressId}" - .replacingOccurrences(of: "{billingAddressId}", with: billingAddressId) - - let apiParams: [String: Any?] = [ - "country": country, - "city": city, - "streetAddress": streetAddress, - "addressLine2": addressLine2, - "state": state, - "postalCode": postalCode - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.BillingAddress = { response in - return AppwriteModels.BillingAddress.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "PUT", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Delete a specific billing address using it's ID. - /// - /// - Parameters: - /// - billingAddressId: String - /// - Throws: Exception if the request fails - /// - Returns: Any - /// - open func deleteBillingAddress( - billingAddressId: String - ) async throws -> Any { - let apiPath: String = "/account/billing-addresses/{billingAddressId}" - .replacingOccurrences(of: "{billingAddressId}", with: billingAddressId) - - 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 ) - } - /// /// Update currently logged in user account email address. After changing user /// address, the user confirmation status will get reset. A new confirmation diff --git a/Sources/Appwrite/Services/Organizations.swift b/Sources/Appwrite/Services/Organizations.swift deleted file mode 100644 index cb95d8a..0000000 --- a/Sources/Appwrite/Services/Organizations.swift +++ /dev/null @@ -1,188 +0,0 @@ -import AsyncHTTPClient -import Foundation -import NIO -import JSONCodable -import AppwriteEnums -import AppwriteModels - -/// -open class Organizations: Service { - - /// - /// Delete an organization. - /// - /// - Parameters: - /// - organizationId: String - /// - Throws: Exception if the request fails - /// - Returns: Any - /// - open func delete( - organizationId: String - ) async throws -> Any { - let apiPath: String = "/organizations/{organizationId}" - .replacingOccurrences(of: "{organizationId}", with: organizationId) - - 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 ) - } - - /// - /// Get a billing address using it's ID. - /// - /// - Parameters: - /// - organizationId: String - /// - billingAddressId: String - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.BillingAddress - /// - open func getBillingAddress( - organizationId: String, - billingAddressId: String - ) async throws -> AppwriteModels.BillingAddress { - let apiPath: String = "/organizations/{organizationId}/billing-addresses/{billingAddressId}" - .replacingOccurrences(of: "{organizationId}", with: organizationId) - .replacingOccurrences(of: "{billingAddressId}", with: billingAddressId) - - let apiParams: [String: Any] = [:] - - let apiHeaders: [String: String] = [:] - - let converter: (Any) -> AppwriteModels.BillingAddress = { response in - return AppwriteModels.BillingAddress.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "GET", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Get estimation for deleting an organization. - /// - /// - Parameters: - /// - organizationId: String - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.EstimationDeleteOrganization - /// - open func estimationDeleteOrganization( - organizationId: String - ) async throws -> AppwriteModels.EstimationDeleteOrganization { - let apiPath: String = "/organizations/{organizationId}/estimations/delete-organization" - .replacingOccurrences(of: "{organizationId}", with: organizationId) - - let apiParams: [String: Any] = [:] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.EstimationDeleteOrganization = { response in - return AppwriteModels.EstimationDeleteOrganization.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "PATCH", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Submit feedback about downgrading from a paid plan to a lower tier. This - /// helps the team understand user experience and improve the platform. - /// - /// - /// - Parameters: - /// - organizationId: String - /// - reason: String - /// - message: String - /// - fromPlanId: String - /// - toPlanId: String - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.DowngradeFeedback - /// - open func createDowngradeFeedback( - organizationId: String, - reason: String, - message: String, - fromPlanId: String, - toPlanId: String - ) async throws -> AppwriteModels.DowngradeFeedback { - let apiPath: String = "/organizations/{organizationId}/feedbacks/downgrade" - .replacingOccurrences(of: "{organizationId}", with: organizationId) - - let apiParams: [String: Any?] = [ - "reason": reason, - "message": message, - "fromPlanId": fromPlanId, - "toPlanId": toPlanId - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.DowngradeFeedback = { response in - return AppwriteModels.DowngradeFeedback.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "POST", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Get an organization's payment method using it's payment method ID. - /// - /// - Parameters: - /// - organizationId: String - /// - paymentMethodId: String - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.PaymentMethod - /// - open func getPaymentMethod( - organizationId: String, - paymentMethodId: String - ) async throws -> AppwriteModels.PaymentMethod { - let apiPath: String = "/organizations/{organizationId}/payment-methods/{paymentMethodId}" - .replacingOccurrences(of: "{organizationId}", with: organizationId) - .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) - - let apiParams: [String: Any] = [:] - - let apiHeaders: [String: String] = [:] - - let converter: (Any) -> AppwriteModels.PaymentMethod = { response in - return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "GET", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - -} \ No newline at end of file diff --git a/Sources/AppwriteModels/BillingAddress.swift b/Sources/AppwriteModels/BillingAddress.swift deleted file mode 100644 index 3f5b924..0000000 --- a/Sources/AppwriteModels/BillingAddress.swift +++ /dev/null @@ -1,106 +0,0 @@ -import Foundation -import JSONCodable - -/// BillingAddress -open class BillingAddress: Codable { - - enum CodingKeys: String, CodingKey { - case id = "$id" - case userId = "userId" - case streetAddress = "streetAddress" - case addressLine2 = "addressLine2" - case country = "country" - case city = "city" - case state = "state" - case postalCode = "postalCode" - } - - /// Region ID - public let id: String - /// User ID - public let userId: String - /// Street address - public let streetAddress: String - /// Address line 2 - public let addressLine2: String - /// Address country - public let country: String - /// city - public let city: String - /// state - public let state: String - /// postal code - public let postalCode: String - - init( - id: String, - userId: String, - streetAddress: String, - addressLine2: String, - country: String, - city: String, - state: String, - postalCode: String - ) { - self.id = id - self.userId = userId - self.streetAddress = streetAddress - self.addressLine2 = addressLine2 - self.country = country - self.city = city - self.state = state - self.postalCode = postalCode - } - - 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.userId = try container.decode(String.self, forKey: .userId) - self.streetAddress = try container.decode(String.self, forKey: .streetAddress) - self.addressLine2 = try container.decode(String.self, forKey: .addressLine2) - self.country = try container.decode(String.self, forKey: .country) - self.city = try container.decode(String.self, forKey: .city) - self.state = try container.decode(String.self, forKey: .state) - self.postalCode = try container.decode(String.self, forKey: .postalCode) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(id, forKey: .id) - try container.encode(userId, forKey: .userId) - try container.encode(streetAddress, forKey: .streetAddress) - try container.encode(addressLine2, forKey: .addressLine2) - try container.encode(country, forKey: .country) - try container.encode(city, forKey: .city) - try container.encode(state, forKey: .state) - try container.encode(postalCode, forKey: .postalCode) - } - - public func toMap() -> [String: Any] { - return [ - "$id": id as Any, - "userId": userId as Any, - "streetAddress": streetAddress as Any, - "addressLine2": addressLine2 as Any, - "country": country as Any, - "city": city as Any, - "state": state as Any, - "postalCode": postalCode as Any - ] - } - - public static func from(map: [String: Any] ) -> BillingAddress { - return BillingAddress( - id: map["$id"] as! String, - userId: map["userId"] as! String, - streetAddress: map["streetAddress"] as! String, - addressLine2: map["addressLine2"] as! String, - country: map["country"] as! String, - city: map["city"] as! String, - state: map["state"] as! String, - postalCode: map["postalCode"] as! String - ) - } -} diff --git a/Sources/AppwriteModels/BillingAddressList.swift b/Sources/AppwriteModels/BillingAddressList.swift deleted file mode 100644 index fd9dda9..0000000 --- a/Sources/AppwriteModels/BillingAddressList.swift +++ /dev/null @@ -1,52 +0,0 @@ -import Foundation -import JSONCodable - -/// Billing address list -open class BillingAddressList: Codable { - - enum CodingKeys: String, CodingKey { - case total = "total" - case billingAddresses = "billingAddresses" - } - - /// Total number of billingAddresses that matched your query. - public let total: Int - /// List of billingAddresses. - public let billingAddresses: [BillingAddress] - - init( - total: Int, - billingAddresses: [BillingAddress] - ) { - self.total = total - self.billingAddresses = billingAddresses - } - - 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.billingAddresses = try container.decode([BillingAddress].self, forKey: .billingAddresses) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(total, forKey: .total) - try container.encode(billingAddresses, forKey: .billingAddresses) - } - - public func toMap() -> [String: Any] { - return [ - "total": total as Any, - "billingAddresses": billingAddresses.map { $0.toMap() } as Any - ] - } - - public static func from(map: [String: Any] ) -> BillingAddressList { - return BillingAddressList( - total: map["total"] as! Int, - billingAddresses: (map["billingAddresses"] as! [[String: Any]]).map { BillingAddress.from(map: $0) } - ) - } -} diff --git a/Sources/AppwriteModels/DowngradeFeedback.swift b/Sources/AppwriteModels/DowngradeFeedback.swift deleted file mode 100644 index 2bf7372..0000000 --- a/Sources/AppwriteModels/DowngradeFeedback.swift +++ /dev/null @@ -1,124 +0,0 @@ -import Foundation -import JSONCodable - -/// Downgrade Feedback -open class DowngradeFeedback: Codable { - - enum CodingKeys: String, CodingKey { - case id = "$id" - case createdAt = "$createdAt" - case updatedAt = "$updatedAt" - case title = "title" - case message = "message" - case fromPlanId = "fromPlanId" - case toPlanId = "toPlanId" - case teamId = "teamId" - case userId = "userId" - case version = "version" - } - - /// Feedback ID. - public let id: String - /// Feedback creation date in ISO 8601 format. - public let createdAt: String - /// Feedback update date in ISO 8601 format. - public let updatedAt: String - /// Feedback reason - public let title: String - /// Feedback message - public let message: String - /// Plan ID downgrading from - public let fromPlanId: String - /// Plan ID downgrading to - public let toPlanId: String - /// Organization ID - public let teamId: String - /// User ID who submitted feedback - public let userId: String - /// Console version - public let version: String - - init( - id: String, - createdAt: String, - updatedAt: String, - title: String, - message: String, - fromPlanId: String, - toPlanId: String, - teamId: String, - userId: String, - version: String - ) { - self.id = id - self.createdAt = createdAt - self.updatedAt = updatedAt - self.title = title - self.message = message - self.fromPlanId = fromPlanId - self.toPlanId = toPlanId - self.teamId = teamId - self.userId = userId - self.version = version - } - - public required init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(String.self, forKey: .id) - self.createdAt = try container.decode(String.self, forKey: .createdAt) - self.updatedAt = try container.decode(String.self, forKey: .updatedAt) - self.title = try container.decode(String.self, forKey: .title) - self.message = try container.decode(String.self, forKey: .message) - self.fromPlanId = try container.decode(String.self, forKey: .fromPlanId) - self.toPlanId = try container.decode(String.self, forKey: .toPlanId) - self.teamId = try container.decode(String.self, forKey: .teamId) - self.userId = try container.decode(String.self, forKey: .userId) - self.version = try container.decode(String.self, forKey: .version) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(id, forKey: .id) - try container.encode(createdAt, forKey: .createdAt) - try container.encode(updatedAt, forKey: .updatedAt) - try container.encode(title, forKey: .title) - try container.encode(message, forKey: .message) - try container.encode(fromPlanId, forKey: .fromPlanId) - try container.encode(toPlanId, forKey: .toPlanId) - try container.encode(teamId, forKey: .teamId) - try container.encode(userId, forKey: .userId) - try container.encode(version, forKey: .version) - } - - public func toMap() -> [String: Any] { - return [ - "$id": id as Any, - "$createdAt": createdAt as Any, - "$updatedAt": updatedAt as Any, - "title": title as Any, - "message": message as Any, - "fromPlanId": fromPlanId as Any, - "toPlanId": toPlanId as Any, - "teamId": teamId as Any, - "userId": userId as Any, - "version": version as Any - ] - } - - public static func from(map: [String: Any] ) -> DowngradeFeedback { - return DowngradeFeedback( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - title: map["title"] as! String, - message: map["message"] as! String, - fromPlanId: map["fromPlanId"] as! String, - toPlanId: map["toPlanId"] as! String, - teamId: map["teamId"] as! String, - userId: map["userId"] as! String, - version: map["version"] as! String - ) - } -} diff --git a/Sources/AppwriteModels/EstimationDeleteOrganization.swift b/Sources/AppwriteModels/EstimationDeleteOrganization.swift deleted file mode 100644 index 0620a3e..0000000 --- a/Sources/AppwriteModels/EstimationDeleteOrganization.swift +++ /dev/null @@ -1,43 +0,0 @@ -import Foundation -import JSONCodable - -/// EstimationDeleteOrganization -open class EstimationDeleteOrganization: Codable { - - enum CodingKeys: String, CodingKey { - case unpaidInvoices = "unpaidInvoices" - } - - /// List of unpaid invoices - public let unpaidInvoices: [Invoice] - - init( - unpaidInvoices: [Invoice] - ) { - self.unpaidInvoices = unpaidInvoices - } - - public required init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.unpaidInvoices = try container.decode([Invoice].self, forKey: .unpaidInvoices) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(unpaidInvoices, forKey: .unpaidInvoices) - } - - public func toMap() -> [String: Any] { - return [ - "unpaidInvoices": unpaidInvoices.map { $0.toMap() } as Any - ] - } - - public static func from(map: [String: Any] ) -> EstimationDeleteOrganization { - return EstimationDeleteOrganization( - unpaidInvoices: (map["unpaidInvoices"] as! [[String: Any]]).map { Invoice.from(map: $0) } - ) - } -} diff --git a/Sources/AppwriteModels/Invoice.swift b/Sources/AppwriteModels/Invoice.swift deleted file mode 100644 index 87106de..0000000 --- a/Sources/AppwriteModels/Invoice.swift +++ /dev/null @@ -1,232 +0,0 @@ -import Foundation -import JSONCodable - -/// Invoice -open class Invoice: Codable { - - enum CodingKeys: String, CodingKey { - case id = "$id" - case createdAt = "$createdAt" - case updatedAt = "$updatedAt" - case permissions = "$permissions" - case teamId = "teamId" - case aggregationId = "aggregationId" - case plan = "plan" - case usage = "usage" - case amount = "amount" - case tax = "tax" - case taxAmount = "taxAmount" - case vat = "vat" - case vatAmount = "vatAmount" - case grossAmount = "grossAmount" - case creditsUsed = "creditsUsed" - case currency = "currency" - case clientSecret = "clientSecret" - case status = "status" - case lastError = "lastError" - case dueAt = "dueAt" - case from = "from" - case to = "to" - } - - /// Invoice ID. - public let id: String - /// Invoice creation time in ISO 8601 format. - public let createdAt: String - /// Invoice update date in ISO 8601 format. - public let updatedAt: String - /// Invoice permissions. [Learn more about permissions](/docs/permissions). - public let permissions: [String] - /// Project ID - public let teamId: String - /// Aggregation ID - public let aggregationId: String - /// Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`. - public let plan: String - /// Usage breakdown per resource - public let usage: [UsageResources] - /// Invoice Amount - public let amount: Double - /// Tax percentage - public let tax: Double - /// Tax amount - public let taxAmount: Double - /// VAT percentage - public let vat: Double - /// VAT amount - public let vatAmount: Double - /// Gross amount after vat, tax, and discounts applied. - public let grossAmount: Double - /// Credits used. - public let creditsUsed: Double - /// Currency the invoice is in - public let currency: String - /// Client secret for processing failed payments in front-end - public let clientSecret: String - /// Invoice status - public let status: String - /// Last payment error associated with the invoice - public let lastError: String - /// Invoice due date. - public let dueAt: String - /// Beginning date of the invoice - public let from: String - /// End date of the invoice - public let to: String - - init( - id: String, - createdAt: String, - updatedAt: String, - permissions: [String], - teamId: String, - aggregationId: String, - plan: String, - usage: [UsageResources], - amount: Double, - tax: Double, - taxAmount: Double, - vat: Double, - vatAmount: Double, - grossAmount: Double, - creditsUsed: Double, - currency: String, - clientSecret: String, - status: String, - lastError: String, - dueAt: String, - from: String, - to: String - ) { - self.id = id - self.createdAt = createdAt - self.updatedAt = updatedAt - self.permissions = permissions - self.teamId = teamId - self.aggregationId = aggregationId - self.plan = plan - self.usage = usage - self.amount = amount - self.tax = tax - self.taxAmount = taxAmount - self.vat = vat - self.vatAmount = vatAmount - self.grossAmount = grossAmount - self.creditsUsed = creditsUsed - self.currency = currency - self.clientSecret = clientSecret - self.status = status - self.lastError = lastError - self.dueAt = dueAt - self.from = from - self.to = to - } - - public required init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(String.self, forKey: .id) - self.createdAt = try container.decode(String.self, forKey: .createdAt) - self.updatedAt = try container.decode(String.self, forKey: .updatedAt) - self.permissions = try container.decode([String].self, forKey: .permissions) - self.teamId = try container.decode(String.self, forKey: .teamId) - self.aggregationId = try container.decode(String.self, forKey: .aggregationId) - self.plan = try container.decode(String.self, forKey: .plan) - self.usage = try container.decode([UsageResources].self, forKey: .usage) - self.amount = try container.decode(Double.self, forKey: .amount) - self.tax = try container.decode(Double.self, forKey: .tax) - self.taxAmount = try container.decode(Double.self, forKey: .taxAmount) - self.vat = try container.decode(Double.self, forKey: .vat) - self.vatAmount = try container.decode(Double.self, forKey: .vatAmount) - self.grossAmount = try container.decode(Double.self, forKey: .grossAmount) - self.creditsUsed = try container.decode(Double.self, forKey: .creditsUsed) - self.currency = try container.decode(String.self, forKey: .currency) - self.clientSecret = try container.decode(String.self, forKey: .clientSecret) - self.status = try container.decode(String.self, forKey: .status) - self.lastError = try container.decode(String.self, forKey: .lastError) - self.dueAt = try container.decode(String.self, forKey: .dueAt) - self.from = try container.decode(String.self, forKey: .from) - self.to = try container.decode(String.self, forKey: .to) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(id, forKey: .id) - try container.encode(createdAt, forKey: .createdAt) - try container.encode(updatedAt, forKey: .updatedAt) - try container.encode(permissions, forKey: .permissions) - try container.encode(teamId, forKey: .teamId) - try container.encode(aggregationId, forKey: .aggregationId) - try container.encode(plan, forKey: .plan) - try container.encode(usage, forKey: .usage) - try container.encode(amount, forKey: .amount) - try container.encode(tax, forKey: .tax) - try container.encode(taxAmount, forKey: .taxAmount) - try container.encode(vat, forKey: .vat) - try container.encode(vatAmount, forKey: .vatAmount) - try container.encode(grossAmount, forKey: .grossAmount) - try container.encode(creditsUsed, forKey: .creditsUsed) - try container.encode(currency, forKey: .currency) - try container.encode(clientSecret, forKey: .clientSecret) - try container.encode(status, forKey: .status) - try container.encode(lastError, forKey: .lastError) - try container.encode(dueAt, forKey: .dueAt) - try container.encode(from, forKey: .from) - try container.encode(to, forKey: .to) - } - - public func toMap() -> [String: Any] { - return [ - "$id": id as Any, - "$createdAt": createdAt as Any, - "$updatedAt": updatedAt as Any, - "$permissions": permissions as Any, - "teamId": teamId as Any, - "aggregationId": aggregationId as Any, - "plan": plan as Any, - "usage": usage.map { $0.toMap() } as Any, - "amount": amount as Any, - "tax": tax as Any, - "taxAmount": taxAmount as Any, - "vat": vat as Any, - "vatAmount": vatAmount as Any, - "grossAmount": grossAmount as Any, - "creditsUsed": creditsUsed as Any, - "currency": currency as Any, - "clientSecret": clientSecret as Any, - "status": status as Any, - "lastError": lastError as Any, - "dueAt": dueAt as Any, - "from": from as Any, - "to": to as Any - ] - } - - public static func from(map: [String: Any] ) -> Invoice { - return Invoice( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [String], - teamId: map["teamId"] as! String, - aggregationId: map["aggregationId"] as! String, - plan: map["plan"] as! String, - usage: (map["usage"] as! [[String: Any]]).map { UsageResources.from(map: $0) }, - amount: map["amount"] as! Double, - tax: map["tax"] as! Double, - taxAmount: map["taxAmount"] as! Double, - vat: map["vat"] as! Double, - vatAmount: map["vatAmount"] as! Double, - grossAmount: map["grossAmount"] as! Double, - creditsUsed: map["creditsUsed"] as! Double, - currency: map["currency"] as! String, - clientSecret: map["clientSecret"] as! String, - status: map["status"] as! String, - lastError: map["lastError"] as! String, - dueAt: map["dueAt"] as! String, - from: map["from"] as! String, - to: map["to"] as! String - ) - } -} diff --git a/Sources/AppwriteModels/UsageResources.swift b/Sources/AppwriteModels/UsageResources.swift deleted file mode 100644 index 5673af3..0000000 --- a/Sources/AppwriteModels/UsageResources.swift +++ /dev/null @@ -1,88 +0,0 @@ -import Foundation -import JSONCodable - -/// UsageResource -open class UsageResources: Codable { - - enum CodingKeys: String, CodingKey { - case name = "name" - case value = "value" - case amount = "amount" - case rate = "rate" - case desc = "desc" - case resourceId = "resourceId" - } - - /// Invoice name - public let name: String - /// Invoice value - public let value: Int - /// Invoice amount - public let amount: Double - /// Invoice rate - public let rate: Double - /// Invoice description - public let desc: String - /// Resource ID - public let resourceId: String - - init( - name: String, - value: Int, - amount: Double, - rate: Double, - desc: String, - resourceId: String - ) { - self.name = name - self.value = value - self.amount = amount - self.rate = rate - self.desc = desc - self.resourceId = resourceId - } - - public required init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.name = try container.decode(String.self, forKey: .name) - self.value = try container.decode(Int.self, forKey: .value) - self.amount = try container.decode(Double.self, forKey: .amount) - self.rate = try container.decode(Double.self, forKey: .rate) - self.desc = try container.decode(String.self, forKey: .desc) - self.resourceId = try container.decode(String.self, forKey: .resourceId) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(name, forKey: .name) - try container.encode(value, forKey: .value) - try container.encode(amount, forKey: .amount) - try container.encode(rate, forKey: .rate) - try container.encode(desc, forKey: .desc) - try container.encode(resourceId, forKey: .resourceId) - } - - public func toMap() -> [String: Any] { - return [ - "name": name as Any, - "value": value as Any, - "amount": amount as Any, - "rate": rate as Any, - "desc": desc as Any, - "resourceId": resourceId as Any - ] - } - - public static func from(map: [String: Any] ) -> UsageResources { - return UsageResources( - name: map["name"] as! String, - value: map["value"] as! Int, - amount: map["amount"] as! Double, - rate: map["rate"] as! Double, - desc: map["desc"] as! String, - resourceId: map["resourceId"] as! String - ) - } -} diff --git a/docs/examples/account/create-billing-address.md b/docs/examples/account/create-billing-address.md deleted file mode 100644 index 123629b..0000000 --- a/docs/examples/account/create-billing-address.md +++ /dev/null @@ -1,19 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let billingAddress = try await account.createBillingAddress( - country: "", - city: "", - streetAddress: "", - addressLine2: "", // optional - state: "", // optional - postalCode: "" // optional -) - -``` diff --git a/docs/examples/account/delete-billing-address.md b/docs/examples/account/delete-billing-address.md deleted file mode 100644 index d663980..0000000 --- a/docs/examples/account/delete-billing-address.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -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.deleteBillingAddress( - billingAddressId: "" -) - -``` diff --git a/docs/examples/account/get-billing-address.md b/docs/examples/account/get-billing-address.md deleted file mode 100644 index 52a1ea6..0000000 --- a/docs/examples/account/get-billing-address.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let billingAddress = try await account.getBillingAddress( - billingAddressId: "" -) - -``` diff --git a/docs/examples/account/list-billing-addresses.md b/docs/examples/account/list-billing-addresses.md deleted file mode 100644 index 9bfa316..0000000 --- a/docs/examples/account/list-billing-addresses.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let billingAddressList = try await account.listBillingAddresses( - queries: [] // optional -) - -``` diff --git a/docs/examples/account/update-billing-address.md b/docs/examples/account/update-billing-address.md deleted file mode 100644 index 21a3fc3..0000000 --- a/docs/examples/account/update-billing-address.md +++ /dev/null @@ -1,20 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let billingAddress = try await account.updateBillingAddress( - billingAddressId: "", - country: "", - city: "", - streetAddress: "", - addressLine2: "", // optional - state: "", // optional - postalCode: "" // optional -) - -``` diff --git a/docs/examples/organizations/create-downgrade-feedback.md b/docs/examples/organizations/create-downgrade-feedback.md deleted file mode 100644 index 69cb880..0000000 --- a/docs/examples/organizations/create-downgrade-feedback.md +++ /dev/null @@ -1,18 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let organizations = Organizations(client) - -let downgradeFeedback = try await organizations.createDowngradeFeedback( - organizationId: "", - reason: "", - message: "", - fromPlanId: "", - toPlanId: "" -) - -``` diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md deleted file mode 100644 index e0270c5..0000000 --- a/docs/examples/organizations/delete.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let organizations = Organizations(client) - -let result = try await organizations.delete( - organizationId: "" -) - -``` diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md deleted file mode 100644 index 5c22289..0000000 --- a/docs/examples/organizations/estimation-delete-organization.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let organizations = Organizations(client) - -let estimationDeleteOrganization = try await organizations.estimationDeleteOrganization( - organizationId: "" -) - -``` diff --git a/docs/examples/organizations/get-billing-address.md b/docs/examples/organizations/get-billing-address.md deleted file mode 100644 index 800fb0f..0000000 --- a/docs/examples/organizations/get-billing-address.md +++ /dev/null @@ -1,15 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let organizations = Organizations(client) - -let billingAddress = try await organizations.getBillingAddress( - organizationId: "", - billingAddressId: "" -) - -``` diff --git a/docs/examples/organizations/get-payment-method.md b/docs/examples/organizations/get-payment-method.md deleted file mode 100644 index 86bf315..0000000 --- a/docs/examples/organizations/get-payment-method.md +++ /dev/null @@ -1,15 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let organizations = Organizations(client) - -let paymentMethod = try await organizations.getPaymentMethod( - organizationId: "", - paymentMethodId: "" -) - -``` From d18aeced12a29d456a40fa8f90d57a6a104c6269 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 13 Feb 2026 10:01:57 +0000 Subject: [PATCH 3/4] updated --- Sources/Appwrite/Services/Account.swift | 238 ------------------ Sources/AppwriteModels/PaymentMethod.swift | 214 ---------------- .../AppwriteModels/PaymentMethodList.swift | 52 ---- .../examples/account/create-payment-method.md | 12 - .../examples/account/delete-payment-method.md | 14 -- docs/examples/account/get-payment-method.md | 14 -- docs/examples/account/list-payment-methods.md | 14 -- .../update-payment-method-mandate-options.md | 14 -- .../account/update-payment-method-provider.md | 17 -- .../examples/account/update-payment-method.md | 17 -- 10 files changed, 606 deletions(-) delete mode 100644 Sources/AppwriteModels/PaymentMethod.swift delete mode 100644 Sources/AppwriteModels/PaymentMethodList.swift delete mode 100644 docs/examples/account/create-payment-method.md delete mode 100644 docs/examples/account/delete-payment-method.md delete mode 100644 docs/examples/account/get-payment-method.md delete mode 100644 docs/examples/account/list-payment-methods.md delete mode 100644 docs/examples/account/update-payment-method-mandate-options.md delete mode 100644 docs/examples/account/update-payment-method-provider.md delete mode 100644 docs/examples/account/update-payment-method.md diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 7942f87..ae84809 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -1339,244 +1339,6 @@ open class Account: Service { ) } - /// - /// List payment methods for this account. - /// - /// - Parameters: - /// - queries: [String] (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.PaymentMethodList - /// - open func listPaymentMethods( - queries: [String]? = nil - ) async throws -> AppwriteModels.PaymentMethodList { - let apiPath: String = "/account/payment-methods" - - let apiParams: [String: Any?] = [ - "queries": queries - ] - - let apiHeaders: [String: String] = [:] - - let converter: (Any) -> AppwriteModels.PaymentMethodList = { response in - return AppwriteModels.PaymentMethodList.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "GET", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Create a new payment method for the current user account. - /// - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.PaymentMethod - /// - open func createPaymentMethod( - ) async throws -> AppwriteModels.PaymentMethod { - let apiPath: String = "/account/payment-methods" - - let apiParams: [String: Any] = [:] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.PaymentMethod = { response in - return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "POST", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Get a specific payment method for the user. - /// - /// - Parameters: - /// - paymentMethodId: String - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.PaymentMethod - /// - open func getPaymentMethod( - paymentMethodId: String - ) async throws -> AppwriteModels.PaymentMethod { - let apiPath: String = "/account/payment-methods/{paymentMethodId}" - .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) - - let apiParams: [String: Any] = [:] - - let apiHeaders: [String: String] = [:] - - let converter: (Any) -> AppwriteModels.PaymentMethod = { response in - return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "GET", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Update a new payment method for the current user account. - /// - /// - Parameters: - /// - paymentMethodId: String - /// - expiryMonth: Int - /// - expiryYear: Int - /// - state: String (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.PaymentMethod - /// - open func updatePaymentMethod( - paymentMethodId: String, - expiryMonth: Int, - expiryYear: Int, - state: String? = nil - ) async throws -> AppwriteModels.PaymentMethod { - let apiPath: String = "/account/payment-methods/{paymentMethodId}" - .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) - - let apiParams: [String: Any?] = [ - "expiryMonth": expiryMonth, - "expiryYear": expiryYear, - "state": state - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.PaymentMethod = { response in - return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "PATCH", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Delete a specific payment method from a user's account. - /// - /// - Parameters: - /// - paymentMethodId: String - /// - Throws: Exception if the request fails - /// - Returns: Any - /// - open func deletePaymentMethod( - paymentMethodId: String - ) async throws -> Any { - let apiPath: String = "/account/payment-methods/{paymentMethodId}" - .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) - - 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 ) - } - - /// - /// Update payment method provider. - /// - /// - Parameters: - /// - paymentMethodId: String - /// - providerMethodId: String - /// - name: String - /// - state: String (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.PaymentMethod - /// - open func updatePaymentMethodProvider( - paymentMethodId: String, - providerMethodId: String, - name: String, - state: String? = nil - ) async throws -> AppwriteModels.PaymentMethod { - let apiPath: String = "/account/payment-methods/{paymentMethodId}/provider" - .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) - - let apiParams: [String: Any?] = [ - "providerMethodId": providerMethodId, - "name": name, - "state": state - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.PaymentMethod = { response in - return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "PATCH", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Update payment method mandate options. - /// - /// - Parameters: - /// - paymentMethodId: String - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.PaymentMethod - /// - open func updatePaymentMethodMandateOptions( - paymentMethodId: String - ) async throws -> AppwriteModels.PaymentMethod { - let apiPath: String = "/account/payment-methods/{paymentMethodId}/setup" - .replacingOccurrences(of: "{paymentMethodId}", with: paymentMethodId) - - let apiParams: [String: Any] = [:] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.PaymentMethod = { response in - return AppwriteModels.PaymentMethod.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "PATCH", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - /// /// Update the currently logged in user's phone number. After updating the /// phone number, the phone verification status will be reset. A confirmation diff --git a/Sources/AppwriteModels/PaymentMethod.swift b/Sources/AppwriteModels/PaymentMethod.swift deleted file mode 100644 index 280b97e..0000000 --- a/Sources/AppwriteModels/PaymentMethod.swift +++ /dev/null @@ -1,214 +0,0 @@ -import Foundation -import JSONCodable - -/// paymentMethod -open class PaymentMethod: Codable { - - enum CodingKeys: String, CodingKey { - case id = "$id" - case createdAt = "$createdAt" - case updatedAt = "$updatedAt" - case permissions = "$permissions" - case providerMethodId = "providerMethodId" - case clientSecret = "clientSecret" - case providerUserId = "providerUserId" - case userId = "userId" - case expiryMonth = "expiryMonth" - case expiryYear = "expiryYear" - case last4 = "last4" - case brand = "brand" - case name = "name" - case mandateId = "mandateId" - case country = "country" - case state = "state" - case lastError = "lastError" - case `default` = "default" - case expired = "expired" - case failed = "failed" - } - - /// Payment Method ID. - public let id: String - /// Payment method creation time in ISO 8601 format. - public let createdAt: String - /// Payment method update date in ISO 8601 format. - public let updatedAt: String - /// Payment method permissions. [Learn more about permissions](/docs/permissions). - public let permissions: [String] - /// Payment method ID from the payment provider - public let providerMethodId: String - /// Client secret hash for payment setup - public let clientSecret: String - /// User ID from the payment provider. - public let providerUserId: String - /// ID of the Team. - public let userId: String - /// Expiry month of the payment method. - public let expiryMonth: Int - /// Expiry year of the payment method. - public let expiryYear: Int - /// Last 4 digit of the payment method - public let last4: String - /// Payment method brand - public let brand: String - /// Name of the owner - public let name: String - /// Mandate ID of the payment method - public let mandateId: String - /// Country of the payment method - public let country: String - /// State of the payment method - public let state: String - /// Last payment error associated with the payment method. - public let lastError: String - /// True when it's the default payment method. - public let `default`: Bool - /// True when payment method has expired. - public let expired: Bool - /// True when payment method has failed to process multiple times. - public let failed: Bool - - init( - id: String, - createdAt: String, - updatedAt: String, - permissions: [String], - providerMethodId: String, - clientSecret: String, - providerUserId: String, - userId: String, - expiryMonth: Int, - expiryYear: Int, - last4: String, - brand: String, - name: String, - mandateId: String, - country: String, - state: String, - lastError: String, - `default`: Bool, - expired: Bool, - failed: Bool - ) { - self.id = id - self.createdAt = createdAt - self.updatedAt = updatedAt - self.permissions = permissions - self.providerMethodId = providerMethodId - self.clientSecret = clientSecret - self.providerUserId = providerUserId - self.userId = userId - self.expiryMonth = expiryMonth - self.expiryYear = expiryYear - self.last4 = last4 - self.brand = brand - self.name = name - self.mandateId = mandateId - self.country = country - self.state = state - self.lastError = lastError - self.`default` = `default` - self.expired = expired - self.failed = failed - } - - public required init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(String.self, forKey: .id) - self.createdAt = try container.decode(String.self, forKey: .createdAt) - self.updatedAt = try container.decode(String.self, forKey: .updatedAt) - self.permissions = try container.decode([String].self, forKey: .permissions) - self.providerMethodId = try container.decode(String.self, forKey: .providerMethodId) - self.clientSecret = try container.decode(String.self, forKey: .clientSecret) - self.providerUserId = try container.decode(String.self, forKey: .providerUserId) - self.userId = try container.decode(String.self, forKey: .userId) - self.expiryMonth = try container.decode(Int.self, forKey: .expiryMonth) - self.expiryYear = try container.decode(Int.self, forKey: .expiryYear) - self.last4 = try container.decode(String.self, forKey: .last4) - self.brand = try container.decode(String.self, forKey: .brand) - self.name = try container.decode(String.self, forKey: .name) - self.mandateId = try container.decode(String.self, forKey: .mandateId) - self.country = try container.decode(String.self, forKey: .country) - self.state = try container.decode(String.self, forKey: .state) - self.lastError = try container.decode(String.self, forKey: .lastError) - self.`default` = try container.decode(Bool.self, forKey: .`default`) - self.expired = try container.decode(Bool.self, forKey: .expired) - self.failed = try container.decode(Bool.self, forKey: .failed) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(id, forKey: .id) - try container.encode(createdAt, forKey: .createdAt) - try container.encode(updatedAt, forKey: .updatedAt) - try container.encode(permissions, forKey: .permissions) - try container.encode(providerMethodId, forKey: .providerMethodId) - try container.encode(clientSecret, forKey: .clientSecret) - try container.encode(providerUserId, forKey: .providerUserId) - try container.encode(userId, forKey: .userId) - try container.encode(expiryMonth, forKey: .expiryMonth) - try container.encode(expiryYear, forKey: .expiryYear) - try container.encode(last4, forKey: .last4) - try container.encode(brand, forKey: .brand) - try container.encode(name, forKey: .name) - try container.encode(mandateId, forKey: .mandateId) - try container.encode(country, forKey: .country) - try container.encode(state, forKey: .state) - try container.encode(lastError, forKey: .lastError) - try container.encode(`default`, forKey: .`default`) - try container.encode(expired, forKey: .expired) - try container.encode(failed, forKey: .failed) - } - - public func toMap() -> [String: Any] { - return [ - "$id": id as Any, - "$createdAt": createdAt as Any, - "$updatedAt": updatedAt as Any, - "$permissions": permissions as Any, - "providerMethodId": providerMethodId as Any, - "clientSecret": clientSecret as Any, - "providerUserId": providerUserId as Any, - "userId": userId as Any, - "expiryMonth": expiryMonth as Any, - "expiryYear": expiryYear as Any, - "last4": last4 as Any, - "brand": brand as Any, - "name": name as Any, - "mandateId": mandateId as Any, - "country": country as Any, - "state": state as Any, - "lastError": lastError as Any, - "default": `default` as Any, - "expired": expired as Any, - "failed": failed as Any - ] - } - - public static func from(map: [String: Any] ) -> PaymentMethod { - return PaymentMethod( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - permissions: map["$permissions"] as! [String], - providerMethodId: map["providerMethodId"] as! String, - clientSecret: map["clientSecret"] as! String, - providerUserId: map["providerUserId"] as! String, - userId: map["userId"] as! String, - expiryMonth: map["expiryMonth"] as! Int, - expiryYear: map["expiryYear"] as! Int, - last4: map["last4"] as! String, - brand: map["brand"] as! String, - name: map["name"] as! String, - mandateId: map["mandateId"] as! String, - country: map["country"] as! String, - state: map["state"] as! String, - lastError: map["lastError"] as! String, - default: map["default"] as! Bool, - expired: map["expired"] as! Bool, - failed: map["failed"] as! Bool - ) - } -} diff --git a/Sources/AppwriteModels/PaymentMethodList.swift b/Sources/AppwriteModels/PaymentMethodList.swift deleted file mode 100644 index 617f9b4..0000000 --- a/Sources/AppwriteModels/PaymentMethodList.swift +++ /dev/null @@ -1,52 +0,0 @@ -import Foundation -import JSONCodable - -/// Payment methods list -open class PaymentMethodList: Codable { - - enum CodingKeys: String, CodingKey { - case total = "total" - case paymentMethods = "paymentMethods" - } - - /// Total number of paymentMethods that matched your query. - public let total: Int - /// List of paymentMethods. - public let paymentMethods: [PaymentMethod] - - init( - total: Int, - paymentMethods: [PaymentMethod] - ) { - self.total = total - self.paymentMethods = paymentMethods - } - - 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.paymentMethods = try container.decode([PaymentMethod].self, forKey: .paymentMethods) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(total, forKey: .total) - try container.encode(paymentMethods, forKey: .paymentMethods) - } - - public func toMap() -> [String: Any] { - return [ - "total": total as Any, - "paymentMethods": paymentMethods.map { $0.toMap() } as Any - ] - } - - public static func from(map: [String: Any] ) -> PaymentMethodList { - return PaymentMethodList( - total: map["total"] as! Int, - paymentMethods: (map["paymentMethods"] as! [[String: Any]]).map { PaymentMethod.from(map: $0) } - ) - } -} diff --git a/docs/examples/account/create-payment-method.md b/docs/examples/account/create-payment-method.md deleted file mode 100644 index 166010e..0000000 --- a/docs/examples/account/create-payment-method.md +++ /dev/null @@ -1,12 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let paymentMethod = try await account.createPaymentMethod() - -``` diff --git a/docs/examples/account/delete-payment-method.md b/docs/examples/account/delete-payment-method.md deleted file mode 100644 index 32af9c0..0000000 --- a/docs/examples/account/delete-payment-method.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -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.deletePaymentMethod( - paymentMethodId: "" -) - -``` diff --git a/docs/examples/account/get-payment-method.md b/docs/examples/account/get-payment-method.md deleted file mode 100644 index 9ecb0e5..0000000 --- a/docs/examples/account/get-payment-method.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let paymentMethod = try await account.getPaymentMethod( - paymentMethodId: "" -) - -``` diff --git a/docs/examples/account/list-payment-methods.md b/docs/examples/account/list-payment-methods.md deleted file mode 100644 index 63bd09a..0000000 --- a/docs/examples/account/list-payment-methods.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let paymentMethodList = try await account.listPaymentMethods( - queries: [] // optional -) - -``` diff --git a/docs/examples/account/update-payment-method-mandate-options.md b/docs/examples/account/update-payment-method-mandate-options.md deleted file mode 100644 index 4c8ef8d..0000000 --- a/docs/examples/account/update-payment-method-mandate-options.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let paymentMethod = try await account.updatePaymentMethodMandateOptions( - paymentMethodId: "" -) - -``` diff --git a/docs/examples/account/update-payment-method-provider.md b/docs/examples/account/update-payment-method-provider.md deleted file mode 100644 index a7a5b34..0000000 --- a/docs/examples/account/update-payment-method-provider.md +++ /dev/null @@ -1,17 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let paymentMethod = try await account.updatePaymentMethodProvider( - paymentMethodId: "", - providerMethodId: "", - name: "", - state: "" // optional -) - -``` diff --git a/docs/examples/account/update-payment-method.md b/docs/examples/account/update-payment-method.md deleted file mode 100644 index bb53cc0..0000000 --- a/docs/examples/account/update-payment-method.md +++ /dev/null @@ -1,17 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let paymentMethod = try await account.updatePaymentMethod( - paymentMethodId: "", - expiryMonth: 1, - expiryYear: 2026, - state: "" // optional -) - -``` From 0875ee54a9fe4e0f720fb1b3b063ecbc9a56bbd2 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 13 Feb 2026 10:19:19 +0000 Subject: [PATCH 4/4] updated specs --- Sources/Appwrite/Services/Account.swift | 176 ------------------------ Sources/AppwriteEnums/Scopes.swift | 11 -- Sources/AppwriteModels/Key.swift | 115 ---------------- Sources/AppwriteModels/KeyList.swift | 52 ------- docs/examples/account/create-key.md | 17 --- docs/examples/account/delete-key.md | 14 -- docs/examples/account/get-key.md | 14 -- docs/examples/account/list-keys.md | 14 -- docs/examples/account/update-key.md | 18 --- 9 files changed, 431 deletions(-) delete mode 100644 Sources/AppwriteEnums/Scopes.swift delete mode 100644 Sources/AppwriteModels/Key.swift delete mode 100644 Sources/AppwriteModels/KeyList.swift delete mode 100644 docs/examples/account/create-key.md delete mode 100644 docs/examples/account/delete-key.md delete mode 100644 docs/examples/account/get-key.md delete mode 100644 docs/examples/account/list-keys.md delete mode 100644 docs/examples/account/update-key.md diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index ae84809..a05909f 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -303,182 +303,6 @@ open class Account: Service { ) } - /// - /// Get a list of all API keys from the current account. - /// - /// - Parameters: - /// - total: Bool (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.KeyList - /// - open func listKeys( - total: Bool? = nil - ) async throws -> AppwriteModels.KeyList { - let apiPath: String = "/account/keys" - - let apiParams: [String: Any?] = [ - "total": total - ] - - let apiHeaders: [String: String] = [:] - - let converter: (Any) -> AppwriteModels.KeyList = { response in - return AppwriteModels.KeyList.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "GET", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Create a new account API key. - /// - /// - Parameters: - /// - name: String - /// - scopes: [AppwriteEnums.Scopes] - /// - expire: String (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Key - /// - open func createKey( - name: String, - scopes: [AppwriteEnums.Scopes], - expire: String? = nil - ) async throws -> AppwriteModels.Key { - let apiPath: String = "/account/keys" - - let apiParams: [String: Any?] = [ - "name": name, - "scopes": scopes, - "expire": expire - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.Key = { response in - return AppwriteModels.Key.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "POST", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Get a key by its unique ID. This endpoint returns details about a specific - /// API key in your account including it's scopes. - /// - /// - Parameters: - /// - keyId: String - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Key - /// - open func getKey( - keyId: String - ) async throws -> AppwriteModels.Key { - let apiPath: String = "/account/keys/{keyId}" - .replacingOccurrences(of: "{keyId}", with: keyId) - - let apiParams: [String: Any] = [:] - - let apiHeaders: [String: String] = [:] - - let converter: (Any) -> AppwriteModels.Key = { response in - return AppwriteModels.Key.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "GET", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Update a key by its unique ID. Use this endpoint to update the name, - /// scopes, or expiration time of an API key. - /// - /// - Parameters: - /// - keyId: String - /// - name: String - /// - scopes: [AppwriteEnums.Scopes] - /// - expire: String (optional) - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Key - /// - open func updateKey( - keyId: String, - name: String, - scopes: [AppwriteEnums.Scopes], - expire: String? = nil - ) async throws -> AppwriteModels.Key { - let apiPath: String = "/account/keys/{keyId}" - .replacingOccurrences(of: "{keyId}", with: keyId) - - let apiParams: [String: Any?] = [ - "name": name, - "scopes": scopes, - "expire": expire - ] - - let apiHeaders: [String: String] = [ - "content-type": "application/json" - ] - - let converter: (Any) -> AppwriteModels.Key = { response in - return AppwriteModels.Key.from(map: response as! [String: Any]) - } - - return try await client.call( - method: "PUT", - path: apiPath, - headers: apiHeaders, - params: apiParams, - converter: converter - ) - } - - /// - /// Delete a key by its unique ID. Once deleted, the key can no longer be used - /// to authenticate API calls. - /// - /// - Parameters: - /// - keyId: String - /// - Throws: Exception if the request fails - /// - Returns: Any - /// - open func deleteKey( - keyId: String - ) async throws -> Any { - let apiPath: String = "/account/keys/{keyId}" - .replacingOccurrences(of: "{keyId}", with: keyId) - - 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 ) - } - /// /// Get the list of latest security activity logs for the currently logged in /// user. Each log returns user IP address, location and date and time of log. diff --git a/Sources/AppwriteEnums/Scopes.swift b/Sources/AppwriteEnums/Scopes.swift deleted file mode 100644 index 127d59f..0000000 --- a/Sources/AppwriteEnums/Scopes.swift +++ /dev/null @@ -1,11 +0,0 @@ -import Foundation - -public enum Scopes: String, CustomStringConvertible { - case account = "account" - case teamsRead = "teams.read" - case teamsWrite = "teams.write" - - public var description: String { - return rawValue - } -} diff --git a/Sources/AppwriteModels/Key.swift b/Sources/AppwriteModels/Key.swift deleted file mode 100644 index 9376ede..0000000 --- a/Sources/AppwriteModels/Key.swift +++ /dev/null @@ -1,115 +0,0 @@ -import Foundation -import JSONCodable - -/// Key -open class Key: Codable { - - enum CodingKeys: String, CodingKey { - case id = "$id" - case createdAt = "$createdAt" - case updatedAt = "$updatedAt" - case name = "name" - case expire = "expire" - case scopes = "scopes" - case secret = "secret" - case accessedAt = "accessedAt" - case sdks = "sdks" - } - - /// Key ID. - public let id: String - /// Key creation date in ISO 8601 format. - public let createdAt: String - /// Key update date in ISO 8601 format. - public let updatedAt: String - /// Key name. - public let name: String - /// Key expiration date in ISO 8601 format. - public let expire: String - /// Allowed permission scopes. - public let scopes: [String] - /// Secret key. - public let secret: String - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - public let accessedAt: String - /// List of SDK user agents that used this key. - public let sdks: [String] - - init( - id: String, - createdAt: String, - updatedAt: String, - name: String, - expire: String, - scopes: [String], - secret: String, - accessedAt: String, - sdks: [String] - ) { - self.id = id - self.createdAt = createdAt - self.updatedAt = updatedAt - self.name = name - self.expire = expire - self.scopes = scopes - self.secret = secret - self.accessedAt = accessedAt - self.sdks = sdks - } - - public required init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.id = try container.decode(String.self, forKey: .id) - self.createdAt = try container.decode(String.self, forKey: .createdAt) - self.updatedAt = try container.decode(String.self, forKey: .updatedAt) - self.name = try container.decode(String.self, forKey: .name) - self.expire = try container.decode(String.self, forKey: .expire) - self.scopes = try container.decode([String].self, forKey: .scopes) - self.secret = try container.decode(String.self, forKey: .secret) - self.accessedAt = try container.decode(String.self, forKey: .accessedAt) - self.sdks = try container.decode([String].self, forKey: .sdks) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(id, forKey: .id) - try container.encode(createdAt, forKey: .createdAt) - try container.encode(updatedAt, forKey: .updatedAt) - try container.encode(name, forKey: .name) - try container.encode(expire, forKey: .expire) - try container.encode(scopes, forKey: .scopes) - try container.encode(secret, forKey: .secret) - try container.encode(accessedAt, forKey: .accessedAt) - try container.encode(sdks, forKey: .sdks) - } - - public func toMap() -> [String: Any] { - return [ - "$id": id as Any, - "$createdAt": createdAt as Any, - "$updatedAt": updatedAt as Any, - "name": name as Any, - "expire": expire as Any, - "scopes": scopes as Any, - "secret": secret as Any, - "accessedAt": accessedAt as Any, - "sdks": sdks as Any - ] - } - - public static func from(map: [String: Any] ) -> Key { - return Key( - id: map["$id"] as! String, - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String, - name: map["name"] as! String, - expire: map["expire"] as! String, - scopes: map["scopes"] as! [String], - secret: map["secret"] as! String, - accessedAt: map["accessedAt"] as! String, - sdks: map["sdks"] as! [String] - ) - } -} diff --git a/Sources/AppwriteModels/KeyList.swift b/Sources/AppwriteModels/KeyList.swift deleted file mode 100644 index 17ee326..0000000 --- a/Sources/AppwriteModels/KeyList.swift +++ /dev/null @@ -1,52 +0,0 @@ -import Foundation -import JSONCodable - -/// API Keys List -open class KeyList: Codable { - - enum CodingKeys: String, CodingKey { - case total = "total" - case keys = "keys" - } - - /// Total number of keys that matched your query. - public let total: Int - /// List of keys. - public let keys: [Key] - - init( - total: Int, - keys: [Key] - ) { - self.total = total - self.keys = keys - } - - 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.keys = try container.decode([Key].self, forKey: .keys) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - try container.encode(total, forKey: .total) - try container.encode(keys, forKey: .keys) - } - - public func toMap() -> [String: Any] { - return [ - "total": total as Any, - "keys": keys.map { $0.toMap() } as Any - ] - } - - public static func from(map: [String: Any] ) -> KeyList { - return KeyList( - total: map["total"] as! Int, - keys: (map["keys"] as! [[String: Any]]).map { Key.from(map: $0) } - ) - } -} diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md deleted file mode 100644 index d520953..0000000 --- a/docs/examples/account/create-key.md +++ /dev/null @@ -1,17 +0,0 @@ -```swift -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 key = try await account.createKey( - name: "", - scopes: [.account], - expire: "" // optional -) - -``` diff --git a/docs/examples/account/delete-key.md b/docs/examples/account/delete-key.md deleted file mode 100644 index a20834b..0000000 --- a/docs/examples/account/delete-key.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -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.deleteKey( - keyId: "" -) - -``` diff --git a/docs/examples/account/get-key.md b/docs/examples/account/get-key.md deleted file mode 100644 index 3a5990b..0000000 --- a/docs/examples/account/get-key.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let key = try await account.getKey( - keyId: "" -) - -``` diff --git a/docs/examples/account/list-keys.md b/docs/examples/account/list-keys.md deleted file mode 100644 index cbf459c..0000000 --- a/docs/examples/account/list-keys.md +++ /dev/null @@ -1,14 +0,0 @@ -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let keyList = try await account.listKeys( - total: false // optional -) - -``` diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md deleted file mode 100644 index 9444e1f..0000000 --- a/docs/examples/account/update-key.md +++ /dev/null @@ -1,18 +0,0 @@ -```swift -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 key = try await account.updateKey( - keyId: "", - name: "", - scopes: [.account], - expire: "" // optional -) - -```