Skip to content
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 13.5.0

* Add `getScreenshot` method to `Avatars` service
* Add `Theme`, `Timezone` and `Output` enums

## 13.4.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 @@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "13.4.0"),
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "13.5.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 @@ -23,7 +24,7 @@ open class Client {
"x-sdk-name": "Apple",
"x-sdk-platform": "client",
"x-sdk-language": "apple",
"x-sdk-version": "13.4.0",
"x-sdk-version": "13.5.0",
"x-appwrite-response-format": "1.8.0"
]

Expand Down
91 changes: 91 additions & 0 deletions Sources/Appwrite/Services/Avatars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,96 @@ 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"]
]

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


}
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
}
}
10 changes: 10 additions & 0 deletions Sources/AppwriteEnums/Theme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

public enum Theme: String, CustomStringConvertible {
case light = "light"
case dark = "dark"

public var description: String {
return rawValue
}
}
Loading