Skip to content

Commit be01492

Browse files
authored
Merge pull request #49 from appwrite/dev
feat: Swift SDK update for version 14.0.0
2 parents a049430 + c5ed447 commit be01492

22 files changed

+662
-29
lines changed

β€ŽCHANGELOG.mdβ€Ž

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

3+
## 14.0.0
4+
5+
* Rename `VCSDeploymentType` enum to `VCSReferenceType`
6+
* Change `createTemplateDeployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) and `reference` parameters
7+
* Add `getScreenshot` method to `Avatars` service
8+
* Add `Theme`, `Timezone` and `Output` enums
9+
310
## 13.3.0
411

512
* 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
@@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:
3333

3434
```swift
3535
dependencies: [
36-
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "13.3.0"),
36+
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "14.0.0"),
3737
],
3838
```
3939

β€Ž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"
@@ -21,7 +22,7 @@ open class Client {
2122
"x-sdk-name": "Swift",
2223
"x-sdk-platform": "server",
2324
"x-sdk-language": "swift",
24-
"x-sdk-version": "13.3.0",
25+
"x-sdk-version": "14.0.0",
2526
"x-appwrite-response-format": "1.8.0"
2627
]
2728

β€Ž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: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,5 +311,99 @@ open class Avatars: Service {
311311
)
312312
}
313313

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

315409
}

β€ŽSources/Appwrite/Services/Functions.swiftβ€Ž

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ open class Functions: Service {
528528
/// - repository: String
529529
/// - owner: String
530530
/// - rootDirectory: String
531-
/// - version: String
531+
/// - type: AppwriteEnums.TemplateReferenceType
532+
/// - reference: String
532533
/// - activate: Bool (optional)
533534
/// - Throws: Exception if the request fails
534535
/// - Returns: AppwriteModels.Deployment
@@ -538,7 +539,8 @@ open class Functions: Service {
538539
repository: String,
539540
owner: String,
540541
rootDirectory: String,
541-
version: String,
542+
type: AppwriteEnums.TemplateReferenceType,
543+
reference: String,
542544
activate: Bool? = nil
543545
) async throws -> AppwriteModels.Deployment {
544546
let apiPath: String = "/functions/{functionId}/deployments/template"
@@ -548,7 +550,8 @@ open class Functions: Service {
548550
"repository": repository,
549551
"owner": owner,
550552
"rootDirectory": rootDirectory,
551-
"version": version,
553+
"type": type,
554+
"reference": reference,
552555
"activate": activate
553556
]
554557

@@ -576,15 +579,15 @@ open class Functions: Service {
576579
///
577580
/// - Parameters:
578581
/// - functionId: String
579-
/// - type: AppwriteEnums.VCSDeploymentType
582+
/// - type: AppwriteEnums.VCSReferenceType
580583
/// - reference: String
581584
/// - activate: Bool (optional)
582585
/// - Throws: Exception if the request fails
583586
/// - Returns: AppwriteModels.Deployment
584587
///
585588
open func createVcsDeployment(
586589
functionId: String,
587-
type: AppwriteEnums.VCSDeploymentType,
590+
type: AppwriteEnums.VCSReferenceType,
588591
reference: String,
589592
activate: Bool? = nil
590593
) async throws -> AppwriteModels.Deployment {

β€ŽSources/Appwrite/Services/Sites.swiftβ€Ž

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ open class Sites: Service {
413413
///
414414
/// Create a new site code deployment. Use this endpoint to upload a new
415415
/// version of your site code. To activate your newly uploaded code, you'll
416-
/// need to update the function's deployment to use your new deployment ID.
416+
/// need to update the site's deployment to use your new deployment ID.
417417
///
418418
/// - Parameters:
419419
/// - siteId: String
@@ -519,7 +519,8 @@ open class Sites: Service {
519519
/// - repository: String
520520
/// - owner: String
521521
/// - rootDirectory: String
522-
/// - version: String
522+
/// - type: AppwriteEnums.TemplateReferenceType
523+
/// - reference: String
523524
/// - activate: Bool (optional)
524525
/// - Throws: Exception if the request fails
525526
/// - Returns: AppwriteModels.Deployment
@@ -529,7 +530,8 @@ open class Sites: Service {
529530
repository: String,
530531
owner: String,
531532
rootDirectory: String,
532-
version: String,
533+
type: AppwriteEnums.TemplateReferenceType,
534+
reference: String,
533535
activate: Bool? = nil
534536
) async throws -> AppwriteModels.Deployment {
535537
let apiPath: String = "/sites/{siteId}/deployments/template"
@@ -539,7 +541,8 @@ open class Sites: Service {
539541
"repository": repository,
540542
"owner": owner,
541543
"rootDirectory": rootDirectory,
542-
"version": version,
544+
"type": type,
545+
"reference": reference,
543546
"activate": activate
544547
]
545548

@@ -567,15 +570,15 @@ open class Sites: Service {
567570
///
568571
/// - Parameters:
569572
/// - siteId: String
570-
/// - type: AppwriteEnums.VCSDeploymentType
573+
/// - type: AppwriteEnums.VCSReferenceType
571574
/// - reference: String
572575
/// - activate: Bool (optional)
573576
/// - Throws: Exception if the request fails
574577
/// - Returns: AppwriteModels.Deployment
575578
///
576579
open func createVcsDeployment(
577580
siteId: String,
578-
type: AppwriteEnums.VCSDeploymentType,
581+
type: AppwriteEnums.VCSReferenceType,
579582
reference: String,
580583
activate: Bool? = nil
581584
) async throws -> AppwriteModels.Deployment {

β€ŽSources/Appwrite/Services/Storage.swiftβ€Ž

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ open class Storage: Service {
6161
/// - compression: AppwriteEnums.Compression (optional)
6262
/// - encryption: Bool (optional)
6363
/// - antivirus: Bool (optional)
64+
/// - transformations: Bool (optional)
6465
/// - Throws: Exception if the request fails
6566
/// - Returns: AppwriteModels.Bucket
6667
///
@@ -74,7 +75,8 @@ open class Storage: Service {
7475
allowedFileExtensions: [String]? = nil,
7576
compression: AppwriteEnums.Compression? = nil,
7677
encryption: Bool? = nil,
77-
antivirus: Bool? = nil
78+
antivirus: Bool? = nil,
79+
transformations: Bool? = nil
7880
) async throws -> AppwriteModels.Bucket {
7981
let apiPath: String = "/storage/buckets"
8082

@@ -88,7 +90,8 @@ open class Storage: Service {
8890
"allowedFileExtensions": allowedFileExtensions,
8991
"compression": compression,
9092
"encryption": encryption,
91-
"antivirus": antivirus
93+
"antivirus": antivirus,
94+
"transformations": transformations
9295
]
9396

9497
let apiHeaders: [String: String] = [
@@ -154,6 +157,7 @@ open class Storage: Service {
154157
/// - compression: AppwriteEnums.Compression (optional)
155158
/// - encryption: Bool (optional)
156159
/// - antivirus: Bool (optional)
160+
/// - transformations: Bool (optional)
157161
/// - Throws: Exception if the request fails
158162
/// - Returns: AppwriteModels.Bucket
159163
///
@@ -167,7 +171,8 @@ open class Storage: Service {
167171
allowedFileExtensions: [String]? = nil,
168172
compression: AppwriteEnums.Compression? = nil,
169173
encryption: Bool? = nil,
170-
antivirus: Bool? = nil
174+
antivirus: Bool? = nil,
175+
transformations: Bool? = nil
171176
) async throws -> AppwriteModels.Bucket {
172177
let apiPath: String = "/storage/buckets/{bucketId}"
173178
.replacingOccurrences(of: "{bucketId}", with: bucketId)
@@ -181,7 +186,8 @@ open class Storage: Service {
181186
"allowedFileExtensions": allowedFileExtensions,
182187
"compression": compression,
183188
"encryption": encryption,
184-
"antivirus": antivirus
189+
"antivirus": antivirus,
190+
"transformations": transformations
185191
]
186192

187193
let apiHeaders: [String: String] = [

β€ŽSources/AppwriteEnums/BuildRuntime.swiftβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public enum BuildRuntime: String, CustomStringConvertible {
3939
case dart33 = "dart-3.3"
4040
case dart35 = "dart-3.5"
4141
case dart38 = "dart-3.8"
42+
case dart39 = "dart-3.9"
4243
case dotnet60 = "dotnet-6.0"
4344
case dotnet70 = "dotnet-7.0"
4445
case dotnet80 = "dotnet-8.0"
@@ -66,6 +67,7 @@ public enum BuildRuntime: String, CustomStringConvertible {
6667
case flutter327 = "flutter-3.27"
6768
case flutter329 = "flutter-3.29"
6869
case flutter332 = "flutter-3.32"
70+
case flutter335 = "flutter-3.35"
6971

7072
public var description: String {
7173
return rawValue

0 commit comments

Comments
Β (0)