Skip to content

Commit 4787056

Browse files
authored
Merge pull request #96 from appwrite/dev
feat: Apple SDK update for version 13.5.0
2 parents 18b675b + 53f073c commit 4787056

File tree

10 files changed

+590
-6
lines changed

10 files changed

+590
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 13.5.0
4+
5+
* Add `getScreenshot` method to `Avatars` service
6+
* Add `Theme`, `Timezone` and `Output` enums
7+
38
## 13.4.0
49

510
* Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:
3131

3232
```swift
3333
dependencies: [
34-
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "13.4.0"),
34+
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "13.5.0"),
3535
],
3636
```
3737

Sources/Appwrite/Client.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import NIOSSL
55
import Foundation
66
import AsyncHTTPClient
77
@_exported import AppwriteModels
8+
@_exported import JSONCodable
89

910
let DASHDASH = "--"
1011
let CRLF = "\r\n"
@@ -23,7 +24,7 @@ open class Client {
2324
"x-sdk-name": "Apple",
2425
"x-sdk-platform": "client",
2526
"x-sdk-language": "apple",
26-
"x-sdk-version": "13.4.0",
27+
"x-sdk-version": "13.5.0",
2728
"x-appwrite-response-format": "1.8.0"
2829
]
2930

Sources/Appwrite/Services/Account.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ open class Account: Service {
654654
open func createMfaChallenge(
655655
factor: AppwriteEnums.AuthenticationFactor
656656
) async throws -> AppwriteModels.MfaChallenge {
657-
let apiPath: String = "/account/mfa/challenge"
657+
let apiPath: String = "/account/mfa/challenges"
658658

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

695695
let apiParams: [String: Any?] = [
696696
"factor": factor
@@ -731,7 +731,7 @@ open class Account: Service {
731731
challengeId: String,
732732
otp: String
733733
) async throws -> AppwriteModels.Session {
734-
let apiPath: String = "/account/mfa/challenge"
734+
let apiPath: String = "/account/mfa/challenges"
735735

736736
let apiParams: [String: Any?] = [
737737
"challengeId": challengeId,
@@ -772,7 +772,7 @@ open class Account: Service {
772772
challengeId: String,
773773
otp: String
774774
) async throws -> AppwriteModels.Session {
775-
let apiPath: String = "/account/mfa/challenge"
775+
let apiPath: String = "/account/mfa/challenges"
776776

777777
let apiParams: [String: Any?] = [
778778
"challengeId": challengeId,

Sources/Appwrite/Services/Avatars.swift

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,96 @@ open class Avatars: Service {
290290
)
291291
}
292292

293+
///
294+
/// Use this endpoint to capture a screenshot of any website URL. This endpoint
295+
/// uses a headless browser to render the webpage and capture it as an image.
296+
///
297+
/// You can configure the browser viewport size, theme, user agent,
298+
/// geolocation, permissions, and more. Capture either just the viewport or the
299+
/// full page scroll.
300+
///
301+
/// When width and height are specified, the image is resized accordingly. If
302+
/// both dimensions are 0, the API provides an image at original size. If
303+
/// dimensions are not specified, the default viewport size is 1280x720px.
304+
///
305+
/// - Parameters:
306+
/// - url: String
307+
/// - headers: Any (optional)
308+
/// - viewportWidth: Int (optional)
309+
/// - viewportHeight: Int (optional)
310+
/// - scale: Double (optional)
311+
/// - theme: AppwriteEnums.Theme (optional)
312+
/// - userAgent: String (optional)
313+
/// - fullpage: Bool (optional)
314+
/// - locale: String (optional)
315+
/// - timezone: AppwriteEnums.Timezone (optional)
316+
/// - latitude: Double (optional)
317+
/// - longitude: Double (optional)
318+
/// - accuracy: Double (optional)
319+
/// - touch: Bool (optional)
320+
/// - permissions: [String] (optional)
321+
/// - sleep: Int (optional)
322+
/// - width: Int (optional)
323+
/// - height: Int (optional)
324+
/// - quality: Int (optional)
325+
/// - output: AppwriteEnums.Output (optional)
326+
/// - Throws: Exception if the request fails
327+
/// - Returns: ByteBuffer
328+
///
329+
open func getScreenshot(
330+
url: String,
331+
headers: Any? = nil,
332+
viewportWidth: Int? = nil,
333+
viewportHeight: Int? = nil,
334+
scale: Double? = nil,
335+
theme: AppwriteEnums.Theme? = nil,
336+
userAgent: String? = nil,
337+
fullpage: Bool? = nil,
338+
locale: String? = nil,
339+
timezone: AppwriteEnums.Timezone? = nil,
340+
latitude: Double? = nil,
341+
longitude: Double? = nil,
342+
accuracy: Double? = nil,
343+
touch: Bool? = nil,
344+
permissions: [String]? = nil,
345+
sleep: Int? = nil,
346+
width: Int? = nil,
347+
height: Int? = nil,
348+
quality: Int? = nil,
349+
output: AppwriteEnums.Output? = nil
350+
) async throws -> ByteBuffer {
351+
let apiPath: String = "/avatars/screenshots"
352+
353+
let apiParams: [String: Any?] = [
354+
"url": url,
355+
"headers": headers,
356+
"viewportWidth": viewportWidth,
357+
"viewportHeight": viewportHeight,
358+
"scale": scale,
359+
"theme": theme,
360+
"userAgent": userAgent,
361+
"fullpage": fullpage,
362+
"locale": locale,
363+
"timezone": timezone,
364+
"latitude": latitude,
365+
"longitude": longitude,
366+
"accuracy": accuracy,
367+
"touch": touch,
368+
"permissions": permissions,
369+
"sleep": sleep,
370+
"width": width,
371+
"height": height,
372+
"quality": quality,
373+
"output": output,
374+
"project": client.config["project"]
375+
]
376+
377+
return try await client.call(
378+
method: "GET",
379+
path: apiPath,
380+
params: apiParams
381+
)
382+
}
383+
293384

294385
}

Sources/AppwriteEnums/Output.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Foundation
2+
3+
public enum Output: String, CustomStringConvertible {
4+
case jpg = "jpg"
5+
case jpeg = "jpeg"
6+
case png = "png"
7+
case webp = "webp"
8+
case heic = "heic"
9+
case avif = "avif"
10+
case gif = "gif"
11+
12+
public var description: String {
13+
return rawValue
14+
}
15+
}

Sources/AppwriteEnums/Theme.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Foundation
2+
3+
public enum Theme: String, CustomStringConvertible {
4+
case light = "light"
5+
case dark = "dark"
6+
7+
public var description: String {
8+
return rawValue
9+
}
10+
}

0 commit comments

Comments
 (0)