Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 14.0.0

* Rename `VCSDeploymentType` enum to `VCSReferenceType`
* Change `createTemplateDeployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) and `reference` parameters
* Add `getScreenshot` method to `Avatars` service
* Add `Theme`, `Timezone` and `Output` enums

## 13.3.0

* Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance
Expand Down
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: "git@github.com:appwrite/sdk-for-swift.git", from: "13.3.0"),
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "14.0.0"),
],
```

Expand Down
3 changes: 2 additions & 1 deletion Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import NIOSSL
import Foundation
import AsyncHTTPClient
@_exported import AppwriteModels
@_exported import JSONCodable

let DASHDASH = "--"
let CRLF = "\r\n"
Expand All @@ -21,7 +22,7 @@ open class Client {
"x-sdk-name": "Swift",
"x-sdk-platform": "server",
"x-sdk-language": "swift",
"x-sdk-version": "13.3.0",
"x-sdk-version": "14.0.0",
"x-appwrite-response-format": "1.8.0"
]

Expand Down
8 changes: 4 additions & 4 deletions Sources/Appwrite/Services/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ open class Account: Service {
open func createMfaChallenge(
factor: AppwriteEnums.AuthenticationFactor
) async throws -> AppwriteModels.MfaChallenge {
let apiPath: String = "/account/mfa/challenge"
let apiPath: String = "/account/mfa/challenges"

let apiParams: [String: Any?] = [
"factor": factor
Expand Down Expand Up @@ -690,7 +690,7 @@ open class Account: Service {
open func createMFAChallenge(
factor: AppwriteEnums.AuthenticationFactor
) async throws -> AppwriteModels.MfaChallenge {
let apiPath: String = "/account/mfa/challenge"
let apiPath: String = "/account/mfa/challenges"

let apiParams: [String: Any?] = [
"factor": factor
Expand Down Expand Up @@ -731,7 +731,7 @@ open class Account: Service {
challengeId: String,
otp: String
) async throws -> AppwriteModels.Session {
let apiPath: String = "/account/mfa/challenge"
let apiPath: String = "/account/mfa/challenges"

let apiParams: [String: Any?] = [
"challengeId": challengeId,
Expand Down Expand Up @@ -772,7 +772,7 @@ open class Account: Service {
challengeId: String,
otp: String
) async throws -> AppwriteModels.Session {
let apiPath: String = "/account/mfa/challenge"
let apiPath: String = "/account/mfa/challenges"

let apiParams: [String: Any?] = [
"challengeId": challengeId,
Expand Down
94 changes: 94 additions & 0 deletions Sources/Appwrite/Services/Avatars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,99 @@ open class Avatars: Service {
)
}

///
/// Use this endpoint to capture a screenshot of any website URL. This endpoint
/// uses a headless browser to render the webpage and capture it as an image.
///
/// You can configure the browser viewport size, theme, user agent,
/// geolocation, permissions, and more. Capture either just the viewport or the
/// full page scroll.
///
/// When width and height are specified, the image is resized accordingly. If
/// both dimensions are 0, the API provides an image at original size. If
/// dimensions are not specified, the default viewport size is 1280x720px.
///
/// - Parameters:
/// - url: String
/// - headers: Any (optional)
/// - viewportWidth: Int (optional)
/// - viewportHeight: Int (optional)
/// - scale: Double (optional)
/// - theme: AppwriteEnums.Theme (optional)
/// - userAgent: String (optional)
/// - fullpage: Bool (optional)
/// - locale: String (optional)
/// - timezone: AppwriteEnums.Timezone (optional)
/// - latitude: Double (optional)
/// - longitude: Double (optional)
/// - accuracy: Double (optional)
/// - touch: Bool (optional)
/// - permissions: [String] (optional)
/// - sleep: Int (optional)
/// - width: Int (optional)
/// - height: Int (optional)
/// - quality: Int (optional)
/// - output: AppwriteEnums.Output (optional)
/// - Throws: Exception if the request fails
/// - Returns: ByteBuffer
///
open func getScreenshot(
url: String,
headers: Any? = nil,
viewportWidth: Int? = nil,
viewportHeight: Int? = nil,
scale: Double? = nil,
theme: AppwriteEnums.Theme? = nil,
userAgent: String? = nil,
fullpage: Bool? = nil,
locale: String? = nil,
timezone: AppwriteEnums.Timezone? = nil,
latitude: Double? = nil,
longitude: Double? = nil,
accuracy: Double? = nil,
touch: Bool? = nil,
permissions: [String]? = nil,
sleep: Int? = nil,
width: Int? = nil,
height: Int? = nil,
quality: Int? = nil,
output: AppwriteEnums.Output? = nil
) async throws -> ByteBuffer {
let apiPath: String = "/avatars/screenshots"

let apiParams: [String: Any?] = [
"url": url,
"headers": headers,
"viewportWidth": viewportWidth,
"viewportHeight": viewportHeight,
"scale": scale,
"theme": theme,
"userAgent": userAgent,
"fullpage": fullpage,
"locale": locale,
"timezone": timezone,
"latitude": latitude,
"longitude": longitude,
"accuracy": accuracy,
"touch": touch,
"permissions": permissions,
"sleep": sleep,
"width": width,
"height": height,
"quality": quality,
"output": output,
"project": client.config["project"],
"session": client.config["session"]
]

let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
path: apiPath,
params: apiParams
)
}


}
13 changes: 8 additions & 5 deletions Sources/Appwrite/Services/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ open class Functions: Service {
/// - repository: String
/// - owner: String
/// - rootDirectory: String
/// - version: String
/// - type: AppwriteEnums.TemplateReferenceType
/// - reference: String
/// - activate: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Deployment
Expand All @@ -538,7 +539,8 @@ open class Functions: Service {
repository: String,
owner: String,
rootDirectory: String,
version: String,
type: AppwriteEnums.TemplateReferenceType,
reference: String,
activate: Bool? = nil
) async throws -> AppwriteModels.Deployment {
let apiPath: String = "/functions/{functionId}/deployments/template"
Expand All @@ -548,7 +550,8 @@ open class Functions: Service {
"repository": repository,
"owner": owner,
"rootDirectory": rootDirectory,
"version": version,
"type": type,
"reference": reference,
"activate": activate
]

Expand Down Expand Up @@ -576,15 +579,15 @@ open class Functions: Service {
///
/// - Parameters:
/// - functionId: String
/// - type: AppwriteEnums.VCSDeploymentType
/// - type: AppwriteEnums.VCSReferenceType
/// - reference: String
/// - activate: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Deployment
///
open func createVcsDeployment(
functionId: String,
type: AppwriteEnums.VCSDeploymentType,
type: AppwriteEnums.VCSReferenceType,
reference: String,
activate: Bool? = nil
) async throws -> AppwriteModels.Deployment {
Expand Down
15 changes: 9 additions & 6 deletions Sources/Appwrite/Services/Sites.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ open class Sites: Service {
///
/// Create a new site code deployment. Use this endpoint to upload a new
/// version of your site code. To activate your newly uploaded code, you'll
/// need to update the function's deployment to use your new deployment ID.
/// need to update the site's deployment to use your new deployment ID.
///
/// - Parameters:
/// - siteId: String
Expand Down Expand Up @@ -519,7 +519,8 @@ open class Sites: Service {
/// - repository: String
/// - owner: String
/// - rootDirectory: String
/// - version: String
/// - type: AppwriteEnums.TemplateReferenceType
/// - reference: String
/// - activate: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Deployment
Expand All @@ -529,7 +530,8 @@ open class Sites: Service {
repository: String,
owner: String,
rootDirectory: String,
version: String,
type: AppwriteEnums.TemplateReferenceType,
reference: String,
activate: Bool? = nil
) async throws -> AppwriteModels.Deployment {
let apiPath: String = "/sites/{siteId}/deployments/template"
Expand All @@ -539,7 +541,8 @@ open class Sites: Service {
"repository": repository,
"owner": owner,
"rootDirectory": rootDirectory,
"version": version,
"type": type,
"reference": reference,
"activate": activate
]

Expand Down Expand Up @@ -567,15 +570,15 @@ open class Sites: Service {
///
/// - Parameters:
/// - siteId: String
/// - type: AppwriteEnums.VCSDeploymentType
/// - type: AppwriteEnums.VCSReferenceType
/// - reference: String
/// - activate: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Deployment
///
open func createVcsDeployment(
siteId: String,
type: AppwriteEnums.VCSDeploymentType,
type: AppwriteEnums.VCSReferenceType,
reference: String,
activate: Bool? = nil
) async throws -> AppwriteModels.Deployment {
Expand Down
14 changes: 10 additions & 4 deletions Sources/Appwrite/Services/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ open class Storage: Service {
/// - compression: AppwriteEnums.Compression (optional)
/// - encryption: Bool (optional)
/// - antivirus: Bool (optional)
/// - transformations: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Bucket
///
Expand All @@ -74,7 +75,8 @@ open class Storage: Service {
allowedFileExtensions: [String]? = nil,
compression: AppwriteEnums.Compression? = nil,
encryption: Bool? = nil,
antivirus: Bool? = nil
antivirus: Bool? = nil,
transformations: Bool? = nil
) async throws -> AppwriteModels.Bucket {
let apiPath: String = "/storage/buckets"

Expand All @@ -88,7 +90,8 @@ open class Storage: Service {
"allowedFileExtensions": allowedFileExtensions,
"compression": compression,
"encryption": encryption,
"antivirus": antivirus
"antivirus": antivirus,
"transformations": transformations
]

let apiHeaders: [String: String] = [
Expand Down Expand Up @@ -154,6 +157,7 @@ open class Storage: Service {
/// - compression: AppwriteEnums.Compression (optional)
/// - encryption: Bool (optional)
/// - antivirus: Bool (optional)
/// - transformations: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Bucket
///
Expand All @@ -167,7 +171,8 @@ open class Storage: Service {
allowedFileExtensions: [String]? = nil,
compression: AppwriteEnums.Compression? = nil,
encryption: Bool? = nil,
antivirus: Bool? = nil
antivirus: Bool? = nil,
transformations: Bool? = nil
) async throws -> AppwriteModels.Bucket {
let apiPath: String = "/storage/buckets/{bucketId}"
.replacingOccurrences(of: "{bucketId}", with: bucketId)
Expand All @@ -181,7 +186,8 @@ open class Storage: Service {
"allowedFileExtensions": allowedFileExtensions,
"compression": compression,
"encryption": encryption,
"antivirus": antivirus
"antivirus": antivirus,
"transformations": transformations
]

let apiHeaders: [String: String] = [
Expand Down
2 changes: 2 additions & 0 deletions Sources/AppwriteEnums/BuildRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum BuildRuntime: String, CustomStringConvertible {
case dart33 = "dart-3.3"
case dart35 = "dart-3.5"
case dart38 = "dart-3.8"
case dart39 = "dart-3.9"
case dotnet60 = "dotnet-6.0"
case dotnet70 = "dotnet-7.0"
case dotnet80 = "dotnet-8.0"
Expand Down Expand Up @@ -66,6 +67,7 @@ public enum BuildRuntime: String, CustomStringConvertible {
case flutter327 = "flutter-3.27"
case flutter329 = "flutter-3.29"
case flutter332 = "flutter-3.32"
case flutter335 = "flutter-3.35"

public var description: String {
return rawValue
Expand Down
15 changes: 15 additions & 0 deletions Sources/AppwriteEnums/Output.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation

public enum Output: String, CustomStringConvertible {
case jpg = "jpg"
case jpeg = "jpeg"
case png = "png"
case webp = "webp"
case heic = "heic"
case avif = "avif"
case gif = "gif"

public var description: String {
return rawValue
}
}
2 changes: 2 additions & 0 deletions Sources/AppwriteEnums/Runtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum Runtime: String, CustomStringConvertible {
case dart33 = "dart-3.3"
case dart35 = "dart-3.5"
case dart38 = "dart-3.8"
case dart39 = "dart-3.9"
case dotnet60 = "dotnet-6.0"
case dotnet70 = "dotnet-7.0"
case dotnet80 = "dotnet-8.0"
Expand Down Expand Up @@ -66,6 +67,7 @@ public enum Runtime: String, CustomStringConvertible {
case flutter327 = "flutter-3.27"
case flutter329 = "flutter-3.29"
case flutter332 = "flutter-3.32"
case flutter335 = "flutter-3.35"

public var description: String {
return rawValue
Expand Down
11 changes: 11 additions & 0 deletions Sources/AppwriteEnums/TemplateReferenceType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

public enum TemplateReferenceType: String, CustomStringConvertible {
case branch = "branch"
case commit = "commit"
case tag = "tag"

public var description: String {
return rawValue
}
}
Loading