diff --git a/README.md b/README.md index 5655f98..1d8bc8b 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies: ```swift dependencies: [ - .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "11.0.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "12.0.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 1eb5a93..a1dd6e3 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -21,7 +21,7 @@ open class Client { "x-sdk-name": "Swift", "x-sdk-platform": "server", "x-sdk-language": "swift", - "x-sdk-version": "11.0.0", + "x-sdk-version": "12.0.0", "x-appwrite-response-format": "1.8.0" ] diff --git a/Sources/Appwrite/Query.swift b/Sources/Appwrite/Query.swift index 1956cdd..5af7f4a 100644 --- a/Sources/Appwrite/Query.swift +++ b/Sources/Appwrite/Query.swift @@ -6,10 +6,11 @@ enum QueryValue: Codable { case double(Double) case bool(Bool) case query(Query) + case array([QueryValue]) // for nested arrays init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - // Attempt to decode each type + if let stringValue = try? container.decode(String.self) { self = .string(stringValue) } else if let intValue = try? container.decode(Int.self) { @@ -20,8 +21,13 @@ enum QueryValue: Codable { self = .bool(boolValue) } else if let queryValue = try? container.decode(Query.self) { self = .query(queryValue) + } else if let arrayValue = try? container.decode([QueryValue].self) { + self = .array(arrayValue) } else { - throw DecodingError.dataCorruptedError(in: container, debugDescription: "QueryValue cannot be decoded") + throw DecodingError.dataCorruptedError( + in: container, + debugDescription: "QueryValue cannot be decoded" + ) } } @@ -38,6 +44,8 @@ enum QueryValue: Codable { try container.encode(value) case .query(let value): try container.encode(value) + case .array(let value): + try container.encode(value) } } } @@ -85,6 +93,30 @@ public struct Query : Codable, CustomStringConvertible { return [.bool(boolValue)] case let queryValue as Query: return [.query(queryValue)] + case let anyArray as [Any]: + // Handle nested arrays + let nestedValues = anyArray.compactMap { item -> QueryValue? in + if let stringValue = item as? String { + return .string(stringValue) + } else if let intValue = item as? Int { + return .int(intValue) + } else if let doubleValue = item as? Double { + return .double(doubleValue) + } else if let boolValue = item as? Bool { + return .bool(boolValue) + } else if let queryValue = item as? Query { + return .query(queryValue) + } else if let nestedArray = item as? [Any] { + // Convert nested array to QueryValue.array + if let converted = convertToQueryValueArray(nestedArray) { + return .array(converted) + } + return nil + } + return nil + } + return nestedValues.isEmpty ? nil : nestedValues + default: return nil } @@ -354,6 +386,13 @@ public struct Query : Codable, CustomStringConvertible { ).description } + public static func createdBetween(_ start: String, _ end: String) -> String { + return Query( + method: "createdBetween", + values: [start, end] + ).description + } + public static func updatedBefore(_ value: String) -> String { return Query( method: "updatedBefore", @@ -368,6 +407,13 @@ public struct Query : Codable, CustomStringConvertible { ).description } + public static func updatedBetween(_ start: String, _ end: String) -> String { + return Query( + method: "updatedBetween", + values: [start, end] + ).description + } + public static func or(_ queries: [String]) -> String { let decoder = JSONDecoder() let decodedQueries = queries.compactMap { queryStr -> Query? in @@ -398,6 +444,102 @@ public struct Query : Codable, CustomStringConvertible { ).description } + public static func distanceEqual(_ attribute: String, values: [Any], distance: Double, meters: Bool = true) -> String { + return Query( + method: "distanceEqual", + attribute: attribute, + values: [[values, distance, meters]] + ).description + } + + public static func distanceNotEqual(_ attribute: String, values: [Any], distance: Double, meters: Bool = true) -> String { + return Query( + method: "distanceNotEqual", + attribute: attribute, + values: [[values, distance, meters]] + ).description + } + + public static func distanceGreaterThan(_ attribute: String, values: [Any], distance: Double, meters: Bool = true) -> String { + return Query( + method: "distanceGreaterThan", + attribute: attribute, + values: [[values, distance, meters]] + ).description + } + + public static func distanceLessThan(_ attribute: String, values: [Any], distance: Double, meters: Bool = true) -> String { + return Query( + method: "distanceLessThan", + attribute: attribute, + values: [[values, distance, meters]] + ).description + } + + public static func intersects(_ attribute: String, values: [Any]) -> String { + return Query( + method: "intersects", + attribute: attribute, + values: [values] + ).description + } + + public static func notIntersects(_ attribute: String, values: [Any]) -> String { + return Query( + method: "notIntersects", + attribute: attribute, + values: [values] + ).description + } + + public static func crosses(_ attribute: String, values: [Any]) -> String { + return Query( + method: "crosses", + attribute: attribute, + values: [values] + ).description + } + + public static func notCrosses(_ attribute: String, values: [Any]) -> String { + return Query( + method: "notCrosses", + attribute: attribute, + values: [values] + ).description + } + + public static func overlaps(_ attribute: String, values: [Any]) -> String { + return Query( + method: "overlaps", + attribute: attribute, + values: [values] + ).description + } + + public static func notOverlaps(_ attribute: String, values: [Any]) -> String { + return Query( + method: "notOverlaps", + attribute: attribute, + values: [values] + ).description + } + + public static func touches(_ attribute: String, values: [Any]) -> String { + return Query( + method: "touches", + attribute: attribute, + values: [values] + ).description + } + + public static func notTouches(_ attribute: String, values: [Any]) -> String { + return Query( + method: "notTouches", + attribute: attribute, + values: [values] + ).description + } + private static func parseValue(_ value: Any) -> [Any] { if let value = value as? [Any] { return value diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index b68ba76..2505dd3 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -1548,7 +1548,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// - @available(*, deprecated, message: "This API has been deprecated.") + @available(*, deprecated, message: "This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.") open func updateMagicURLSession( userId: String, secret: String @@ -1588,7 +1588,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// - @available(*, deprecated, message: "This API has been deprecated.") + @available(*, deprecated, message: "This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.") open func updatePhoneSession( userId: String, secret: String diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index 12e0c8a..03c7f4a 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -56,7 +56,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createDatabase` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.create` instead.") open func create( databaseId: String, name: String, @@ -1191,6 +1191,300 @@ open class Databases: Service { ) } + /// + /// Create a geometric line attribute. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeLine + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead.") + open func createLineAttribute( + databaseId: String, + collectionId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil + ) async throws -> AppwriteModels.AttributeLine { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/line" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default` + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.AttributeLine = { response in + return AppwriteModels.AttributeLine.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a line attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeLine + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead.") + open func updateLineAttribute( + databaseId: String, + collectionId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.AttributeLine { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.AttributeLine = { response in + return AppwriteModels.AttributeLine.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a geometric point attribute. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributePoint + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead.") + open func createPointAttribute( + databaseId: String, + collectionId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil + ) async throws -> AppwriteModels.AttributePoint { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/point" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default` + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.AttributePoint = { response in + return AppwriteModels.AttributePoint.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a point attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributePoint + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead.") + open func updatePointAttribute( + databaseId: String, + collectionId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.AttributePoint { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.AttributePoint = { response in + return AppwriteModels.AttributePoint.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a geometric polygon attribute. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributePolygon + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead.") + open func createPolygonAttribute( + databaseId: String, + collectionId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil + ) async throws -> AppwriteModels.AttributePolygon { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default` + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.AttributePolygon = { response in + return AppwriteModels.AttributePolygon.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a polygon attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributePolygon + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead.") + open func updatePolygonAttribute( + databaseId: String, + collectionId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.AttributePolygon { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.AttributePolygon = { response in + return AppwriteModels.AttributePolygon.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Create relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift index e1c3790..8bbbf4c 100644 --- a/Sources/Appwrite/Services/TablesDb.swift +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -1165,6 +1165,294 @@ open class TablesDB: Service { ) } + /// + /// Create a geometric line column. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnLine + /// + open func createLineColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil + ) async throws -> AppwriteModels.ColumnLine { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/line" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default` + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnLine = { response in + return AppwriteModels.ColumnLine.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a line column. Changing the `default` value will not update already + /// existing rows. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnLine + /// + open func updateLineColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnLine { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnLine = { response in + return AppwriteModels.ColumnLine.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a geometric point column. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnPoint + /// + open func createPointColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil + ) async throws -> AppwriteModels.ColumnPoint { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/point" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default` + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnPoint = { response in + return AppwriteModels.ColumnPoint.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a point column. Changing the `default` value will not update already + /// existing rows. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnPoint + /// + open func updatePointColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnPoint { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnPoint = { response in + return AppwriteModels.ColumnPoint.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a geometric polygon column. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnPolygon + /// + open func createPolygonColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil + ) async throws -> AppwriteModels.ColumnPolygon { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default` + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnPolygon = { response in + return AppwriteModels.ColumnPolygon.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a polygon column. Changing the `default` value will not update + /// already existing rows. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: [AnyCodable] (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnPolygon + /// + open func updatePolygonColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: [AnyCodable]? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnPolygon { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnPolygon = { response in + return AppwriteModels.ColumnPolygon.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Create relationship column. [Learn more about relationship /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). diff --git a/Sources/AppwriteEnums/CreditCard.swift b/Sources/AppwriteEnums/CreditCard.swift index 688c5a4..df6079c 100644 --- a/Sources/AppwriteEnums/CreditCard.swift +++ b/Sources/AppwriteEnums/CreditCard.swift @@ -13,7 +13,7 @@ public enum CreditCard: String, CustomStringConvertible { case mastercard = "mastercard" case naranja = "naranja" case tarjetaShopping = "targeta-shopping" - case unionChinaPay = "union-china-pay" + case unionPay = "unionpay" case visa = "visa" case mIR = "mir" case maestro = "maestro" diff --git a/Sources/AppwriteEnums/ExecutionMethod.swift b/Sources/AppwriteEnums/ExecutionMethod.swift index 85111a6..d2153d2 100644 --- a/Sources/AppwriteEnums/ExecutionMethod.swift +++ b/Sources/AppwriteEnums/ExecutionMethod.swift @@ -7,6 +7,7 @@ public enum ExecutionMethod: String, CustomStringConvertible { case pATCH = "PATCH" case dELETE = "DELETE" case oPTIONS = "OPTIONS" + case hEAD = "HEAD" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/IndexType.swift b/Sources/AppwriteEnums/IndexType.swift index 9687f08..a69096e 100644 --- a/Sources/AppwriteEnums/IndexType.swift +++ b/Sources/AppwriteEnums/IndexType.swift @@ -4,6 +4,7 @@ public enum IndexType: String, CustomStringConvertible { case key = "key" case fulltext = "fulltext" case unique = "unique" + case spatial = "spatial" public var description: String { return rawValue diff --git a/Sources/AppwriteModels/AttributeLine.swift b/Sources/AppwriteModels/AttributeLine.swift new file mode 100644 index 0000000..8457304 --- /dev/null +++ b/Sources/AppwriteModels/AttributeLine.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// AttributeLine +open class AttributeLine: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case `default` = "default" + } + + /// Attribute Key. + public let key: String + + /// Attribute type. + public let type: String + + /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an attribute. + public let error: String + + /// Is attribute required? + public let `required`: Bool + + /// Is attribute an array? + public let array: Bool? + + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: [AnyCodable]? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + `default`: [AnyCodable]? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.`default` = try container.decodeIfPresent([AnyCodable].self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "required": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "default": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> AttributeLine { + return AttributeLine( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + default: (map["default"] as? [Any] ?? []).map { AnyCodable($0) } + ) + } +} diff --git a/Sources/AppwriteModels/AttributePoint.swift b/Sources/AppwriteModels/AttributePoint.swift new file mode 100644 index 0000000..7c5fc2b --- /dev/null +++ b/Sources/AppwriteModels/AttributePoint.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// AttributePoint +open class AttributePoint: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case `default` = "default" + } + + /// Attribute Key. + public let key: String + + /// Attribute type. + public let type: String + + /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an attribute. + public let error: String + + /// Is attribute required? + public let `required`: Bool + + /// Is attribute an array? + public let array: Bool? + + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: [AnyCodable]? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + `default`: [AnyCodable]? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.`default` = try container.decodeIfPresent([AnyCodable].self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "required": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "default": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> AttributePoint { + return AttributePoint( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + default: (map["default"] as? [Any] ?? []).map { AnyCodable($0) } + ) + } +} diff --git a/Sources/AppwriteModels/AttributePolygon.swift b/Sources/AppwriteModels/AttributePolygon.swift new file mode 100644 index 0000000..14cb7fd --- /dev/null +++ b/Sources/AppwriteModels/AttributePolygon.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// AttributePolygon +open class AttributePolygon: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case `default` = "default" + } + + /// Attribute Key. + public let key: String + + /// Attribute type. + public let type: String + + /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an attribute. + public let error: String + + /// Is attribute required? + public let `required`: Bool + + /// Is attribute an array? + public let array: Bool? + + /// Attribute creation date in ISO 8601 format. + public let createdAt: String + + /// Attribute update date in ISO 8601 format. + public let updatedAt: String + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: [AnyCodable]? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + `default`: [AnyCodable]? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.`default` = try container.decodeIfPresent([AnyCodable].self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "required": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "default": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> AttributePolygon { + return AttributePolygon( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + default: (map["default"] as? [Any] ?? []).map { AnyCodable($0) } + ) + } +} diff --git a/Sources/AppwriteModels/ColumnLine.swift b/Sources/AppwriteModels/ColumnLine.swift new file mode 100644 index 0000000..09c0543 --- /dev/null +++ b/Sources/AppwriteModels/ColumnLine.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// ColumnLine +open class ColumnLine: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// Default value for column when not provided. Cannot be set when column is required. + public let `default`: [AnyCodable]? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + `default`: [AnyCodable]? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.`default` = try container.decodeIfPresent([AnyCodable].self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "required": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "default": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnLine { + return ColumnLine( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + default: (map["default"] as? [Any] ?? []).map { AnyCodable($0) } + ) + } +} diff --git a/Sources/AppwriteModels/ColumnPoint.swift b/Sources/AppwriteModels/ColumnPoint.swift new file mode 100644 index 0000000..96b1f65 --- /dev/null +++ b/Sources/AppwriteModels/ColumnPoint.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// ColumnPoint +open class ColumnPoint: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// Default value for column when not provided. Cannot be set when column is required. + public let `default`: [AnyCodable]? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + `default`: [AnyCodable]? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.`default` = try container.decodeIfPresent([AnyCodable].self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "required": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "default": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnPoint { + return ColumnPoint( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + default: (map["default"] as? [Any] ?? []).map { AnyCodable($0) } + ) + } +} diff --git a/Sources/AppwriteModels/ColumnPolygon.swift b/Sources/AppwriteModels/ColumnPolygon.swift new file mode 100644 index 0000000..0f64db7 --- /dev/null +++ b/Sources/AppwriteModels/ColumnPolygon.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// ColumnPolygon +open class ColumnPolygon: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// Default value for column when not provided. Cannot be set when column is required. + public let `default`: [AnyCodable]? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + `default`: [AnyCodable]? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.`default` = try container.decodeIfPresent([AnyCodable].self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "required": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "default": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnPolygon { + return ColumnPolygon( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + default: (map["default"] as? [Any] ?? []).map { AnyCodable($0) } + ) + } +} diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 53bf623..cc7b5e6 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -8,6 +8,10 @@ let client = Client() let account = Account(client) let user = try await account.updatePrefs( - prefs: [:] + prefs: [ + "language": "en", + "timezone": "UTC", + "darkTheme": true + ] ) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index daeaf14..cc25fd8 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -11,7 +11,13 @@ let document = try await databases.createDocument( databaseId: "", collectionId: "", documentId: "", - data: [:], + data: [ + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + ], permissions: ["read("any")"] // optional ) diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md new file mode 100644 index 0000000..6683ba3 --- /dev/null +++ b/docs/examples/databases/create-line-attribute.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let databases = Databases(client) + +let attributeLine = try await databases.createLineAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +) + diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md new file mode 100644 index 0000000..62d95f8 --- /dev/null +++ b/docs/examples/databases/create-point-attribute.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let databases = Databases(client) + +let attributePoint = try await databases.createPointAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +) + diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md new file mode 100644 index 0000000..6f7c2d2 --- /dev/null +++ b/docs/examples/databases/create-polygon-attribute.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let databases = Databases(client) + +let attributePolygon = try await databases.createPolygonAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +) + diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md new file mode 100644 index 0000000..c71bffd --- /dev/null +++ b/docs/examples/databases/update-line-attribute.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let databases = Databases(client) + +let attributeLine = try await databases.updateLineAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +) + diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md new file mode 100644 index 0000000..7fc8c11 --- /dev/null +++ b/docs/examples/databases/update-point-attribute.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let databases = Databases(client) + +let attributePoint = try await databases.updatePointAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +) + diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md new file mode 100644 index 0000000..5ceeacb --- /dev/null +++ b/docs/examples/databases/update-polygon-attribute.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let databases = Databases(client) + +let attributePolygon = try await databases.updatePolygonAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md new file mode 100644 index 0000000..31a09d9 --- /dev/null +++ b/docs/examples/tablesdb/create-line-column.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDB = TablesDB(client) + +let columnLine = try await tablesDB.createLineColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +) + diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md new file mode 100644 index 0000000..81e5fe9 --- /dev/null +++ b/docs/examples/tablesdb/create-point-column.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDB = TablesDB(client) + +let columnPoint = try await tablesDB.createPointColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +) + diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md new file mode 100644 index 0000000..d336faa --- /dev/null +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -0,0 +1,17 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDB = TablesDB(client) + +let columnPolygon = try await tablesDB.createPolygonColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +) + diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 31e0ea9..0c59a65 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -11,7 +11,13 @@ let row = try await tablesDB.createRow( databaseId: "", tableId: "", rowId: "", - data: [:], + data: [ + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + ], permissions: ["read("any")"] // optional ) diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md new file mode 100644 index 0000000..86a8959 --- /dev/null +++ b/docs/examples/tablesdb/update-line-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDB = TablesDB(client) + +let columnLine = try await tablesDB.updateLineColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md new file mode 100644 index 0000000..1ebfcfa --- /dev/null +++ b/docs/examples/tablesdb/update-point-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDB = TablesDB(client) + +let columnPoint = try await tablesDB.updatePointColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md new file mode 100644 index 0000000..d05f886 --- /dev/null +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDB = TablesDB(client) + +let columnPolygon = try await tablesDB.updatePolygonColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +) +