Skip to content

Commit 456310c

Browse files
committed
fix: pong response & chunked upload
1 parent f62348c commit 456310c

File tree

10 files changed

+57
-44
lines changed

10 files changed

+57
-44
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
1+
Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

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: "git@github.com:appwrite/sdk-for-swift.git", from: "6.2.0"),
36+
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "6.2.1"),
3737
],
3838
```
3939

Sources/Appwrite/Client.swift

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ open class Client {
2121
"x-sdk-name": "Swift",
2222
"x-sdk-platform": "server",
2323
"x-sdk-language": "swift",
24-
"x-sdk-version": "6.2.0",
24+
"x-sdk-version": "6.2.1",
2525
"x-appwrite-response-format": "1.6.0"
2626
]
2727

@@ -257,6 +257,26 @@ open class Client {
257257
) ?? ""
258258
}
259259

260+
///
261+
/// Sends a "ping" request to Appwrite to verify connectivity.
262+
///
263+
/// @return String
264+
/// @throws Exception
265+
///
266+
open func ping() async throws -> String {
267+
let apiPath: String = "/ping"
268+
269+
let apiHeaders: [String: String] = [
270+
"content-type": "application/json"
271+
]
272+
273+
return try await call(
274+
method: "GET",
275+
path: apiPath,
276+
headers: apiHeaders
277+
)
278+
}
279+
260280
///
261281
/// Make an API call
262282
///
@@ -392,15 +412,18 @@ open class Client {
392412
}
393413
}
394414

415+
var data = try await response.body.collect(upTo: Int.max)
416+
395417
switch response.status.code {
396418
case 0..<400:
397419
switch T.self {
398420
case is Bool.Type:
399421
return true as! T
422+
case is String.Type:
423+
return (data.readString(length: data.readableBytes) ?? "") as! T
400424
case is ByteBuffer.Type:
401-
return try await response.body.collect(upTo: Int.max) as! T
425+
return data as! T
402426
default:
403-
let data = try await response.body.collect(upTo: Int.max)
404427
if data.readableBytes == 0 {
405428
return true as! T
406429
}
@@ -410,7 +433,6 @@ open class Client {
410433
}
411434
default:
412435
var message = ""
413-
var data = try await response.body.collect(upTo: Int.max)
414436
var type = ""
415437

416438
do {
@@ -466,7 +488,7 @@ open class Client {
466488
var offset = 0
467489
var result = [String:Any]()
468490

469-
if idParamName != nil && params[idParamName!] as! String != "unique()" {
491+
if idParamName != nil {
470492
// Make a request to check if a file already exists
471493
do {
472494
let map = try await call(

Sources/Appwrite/Services/Account.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ open class Account: Service {
584584
open func updateMfaChallenge(
585585
challengeId: String,
586586
otp: String
587-
) async throws -> Any {
587+
) async throws -> AppwriteModels.Session {
588588
let apiPath: String = "/account/mfa/challenge"
589589

590590
let apiParams: [String: Any?] = [
@@ -596,11 +596,17 @@ open class Account: Service {
596596
"content-type": "application/json"
597597
]
598598

599+
let converter: (Any) -> AppwriteModels.Session = { response in
600+
return AppwriteModels.Session.from(map: response as! [String: Any])
601+
}
602+
599603
return try await client.call(
600604
method: "PUT",
601605
path: apiPath,
602606
headers: apiHeaders,
603-
params: apiParams )
607+
params: apiParams,
608+
converter: converter
609+
)
604610
}
605611

606612
///

Sources/Appwrite/Services/Functions.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ open class Functions: Service {
572572
///
573573
/// Rebuild deployment
574574
///
575+
/// Create a new build for an existing function deployment. This endpoint
576+
/// allows you to rebuild a deployment with the updated function configuration,
577+
/// including its entrypoint and build commands if they have been modified The
578+
/// build process will be queued and executed asynchronously. The original
579+
/// deployment's code will be preserved and used for the new build.
580+
///
575581
/// @param String functionId
576582
/// @param String deploymentId
577583
/// @param String buildId
@@ -605,6 +611,12 @@ open class Functions: Service {
605611
///
606612
/// Cancel deployment
607613
///
614+
/// Cancel an ongoing function deployment build. If the build is already in
615+
/// progress, it will be stopped and marked as canceled. If the build hasn't
616+
/// started yet, it will be marked as canceled without executing. You cannot
617+
/// cancel builds that have already completed (status 'ready') or failed. The
618+
/// response includes the final build status and details.
619+
///
608620
/// @param String functionId
609621
/// @param String deploymentId
610622
/// @throws Exception

Sources/Appwrite/Services/Messaging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ open class Messaging: Service {
418418
///
419419
/// Update SMS
420420
///
421-
/// Update an email message by its unique ID.
421+
/// Update an SMS message by its unique ID.
422422
///
423423
///
424424
/// @param String messageId

Sources/Appwrite/Services/Users.swift

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,11 +1217,10 @@ open class Users: Service {
12171217
/// @throws Exception
12181218
/// @return array
12191219
///
1220-
open func deleteMfaAuthenticator<T>(
1220+
open func deleteMfaAuthenticator(
12211221
userId: String,
1222-
type: AppwriteEnums.AuthenticatorType,
1223-
nestedType: T.Type
1224-
) async throws -> AppwriteModels.User<T> {
1222+
type: AppwriteEnums.AuthenticatorType
1223+
) async throws -> Any {
12251224
let apiPath: String = "/users/{userId}/mfa/authenticators/{type}"
12261225
.replacingOccurrences(of: "{userId}", with: userId)
12271226
.replacingOccurrences(of: "{type}", with: type.rawValue)
@@ -1232,38 +1231,11 @@ open class Users: Service {
12321231
"content-type": "application/json"
12331232
]
12341233

1235-
let converter: (Any) -> AppwriteModels.User<T> = { response in
1236-
return AppwriteModels.User.from(map: response as! [String: Any])
1237-
}
1238-
12391234
return try await client.call(
12401235
method: "DELETE",
12411236
path: apiPath,
12421237
headers: apiHeaders,
1243-
params: apiParams,
1244-
converter: converter
1245-
)
1246-
}
1247-
1248-
///
1249-
/// Delete authenticator
1250-
///
1251-
/// Delete an authenticator app.
1252-
///
1253-
/// @param String userId
1254-
/// @param AppwriteEnums.AuthenticatorType type
1255-
/// @throws Exception
1256-
/// @return array
1257-
///
1258-
open func deleteMfaAuthenticator(
1259-
userId: String,
1260-
type: AppwriteEnums.AuthenticatorType
1261-
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
1262-
return try await deleteMfaAuthenticator(
1263-
userId: userId,
1264-
type: type,
1265-
nestedType: [String: AnyCodable].self
1266-
)
1238+
params: apiParams )
12671239
}
12681240

12691241
///

Sources/AppwriteEnums/ImageFormat.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public enum ImageFormat: String, CustomStringConvertible {
66
case gif = "gif"
77
case png = "png"
88
case webp = "webp"
9+
case heic = "heic"
910
case avif = "avif"
1011

1112
public var description: String {

docs/examples/account/update-mfa-challenge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let client = Client()
77

88
let account = Account(client)
99

10-
let result = try await account.updateMfaChallenge(
10+
let session = try await account.updateMfaChallenge(
1111
challengeId: "<CHALLENGE_ID>",
1212
otp: "<OTP>"
1313
)

docs/examples/users/delete-mfa-authenticator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let client = Client()
88

99
let users = Users(client)
1010

11-
let user = try await users.deleteMfaAuthenticator(
11+
let result = try await users.deleteMfaAuthenticator(
1212
userId: "<USER_ID>",
1313
type: .totp
1414
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy