Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "11.0.0"),
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "11.1.0"),
],
```

Expand Down
2 changes: 1 addition & 1 deletion Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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": "11.1.0",
"x-appwrite-response-format": "1.8.0"
]

Expand Down
14 changes: 14 additions & 0 deletions Sources/Appwrite/Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,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",
Expand All @@ -368,6 +375,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
Expand Down
4 changes: 2 additions & 2 deletions Sources/Appwrite/Services/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
296 changes: 295 additions & 1 deletion Sources/Appwrite/Services/Databases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1191,6 +1191,300 @@ open class Databases: Service {
)
}

///
/// Create a geometric line attribute.
///
/// - Parameters:
/// - databaseId: String
/// - collectionId: String
/// - key: String
/// - required: Bool
/// - default: 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.createLineColumn` instead.")
open func createLineAttribute(
databaseId: String,
collectionId: String,
key: String,
`required`: Bool,
`default`: String? = 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: String (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`: String? = 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 2d point attribute.
///
/// - Parameters:
/// - databaseId: String
/// - collectionId: String
/// - key: String
/// - required: Bool
/// - default: 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.createPointColumn` instead.")
open func createPointAttribute(
databaseId: String,
collectionId: String,
key: String,
`required`: Bool,
`default`: String? = 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: String (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`: String? = 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: 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.createPolygonColumn` instead.")
open func createPolygonAttribute(
databaseId: String,
collectionId: String,
key: String,
`required`: Bool,
`default`: String? = 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: String (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`: String? = 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).
Expand Down
Loading